From 2d3cc1eac126990c5cd4ca8a47b0c09814dc1e5c Mon Sep 17 00:00:00 2001 From: Zachary T Welch Date: Wed, 11 Nov 2009 05:26:17 -0800 Subject: add command_name helper The command_name function returns a malloced string for a given command and its parents. This can be used to display a message to the user, but it is used internally to handle registration and syntax errors. This helps permit arbitrary command nesting. --- src/helper/command.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/helper/command.h') diff --git a/src/helper/command.h b/src/helper/command.h index 0b86b881..732fa525 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -84,6 +84,16 @@ typedef struct command_s struct command_s *next; } command_t; +/** + * @param c The command to be named. + * @param delim The character to place between command names. + * @returns A malloc'd string containing the full command name, + * which may include one or more ancestor components. Multiple names + * are separated by single spaces. The caller must free() the string + * when done with it. + */ +char *command_name(struct command_s *c, char delim); + command_t* register_command(command_context_t *context, command_t *parent, char *name, int (*handler)(struct command_context_s *context, -- cgit v1.2.3