From 7cc78f4172631fc67d10045518dc6c5ac63ac66a Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 25 Nov 2007 00:17:43 +0100 Subject: Added buffer argument in command hooks, code cleanup in IRC plugin --- src/core/wee-hook.c | 11 ++++++----- src/core/wee-hook.h | 6 +++--- src/core/wee-input.c | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src/core') diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index fa1cf7ad1..9d44f4f06 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -173,13 +173,13 @@ hook_command (void *plugin, char *command, char *description, */ int -hook_command_exec (void *plugin, char *string) +hook_command_exec (void *buffer, char *string) { struct t_hook *ptr_hook, *next_hook; char **argv, **argv_eol; int argc, rc; - - if (!string || !string[0]) + + if (!buffer || !string || !string[0]) return -1; argv = string_explode (string, " ", 0, 0, &argc); @@ -197,13 +197,14 @@ hook_command_exec (void *plugin, char *string) if ((ptr_hook->type == HOOK_TYPE_COMMAND) && (!ptr_hook->running) - && (!plugin || (plugin == ptr_hook->plugin)) + && (!((struct t_gui_buffer *)buffer)->plugin + || (((struct t_gui_buffer *)buffer)->plugin == ptr_hook->plugin)) && (string_strcasecmp (argv[0] + 1, HOOK_COMMAND(ptr_hook, command)) == 0)) { ptr_hook->running = 1; rc = (int) (HOOK_COMMAND(ptr_hook, callback)) - (ptr_hook->callback_data, argc, argv, argv_eol); + (ptr_hook->callback_data, buffer, argc, argv, argv_eol); if (hook_valid (ptr_hook)) ptr_hook->running = 0; if (rc == PLUGIN_RC_FAILED) diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index ece199fb6..10ebdc14a 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -55,11 +55,11 @@ struct t_hook void *hook_data; /* hook specific data */ int running; /* 1 if hook is currently running */ - struct t_hook *prev_hook; /* pointer to previous hook */ - struct t_hook *next_hook; /* pointer to next hook */ + struct t_hook *prev_hook; /* link to previous hook */ + struct t_hook *next_hook; /* link to next hook */ }; -typedef int (t_hook_callback_command)(void *, int, char **, char **); +typedef int (t_hook_callback_command)(void *, void *, int, char **, char **); struct t_hook_command { diff --git a/src/core/wee-input.c b/src/core/wee-input.c index b3fc0da40..a395b4725 100644 --- a/src/core/wee-input.c +++ b/src/core/wee-input.c @@ -76,7 +76,7 @@ input_exec_command (struct t_gui_buffer *buffer, char *string, rc = -1; if (!only_builtin) { - rc = hook_command_exec (buffer->plugin, command); + rc = hook_command_exec (buffer, command); /*vars_replaced = alias_replace_vars (window, ptr_args); rc = plugin_cmd_handler_exec (window->buffer->protocol, command + 1, (vars_replaced) ? vars_replaced : ptr_args); @@ -375,7 +375,7 @@ input_data (struct t_gui_buffer *buffer, char *data, int only_builtin) if (command_is_command (ptr_data)) { - /* WeeChat or protocol command */ + /* WeeChat or plugin command */ (void) input_exec_command (buffer, ptr_data, only_builtin); } @@ -384,7 +384,7 @@ input_data (struct t_gui_buffer *buffer, char *data, int only_builtin) if ((ptr_data[0] == '/') && (ptr_data[1] == '/')) ptr_data++; - hook_command_exec (buffer->plugin, ptr_data); + hook_command_exec (buffer, ptr_data); if (buffer->input_data_cb) { -- cgit v1.2.3