summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-09-16 21:05:51 +0200
committerSébastien Helleu <flashcode@flashtux.org>2022-09-16 21:05:51 +0200
commit96c22c41ba59080893a4c4a2ca1e66c16d88ff32 (patch)
treef300c7bd9c8823a7ea409d96784241a2363bee62 /src/core
parentba27ec8d65633415bb0220674f002e7deb5ba0a0 (diff)
downloadweechat-96c22c41ba59080893a4c4a2ca1e66c16d88ff32.zip
api: add support of priority in function hook_line (closes #1821)
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hook/wee-hook-line.c11
-rw-r--r--src/core/wee-hook.c3
2 files changed, 10 insertions, 4 deletions
diff --git a/src/core/hook/wee-hook-line.c b/src/core/hook/wee-hook-line.c
index 00bd7f138..366c9bf2e 100644
--- a/src/core/hook/wee-hook-line.c
+++ b/src/core/hook/wee-hook-line.c
@@ -71,6 +71,8 @@ hook_line (struct t_weechat_plugin *plugin, const char *buffer_type,
{
struct t_hook *new_hook;
struct t_hook_line *new_hook_line;
+ int priority;
+ const char *ptr_buffer_type;
if (!callback)
return NULL;
@@ -85,17 +87,18 @@ hook_line (struct t_weechat_plugin *plugin, const char *buffer_type,
return NULL;
}
- hook_init_data (new_hook, plugin, HOOK_TYPE_LINE, HOOK_PRIORITY_DEFAULT,
+ hook_get_priority_and_name (buffer_type, &priority, &ptr_buffer_type);
+ hook_init_data (new_hook, plugin, HOOK_TYPE_LINE, priority,
callback_pointer, callback_data);
new_hook->hook_data = new_hook_line;
new_hook_line->callback = callback;
- if (!buffer_type || !buffer_type[0])
+ if (!ptr_buffer_type || !ptr_buffer_type[0])
new_hook_line->buffer_type = GUI_BUFFER_TYPE_DEFAULT;
- else if (strcmp (buffer_type, "*") == 0)
+ else if (strcmp (ptr_buffer_type, "*") == 0)
new_hook_line->buffer_type = -1;
else
- new_hook_line->buffer_type = gui_buffer_search_type (buffer_type);
+ new_hook_line->buffer_type = gui_buffer_search_type (ptr_buffer_type);
new_hook_line->buffers = string_split (
(buffer_name && buffer_name[0]) ? buffer_name : "*",
",",
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index 04b1acc2e..b50a664e7 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -362,6 +362,9 @@ hook_get_priority_and_name (const char *string,
if (name)
*name = string;
+ if (!string)
+ return;
+
pos = strchr (string, '|');
if (pos)
{