add public API for locating commands

Allow other modules to find a command, primarily for the purpose of
registering and unregistering subcommands.
This commit is contained in:
Zachary T Welch 2009-11-22 01:48:55 -08:00
parent 4c54c27da7
commit 769fbfa058
2 changed files with 15 additions and 0 deletions

View File

@ -193,6 +193,16 @@ static struct command *command_find(struct command *head, const char *name)
}
return NULL;
}
struct command *command_find_in_context(struct command_context *cmd_ctx,
const char *name)
{
return command_find(cmd_ctx->commands, name);
}
struct command *command_find_in_parent(struct command *parent,
const char *name)
{
return command_find(parent->children, name);
}
/**
* Add the command into the linked list, sorted by name.

View File

@ -281,6 +281,11 @@ int unregister_command(struct command_context *cmd_ctx,
int unregister_all_commands(struct command_context *cmd_ctx,
struct command *parent);
struct command *command_find_in_context(struct command_context *cmd_ctx,
const char *name);
struct command *command_find_in_parent(struct command *parent,
const char *name);
void command_set_output_handler(struct command_context* context,
command_output_handler_t output_handler, void *priv);