summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/script-api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/scripts/script-api.c')
-rw-r--r--src/plugins/scripts/script-api.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c
index 04b8b5951..1a56807d7 100644
--- a/src/plugins/scripts/script-api.c
+++ b/src/plugins/scripts/script-api.c
@@ -1203,6 +1203,50 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
}
/*
+ * script_api_hook_info_hashtable: hook an info_hashtable
+ * return new hook, NULL if error
+ */
+
+struct t_hook *
+script_api_hook_info_hashtable (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ const char *info_name,
+ const char *description,
+ const char *args_description,
+ const char *output_description,
+ struct t_hashtable *(*callback)(void *data,
+ const char *info_name,
+ struct t_hashtable *hashtable),
+ const char *function,
+ const char *data)
+{
+ struct t_script_callback *new_script_callback;
+ struct t_hook *new_hook;
+
+ new_script_callback = script_callback_alloc ();
+ if (!new_script_callback)
+ return NULL;
+
+ new_hook = weechat_hook_info_hashtable (info_name, description,
+ args_description,
+ output_description,
+ callback, new_script_callback);
+ if (!new_hook)
+ {
+ script_callback_free_data (new_script_callback);
+ free (new_script_callback);
+ return NULL;
+ }
+
+ script_callback_init (new_script_callback, script, function, data);
+ new_script_callback->hook = new_hook;
+
+ script_callback_add (script, new_script_callback);
+
+ return new_hook;
+}
+
+/*
* script_api_hook_infolist: hook an infolist
* return new hook, NULL if error
*/