diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2017-04-15 10:58:31 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2017-04-15 10:58:31 +0100 |
commit | a6bb8ad100348693a39ea13ba6af361f2dab5101 (patch) | |
tree | 31fe0a8386aa4f5fe1f2dd4581cbf4044d102fdb /src/commands.c | |
parent | ec0923e5cf9715943b198ea5c6f60e1037cef248 (diff) | |
download | imv-a6bb8ad100348693a39ea13ba6af361f2dab5101.tar.gz |
Let commands take an arbitrary pointer
Diffstat (limited to 'src/commands.c')
-rw-r--r-- | src/commands.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/commands.c b/src/commands.c index a3a59b1..0f31bfc 100644 --- a/src/commands.c +++ b/src/commands.c @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. struct command { char* command; - void (*handler)(struct imv_list *args); + void (*handler)(struct imv_list *args, void *data); char* alias; }; @@ -63,7 +63,7 @@ void imv_command_alias(struct imv_commands *cmds, const char *command, const cha imv_list_append(cmds->command_list, cmd); } -int imv_command_exec(struct imv_commands *cmds, const char *command) +int imv_command_exec(struct imv_commands *cmds, const char *command, void *data) { struct imv_list *args = imv_split_string(command, ' '); int ret = 1; @@ -73,10 +73,10 @@ int imv_command_exec(struct imv_commands *cmds, const char *command) struct command *cmd = cmds->command_list->items[i]; if(!strcmp(cmd->command, args->items[0])) { if(cmd->handler) { - cmd->handler(args); + cmd->handler(args, data); ret = 0; } else if(cmd->alias) { - ret = imv_command_exec(cmds, cmd->alias); + ret = imv_command_exec(cmds, cmd->alias, data); } break; } |