diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-05-22 12:55:37 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-05-22 12:55:37 +0200 |
commit | a4a4e5126cfc7c5bee39c08403ea3a9b6d3f33dc (patch) | |
tree | 7e17e27913af7ff902e32f8aae56d132c5920fbd /src | |
parent | ec6f2c2e177eb99370a5dc58ce932aeff57f0648 (diff) | |
download | weechat-a4a4e5126cfc7c5bee39c08403ea3a9b6d3f33dc.zip |
Increase number of authorized calls to same command (recursive calls), from 1 to 5 (more than 5 is considered as looping)
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-hook.c | 11 | ||||
-rw-r--r-- | src/core/wee-hook.h | 5 | ||||
-rw-r--r-- | src/core/wee-input.c | 3 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 8de5b8eec..99034c7b2 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -417,9 +417,10 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin, && ((argv[0][0] == '/') && (string_strcasecmp (argv[0] + 1, HOOK_COMMAND(ptr_hook, command)) == 0))) { - if (ptr_hook->running) - command_is_running = 1; - else + if (ptr_hook->running > 0) + command_is_running = ptr_hook->running; + + if (ptr_hook->running < HOOK_COMMAND_MAX_CALLS) { if (ptr_hook->plugin == plugin) { @@ -452,10 +453,10 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin, if (ptr_hook) { - ptr_hook->running = 1; + ptr_hook->running++; rc = (int) (HOOK_COMMAND(ptr_hook, callback)) (ptr_hook->callback_data, buffer, argc, argv, argv_eol); - ptr_hook->running = 0; + ptr_hook->running--; if (rc == WEECHAT_RC_ERROR) rc = 0; else diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index 7959f0232..22d7cf552 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -44,10 +44,15 @@ enum t_hook_type HOOK_NUM_TYPES, }; +/* max calls that can be done for a command (recursive calls) */ +#define HOOK_COMMAND_MAX_CALLS 5 + +/* flags for fd hooks */ #define HOOK_FD_FLAG_READ 1 #define HOOK_FD_FLAG_WRITE 2 #define HOOK_FD_FLAG_EXCEPTION 4 +/* macros to access hook specific data */ #define HOOK_COMMAND(hook, var) (((struct t_hook_command *)hook->hook_data)->var) #define HOOK_TIMER(hook, var) (((struct t_hook_timer *)hook->hook_data)->var) #define HOOK_FD(hook, var) (((struct t_hook_fd *)hook->hook_data)->var) diff --git a/src/core/wee-input.c b/src/core/wee-input.c index c0e938bc3..f2f3adc59 100644 --- a/src/core/wee-input.c +++ b/src/core/wee-input.c @@ -114,7 +114,8 @@ input_exec_command (struct t_gui_buffer *buffer, break; case -3: /* command is running */ gui_chat_printf (NULL, - _("%sError: command \"%s\" is running"), + _("%sError: too much calls to command \"%s\" " + "(looping)"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], command + 1); break; |