add command_handler_t type
This patch adds new typedefs for command handler callback functions. Users of this type signature were updated to use these new types. It uses the new __COMMAND_HANDLER macro to prevent duplication.
This commit is contained in:
parent
3f9fd4e2a6
commit
ddb6138ed4
|
@ -225,9 +225,7 @@ static void command_add_child(struct command_s **head, struct command_s *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
command_t* register_command(command_context_t *context,
|
command_t* register_command(command_context_t *context,
|
||||||
command_t *parent, char *name,
|
command_t *parent, char *name, command_handler_t handler,
|
||||||
int (*handler)(struct command_context_s *context,
|
|
||||||
char* name, char** args, int argc),
|
|
||||||
enum command_mode mode, char *help)
|
enum command_mode mode, char *help)
|
||||||
{
|
{
|
||||||
if (!context || !name)
|
if (!context || !name)
|
||||||
|
|
|
@ -122,12 +122,15 @@ typedef struct command_context_s
|
||||||
#define COMMAND_HELPER(name, extra...) __COMMAND_HANDLER(name, extra)
|
#define COMMAND_HELPER(name, extra...) __COMMAND_HANDLER(name, extra)
|
||||||
|
|
||||||
|
|
||||||
|
/// The type signature for commands' handler functions.
|
||||||
|
typedef __COMMAND_HANDLER((*command_handler_t));
|
||||||
|
|
||||||
typedef struct command_s
|
typedef struct command_s
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
struct command_s *parent;
|
struct command_s *parent;
|
||||||
struct command_s *children;
|
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;
|
enum command_mode mode;
|
||||||
struct command_s *next;
|
struct command_s *next;
|
||||||
} command_t;
|
} command_t;
|
||||||
|
@ -143,9 +146,7 @@ typedef struct command_s
|
||||||
char *command_name(struct command_s *c, char delim);
|
char *command_name(struct command_s *c, char delim);
|
||||||
|
|
||||||
command_t* register_command(command_context_t *context,
|
command_t* register_command(command_context_t *context,
|
||||||
command_t *parent, char *name,
|
command_t *parent, char *name, command_handler_t handler,
|
||||||
int (*handler)(struct command_context_s *context,
|
|
||||||
char* name, char** args, int argc),
|
|
||||||
enum command_mode mode, char *help);
|
enum command_mode mode, char *help);
|
||||||
|
|
||||||
int unregister_command(command_context_t *context, char *name);
|
int unregister_command(command_context_t *context, char *name);
|
||||||
|
|
Loading…
Reference in New Issue