diff options
Diffstat (limited to 'src/commands.h')
-rw-r--r-- | src/commands.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/commands.h b/src/commands.h index cf81f68..3bd7650 100644 --- a/src/commands.h +++ b/src/commands.h @@ -2,16 +2,29 @@ #define COMMANDS_H struct list; +struct imv_commands; -struct imv_commands { - struct list *command_list; -}; - +/* Create an imv_commands instance */ struct imv_commands *imv_commands_create(void); + +/* Cleans up an imv_commands instance */ void imv_commands_free(struct imv_commands *cmds); -void imv_command_register(struct imv_commands *cmds, const char *command, void (*handler)(struct list*, const char*, void*)); + +/* Register a new command. When a command is executed, the appropriate handler + * is called, with a void* for passing context. + */ +void imv_command_register(struct imv_commands *cmds, const char *command, + void (*handler)(struct list*, const char*, void*)); + +/* Add a command alias. Any arguments provided when invoking an alias are + * appended to the arguments being passed to the command. + */ void imv_command_alias(struct imv_commands *cmds, const char *command, const char *alias); + +/* Execute a single command */ int imv_command_exec(struct imv_commands *cmds, const char *command, void *data); + +/* Execute a list of commands */ int imv_command_exec_list(struct imv_commands *cmds, struct list *commands, void *data); #endif |