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.
This commit is contained in:
Zachary T Welch
2009-11-11 05:26:17 -08:00
parent f93c98081f
commit 2d3cc1eac1
2 changed files with 49 additions and 32 deletions
+10
View File
@@ -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,