From: Zachary T Welch Date: Sun, 22 Nov 2009 09:48:55 +0000 (-0800) Subject: add public API for locating commands X-Git-Tag: v0.4.0-rc1~404 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=769fbfa058946e1581d5f9ad75d17947d1ee9ff1;hp=4c54c27da774f8035a04f3b091fcfc5661253a0e add public API for locating commands Allow other modules to find a command, primarily for the purpose of registering and unregistering subcommands. --- diff --git a/src/helper/command.c b/src/helper/command.c index af481cd414..54bfb964a9 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -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. diff --git a/src/helper/command.h b/src/helper/command.h index 6e3e93afae..2edeca9190 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -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);