mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 20:36:38 +02:00
Add new hooks (info and infolist), IRC plugin now return infos and infolists
This commit is contained in:
@@ -875,6 +875,84 @@ script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin,
|
||||
return new_hook;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_hook_info: hook an info
|
||||
* return new hook, NULL if error
|
||||
*/
|
||||
|
||||
struct t_hook *
|
||||
script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *info_name,
|
||||
char *(*callback)(void *data,
|
||||
const char *info_name,
|
||||
const char *arguments),
|
||||
const char *function)
|
||||
{
|
||||
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 (info_name, callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
script_callback_free_data (new_script_callback);
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_script_callback->script = script;
|
||||
new_script_callback->function = strdup (function);
|
||||
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
|
||||
*/
|
||||
|
||||
struct t_hook *
|
||||
script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *infolist_name,
|
||||
struct t_infolist *(*callback)(void *data,
|
||||
const char *infolist_name,
|
||||
void *pointer,
|
||||
const char *arguments),
|
||||
const char *function)
|
||||
{
|
||||
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_infolist (infolist_name,
|
||||
callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
script_callback_free_data (new_script_callback);
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_script_callback->script = script;
|
||||
new_script_callback->function = strdup (function);
|
||||
new_script_callback->hook = new_hook;
|
||||
|
||||
script_callback_add (script, new_script_callback);
|
||||
|
||||
return new_hook;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_unhook: unhook something
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user