1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 11:13:12 +02:00

Added keep_eol flag to string_explode(), updated hook command callback arguments

This commit is contained in:
Sebastien Helleu
2007-11-05 13:29:54 +01:00
parent a98feff2bb
commit a97e2955be
10 changed files with 82 additions and 47 deletions
+22 -3
View File
@@ -150,26 +150,45 @@ hook_command (void *plugin, char *command, char *description,
*/
int
hook_command_exec (void *plugin, char *command, char *args)
hook_command_exec (void *plugin, char *string)
{
struct t_hook *ptr_hook;
char **argv, **argv_eol;
int argc;
if (!string || !string[0])
return -1;
argv = string_explode (string, " ", 0, 0, &argc);
if (argc == 0)
{
if (argv)
string_free_exploded (argv);
return -1;
}
argv_eol = string_explode (string, " ", 1, 0, NULL);
for (ptr_hook = weechat_hooks; ptr_hook;
ptr_hook = ptr_hook->next_hook)
{
if ((ptr_hook->type == HOOK_TYPE_COMMAND)
&& (!plugin || (plugin == ptr_hook->plugin))
&& (string_strcasecmp (command,
&& (string_strcasecmp (argv[0] + 1,
HOOK_COMMAND(ptr_hook, command)) == 0))
{
if ((int) (HOOK_COMMAND(ptr_hook, callback))
(ptr_hook->callback_data, args) == PLUGIN_RC_FAILED)
(ptr_hook->callback_data, argc, argv, argv_eol) == PLUGIN_RC_FAILED)
return 0;
else
return 1;
}
}
if (argv)
string_free_exploded (argv);
if (argv_eol)
string_free_exploded (argv_eol);
/* no hook found */
return -1;
}