summaryrefslogtreecommitdiff
path: root/src/plugins/trigger/trigger.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-04-24 21:37:38 +0200
committerSébastien Helleu <flashcode@flashtux.org>2022-04-24 22:09:15 +0200
commitb7f3127bf81d53ea51a4147bb6ae3b7edcff2acd (patch)
tree1abcf4b64fd9f6c73e75da4a4079a31a97b2812b /src/plugins/trigger/trigger.c
parentf69ef840e0baa40456eda6dcad43e2ec26c7a968 (diff)
downloadweechat-b7f3127bf81d53ea51a4147bb6ae3b7edcff2acd.zip
api: allow to catch multiple signals in functions hook_signal and hook_hsignal (closes #1780)
Diffstat (limited to 'src/plugins/trigger/trigger.c')
-rw-r--r--src/plugins/trigger/trigger.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c
index ee201b5bd..af2ad0c4e 100644
--- a/src/plugins/trigger/trigger.c
+++ b/src/plugins/trigger/trigger.c
@@ -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;