1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +02:00

api: allow to catch multiple signals in functions hook_signal and hook_hsignal (closes #1780)

This commit is contained in:
Sébastien Helleu
2022-04-24 21:37:38 +02:00
parent f69ef840e0
commit b7f3127bf8
14 changed files with 226 additions and 199 deletions
+12 -18
View File
@@ -301,34 +301,28 @@ trigger_hook (struct t_trigger *trigger)
case TRIGGER_HOOK_SIGNAL:
if (argv && (argc >= 1))
{
trigger->hooks = malloc (argc * sizeof (trigger->hooks[0]));
trigger->hooks = malloc (sizeof (trigger->hooks[0]));
if (trigger->hooks)
{
trigger->hooks_count = argc;
for (i = 0; i < argc; i++)
{
trigger->hooks[i] = weechat_hook_signal (
argv[i],
&trigger_callback_signal_cb,
trigger, NULL);
}
trigger->hooks_count = 1;
trigger->hooks[0] = weechat_hook_signal (
weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]),
&trigger_callback_signal_cb,
trigger, NULL);
}
}
break;
case TRIGGER_HOOK_HSIGNAL:
if (argv && (argc >= 1))
{
trigger->hooks = malloc (argc * sizeof (trigger->hooks[0]));
trigger->hooks = malloc (sizeof (trigger->hooks[0]));
if (trigger->hooks)
{
trigger->hooks_count = argc;
for (i = 0; i < argc; i++)
{
trigger->hooks[i] = weechat_hook_hsignal (
argv[i],
&trigger_callback_hsignal_cb,
trigger, NULL);
}
trigger->hooks_count = 1;
trigger->hooks[0] = weechat_hook_hsignal (
weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]),
&trigger_callback_hsignal_cb,
trigger, NULL);
}
}
break;