X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fhelper%2Fcommand.h;h=74c6f367b0bc88452fbff38f4deae9e37e07eb78;hp=236dabbe85c202f6034ed3fb4517d5dd3558c5fc;hb=a585bdf7269ce5c861c83ee3294ba1f074e9c877;hpb=3f9fd4e2a6ab7b3ce3819c385c34cf6f4630763c diff --git a/src/helper/command.h b/src/helper/command.h index 236dabbe85..74c6f367b0 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -121,13 +121,22 @@ typedef struct command_context_s */ #define COMMAND_HELPER(name, extra...) __COMMAND_HANDLER(name, extra) +/** + * Use this macro to access the name of the command being handled, + * rather than accessing the variable directly. It may be moved. + */ +#define CMD_NAME cmd + + +/// The type signature for commands' handler functions. +typedef __COMMAND_HANDLER((*command_handler_t)); typedef struct command_s { char *name; struct command_s *parent; struct command_s *children; - int (*handler)(struct command_context_s *context, char* name, char** args, int argc); + command_handler_t handler; enum command_mode mode; struct command_s *next; } command_t; @@ -143,9 +152,7 @@ typedef struct command_s 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, - char* name, char** args, int argc), + command_t *parent, char *name, command_handler_t handler, enum command_mode mode, char *help); int unregister_command(command_context_t *context, char *name);