1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 14:26:39 +02:00

Increase number of authorized calls to same command (recursive calls), from 1 to 5 (more than 5 is considered as looping)

This commit is contained in:
Sebastien Helleu
2008-05-22 12:55:37 +02:00
parent ec6f2c2e17
commit a4a4e5126c
10 changed files with 54 additions and 50 deletions
+6 -5
View File
@@ -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
+5
View File
@@ -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)
+2 -1
View File
@@ -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;