diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-02-12 17:15:30 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-02-12 17:15:30 +0100 |
commit | 922e67cabd767c3da74de6d2c9aa59078fa4ad0f (patch) | |
tree | cab0813b2162e145f7a4d9a3fece6922fd699b19 /src | |
parent | 8d25a7520005625822b0a3e8f9c1e72ee756d30d (diff) | |
download | weechat-922e67cabd767c3da74de6d2c9aa59078fa4ad0f.zip |
Add description of arguments for API functions hook_info and hook_infolist
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-hook.c | 41 | ||||
-rw-r--r-- | src/core/wee-hook.h | 6 | ||||
-rw-r--r-- | src/plugins/alias/alias-info.c | 2 | ||||
-rw-r--r-- | src/plugins/fifo/fifo-info.c | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-info.c | 15 | ||||
-rw-r--r-- | src/plugins/logger/logger-info.c | 4 | ||||
-rw-r--r-- | src/plugins/plugin-api.c | 57 | ||||
-rw-r--r-- | src/plugins/relay/relay-info.c | 2 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 28 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 23 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 20 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 36 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.c | 6 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.h | 3 | ||||
-rw-r--r-- | src/plugins/scripts/script.c | 2 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 23 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 19 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-info.c | 2 |
18 files changed, 225 insertions, 66 deletions
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 08bea3d12..fc298e226 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -2000,7 +2000,7 @@ hook_modifier_exec (struct t_weechat_plugin *plugin, const char *modifier, struct t_hook * hook_info (struct t_weechat_plugin *plugin, const char *info_name, - const char *description, + const char *description, const char *args_description, t_hook_callback_info *callback, void *callback_data) { struct t_hook *new_hook; @@ -2026,6 +2026,8 @@ hook_info (struct t_weechat_plugin *plugin, const char *info_name, new_hook_info->info_name = strdup (info_name); new_hook_info->description = (description) ? strdup (description) : strdup (""); + new_hook_info->args_description = (args_description) ? + strdup (args_description) : strdup (""); hook_add_to_list (new_hook); @@ -2085,7 +2087,8 @@ hook_info_get (struct t_weechat_plugin *plugin, const char *info_name, struct t_hook * hook_infolist (struct t_weechat_plugin *plugin, const char *infolist_name, - const char *description, + const char *description, const char *pointer_description, + const char *args_description, t_hook_callback_infolist *callback, void *callback_data) { struct t_hook *new_hook; @@ -2111,6 +2114,10 @@ hook_infolist (struct t_weechat_plugin *plugin, const char *infolist_name, new_hook_infolist->infolist_name = strdup (infolist_name); new_hook_infolist->description = (description) ? strdup (description) : strdup (""); + new_hook_infolist->pointer_description = (pointer_description) ? + strdup (pointer_description) : strdup (""); + new_hook_infolist->args_description = (args_description) ? + strdup (args_description) : strdup (""); hook_add_to_list (new_hook); @@ -2311,12 +2318,18 @@ unhook (struct t_hook *hook) free (HOOK_INFO(hook, info_name)); if (HOOK_INFO(hook, description)) free (HOOK_INFO(hook, description)); + if (HOOK_INFO(hook, args_description)) + free (HOOK_INFO(hook, args_description)); break; case HOOK_TYPE_INFOLIST: if (HOOK_INFOLIST(hook, infolist_name)) free (HOOK_INFOLIST(hook, infolist_name)); if (HOOK_INFOLIST(hook, description)) free (HOOK_INFOLIST(hook, description)); + if (HOOK_INFOLIST(hook, pointer_description)) + free (HOOK_INFOLIST(hook, pointer_description)); + if (HOOK_INFOLIST(hook, args_description)) + free (HOOK_INFOLIST(hook, args_description)); break; case HOOK_NUM_TYPES: /* this constant is used to count types only, @@ -2632,6 +2645,13 @@ hook_add_to_infolist_type (struct t_infolist *infolist, && HOOK_INFO(ptr_hook, description)[0]) ? _(HOOK_INFO(ptr_hook, description)) : "")) return 0; + if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFO(ptr_hook, args_description))) + return 0; + if (!infolist_new_var_string (ptr_item, "args_description_nls", + (HOOK_INFO(ptr_hook, args_description) + && HOOK_INFO(ptr_hook, args_description)[0]) ? + _(HOOK_INFO(ptr_hook, args_description)) : "")) + return 0; } break; case HOOK_TYPE_INFOLIST: @@ -2648,6 +2668,20 @@ hook_add_to_infolist_type (struct t_infolist *infolist, && HOOK_INFOLIST(ptr_hook, description)[0]) ? _(HOOK_INFOLIST(ptr_hook, description)) : "")) return 0; + if (!infolist_new_var_string (ptr_item, "pointer_description", HOOK_INFOLIST(ptr_hook, pointer_description))) + return 0; + if (!infolist_new_var_string (ptr_item, "pointer_description_nls", + (HOOK_INFOLIST(ptr_hook, pointer_description) + && HOOK_INFOLIST(ptr_hook, pointer_description)[0]) ? + _(HOOK_INFOLIST(ptr_hook, pointer_description)) : "")) + return 0; + if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFOLIST(ptr_hook, args_description))) + return 0; + if (!infolist_new_var_string (ptr_item, "args_description_nls", + (HOOK_INFOLIST(ptr_hook, args_description) + && HOOK_INFOLIST(ptr_hook, args_description)[0]) ? + _(HOOK_INFOLIST(ptr_hook, args_description)) : "")) + return 0; } break; case HOOK_NUM_TYPES: @@ -2878,6 +2912,7 @@ hook_print_log () log_printf (" callback. . . . . . . : 0x%lx", HOOK_INFO(ptr_hook, callback)); log_printf (" info_name . . . . . . : '%s'", HOOK_INFO(ptr_hook, info_name)); log_printf (" description . . . . . : '%s'", HOOK_INFO(ptr_hook, description)); + log_printf (" args_description. . . : '%s'", HOOK_INFO(ptr_hook, args_description)); } break; case HOOK_TYPE_INFOLIST: @@ -2887,6 +2922,8 @@ hook_print_log () log_printf (" callback. . . . . . . : 0x%lx", HOOK_INFOLIST(ptr_hook, callback)); log_printf (" infolist_name . . . . : '%s'", HOOK_INFOLIST(ptr_hook, infolist_name)); log_printf (" description . . . . . : '%s'", HOOK_INFOLIST(ptr_hook, description)); + log_printf (" pointer_description . : '%s'", HOOK_INFOLIST(ptr_hook, pointer_description)); + log_printf (" args_description. . . : '%s'", HOOK_INFOLIST(ptr_hook, args_description)); } break; case HOOK_NUM_TYPES: diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index 046d39ff3..ffe97c602 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -290,6 +290,7 @@ struct t_hook_info t_hook_callback_info *callback; /* info callback */ char *info_name; /* name of info returned */ char *description; /* description */ + char *args_description; /* description of arguments */ }; /* hook infolist */ @@ -304,6 +305,8 @@ struct t_hook_infolist t_hook_callback_infolist *callback; /* infolist callback */ char *infolist_name; /* name of infolist returned */ char *description; /* description */ + char *pointer_description; /* description of pointer */ + char *args_description; /* description of arguments */ }; /* hook variables */ @@ -409,6 +412,7 @@ extern char *hook_modifier_exec (struct t_weechat_plugin *plugin, extern struct t_hook *hook_info (struct t_weechat_plugin *plugin, const char *info_name, const char *description, + const char *args_description, t_hook_callback_info *callback, void *callback_data); extern const char *hook_info_get (struct t_weechat_plugin *plugin, @@ -417,6 +421,8 @@ extern const char *hook_info_get (struct t_weechat_plugin *plugin, extern struct t_hook *hook_infolist (struct t_weechat_plugin *plugin, const char *infolist_name, const char *description, + const char *pointer_description, + const char *args_description, t_hook_callback_infolist *callback, void *callback_data); extern struct t_infolist *hook_infolist_get (struct t_weechat_plugin *plugin, diff --git a/src/plugins/alias/alias-info.c b/src/plugins/alias/alias-info.c index d5132bb16..f4841bd1e 100644 --- a/src/plugins/alias/alias-info.c +++ b/src/plugins/alias/alias-info.c @@ -94,5 +94,7 @@ alias_info_init () { /* alias infolist hooks */ weechat_hook_infolist ("alias", N_("list of aliases"), + N_("alias pointer (optional)"), + N_("alias name (can start or end with \"*\" as joker) (optional)"), &alias_info_get_infolist_cb, NULL); } diff --git a/src/plugins/fifo/fifo-info.c b/src/plugins/fifo/fifo-info.c index ed19a2b8f..e4ed0a02a 100644 --- a/src/plugins/fifo/fifo-info.c +++ b/src/plugins/fifo/fifo-info.c @@ -53,6 +53,6 @@ void fifo_info_init () { /* fifo info hooks */ - weechat_hook_info ("fifo_filename", N_("name of FIFO pipe"), + weechat_hook_info ("fifo_filename", N_("name of FIFO pipe"), NULL, &fifo_info_get_info_cb, NULL); } diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c index a561e5ae2..60c9b6eae 100644 --- a/src/plugins/irc/irc-info.c +++ b/src/plugins/irc/irc-info.c @@ -395,23 +395,36 @@ irc_info_init () { /* info hooks */ weechat_hook_info ("irc_is_channel", N_("1 if string is an IRC channel"), + N_("channel name"), &irc_info_get_info_cb, NULL); weechat_hook_info ("irc_nick", N_("get current nick on a server"), + N_("server name"), &irc_info_get_info_cb, NULL); weechat_hook_info ("irc_nick_from_host", N_("get nick from IRC host"), + N_("IRC host (like `:nick!name@server.com`)"), &irc_info_get_info_cb, NULL); weechat_hook_info ("irc_nick_color", N_("get nick color"), + N_("nickname"), &irc_info_get_info_cb, NULL); - weechat_hook_info ("irc_buffer", N_("get buffer pointer for an IRC server/channel"), + weechat_hook_info ("irc_buffer", N_("get buffer pointer for an IRC server/channel/nick"), + N_("server,channel,nick (channel and nicks are optional)"), &irc_info_get_info_cb, NULL); /* infolist hooks */ weechat_hook_infolist ("irc_server", N_("list of IRC servers"), + N_("server pointer (optional)"), + N_("server name (can start or end with \"*\" as joker) (optional)"), &irc_info_get_infolist_cb, NULL); weechat_hook_infolist ("irc_channel", N_("list of channels for an IRC server"), + N_("channel pointer (optional)"), + N_("server name"), &irc_info_get_infolist_cb, NULL); weechat_hook_infolist ("irc_nick", N_("list of nicks for an IRC channel"), + N_("nick pointer (optional)"), + N_("server,channel,nick (channel and nick are optional)"), &irc_info_get_infolist_cb, NULL); weechat_hook_infolist ("irc_ignore", N_("list of IRC ignores"), + N_("ignore pointer (optional)"), + NULL, &irc_info_get_infolist_cb, NULL); } diff --git a/src/plugins/logger/logger-info.c b/src/plugins/logger/logger-info.c index 930c97864..0befbe10e 100644 --- a/src/plugins/logger/logger-info.c +++ b/src/plugins/logger/logger-info.c @@ -91,7 +91,9 @@ logger_info_get_infolist_cb (void *data, const char *infolist_name, void logger_info_init () { - /* irc infolist hooks */ + /* logger infolist hooks */ weechat_hook_infolist ("logger_buffer", N_("list of logger buffers"), + N_("logger pointer (optional)"), + NULL, &logger_info_get_infolist_cb, NULL); } diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index d3286845f..4e4679a61 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -928,62 +928,91 @@ void plugin_api_init () { /* WeeChat core info hooks */ - hook_info (NULL, "version", N_("WeeChat version"), + hook_info (NULL, "version", N_("WeeChat version"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "version_number", N_("WeeChat version (as number)"), + hook_info (NULL, "version_number", N_("WeeChat version (as number)"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "date", N_("WeeChat compilation date"), + hook_info (NULL, "date", N_("WeeChat compilation date"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "dir_separator", N_("directory separator"), + hook_info (NULL, "dir_separator", N_("directory separator"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "weechat_dir", N_("WeeChat directory"), + hook_info (NULL, "weechat_dir", N_("WeeChat directory"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "weechat_libdir", N_("WeeChat \"lib\" directory"), + hook_info (NULL, "weechat_libdir", N_("WeeChat \"lib\" directory"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "weechat_sharedir", N_("WeeChat \"share\" directory"), + hook_info (NULL, "weechat_sharedir", N_("WeeChat \"share\" directory"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "weechat_localedir", N_("WeeChat \"locale\" directory"), + hook_info (NULL, "weechat_localedir", N_("WeeChat \"locale\" directory"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "weechat_site", N_("WeeChat site"), + hook_info (NULL, "weechat_site", N_("WeeChat site"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "weechat_site_download", N_("WeeChat site, download page"), + hook_info (NULL, "weechat_site_download", N_("WeeChat site, download page"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "charset_terminal", N_("terminal charset"), + hook_info (NULL, "charset_terminal", N_("terminal charset"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "charset_internal", N_("WeeChat internal charset"), + hook_info (NULL, "charset_internal", N_("WeeChat internal charset"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "inactivity", N_("keyboard inactivity (seconds)"), + hook_info (NULL, "inactivity", N_("keyboard inactivity (seconds)"), NULL, &plugin_api_info_get_internal, NULL); - hook_info (NULL, "filters_enabled", N_("1 if filters are enabled"), + hook_info (NULL, "filters_enabled", N_("1 if filters are enabled"), NULL, &plugin_api_info_get_internal, NULL); /* WeeChat core infolist hooks */ hook_infolist (NULL, "bar", N_("list of bars"), + N_("bar pointer (optional)"), + N_("bar name (can start or end with \"*\" as joker) (optional)"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "bar_item", N_("list of bar items"), + N_("bar item pointer (optional)"), + N_("bar item name (can start or end with \"*\" as joker) (optional)"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "bar_window", N_("list of bar windows"), + N_("bar window pointer (optional)"), + NULL, &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "buffer", N_("list of buffers"), + N_("buffer pointer (optional)"), + N_("buffer name (can start or end with \"*\" as joker) (optional)"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "buffer_lines", N_("lines of a buffer"), + N_("buffer pointer"), + NULL, &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "filter", N_("list of filters"), + NULL, + N_("filter name (can start or end with \"*\" as joker) (optional)"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "history", N_("history of commands"), + N_("buffer pointer (if not set, return global history) (optional)"), + NULL, &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "hook", N_("list of hooks"), + NULL, + N_("hook type: command, timer, .. (optional)"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "hotlist", N_("list of buffers in hotlist"), + NULL, + NULL, &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "key", N_("list of key bindings"), + NULL, + NULL, &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "nicklist", N_("nicks in nicklist for a buffer"), + N_("buffer pointer"), + N_("nick_xxx or group_xxx to get only nick/group xxx " + "(optional)"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "option", N_("list of options"), + NULL, + N_("option name (can start or end with \"*\" as joker) (optional)"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "plugin", N_("list of plugins"), + N_("plugin pointer (optional)"), + N_("plugin name (can start or end with \"*\" as joker) (optional)"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "window", N_("list of windows"), + N_("window pointer (optional)"), + N_("window name (can start or end with \"*\" as joker) (optional)"), &plugin_api_infolist_get_internal, NULL); } diff --git a/src/plugins/relay/relay-info.c b/src/plugins/relay/relay-info.c index 1b3fd50ad..b1a0ab3d3 100644 --- a/src/plugins/relay/relay-info.c +++ b/src/plugins/relay/relay-info.c @@ -92,5 +92,7 @@ relay_info_init () { /* relay infolist hooks */ weechat_hook_infolist ("relay", N_("list of relay clients"), + N_("relay pointer (optional)"), + NULL, &relay_info_get_infolist_cb, NULL); } diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index ff2db2fd1..d166782b9 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -4291,7 +4291,7 @@ weechat_lua_api_hook_info_cb (void *data, const char *info_name, static int weechat_lua_api_hook_info (lua_State *L) { - const char *info_name, *description, *function, *data; + const char *info_name, *description, *args_description, *function, *data; char *result; int n; @@ -4305,19 +4305,22 @@ weechat_lua_api_hook_info (lua_State *L) } info_name = NULL; + description = NULL; + args_description = NULL; function = NULL; data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 4) + if (n < 5) { WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_info"); LUA_RETURN_EMPTY; } - info_name = lua_tostring (lua_current_interpreter, -4); - description = lua_tostring (lua_current_interpreter, -3); + info_name = lua_tostring (lua_current_interpreter, -5); + description = lua_tostring (lua_current_interpreter, -4); + args_description = lua_tostring (lua_current_interpreter, -3); function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); @@ -4325,6 +4328,7 @@ weechat_lua_api_hook_info (lua_State *L) lua_current_script, info_name, description, + args_description, &weechat_lua_api_hook_info_cb, function, data)); @@ -4375,7 +4379,8 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name, static int weechat_lua_api_hook_infolist (lua_State *L) { - const char *infolist_name, *description, *function, *data; + const char *infolist_name, *description, *pointer_description; + const char *args_description, *function, *data; char *result; int n; @@ -4389,19 +4394,24 @@ weechat_lua_api_hook_infolist (lua_State *L) } infolist_name = NULL; + description = NULL; + pointer_description = NULL; + args_description = NULL; function = NULL; data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 4) + if (n < 6) { WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_infolist"); LUA_RETURN_EMPTY; } - infolist_name = lua_tostring (lua_current_interpreter, -4); - description = lua_tostring (lua_current_interpreter, -3); + infolist_name = lua_tostring (lua_current_interpreter, -6); + description = lua_tostring (lua_current_interpreter, -5); + pointer_description = lua_tostring (lua_current_interpreter, -4); + args_description = lua_tostring (lua_current_interpreter, -3); function = lua_tostring (lua_current_interpreter, -2); data = lua_tostring (lua_current_interpreter, -1); @@ -4409,6 +4419,8 @@ weechat_lua_api_hook_infolist (lua_State *L) lua_current_script, infolist_name, description, + pointer_description, + args_description, &weechat_lua_api_hook_infolist_cb, function, data)); diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 4406b097c..660af505f 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -3650,7 +3650,7 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name, XS (XS_weechat_api_hook_info) { - char *result, *info_name, *description, *function, *data; + char *result, *info_name, *description, *args_description, *function, *data; dXSARGS; /* make C compiler happy */ @@ -3662,7 +3662,7 @@ XS (XS_weechat_api_hook_info) PERL_RETURN_EMPTY; } - if (items < 4) + if (items < 5) { WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_info"); PERL_RETURN_EMPTY; @@ -3670,13 +3670,15 @@ XS (XS_weechat_api_hook_info) info_name = SvPV (ST (0), PL_na); description = SvPV (ST (1), PL_na); - function = SvPV (ST (2), PL_na); - data = SvPV (ST (3), PL_na); + args_description = SvPV (ST (2), PL_na); + function = SvPV (ST (3), PL_na); + data = SvPV (ST (4), PL_na); result = script_ptr2str (script_api_hook_info (weechat_perl_plugin, perl_current_script, info_name, description, + args_description, &weechat_perl_api_hook_info_cb, function, data)); @@ -3726,7 +3728,8 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name, XS (XS_weechat_api_hook_infolist) { - char *result, *infolist_name, *description, *function, *data; + char *result, *infolist_name, *description, *pointer_description; + char *args_description, *function, *data; dXSARGS; /* make C compiler happy */ @@ -3738,7 +3741,7 @@ XS (XS_weechat_api_hook_infolist) PERL_RETURN_EMPTY; } - if (items < 4) + if (items < 6) { WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_infolist"); PERL_RETURN_EMPTY; @@ -3746,13 +3749,17 @@ XS (XS_weechat_api_hook_infolist) infolist_name = SvPV (ST (0), PL_na); description = SvPV (ST (1), PL_na); - function = SvPV (ST (2), PL_na); - data = SvPV (ST (3), PL_na); + pointer_description = SvPV (ST (2), PL_na); + args_description = SvPV (ST (3), PL_na); + function = SvPV (ST (4), PL_na); + data = SvPV (ST (5), PL_na); result = script_ptr2str (script_api_hook_infolist (weechat_perl_plugin, perl_current_script, infolist_name, description, + pointer_description, + args_description, &weechat_perl_api_hook_infolist_cb, function, data)); diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index f54772f55..5ab77a57a 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -3838,7 +3838,7 @@ weechat_python_api_hook_info_cb (void *data, const char *info_name, static PyObject * weechat_python_api_hook_info (PyObject *self, PyObject *args) { - char *info_name, *description, *function, *data, *result; + char *info_name, *description, *args_description, *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -3852,11 +3852,12 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args) info_name = NULL; description = NULL; + args_description = NULL; function = NULL; data = NULL; - if (!PyArg_ParseTuple (args, "ssss", &info_name, &description, &function, - &data)) + if (!PyArg_ParseTuple (args, "sssss", &info_name, &description, + &args_description, &function, &data)) { WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_info"); PYTHON_RETURN_EMPTY; @@ -3866,6 +3867,7 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args) python_current_script, info_name, description, + args_description, &weechat_python_api_hook_info_cb, function, data)); @@ -3916,7 +3918,8 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name, static PyObject * weechat_python_api_hook_infolist (PyObject *self, PyObject *args) { - char *infolist_name, *description, *function, *data, *result; + char *infolist_name, *description, *pointer_description, *args_description; + char *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -3930,11 +3933,14 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args) infolist_name = NULL; description = NULL; + pointer_description = NULL; + args_description = NULL; function = NULL; data = NULL; - if (!PyArg_ParseTuple (args, "ssss", &infolist_name, &description, - &function, &data)) + if (!PyArg_ParseTuple (args, "ssssss", &infolist_name, &description, + &pointer_description, &args_description, &function, + &data)) { WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_infolist"); PYTHON_RETURN_EMPTY; @@ -3944,6 +3950,8 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args) python_current_script, infolist_name, description, + pointer_description, + args_description, &weechat_python_api_hook_infolist_cb, function, data)); diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index f81be474b..a5af066cd 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -4428,9 +4428,10 @@ weechat_ruby_api_hook_info_cb (void *data, const char *info_name, static VALUE weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description, - VALUE function, VALUE data) + VALUE args_description, VALUE function, VALUE data) { - char *c_info_name, *c_description, *c_function, *c_data, *result; + char *c_info_name, *c_description, *c_args_description, *c_function; + char *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -4444,11 +4445,12 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description, c_info_name = NULL; c_description = NULL; + c_args_description = NULL; c_function = NULL; c_data = NULL; - if (NIL_P (info_name) || NIL_P (description) || NIL_P (function) - || NIL_P (data)) + if (NIL_P (info_name) || NIL_P (description) || NIL_P (args_description) + || NIL_P (function) || NIL_P (data)) { WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_info"); RUBY_RETURN_EMPTY; @@ -4456,11 +4458,13 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description, Check_Type (info_name, T_STRING); Check_Type (description, T_STRING); + Check_Type (args_description, T_STRING); Check_Type (function, T_STRING); Check_Type (data, T_STRING); c_info_name = STR2CSTR (info_name); c_description = STR2CSTR (description); + c_args_description = STR2CSTR (args_description); c_function = STR2CSTR (function); c_data = STR2CSTR (data); @@ -4468,6 +4472,7 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description, ruby_current_script, c_info_name, c_description, + c_args_description, &weechat_ruby_api_hook_info_cb, c_function, c_data)); @@ -4517,10 +4522,12 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name, static VALUE weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, - VALUE description, VALUE function, + VALUE description, VALUE pointer_description, + VALUE args_description, VALUE function, VALUE data) { - char *c_infolist_name, *c_description, *c_function, *c_data, *result; + char *c_infolist_name, *c_description, *c_pointer_description; + char *c_args_description, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -4534,11 +4541,14 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, c_infolist_name = NULL; c_description = NULL; + c_pointer_description = NULL; + c_args_description = NULL; c_function = NULL; c_data = NULL; - if (NIL_P (infolist_name) || NIL_P (description) || NIL_P (function) - || NIL_P (data)) + if (NIL_P (infolist_name) || NIL_P (description) + || NIL_P (pointer_description) || NIL_P (args_description) + || NIL_P (function) || NIL_P (data)) { WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_infolist"); RUBY_RETURN_EMPTY; @@ -4546,11 +4556,15 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, Check_Type (infolist_name, T_STRING); Check_Type (description, T_STRING); + Check_Type (pointer_description, T_STRING); + Check_Type (args_description, T_STRING); Check_Type (function, T_STRING); Check_Type (data, T_STRING); c_infolist_name = STR2CSTR (infolist_name); c_description = STR2CSTR (description); + c_pointer_description = STR2CSTR (pointer_description); + c_args_description = STR2CSTR (args_description); c_function = STR2CSTR (function); c_data = STR2CSTR (data); @@ -4558,6 +4572,8 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, ruby_current_script, c_infolist_name, c_description, + c_pointer_description, + c_args_description, &weechat_ruby_api_hook_infolist_cb, c_function, c_data)); @@ -7078,8 +7094,8 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "hook_completion_list_add", &weechat_ruby_api_hook_completion_list_add, 4); rb_define_module_function (ruby_mWeechat, "hook_modifier", &weechat_ruby_api_hook_modifier, 3); rb_define_module_function (ruby_mWeechat, "hook_modifier_exec", &weechat_ruby_api_hook_modifier_exec, 3); - rb_define_module_function (ruby_mWeechat, "hook_info", &weechat_ruby_api_hook_info, 4); - rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 4); + rb_define_module_function (ruby_mWeechat, "hook_info", &weechat_ruby_api_hook_info, 5); + rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 6); rb_define_module_function (ruby_mWeechat, "unhook", &weechat_ruby_api_unhook, 1); rb_define_module_function (ruby_mWeechat, "unhook_all", &weechat_ruby_api_unhook_all, 0); rb_define_module_function (ruby_mWeechat, "buffer_new", &weechat_ruby_api_buffer_new, 5); diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c index 89ba84444..879e5bb97 100644 --- a/src/plugins/scripts/script-api.c +++ b/src/plugins/scripts/script-api.c @@ -1169,6 +1169,7 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *info_name, const char *description, + const char *args_description, const char *(*callback)(void *data, const char *info_name, const char *arguments), @@ -1182,7 +1183,7 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin, if (!new_script_callback) return NULL; - new_hook = weechat_hook_info (info_name, description, + new_hook = weechat_hook_info (info_name, description, args_description, callback, new_script_callback); if (!new_hook) { @@ -1209,6 +1210,8 @@ script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *infolist_name, const char *description, + const char *pointer_description, + const char *args_description, struct t_infolist *(*callback)(void *data, const char *infolist_name, void *pointer, @@ -1224,6 +1227,7 @@ script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin, return NULL; new_hook = weechat_hook_infolist (infolist_name, description, + pointer_description, args_description, callback, new_script_callback); if (!new_hook) { diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h index 4b641f502..2f99b819e 100644 --- a/src/plugins/scripts/script-api.h +++ b/src/plugins/scripts/script-api.h @@ -236,6 +236,7 @@ extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plu struct t_plugin_script *script, const char *info_name, const char *description, + const char *args_description, const char *(*callback)(void *data, const char *info_name, const char *arguments), @@ -245,6 +246,8 @@ extern struct t_hook *script_api_hook_infolist (struct t_weechat_plugin *weechat struct t_plugin_script *script, const char *infolist_name, const char *description, + const char *pointer_description, + const char *args_description, struct t_infolist *(*callback)(void *data, const char *infolist_name, void *pointer, diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c index aea1f2611..8d8cf8fc6 100644 --- a/src/plugins/scripts/script.c +++ b/src/plugins/scripts/script.c @@ -278,6 +278,8 @@ script_init (struct t_weechat_plugin *weechat_plugin, weechat_hook_completion (string, N_("list of scripts"), callback_completion, NULL); weechat_hook_infolist (string, N_("list of scripts"), + N_("script pointer (optional)"), + N_("script name (can start or end with \"*\" as joker) (optional)"), callback_infolist, NULL); free (string); } diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index 2e3553256..65fcb1bd4 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -4110,7 +4110,7 @@ weechat_tcl_api_hook_info (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *info_name, *description, *function, *data; + char *result, *info_name, *description, *args_description, *function, *data; int i; /* make C compiler happy */ @@ -4122,7 +4122,7 @@ weechat_tcl_api_hook_info (ClientData clientData, Tcl_Interp *interp, TCL_RETURN_EMPTY; } - if (objc < 5) + if (objc < 6) { WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_info"); TCL_RETURN_EMPTY; @@ -4130,13 +4130,15 @@ weechat_tcl_api_hook_info (ClientData clientData, Tcl_Interp *interp, info_name = Tcl_GetStringFromObj (objv[1], &i); description = Tcl_GetStringFromObj (objv[2], &i); - function = Tcl_GetStringFromObj (objv[3], &i); - data = Tcl_GetStringFromObj (objv[4], &i); + args_description = Tcl_GetStringFromObj (objv[3], &i); + function = Tcl_GetStringFromObj (objv[4], &i); + data = Tcl_GetStringFromObj (objv[5], &i); result = script_ptr2str (script_api_hook_info (weechat_tcl_plugin, tcl_current_script, info_name, description, + args_description, &weechat_tcl_api_hook_info_cb, function, data)); @@ -4189,7 +4191,8 @@ weechat_tcl_api_hook_infolist (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *infolist_name, *description, *function, *data; + char *result, *infolist_name, *description, *pointer_description; + char *args_description, *function, *data; int i; /* make C compiler happy */ @@ -4201,7 +4204,7 @@ weechat_tcl_api_hook_infolist (ClientData clientData, Tcl_Interp *interp, TCL_RETURN_EMPTY; } - if (objc < 5) + if (objc < 7) { WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_infolist"); TCL_RETURN_EMPTY; @@ -4209,13 +4212,17 @@ weechat_tcl_api_hook_infolist (ClientData clientData, Tcl_Interp *interp, infolist_name = Tcl_GetStringFromObj (objv[1], &i); description = Tcl_GetStringFromObj (objv[2], &i); - function = Tcl_GetStringFromObj (objv[3], &i); - data = Tcl_GetStringFromObj (objv[4], &i); + pointer_description = Tcl_GetStringFromObj (objv[3], &i); + args_description = Tcl_GetStringFromObj (objv[4], &i); + function = Tcl_GetStringFromObj (objv[5], &i); + data = Tcl_GetStringFromObj (objv[6], &i); result = script_ptr2str (script_api_hook_infolist (weechat_tcl_plugin, tcl_current_script, infolist_name, description, + pointer_description, + args_description, &weechat_tcl_api_hook_infolist_cb, function, data)); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 5fafeec0c..5f6a0e4e3 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -34,7 +34,7 @@ struct t_weelist; struct timeval; /* API version (used to check that plugin has same API and can be loaded) */ -#define WEECHAT_PLUGIN_API_VERSION "20100209-01" +#define WEECHAT_PLUGIN_API_VERSION "20100212-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -462,6 +462,7 @@ struct t_weechat_plugin struct t_hook *(*hook_info) (struct t_weechat_plugin *plugin, const char *info_name, const char *description, + const char *args_description, const char *(*callback)(void *data, const char *info_name, const char *arguments), @@ -469,6 +470,8 @@ struct t_weechat_plugin struct t_hook *(*hook_infolist) (struct t_weechat_plugin *plugin, const char *infolist_name, const char *description, + const char *pointer_description, + const char *args_description, struct t_infolist *(*callback)(void *data, const char *infolist_name, void *pointer, @@ -1017,14 +1020,18 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); __string) \ weechat_plugin->hook_modifier_exec(weechat_plugin, __modifier, \ __modifier_data, __string) -#define weechat_hook_info(__info_name, __description, __callback, \ - __data) \ +#define weechat_hook_info(__info_name, __description, \ + __args_description, __callback, __data) \ weechat_plugin->hook_info(weechat_plugin, __info_name, \ - __description, __callback, __data) + __description, __args_description, \ + __callback, __data) #define weechat_hook_infolist(__infolist_name, __description, \ - __callback, __data) \ + __pointer_description, \ + __args_description, __callback, __data) \ weechat_plugin->hook_infolist(weechat_plugin, __infolist_name, \ - __description, __callback, __data) + __description, __pointer_description, \ + __args_description, __callback, \ + __data) #define weechat_unhook(__hook) \ weechat_plugin->unhook( __hook) #define weechat_unhook_all() \ diff --git a/src/plugins/xfer/xfer-info.c b/src/plugins/xfer/xfer-info.c index de18a0974..947c0c698 100644 --- a/src/plugins/xfer/xfer-info.c +++ b/src/plugins/xfer/xfer-info.c @@ -91,5 +91,7 @@ xfer_info_init () { /* xfer infolist hooks */ weechat_hook_infolist ("xfer", N_("list of xfer"), + N_("xfer pointer (optional)"), + NULL, &xfer_info_get_infolist_cb, NULL); } |