diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-05-02 16:17:31 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-05-02 16:17:31 +0200 |
commit | 5f1c0c8254fdea03f1c42b569a67acd2b1c493ac (patch) | |
tree | 63083dd3268fb2cc6425ed84fe50e3141d80ef07 /src/plugins | |
parent | a09fc8472698d6f269a0d3f9f203ecd79f757bfc (diff) | |
download | weechat-5f1c0c8254fdea03f1c42b569a67acd2b1c493ac.zip |
Add data string argument in all callbacks of script API, display script name in error messages for scripts
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 1219 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua.c | 8 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua.h | 2 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 1131 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl.h | 2 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 1068 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 21 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python.h | 2 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 1207 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby.c | 34 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby.h | 2 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.c | 187 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.h | 64 | ||||
-rw-r--r-- | src/plugins/scripts/script-callback.c | 23 | ||||
-rw-r--r-- | src/plugins/scripts/script-callback.h | 5 | ||||
-rw-r--r-- | src/plugins/scripts/script.c | 15 | ||||
-rw-r--r-- | src/plugins/scripts/script.h | 16 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 1156 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl.h | 2 |
19 files changed, 3453 insertions, 2711 deletions
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index 957d249b1..854fc16a8 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -83,7 +83,7 @@ weechat_lua_api_register (lua_State *L) if (n < 7) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("register"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(lua_current_script_filename, "register"); LUA_RETURN_ERROR; } @@ -151,7 +151,7 @@ weechat_lua_api_plugin_get_name (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "plugin_get_name"); LUA_RETURN_EMPTY; } @@ -161,7 +161,7 @@ weechat_lua_api_plugin_get_name (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "plugin_get_name"); LUA_RETURN_EMPTY; } @@ -187,7 +187,7 @@ weechat_lua_api_charset_set (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("charset_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "charset_set"); LUA_RETURN_ERROR; } @@ -197,7 +197,7 @@ weechat_lua_api_charset_set (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("charset_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "charset_set"); LUA_RETURN_ERROR; } @@ -225,7 +225,7 @@ weechat_lua_api_iconv_to_internal (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_to_internal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "iconv_to_internal"); LUA_RETURN_EMPTY; } @@ -236,7 +236,7 @@ weechat_lua_api_iconv_to_internal (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_to_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "iconv_to_internal"); LUA_RETURN_EMPTY; } @@ -265,7 +265,7 @@ weechat_lua_api_iconv_from_internal (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_from_internal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "iconv_from_internal"); LUA_RETURN_EMPTY; } @@ -276,7 +276,7 @@ weechat_lua_api_iconv_from_internal (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_from_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "iconv_from_internal"); LUA_RETURN_EMPTY; } @@ -303,7 +303,7 @@ weechat_lua_api_gettext (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("gettext"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "gettext"); LUA_RETURN_EMPTY; } @@ -313,7 +313,7 @@ weechat_lua_api_gettext (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("gettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "gettext"); LUA_RETURN_EMPTY; } @@ -339,7 +339,7 @@ weechat_lua_api_ngettext (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("ngettext"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "ngettext"); LUA_RETURN_EMPTY; } @@ -351,7 +351,7 @@ weechat_lua_api_ngettext (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("ngettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "ngettext"); LUA_RETURN_EMPTY; } @@ -380,7 +380,7 @@ weechat_lua_api_string_remove_color (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("string_remove_color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "string_remove_color"); LUA_RETURN_EMPTY; } @@ -390,7 +390,7 @@ weechat_lua_api_string_remove_color (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "string_remove_color"); LUA_RETURN_EMPTY; } @@ -417,7 +417,7 @@ weechat_lua_api_mkdir_home (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_home"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "mkdir_home"); LUA_RETURN_ERROR; } @@ -428,7 +428,7 @@ weechat_lua_api_mkdir_home (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_home"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "mkdir_home"); LUA_RETURN_ERROR; } @@ -456,7 +456,7 @@ weechat_lua_api_mkdir (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "mkdir"); LUA_RETURN_ERROR; } @@ -467,7 +467,7 @@ weechat_lua_api_mkdir (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "mkdir"); LUA_RETURN_ERROR; } @@ -496,7 +496,7 @@ weechat_lua_api_mkdir_parents (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_parents"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "mkdir_parents"); LUA_RETURN_ERROR; } @@ -507,7 +507,7 @@ weechat_lua_api_mkdir_parents (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_parents"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "mkdir_parents"); LUA_RETURN_ERROR; } @@ -534,7 +534,7 @@ weechat_lua_api_list_new (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_new"); LUA_RETURN_EMPTY; } @@ -559,7 +559,7 @@ weechat_lua_api_list_add (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_add"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_add"); LUA_RETURN_EMPTY; } @@ -572,7 +572,7 @@ weechat_lua_api_list_add (lua_State *L) if (n < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_add"); LUA_RETURN_EMPTY; } @@ -605,7 +605,7 @@ weechat_lua_api_list_search (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_search"); LUA_RETURN_EMPTY; } @@ -616,7 +616,7 @@ weechat_lua_api_list_search (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_search"); LUA_RETURN_EMPTY; } @@ -645,7 +645,7 @@ weechat_lua_api_list_casesearch (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_casesearch"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_casesearch"); LUA_RETURN_EMPTY; } @@ -656,7 +656,7 @@ weechat_lua_api_list_casesearch (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_casesearch"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_casesearch"); LUA_RETURN_EMPTY; } @@ -685,7 +685,7 @@ weechat_lua_api_list_get (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_get"); LUA_RETURN_EMPTY; } @@ -696,7 +696,7 @@ weechat_lua_api_list_get (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_get"); LUA_RETURN_EMPTY; } @@ -724,7 +724,7 @@ weechat_lua_api_list_set (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_set"); LUA_RETURN_ERROR; } @@ -735,7 +735,7 @@ weechat_lua_api_list_set (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_set"); LUA_RETURN_ERROR; } @@ -764,7 +764,7 @@ weechat_lua_api_list_next (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_next"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_next"); LUA_RETURN_EMPTY; } @@ -774,7 +774,7 @@ weechat_lua_api_list_next (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_next"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_next"); LUA_RETURN_EMPTY; } @@ -801,7 +801,7 @@ weechat_lua_api_list_prev (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_prev"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_prev"); LUA_RETURN_EMPTY; } @@ -811,7 +811,7 @@ weechat_lua_api_list_prev (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_prev"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_prev"); LUA_RETURN_EMPTY; } @@ -837,7 +837,7 @@ weechat_lua_api_list_string (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_string"); LUA_RETURN_EMPTY; } @@ -847,7 +847,7 @@ weechat_lua_api_list_string (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_string"); LUA_RETURN_EMPTY; } @@ -873,7 +873,7 @@ weechat_lua_api_list_size (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_size"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_size"); LUA_RETURN_INT(0); } @@ -883,7 +883,7 @@ weechat_lua_api_list_size (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_size"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_size"); LUA_RETURN_INT(0); } @@ -909,7 +909,7 @@ weechat_lua_api_list_remove (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_remove"); LUA_RETURN_ERROR; } @@ -920,7 +920,7 @@ weechat_lua_api_list_remove (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_remove"); LUA_RETURN_ERROR; } @@ -948,7 +948,7 @@ weechat_lua_api_list_remove_all (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_remove_all"); LUA_RETURN_ERROR; } @@ -958,7 +958,7 @@ weechat_lua_api_list_remove_all (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_remove_all"); LUA_RETURN_ERROR; } @@ -984,7 +984,7 @@ weechat_lua_api_list_free (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_free"); LUA_RETURN_ERROR; } @@ -994,7 +994,7 @@ weechat_lua_api_list_free (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_free"); LUA_RETURN_ERROR; } @@ -1014,15 +1014,16 @@ weechat_lua_api_config_reload_cb (void *data, struct t_config_file *config_file) { struct t_script_callback *script_callback; - char *lua_argv[2]; + char *lua_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (config_file); - lua_argv[1] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (config_file); + lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1036,8 +1037,8 @@ weechat_lua_api_config_reload_cb (void *data, ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); + if (lua_argv[1]) + free (lua_argv[1]); return ret; } @@ -1052,7 +1053,7 @@ weechat_lua_api_config_reload_cb (void *data, static int weechat_lua_api_config_new (lua_State *L) { - const char *name, *function; + const char *name, *function, *data; char *result; int n; @@ -1061,29 +1062,32 @@ weechat_lua_api_config_new (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_new"); LUA_RETURN_EMPTY; } name = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 2) + if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_new"); LUA_RETURN_EMPTY; } - name = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + name = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_config_new (weechat_lua_plugin, lua_current_script, name, &weechat_lua_api_config_reload_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -1099,18 +1103,19 @@ weechat_lua_api_config_read_cb (void *data, const char *option_name, const char *value) { struct t_script_callback *script_callback; - char *lua_argv[5], empty_arg[1] = { '\0' }; + char *lua_argv[6], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (config_file); - lua_argv[1] = script_ptr2str (section); - lua_argv[2] = (option_name) ? (char *)option_name : empty_arg; - lua_argv[3] = (value) ? (char *)value : empty_arg; - lua_argv[4] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (config_file); + lua_argv[2] = script_ptr2str (section); + lua_argv[3] = (option_name) ? (char *)option_name : empty_arg; + lua_argv[4] = (value) ? (char *)value : empty_arg; + lua_argv[5] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1124,10 +1129,10 @@ weechat_lua_api_config_read_cb (void *data, ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); if (lua_argv[1]) free (lua_argv[1]); + if (lua_argv[2]) + free (lua_argv[2]); return ret; } @@ -1145,16 +1150,17 @@ weechat_lua_api_config_section_write_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *lua_argv[3], empty_arg[1] = { '\0' }; + char *lua_argv[4], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (config_file); - lua_argv[1] = (section_name) ? (char *)section_name : empty_arg; - lua_argv[2] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (config_file); + lua_argv[2] = (section_name) ? (char *)section_name : empty_arg; + lua_argv[3] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1163,8 +1169,8 @@ weechat_lua_api_config_section_write_cb (void *data, if (rc) free (rc); - if (lua_argv[0]) - free (lua_argv[0]); + if (lua_argv[1]) + free (lua_argv[1]); } } @@ -1179,16 +1185,17 @@ weechat_lua_api_config_section_write_default_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *lua_argv[3], empty_arg[1] = { '\0' }; + char *lua_argv[4], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (config_file); - lua_argv[1] = (section_name) ? (char *)section_name : empty_arg; - lua_argv[2] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (config_file); + lua_argv[2] = (section_name) ? (char *)section_name : empty_arg; + lua_argv[3] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1197,8 +1204,8 @@ weechat_lua_api_config_section_write_default_cb (void *data, if (rc) free (rc); - if (lua_argv[0]) - free (lua_argv[0]); + if (lua_argv[1]) + free (lua_argv[1]); } } @@ -1214,18 +1221,19 @@ weechat_lua_api_config_section_create_option_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *lua_argv[5], empty_arg[1] = { '\0' }; + char *lua_argv[6], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (config_file); - lua_argv[1] = script_ptr2str (section); - lua_argv[2] = (option_name) ? (char *)option_name : empty_arg; - lua_argv[3] = (value) ? (char *)value : empty_arg; - lua_argv[4] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (config_file); + lua_argv[2] = script_ptr2str (section); + lua_argv[3] = (option_name) ? (char *)option_name : empty_arg; + lua_argv[4] = (value) ? (char *)value : empty_arg; + lua_argv[5] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1239,10 +1247,10 @@ weechat_lua_api_config_section_create_option_cb (void *data, ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); if (lua_argv[1]) free (lua_argv[1]); + if (lua_argv[2]) + free (lua_argv[2]); return ret; } @@ -1261,17 +1269,18 @@ weechat_lua_api_config_section_delete_option_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *lua_argv[4]; + char *lua_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (config_file); - lua_argv[1] = script_ptr2str (section); - lua_argv[2] = script_ptr2str (option); - lua_argv[3] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (config_file); + lua_argv[2] = script_ptr2str (section); + lua_argv[3] = script_ptr2str (option); + lua_argv[4] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1285,12 +1294,12 @@ weechat_lua_api_config_section_delete_option_cb (void *data, ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); if (lua_argv[1]) free (lua_argv[1]); if (lua_argv[2]) free (lua_argv[2]); + if (lua_argv[3]) + free (lua_argv[3]); return ret; } @@ -1305,9 +1314,11 @@ weechat_lua_api_config_section_delete_option_cb (void *data, static int weechat_lua_api_config_new_section (lua_State *L) { - const char *config_file, *name, *function_read, *function_write; - const char *function_write_default, *function_create_option; - const char *function_delete_option; + const char *config_file, *name, *function_read, *data_read; + const char *function_write, *data_write, *function_write_default; + const char *data_write_default, *function_create_option; + const char *data_create_option, *function_delete_option; + const char *data_delete_option; char *result; int n, user_can_add_options, user_can_delete_options; @@ -1316,7 +1327,7 @@ weechat_lua_api_config_new_section (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new_section"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_new_section"); LUA_RETURN_EMPTY; } @@ -1325,28 +1336,38 @@ weechat_lua_api_config_new_section (lua_State *L) user_can_add_options = 0; user_can_delete_options = 0; function_read = NULL; + data_read = NULL; function_write = NULL; + data_write = NULL; function_write_default = NULL; + data_write_default = NULL; function_create_option = NULL; + data_create_option = NULL; function_delete_option = NULL; + data_delete_option = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 9) + if (n < 14) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_new_section"); LUA_RETURN_EMPTY; } - config_file = lua_tostring (lua_current_interpreter, -9); - name = lua_tostring (lua_current_interpreter, -8); - user_can_add_options = lua_tonumber (lua_current_interpreter, -7); - user_can_delete_options = lua_tonumber (lua_current_interpreter, -6); - function_read = lua_tostring (lua_current_interpreter, -5); - function_write = lua_tostring (lua_current_interpreter, -4); - function_write_default = lua_tostring (lua_current_interpreter, -3); - function_create_option = lua_tostring (lua_current_interpreter, -2); - function_delete_option = lua_tostring (lua_current_interpreter, -1); + config_file = lua_tostring (lua_current_interpreter, -14); + name = lua_tostring (lua_current_interpreter, -13); + user_can_add_options = lua_tonumber (lua_current_interpreter, -12); + user_can_delete_options = lua_tonumber (lua_current_interpreter, -11); + function_read = lua_tostring (lua_current_interpreter, -10); + data_read = lua_tostring (lua_current_interpreter, -9); + function_write = lua_tostring (lua_current_interpreter, -8); + data_write = lua_tostring (lua_current_interpreter, -7); + function_write_default = lua_tostring (lua_current_interpreter, -6); + data_write_default = lua_tostring (lua_current_interpreter, -5); + function_create_option = lua_tostring (lua_current_interpreter, -4); + data_create_option = lua_tostring (lua_current_interpreter, -3); + function_delete_option = lua_tostring (lua_current_interpreter, -2); + data_delete_option = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_config_new_section (weechat_lua_plugin, lua_current_script, @@ -1356,14 +1377,19 @@ weechat_lua_api_config_new_section (lua_State *L) user_can_delete_options, &weechat_lua_api_config_read_cb, function_read, + data_read, &weechat_lua_api_config_section_write_cb, function_write, + data_write, &weechat_lua_api_config_section_write_default_cb, function_write_default, + data_write_default, &weechat_lua_api_config_section_create_option_cb, function_create_option, + data_create_option, &weechat_lua_api_config_section_delete_option_cb, - function_delete_option)); + function_delete_option, + data_delete_option)); LUA_RETURN_STRING_FREE(result); } @@ -1384,7 +1410,7 @@ weechat_lua_api_config_search_section (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_search_section"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_search_section"); LUA_RETURN_EMPTY; } @@ -1395,7 +1421,7 @@ weechat_lua_api_config_search_section (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_search_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_search_section"); LUA_RETURN_EMPTY; } @@ -1419,16 +1445,17 @@ weechat_lua_api_config_option_check_value_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *lua_argv[3], empty_arg[1] = { '\0' }; + char *lua_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (option); - lua_argv[1] = (value) ? (char *)value : empty_arg; - lua_argv[2] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (option); + lua_argv[2] = (value) ? (char *)value : empty_arg; + lua_argv[3] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1442,8 +1469,8 @@ weechat_lua_api_config_option_check_value_cb (void *data, ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); + if (lua_argv[1]) + free (lua_argv[1]); return ret; } @@ -1460,23 +1487,24 @@ weechat_lua_api_config_option_change_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *lua_argv[2]; + char *lua_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (option); - lua_argv[1] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (option); + lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, script_callback->function, lua_argv); - if (lua_argv[0]) - free (lua_argv[0]); + if (lua_argv[1]) + free (lua_argv[1]); if (rc) free (rc); @@ -1492,23 +1520,24 @@ weechat_lua_api_config_option_delete_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *lua_argv[2]; + char *lua_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (option); - lua_argv[1] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (option); + lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, script_callback->function, lua_argv); - if (lua_argv[0]) - free (lua_argv[0]); + if (lua_argv[1]) + free (lua_argv[1]); if (rc) free (rc); @@ -1524,7 +1553,8 @@ weechat_lua_api_config_new_option (lua_State *L) { const char *config_file, *section, *name, *type, *description; const char *string_values, *default_value, *value; - const char *function_check_value, *function_change, *function_delete; + const char *function_check_value, *data_check_value, *function_change; + const char *data_change, *function_delete, *data_delete; char *result; int n, min, max, null_value_allowed; @@ -1533,7 +1563,7 @@ weechat_lua_api_config_new_option (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_new_option"); LUA_RETURN_EMPTY; } @@ -1549,31 +1579,37 @@ weechat_lua_api_config_new_option (lua_State *L) value = NULL; null_value_allowed = 0; function_check_value = NULL; + data_check_value = NULL; function_change = NULL; + data_change = NULL; function_delete = NULL; + data_delete = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 14) + if (n < 17) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_new_option"); LUA_RETURN_EMPTY; } - config_file = lua_tostring (lua_current_interpreter, -14); - section = lua_tostring (lua_current_interpreter, -13); - name = lua_tostring (lua_current_interpreter, -12); - type = lua_tostring (lua_current_interpreter, -11); - description = lua_tostring (lua_current_interpreter, -10); - string_values = lua_tostring (lua_current_interpreter, -9); - min = lua_tonumber (lua_current_interpreter, -8); - max = lua_tonumber (lua_current_interpreter, -7); - default_value = lua_tostring (lua_current_interpreter, -6); - value = lua_tostring (lua_current_interpreter, -5); - null_value_allowed = lua_tonumber (lua_current_interpreter, -4); - function_check_value = lua_tostring (lua_current_interpreter, -3); - function_change = lua_tostring (lua_current_interpreter, -2); - function_delete = lua_tostring (lua_current_interpreter, -1); + config_file = lua_tostring (lua_current_interpreter, -17); + section = lua_tostring (lua_current_interpreter, -16); + name = lua_tostring (lua_current_interpreter, -15); + type = lua_tostring (lua_current_interpreter, -14); + description = lua_tostring (lua_current_interpreter, -13); + string_values = lua_tostring (lua_current_interpreter, -12); + min = lua_tonumber (lua_current_interpreter, -11); + max = lua_tonumber (lua_current_interpreter, -10); + default_value = lua_tostring (lua_current_interpreter, -9); + value = lua_tostring (lua_current_interpreter, -8); + null_value_allowed = lua_tonumber (lua_current_interpreter, -7); + function_check_value = lua_tostring (lua_current_interpreter, -6); + data_check_value = lua_tostring (lua_current_interpreter, -5); + function_change = lua_tostring (lua_current_interpreter, -4); + data_change = lua_tostring (lua_current_interpreter, -3); + function_delete = lua_tostring (lua_current_interpreter, -2); + data_delete = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_config_new_option (weechat_lua_plugin, lua_current_script, @@ -1590,10 +1626,13 @@ weechat_lua_api_config_new_option (lua_State *L) null_value_allowed, &weechat_lua_api_config_option_check_value_cb, function_check_value, + data_check_value, &weechat_lua_api_config_option_change_cb, function_change, + data_change, &weechat_lua_api_config_option_delete_cb, - function_delete)); + function_delete, + data_delete)); LUA_RETURN_STRING_FREE(result); } @@ -1614,7 +1653,7 @@ weechat_lua_api_config_search_option (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_search_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_search_option"); LUA_RETURN_EMPTY; } @@ -1626,7 +1665,7 @@ weechat_lua_api_config_search_option (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_search_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_search_option"); LUA_RETURN_EMPTY; } @@ -1656,7 +1695,7 @@ weechat_lua_api_config_string_to_boolean (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string_to_boolean"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_string_to_boolean"); LUA_RETURN_INT(0); } @@ -1666,7 +1705,7 @@ weechat_lua_api_config_string_to_boolean (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string_to_boolean"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_string_to_boolean"); LUA_RETURN_INT(0); } @@ -1692,7 +1731,7 @@ weechat_lua_api_config_option_reset (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_reset"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_option_reset"); LUA_RETURN_INT(0); } @@ -1703,7 +1742,7 @@ weechat_lua_api_config_option_reset (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_option_reset"); LUA_RETURN_INT(0); } @@ -1731,7 +1770,7 @@ weechat_lua_api_config_option_set (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_option_set"); LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1743,7 +1782,7 @@ weechat_lua_api_config_option_set (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_option_set"); LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1774,7 +1813,7 @@ weechat_lua_api_config_option_set_null (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_option_set_null"); LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1785,7 +1824,7 @@ weechat_lua_api_config_option_set_null (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_option_set_null"); LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1813,7 +1852,7 @@ weechat_lua_api_config_option_unset (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_option_unset"); LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -1823,7 +1862,7 @@ weechat_lua_api_config_option_unset (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_option_unset"); LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -1849,7 +1888,7 @@ weechat_lua_api_config_option_rename (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_option_rename"); LUA_RETURN_ERROR; } @@ -1860,7 +1899,7 @@ weechat_lua_api_config_option_rename (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_rename"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_option_rename"); LUA_RETURN_ERROR; } @@ -1888,7 +1927,7 @@ weechat_lua_api_config_option_is_null (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_option_is_null"); LUA_RETURN_INT(1); } @@ -1898,7 +1937,7 @@ weechat_lua_api_config_option_is_null (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_option_is_null"); LUA_RETURN_INT(1); } @@ -1925,7 +1964,7 @@ weechat_lua_api_config_option_default_is_null (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_option_default_is_null"); LUA_RETURN_INT(1); } @@ -1935,7 +1974,7 @@ weechat_lua_api_config_option_default_is_null (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_option_default_is_null"); LUA_RETURN_INT(1); } @@ -1961,7 +2000,7 @@ weechat_lua_api_config_boolean (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_boolean"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_boolean"); LUA_RETURN_INT(0); } @@ -1971,7 +2010,7 @@ weechat_lua_api_config_boolean (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_boolean"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_boolean"); LUA_RETURN_INT(0); } @@ -1997,7 +2036,7 @@ weechat_lua_api_config_boolean_default (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_boolean_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_boolean_default"); LUA_RETURN_INT(0); } @@ -2007,7 +2046,7 @@ weechat_lua_api_config_boolean_default (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_boolean_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_boolean_default"); LUA_RETURN_INT(0); } @@ -2033,7 +2072,7 @@ weechat_lua_api_config_integer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_integer"); LUA_RETURN_INT(0); } @@ -2043,7 +2082,7 @@ weechat_lua_api_config_integer (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_integer"); LUA_RETURN_INT(0); } @@ -2069,7 +2108,7 @@ weechat_lua_api_config_integer_default (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_integer_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_integer_default"); LUA_RETURN_INT(0); } @@ -2079,7 +2118,7 @@ weechat_lua_api_config_integer_default (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_integer_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_integer_default"); LUA_RETURN_INT(0); } @@ -2105,7 +2144,7 @@ weechat_lua_api_config_string (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_string"); LUA_RETURN_EMPTY; } @@ -2115,7 +2154,7 @@ weechat_lua_api_config_string (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_string"); LUA_RETURN_INT(0); } @@ -2141,7 +2180,7 @@ weechat_lua_api_config_string_default (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_string_default"); LUA_RETURN_EMPTY; } @@ -2151,7 +2190,7 @@ weechat_lua_api_config_string_default (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_string_default"); LUA_RETURN_INT(0); } @@ -2177,7 +2216,7 @@ weechat_lua_api_config_color (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_color"); LUA_RETURN_INT(0); } @@ -2187,7 +2226,7 @@ weechat_lua_api_config_color (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_color"); LUA_RETURN_INT(0); } @@ -2213,7 +2252,7 @@ weechat_lua_api_config_color_default (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_color_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_color_default"); LUA_RETURN_INT(0); } @@ -2223,7 +2262,7 @@ weechat_lua_api_config_color_default (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_color_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_color_default"); LUA_RETURN_INT(0); } @@ -2249,7 +2288,7 @@ weechat_lua_api_config_write_option (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_write_option"); LUA_RETURN_ERROR; } @@ -2260,7 +2299,7 @@ weechat_lua_api_config_write_option (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_write_option"); LUA_RETURN_ERROR; } @@ -2288,7 +2327,7 @@ weechat_lua_api_config_write_line (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_line"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_write_line"); LUA_RETURN_ERROR; } @@ -2300,7 +2339,7 @@ weechat_lua_api_config_write_line (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_line"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_write_line"); LUA_RETURN_ERROR; } @@ -2331,7 +2370,7 @@ weechat_lua_api_config_write (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_write"); LUA_RETURN_INT(-1); } @@ -2341,7 +2380,7 @@ weechat_lua_api_config_write (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_write"); LUA_RETURN_INT(-1); } @@ -2367,7 +2406,7 @@ weechat_lua_api_config_read (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_read"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_read"); LUA_RETURN_INT(-1); } @@ -2377,7 +2416,7 @@ weechat_lua_api_config_read (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_read"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_read"); LUA_RETURN_INT(-1); } @@ -2403,7 +2442,7 @@ weechat_lua_api_config_reload (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_reload"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_reload"); LUA_RETURN_INT(-1); } @@ -2413,7 +2452,7 @@ weechat_lua_api_config_reload (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_reload"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_reload"); LUA_RETURN_INT(-1); } @@ -2439,7 +2478,7 @@ weechat_lua_api_config_option_free (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_option_free"); LUA_RETURN_ERROR; } @@ -2449,7 +2488,7 @@ weechat_lua_api_config_option_free (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_option_free"); LUA_RETURN_ERROR; } @@ -2478,7 +2517,7 @@ weechat_lua_api_config_section_free_options (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free_options"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_section_free_options"); LUA_RETURN_ERROR; } @@ -2488,7 +2527,7 @@ weechat_lua_api_config_section_free_options (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free_options"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_section_free_options"); LUA_RETURN_ERROR; } @@ -2516,7 +2555,7 @@ weechat_lua_api_config_section_free (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_section_free"); LUA_RETURN_ERROR; } @@ -2526,7 +2565,7 @@ weechat_lua_api_config_section_free (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_section_free"); LUA_RETURN_ERROR; } @@ -2554,7 +2593,7 @@ weechat_lua_api_config_free (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_free"); LUA_RETURN_ERROR; } @@ -2564,7 +2603,7 @@ weechat_lua_api_config_free (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_free"); LUA_RETURN_ERROR; } @@ -2593,7 +2632,7 @@ weechat_lua_api_config_get (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_get"); LUA_RETURN_EMPTY; } @@ -2603,7 +2642,7 @@ weechat_lua_api_config_get (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_get"); LUA_RETURN_EMPTY; } @@ -2629,7 +2668,7 @@ weechat_lua_api_config_get_plugin (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_get_plugin"); LUA_RETURN_EMPTY; } @@ -2639,7 +2678,7 @@ weechat_lua_api_config_get_plugin (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_get_plugin"); LUA_RETURN_EMPTY; } @@ -2667,7 +2706,7 @@ weechat_lua_api_config_set_plugin (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_set_plugin"); LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -2678,7 +2717,7 @@ weechat_lua_api_config_set_plugin (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_set_plugin"); LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -2708,7 +2747,7 @@ weechat_lua_api_config_unset_plugin (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_unset_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_unset_plugin"); LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -2718,7 +2757,7 @@ weechat_lua_api_config_unset_plugin (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_unset_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_unset_plugin"); LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -2746,7 +2785,7 @@ weechat_lua_api_prefix (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("prefix"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "prefix"); LUA_RETURN_EMPTY; } @@ -2756,7 +2795,7 @@ weechat_lua_api_prefix (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prefix"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "prefix"); LUA_RETURN_EMPTY; } @@ -2782,7 +2821,7 @@ weechat_lua_api_color (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "color"); LUA_RETURN_EMPTY; } @@ -2792,7 +2831,7 @@ weechat_lua_api_color (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "color"); LUA_RETURN_EMPTY; } @@ -2823,7 +2862,7 @@ weechat_lua_api_print (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "print"); LUA_RETURN_ERROR; } @@ -2854,7 +2893,7 @@ weechat_lua_api_print_date_tags (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print_date_tags"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "print_date_tags"); LUA_RETURN_ERROR; } @@ -2867,7 +2906,7 @@ weechat_lua_api_print_date_tags (lua_State *L) if (n < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_date_tags"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "print_date_tags"); LUA_RETURN_ERROR; } @@ -2901,7 +2940,7 @@ weechat_lua_api_print_y (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print_y"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "print_y"); LUA_RETURN_ERROR; } @@ -2913,7 +2952,7 @@ weechat_lua_api_print_y (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_y"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "print_y"); LUA_RETURN_ERROR; } @@ -2945,7 +2984,7 @@ weechat_lua_api_log_print (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("log_print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "log_print"); LUA_RETURN_ERROR; } @@ -2955,7 +2994,7 @@ weechat_lua_api_log_print (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("log_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "log_print"); LUA_RETURN_ERROR; } @@ -2977,7 +3016,7 @@ weechat_lua_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { struct t_script_callback *script_callback; - char *lua_argv[3], empty_arg[1] = { '\0' }; + char *lua_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; /* make C compiler happy */ @@ -2987,9 +3026,10 @@ weechat_lua_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (buffer); - lua_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg; - lua_argv[2] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (buffer); + lua_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; + lua_argv[3] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3003,8 +3043,8 @@ weechat_lua_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); + if (lua_argv[1]) + free (lua_argv[1]); return ret; } @@ -3020,7 +3060,7 @@ static int weechat_lua_api_hook_command (lua_State *L) { const char *command, *description, *args, *args_description, *completion; - const char *function; + const char *function, *data; char *result; int n; @@ -3029,7 +3069,7 @@ weechat_lua_api_hook_command (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_command"); LUA_RETURN_EMPTY; } @@ -3039,21 +3079,23 @@ weechat_lua_api_hook_command (lua_State *L) args_description = NULL; completion = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 6) + if (n < 7) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_command"); LUA_RETURN_EMPTY; } - command = lua_tostring (lua_current_interpreter, -6); - description = lua_tostring (lua_current_interpreter, -5); - args = lua_tostring (lua_current_interpreter, -4); - args_description = lua_tostring (lua_current_interpreter, -3); - completion = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + command = lua_tostring (lua_current_interpreter, -7); + description = lua_tostring (lua_current_interpreter, -6); + args = lua_tostring (lua_current_interpreter, -5); + args_description = lua_tostring (lua_current_interpreter, -4); + completion = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_command (weechat_lua_plugin, lua_current_script, @@ -3063,7 +3105,8 @@ weechat_lua_api_hook_command (lua_State *L) args_description, completion, &weechat_lua_api_hook_command_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -3077,16 +3120,17 @@ weechat_lua_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, const char *command) { struct t_script_callback *script_callback; - char *lua_argv[3], empty_arg[1] = { '\0' }; + char *lua_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (buffer); - lua_argv[1] = (command) ? (char *)command : empty_arg; - lua_argv[2] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (buffer); + lua_argv[2] = (command) ? (char *)command : empty_arg; + lua_argv[3] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3100,8 +3144,8 @@ weechat_lua_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); + if (lua_argv[1]) + free (lua_argv[1]); return ret; } @@ -3116,7 +3160,7 @@ weechat_lua_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, static int weechat_lua_api_hook_command_run (lua_State *L) { - const char *command, *function; + const char *command, *function, *data; char *result; int n; @@ -3125,29 +3169,32 @@ weechat_lua_api_hook_command_run (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command_run"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_command_run"); LUA_RETURN_EMPTY; } command = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 2) + if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command_run"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_command_run"); LUA_RETURN_EMPTY; } - command = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + command = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_command_run (weechat_lua_plugin, lua_current_script, command, &weechat_lua_api_hook_command_run_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -3160,7 +3207,7 @@ int weechat_lua_api_hook_timer_cb (void *data, int remaining_calls) { struct t_script_callback *script_callback; - char *lua_argv[2], str_remaining_calls[32]; + char *lua_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3170,8 +3217,9 @@ weechat_lua_api_hook_timer_cb (void *data, int remaining_calls) snprintf (str_remaining_calls, sizeof (str_remaining_calls), "%d", remaining_calls); - lua_argv[0] = str_remaining_calls; - lua_argv[1] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = str_remaining_calls; + lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3200,7 +3248,7 @@ static int weechat_lua_api_hook_timer (lua_State *L) { int n, interval, align_second, max_calls; - const char *function; + const char *function, *data; char *result; /* make C compiler happy */ @@ -3208,7 +3256,7 @@ weechat_lua_api_hook_timer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_timer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_timer"); LUA_RETURN_EMPTY; } @@ -3216,19 +3264,21 @@ weechat_lua_api_hook_timer (lua_State *L) align_second = 0; max_calls = 0; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 4) + if (n < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_timer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_timer"); LUA_RETURN_EMPTY; } - interval = lua_tonumber (lua_current_interpreter, -4); - align_second = lua_tonumber (lua_current_interpreter, -3); - max_calls = lua_tonumber (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + interval = lua_tonumber (lua_current_interpreter, -5); + align_second = lua_tonumber (lua_current_interpreter, -4); + max_calls = lua_tonumber (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_timer (weechat_lua_plugin, lua_current_script, @@ -3236,7 +3286,8 @@ weechat_lua_api_hook_timer (lua_State *L) align_second, max_calls, &weechat_lua_api_hook_timer_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -3249,7 +3300,7 @@ int weechat_lua_api_hook_fd_cb (void *data, int fd) { struct t_script_callback *script_callback; - char *lua_argv[2], str_fd[32]; + char *lua_argv[3], str_fd[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3258,8 +3309,9 @@ weechat_lua_api_hook_fd_cb (void *data, int fd) { snprintf (str_fd, sizeof (str_fd), "%d", fd); - lua_argv[0] = str_fd; - lua_argv[1] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = str_fd; + lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3288,7 +3340,7 @@ static int weechat_lua_api_hook_fd (lua_State *L) { int n, fd, read, write, exception; - const char *function; + const char *function, *data; char *result; /* make C compiler happy */ @@ -3296,7 +3348,7 @@ weechat_lua_api_hook_fd (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_fd"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_fd"); LUA_RETURN_EMPTY; } @@ -3305,20 +3357,22 @@ weechat_lua_api_hook_fd (lua_State *L) write = 0; exception = 0; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 5) + if (n < 6) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_fd"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_fd"); LUA_RETURN_EMPTY; } - fd = lua_tonumber (lua_current_interpreter, -5); - read = lua_tonumber (lua_current_interpreter, -4); - write = lua_tonumber (lua_current_interpreter, -3); - exception = lua_tonumber (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + fd = lua_tonumber (lua_current_interpreter, -6); + read = lua_tonumber (lua_current_interpreter, -5); + write = lua_tonumber (lua_current_interpreter, -4); + exception = lua_tonumber (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_fd (weechat_lua_plugin, lua_current_script, @@ -3327,7 +3381,8 @@ weechat_lua_api_hook_fd (lua_State *L) write, exception, &weechat_lua_api_hook_fd_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -3342,20 +3397,21 @@ weechat_lua_api_hook_process_cb (void *data, const char *stdout, const char *stderr) { struct t_script_callback *script_callback; - char *lua_argv[5], str_rc[32], empty_arg[1] = { '\0' }; + char *lua_argv[6], str_rc[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { snprintf (str_rc, sizeof (str_rc), "%d", return_code); - lua_argv[0] = (command) ? (char *)command : empty_arg; - lua_argv[1] = str_rc; - lua_argv[2] = (stdout) ? (char *)stdout : empty_arg; - lua_argv[3] = (stderr) ? (char *)stderr : empty_arg; - lua_argv[4] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = (command) ? (char *)command : empty_arg; + lua_argv[2] = str_rc; + lua_argv[3] = (stdout) ? (char *)stdout : empty_arg; + lua_argv[4] = (stderr) ? (char *)stderr : empty_arg; + lua_argv[5] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3383,7 +3439,7 @@ weechat_lua_api_hook_process_cb (void *data, static int weechat_lua_api_hook_process (lua_State *L) { - const char *command, *function; + const char *command, *function, *data; int n, timeout; char *result; @@ -3392,7 +3448,7 @@ weechat_lua_api_hook_process (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_process"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_process"); LUA_RETURN_EMPTY; } @@ -3402,22 +3458,24 @@ weechat_lua_api_hook_process (lua_State *L) n = lua_gettop (lua_current_interpreter); - if (n < 3) + if (n < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_process"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_process"); LUA_RETURN_EMPTY; } - command = lua_tostring (lua_current_interpreter, -3); - timeout = lua_tonumber (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + command = lua_tostring (lua_current_interpreter, -4); + timeout = lua_tonumber (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_process (weechat_lua_plugin, lua_current_script, command, timeout, &weechat_lua_api_hook_process_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -3431,7 +3489,7 @@ weechat_lua_api_hook_connect_cb (void *data, int status, const char *error, const char *ip_address) { struct t_script_callback *script_callback; - char *lua_argv[4], str_status[32], empty_arg[1] = { '\0' }; + char *lua_argv[5], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3440,10 +3498,11 @@ weechat_lua_api_hook_connect_cb (void *data, int status, { snprintf (str_status, sizeof (str_status), "%d", status); - lua_argv[0] = str_status; - lua_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; - lua_argv[2] = (error) ? (char *)error : empty_arg; - lua_argv[3] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = str_status; + lua_argv[2] = (ip_address) ? (char *)ip_address : empty_arg; + lua_argv[3] = (error) ? (char *)error : empty_arg; + lua_argv[4] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3471,7 +3530,7 @@ weechat_lua_api_hook_connect_cb (void *data, int status, static int weechat_lua_api_hook_connect (lua_State *L) { - const char *proxy, *address, *local_hostname, *function; + const char *proxy, *address, *local_hostname, *function, *data; int n, port, sock, ipv6; char *result; @@ -3480,7 +3539,7 @@ weechat_lua_api_hook_connect (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_connect"); LUA_RETURN_EMPTY; } @@ -3491,22 +3550,24 @@ weechat_lua_api_hook_connect (lua_State *L) ipv6 = 0; local_hostname = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 7) + if (n < 8) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_connect"); LUA_RETURN_EMPTY; } - proxy = lua_tostring (lua_current_interpreter, -7); - address = lua_tostring (lua_current_interpreter, -6); - port = lua_tonumber (lua_current_interpreter, -5); - sock = lua_tonumber (lua_current_interpreter, -4); - ipv6 = lua_tonumber (lua_current_interpreter, -3); - local_hostname = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + proxy = lua_tostring (lua_current_interpreter, -8); + address = lua_tostring (lua_current_interpreter, -7); + port = lua_tonumber (lua_current_interpreter, -6); + sock = lua_tonumber (lua_current_interpreter, -5); + ipv6 = lua_tonumber (lua_current_interpreter, -4); + local_hostname = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_connect (weechat_lua_plugin, lua_current_script, @@ -3518,7 +3579,8 @@ weechat_lua_api_hook_connect (lua_State *L) NULL, /* gnutls session */ local_hostname, &weechat_lua_api_hook_connect_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -3535,7 +3597,7 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *lua_argv[8], empty_arg[1] = { '\0' }; + char *lua_argv[9], empty_arg[1] = { '\0' }; static char timebuffer[64]; int *rc, ret; @@ -3548,16 +3610,17 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, { snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); - lua_argv[0] = script_ptr2str (buffer); - lua_argv[1] = timebuffer; - lua_argv[2] = weechat_string_build_with_exploded (tags, ","); - if (!lua_argv[2]) - lua_argv[2] = strdup (""); - lua_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); - lua_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); - lua_argv[5] = (prefix) ? (char *)prefix : empty_arg; - lua_argv[6] = (message) ? (char *)message : empty_arg; - lua_argv[7] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (buffer); + lua_argv[2] = timebuffer; + lua_argv[3] = weechat_string_build_with_exploded (tags, ","); + if (!lua_argv[3]) + lua_argv[3] = strdup (""); + lua_argv[4] = (displayed) ? strdup ("1") : strdup ("0"); + lua_argv[5] = (highlight) ? strdup ("1") : strdup ("0"); + lua_argv[6] = (prefix) ? (char *)prefix : empty_arg; + lua_argv[7] = (message) ? (char *)message : empty_arg; + lua_argv[8] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3571,14 +3634,14 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); - if (lua_argv[2]) - free (lua_argv[2]); + if (lua_argv[1]) + free (lua_argv[1]); if (lua_argv[3]) free (lua_argv[3]); if (lua_argv[4]) free (lua_argv[4]); + if (lua_argv[5]) + free (lua_argv[5]); return ret; } @@ -3593,7 +3656,7 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, static int weechat_lua_api_hook_print (lua_State *L) { - const char *buffer, *tags, *message, *function; + const char *buffer, *tags, *message, *function, *data; char *result; int n, strip_colors; @@ -3602,7 +3665,7 @@ weechat_lua_api_hook_print (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_print"); LUA_RETURN_EMPTY; } @@ -3611,20 +3674,22 @@ weechat_lua_api_hook_print (lua_State *L) message = NULL; strip_colors = 0; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 4) + if (n < 6) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_print"); LUA_RETURN_EMPTY; } - buffer = lua_tostring (lua_current_interpreter, -5); - tags = lua_tostring (lua_current_interpreter, -4); - message = lua_tostring (lua_current_interpreter, -3); - strip_colors = lua_tonumber (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + buffer = lua_tostring (lua_current_interpreter, -6); + tags = lua_tostring (lua_current_interpreter, -5); + message = lua_tostring (lua_current_interpreter, -4); + strip_colors = lua_tonumber (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_print (weechat_lua_plugin, lua_current_script, @@ -3633,7 +3698,8 @@ weechat_lua_api_hook_print (lua_State *L) message, strip_colors, &weechat_lua_api_hook_print_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -3647,7 +3713,7 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal, const char *type_data, void *signal_data) { struct t_script_callback *script_callback; - char *lua_argv[3], empty_arg[1] = { '\0' }; + char *lua_argv[4], empty_arg[1] = { '\0' }; static char value_str[64]; int *rc, ret, free_needed; @@ -3655,26 +3721,27 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal, if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (signal) ? (char *)signal : empty_arg; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = (signal) ? (char *)signal : empty_arg; free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { - lua_argv[1] = (signal_data) ? (char *)signal_data : empty_arg; + lua_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { snprintf (value_str, sizeof (value_str) - 1, "%d", *((int *)signal_data)); - lua_argv[1] = value_str; + lua_argv[2] = value_str; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - lua_argv[1] = script_ptr2str (signal_data); + lua_argv[2] = script_ptr2str (signal_data); free_needed = 1; } else - lua_argv[1] = empty_arg; - lua_argv[2] = NULL; + lua_argv[2] = empty_arg; + lua_argv[3] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3688,6 +3755,8 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal, ret = *rc; free (rc); } + if (free_needed && lua_argv[2]) + free (lua_argv[2]); return ret; } @@ -3702,7 +3771,7 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal, static int weechat_lua_api_hook_signal (lua_State *L) { - const char *signal, *function; + const char *signal, *function, *data; char *result; int n; @@ -3711,29 +3780,32 @@ weechat_lua_api_hook_signal (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_signal"); LUA_RETURN_EMPTY; } signal = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 2) + if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_signal"); LUA_RETURN_EMPTY; } - signal = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + signal = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_signal (weechat_lua_plugin, lua_current_script, signal, &weechat_lua_api_hook_signal_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -3753,7 +3825,7 @@ weechat_lua_api_hook_signal_send (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal_send"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_signal_send"); LUA_RETURN_ERROR; } @@ -3765,7 +3837,7 @@ weechat_lua_api_hook_signal_send (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal_send"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_signal_send"); LUA_RETURN_ERROR; } @@ -3804,16 +3876,17 @@ weechat_lua_api_hook_config_cb (void *data, const char *option, const char *value) { struct t_script_callback *script_callback; - char *lua_argv[3], empty_arg[1] = { '\0' }; + char *lua_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (option) ? (char *)option : empty_arg; - lua_argv[1] = (value) ? (char *)value : empty_arg; - lua_argv[2] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = (option) ? (char *)option : empty_arg; + lua_argv[2] = (value) ? (char *)value : empty_arg; + lua_argv[3] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3841,7 +3914,7 @@ weechat_lua_api_hook_config_cb (void *data, const char *option, static int weechat_lua_api_hook_config (lua_State *L) { - const char *type, *option, *function; + const char *type, *option, *function, *data; char *result; int n; @@ -3850,30 +3923,33 @@ weechat_lua_api_hook_config (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_config"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_config"); LUA_RETURN_EMPTY; } type = NULL; option = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 2) + if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_config"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_config"); LUA_RETURN_EMPTY; } - option = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + option = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_config (weechat_lua_plugin, lua_current_script, option, &weechat_lua_api_hook_config_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -3888,17 +3964,18 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_script_callback *script_callback; - char *lua_argv[4], empty_arg[1] = { '\0' }; + char *lua_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (completion_item) ? (char *)completion_item : empty_arg; - lua_argv[1] = script_ptr2str (buffer); - lua_argv[2] = script_ptr2str (completion); - lua_argv[3] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; + lua_argv[2] = script_ptr2str (buffer); + lua_argv[3] = script_ptr2str (completion); + lua_argv[4] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3912,10 +3989,10 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion_item, ret = *rc; free (rc); } - if (lua_argv[1]) - free (lua_argv[1]); if (lua_argv[2]) free (lua_argv[2]); + if (lua_argv[3]) + free (lua_argv[3]); return ret; } @@ -3930,7 +4007,7 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion_item, static int weechat_lua_api_hook_completion (lua_State *L) { - const char *completion, *description, *function; + const char *completion, *description, *function, *data; char *result; int n; @@ -3939,32 +4016,35 @@ weechat_lua_api_hook_completion (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_completion"); LUA_RETURN_EMPTY; } completion = NULL; description = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 3) + if (n < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_completion"); LUA_RETURN_EMPTY; } - completion = lua_tostring (lua_current_interpreter, -3); - description = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + completion = lua_tostring (lua_current_interpreter, -4); + description = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_completion (weechat_lua_plugin, lua_current_script, completion, description, &weechat_lua_api_hook_completion_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -3984,7 +4064,7 @@ weechat_lua_api_hook_completion_list_add (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); LUA_RETURN_ERROR; } @@ -3997,7 +4077,7 @@ weechat_lua_api_hook_completion_list_add (lua_State *L) if (n < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); LUA_RETURN_ERROR; } @@ -4024,16 +4104,17 @@ weechat_lua_api_hook_modifier_cb (void *data, const char *modifier, const char *string) { struct t_script_callback *script_callback; - char *lua_argv[4], empty_arg[1] = { '\0' }; + char *lua_argv[5], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (modifier) ? (char *)modifier : empty_arg; - lua_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg; - lua_argv[2] = (string) ? (char *)string : empty_arg; - lua_argv[3] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = (modifier) ? (char *)modifier : empty_arg; + lua_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg; + lua_argv[3] = (string) ? (char *)string : empty_arg; + lua_argv[4] = NULL; return (char *)weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -4051,7 +4132,7 @@ weechat_lua_api_hook_modifier_cb (void *data, const char *modifier, static int weechat_lua_api_hook_modifier (lua_State *L) { - const char *modifier, *function; + const char *modifier, *function, *data; char *result; int n; @@ -4060,29 +4141,32 @@ weechat_lua_api_hook_modifier (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_modifier"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_modifier"); LUA_RETURN_EMPTY; } modifier = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 2) + if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_modifier"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_modifier"); LUA_RETURN_EMPTY; } - modifier = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + modifier = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_modifier (weechat_lua_plugin, lua_current_script, modifier, &weechat_lua_api_hook_modifier_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -4103,7 +4187,7 @@ weechat_lua_api_hook_modifier_exec (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_modifier_exec"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_modifier_exec"); LUA_RETURN_EMPTY; } @@ -4115,7 +4199,7 @@ weechat_lua_api_hook_modifier_exec (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_modifier_exec"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_modifier_exec"); LUA_RETURN_ERROR; } @@ -4137,15 +4221,16 @@ weechat_lua_api_hook_info_cb (void *data, const char *info_name, const char *arguments) { struct t_script_callback *script_callback; - char *lua_argv[3], empty_arg[1] = { '\0' }; + char *lua_argv[4], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (info_name) ? (char *)info_name : empty_arg; - lua_argv[1] = (arguments) ? (char *)arguments : empty_arg; - lua_argv[2] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = (info_name) ? (char *)info_name : empty_arg; + lua_argv[2] = (arguments) ? (char *)arguments : empty_arg; + lua_argv[3] = NULL; return (const char *)weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -4163,7 +4248,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; + const char *info_name, *description, *function, *data; char *result; int n; @@ -4172,31 +4257,34 @@ weechat_lua_api_hook_info (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_info"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_info"); LUA_RETURN_EMPTY; } info_name = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 3) + if (n < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_info"); LUA_RETURN_EMPTY; } - info_name = lua_tostring (lua_current_interpreter, -3); - description = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + info_name = lua_tostring (lua_current_interpreter, -4); + description = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_info (weechat_lua_plugin, lua_current_script, info_name, description, &weechat_lua_api_hook_info_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -4210,25 +4298,26 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name, void *pointer, const char *arguments) { struct t_script_callback *script_callback; - char *lua_argv[4], empty_arg[1] = { '\0' }; + char *lua_argv[5], empty_arg[1] = { '\0' }; struct t_infolist *result; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = (info_name) ? (char *)info_name : empty_arg; - lua_argv[1] = script_ptr2str (pointer); - lua_argv[2] = (arguments) ? (char *)arguments : empty_arg; - lua_argv[3] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = (info_name) ? (char *)info_name : empty_arg; + lua_argv[2] = script_ptr2str (pointer); + lua_argv[3] = (arguments) ? (char *)arguments : empty_arg; + lua_argv[4] = NULL; result = (struct t_infolist *)weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, script_callback->function, lua_argv); - if (lua_argv[1]) - free (lua_argv[1]); + if (lua_argv[2]) + free (lua_argv[2]); return result; } @@ -4243,7 +4332,7 @@ 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; + const char *infolist_name, *description, *function, *data; char *result; int n; @@ -4252,31 +4341,34 @@ weechat_lua_api_hook_infolist (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_infolist"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_infolist"); LUA_RETURN_EMPTY; } infolist_name = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 3) + if (n < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_infolist"); LUA_RETURN_EMPTY; } - infolist_name = lua_tostring (lua_current_interpreter, -3); - description = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + infolist_name = lua_tostring (lua_current_interpreter, -4); + description = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_hook_infolist (weechat_lua_plugin, lua_current_script, infolist_name, description, &weechat_lua_api_hook_infolist_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -4296,7 +4388,7 @@ weechat_lua_api_unhook (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "unhook"); LUA_RETURN_ERROR; } @@ -4306,7 +4398,7 @@ weechat_lua_api_unhook (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("unhook"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "unhook"); LUA_RETURN_ERROR; } @@ -4331,7 +4423,7 @@ weechat_lua_api_unhook_all (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "unhook_all"); LUA_RETURN_ERROR; } @@ -4349,16 +4441,17 @@ weechat_lua_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { struct t_script_callback *script_callback; - char *lua_argv[3], empty_arg[1] = { '\0' }; + char *lua_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (buffer); - lua_argv[1] = (input_data) ? (char *)input_data : empty_arg; - lua_argv[2] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (buffer); + lua_argv[2] = (input_data) ? (char *)input_data : empty_arg; + lua_argv[3] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -4372,8 +4465,8 @@ weechat_lua_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); + if (lua_argv[1]) + free (lua_argv[1]); return ret; } @@ -4389,15 +4482,16 @@ int weechat_lua_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) { struct t_script_callback *script_callback; - char *lua_argv[2]; + char *lua_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (buffer); - lua_argv[1] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (buffer); + lua_argv[2] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -4411,8 +4505,8 @@ weechat_lua_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); + if (lua_argv[1]) + free (lua_argv[1]); return ret; } @@ -4427,7 +4521,8 @@ weechat_lua_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) static int weechat_lua_api_buffer_new (lua_State *L) { - const char *name, *function_input, *function_close; + const char *name, *function_input, *data_input, *function_close; + const char *data_close; char *result; int n; @@ -4436,33 +4531,39 @@ weechat_lua_api_buffer_new (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_new"); LUA_RETURN_EMPTY; } name = NULL; function_input = NULL; + data_input = NULL; function_close = NULL; + data_close = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 3) + if (n < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_new"); LUA_RETURN_EMPTY; } - name = lua_tostring (lua_current_interpreter, -3); - function_input = lua_tostring (lua_current_interpreter, -2); - function_close = lua_tostring (lua_current_interpreter, -1); + name = lua_tostring (lua_current_interpreter, -5); + function_input = lua_tostring (lua_current_interpreter, -4); + data_input = lua_tostring (lua_current_interpreter, -3); + function_close = lua_tostring (lua_current_interpreter, -2); + data_close = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_buffer_new (weechat_lua_plugin, lua_current_script, name, &weechat_lua_api_buffer_input_data_cb, function_input, + data_input, &weechat_lua_api_buffer_close_cb, - function_close)); + function_close, + data_close)); LUA_RETURN_STRING_FREE(result); } @@ -4483,7 +4584,7 @@ weechat_lua_api_buffer_search (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_search"); LUA_RETURN_EMPTY; } @@ -4494,7 +4595,7 @@ weechat_lua_api_buffer_search (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_search"); LUA_RETURN_EMPTY; } @@ -4520,7 +4621,7 @@ weechat_lua_api_current_buffer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_buffer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "current_buffer"); LUA_RETURN_EMPTY; } @@ -4544,7 +4645,7 @@ weechat_lua_api_buffer_clear (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_clear"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_clear"); LUA_RETURN_ERROR; } @@ -4554,7 +4655,7 @@ weechat_lua_api_buffer_clear (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_clear"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_clear"); LUA_RETURN_ERROR; } @@ -4580,7 +4681,7 @@ weechat_lua_api_buffer_close (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_close"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_close"); LUA_RETURN_ERROR; } @@ -4590,7 +4691,7 @@ weechat_lua_api_buffer_close (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_close"); LUA_RETURN_ERROR; } @@ -4618,7 +4719,7 @@ weechat_lua_api_buffer_get_integer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_get_integer"); LUA_RETURN_INT(-1); } @@ -4629,7 +4730,7 @@ weechat_lua_api_buffer_get_integer (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_get_integer"); LUA_RETURN_INT(-1); } @@ -4657,7 +4758,7 @@ weechat_lua_api_buffer_get_string (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_get_string"); LUA_RETURN_EMPTY; } @@ -4668,7 +4769,7 @@ weechat_lua_api_buffer_get_string (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_get_string"); LUA_RETURN_EMPTY; } @@ -4697,7 +4798,7 @@ weechat_lua_api_buffer_get_pointer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_get_pointer"); LUA_RETURN_EMPTY; } @@ -4708,7 +4809,7 @@ weechat_lua_api_buffer_get_pointer (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_get_pointer"); LUA_RETURN_EMPTY; } @@ -4736,7 +4837,7 @@ weechat_lua_api_buffer_set (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_set"); LUA_RETURN_ERROR; } @@ -4747,7 +4848,7 @@ weechat_lua_api_buffer_set (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_set"); LUA_RETURN_ERROR; } @@ -4774,7 +4875,7 @@ weechat_lua_api_current_window (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_window"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "current_window"); LUA_RETURN_EMPTY; } @@ -4798,7 +4899,7 @@ weechat_lua_api_window_get_integer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "window_get_integer"); LUA_RETURN_INT(-1); } @@ -4809,7 +4910,7 @@ weechat_lua_api_window_get_integer (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "window_get_integer"); LUA_RETURN_INT(-1); } @@ -4837,7 +4938,7 @@ weechat_lua_api_window_get_string (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "window_get_string"); LUA_RETURN_EMPTY; } @@ -4848,7 +4949,7 @@ weechat_lua_api_window_get_string (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "window_get_string"); LUA_RETURN_EMPTY; } @@ -4877,7 +4978,7 @@ weechat_lua_api_window_get_pointer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "window_get_pointer"); LUA_RETURN_EMPTY; } @@ -4888,7 +4989,7 @@ weechat_lua_api_window_get_pointer (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "window_get_pointer"); LUA_RETURN_EMPTY; } @@ -4917,7 +5018,7 @@ weechat_lua_api_nicklist_add_group (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "nicklist_add_group"); LUA_RETURN_EMPTY; } @@ -4931,7 +5032,7 @@ weechat_lua_api_nicklist_add_group (lua_State *L) if (n < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "nicklist_add_group"); LUA_RETURN_EMPTY; } @@ -4966,7 +5067,7 @@ weechat_lua_api_nicklist_search_group (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "nicklist_search_group"); LUA_RETURN_EMPTY; } @@ -4978,7 +5079,7 @@ weechat_lua_api_nicklist_search_group (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "nicklist_search_group"); LUA_RETURN_EMPTY; } @@ -5009,7 +5110,7 @@ weechat_lua_api_nicklist_add_nick (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); LUA_RETURN_EMPTY; } @@ -5025,7 +5126,7 @@ weechat_lua_api_nicklist_add_nick (lua_State *L) if (n < 7) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); LUA_RETURN_EMPTY; } @@ -5064,7 +5165,7 @@ weechat_lua_api_nicklist_search_nick (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "nicklist_search_nick"); LUA_RETURN_EMPTY; } @@ -5076,7 +5177,7 @@ weechat_lua_api_nicklist_search_nick (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "nicklist_search_nick"); LUA_RETURN_EMPTY; } @@ -5106,7 +5207,7 @@ weechat_lua_api_nicklist_remove_group (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "nicklist_remove_group"); LUA_RETURN_ERROR; } @@ -5117,7 +5218,7 @@ weechat_lua_api_nicklist_remove_group (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "nicklist_remove_group"); LUA_RETURN_ERROR; } @@ -5145,7 +5246,7 @@ weechat_lua_api_nicklist_remove_nick (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "nicklist_remove_nick"); LUA_RETURN_ERROR; } @@ -5156,7 +5257,7 @@ weechat_lua_api_nicklist_remove_nick (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "nicklist_remove_nick"); LUA_RETURN_ERROR; } @@ -5184,7 +5285,7 @@ weechat_lua_api_nicklist_remove_all (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "nicklist_remove_all"); LUA_RETURN_ERROR; } @@ -5194,7 +5295,7 @@ weechat_lua_api_nicklist_remove_all (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "nicklist_remove_all"); LUA_RETURN_ERROR; } @@ -5221,7 +5322,7 @@ weechat_lua_api_bar_item_search (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "bar_item_search"); LUA_RETURN_EMPTY; } @@ -5231,7 +5332,7 @@ weechat_lua_api_bar_item_search (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "bar_item_search"); LUA_RETURN_EMPTY; } @@ -5251,25 +5352,26 @@ weechat_lua_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, struct t_gui_window *window) { struct t_script_callback *script_callback; - char *lua_argv[3], *ret; + char *lua_argv[4], empty_arg[1] = { '\0' }, *ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - lua_argv[0] = script_ptr2str (item); - lua_argv[1] = script_ptr2str (window); - lua_argv[2] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (item); + lua_argv[2] = script_ptr2str (window); + lua_argv[3] = NULL; ret = (char *)weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, script_callback->function, lua_argv); - if (lua_argv[0]) - free (lua_argv[0]); if (lua_argv[1]) free (lua_argv[1]); + if (lua_argv[2]) + free (lua_argv[2]); return ret; } @@ -5284,7 +5386,7 @@ weechat_lua_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, static int weechat_lua_api_bar_item_new (lua_State *L) { - const char *name, *function; + const char *name, *function, *data; char *result; int n; @@ -5293,29 +5395,32 @@ weechat_lua_api_bar_item_new (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "bar_item_new"); LUA_RETURN_EMPTY; } name = NULL; function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 2) + if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "bar_item_new"); LUA_RETURN_EMPTY; } - name = lua_tostring (lua_current_interpreter, -2); - function = lua_tostring (lua_current_interpreter, -1); + name = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); result = script_ptr2str (script_api_bar_item_new (weechat_lua_plugin, lua_current_script, name, &weechat_lua_api_bar_item_build_cb, - function)); + function, + data)); LUA_RETURN_STRING_FREE(result); } @@ -5335,7 +5440,7 @@ weechat_lua_api_bar_item_update (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_update"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "bar_item_update"); LUA_RETURN_ERROR; } @@ -5345,7 +5450,7 @@ weechat_lua_api_bar_item_update (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_update"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "bar_item_update"); LUA_RETURN_ERROR; } @@ -5371,7 +5476,7 @@ weechat_lua_api_bar_item_remove (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "bar_item_remove"); LUA_RETURN_ERROR; } @@ -5381,7 +5486,7 @@ weechat_lua_api_bar_item_remove (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "bar_item_remove"); LUA_RETURN_ERROR; } @@ -5410,7 +5515,7 @@ weechat_lua_api_bar_search (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "bar_search"); LUA_RETURN_EMPTY; } @@ -5420,7 +5525,7 @@ weechat_lua_api_bar_search (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "bar_search"); LUA_RETURN_EMPTY; } @@ -5449,7 +5554,7 @@ weechat_lua_api_bar_new (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "bar_new"); LUA_RETURN_EMPTY; } @@ -5473,7 +5578,7 @@ weechat_lua_api_bar_new (lua_State *L) if (n < 15) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "bar_new"); LUA_RETURN_EMPTY; } @@ -5527,7 +5632,7 @@ weechat_lua_api_bar_set (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "bar_set"); LUA_RETURN_ERROR; } @@ -5538,7 +5643,7 @@ weechat_lua_api_bar_set (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "bar_set"); LUA_RETURN_ERROR; } @@ -5568,7 +5673,7 @@ weechat_lua_api_bar_update (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_update"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "bar_update"); LUA_RETURN_ERROR; } @@ -5578,7 +5683,7 @@ weechat_lua_api_bar_update (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_update"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "bar_update"); LUA_RETURN_ERROR; } @@ -5604,7 +5709,7 @@ weechat_lua_api_bar_remove (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "bar_remove"); LUA_RETURN_ERROR; } @@ -5614,7 +5719,7 @@ weechat_lua_api_bar_remove (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "bar_remove"); LUA_RETURN_ERROR; } @@ -5640,7 +5745,7 @@ weechat_lua_api_command (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("command"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "command"); LUA_RETURN_ERROR; } @@ -5651,7 +5756,7 @@ weechat_lua_api_command (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "command"); LUA_RETURN_ERROR; } @@ -5681,7 +5786,7 @@ weechat_lua_api_info_get (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("info_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "info_get"); LUA_RETURN_EMPTY; } @@ -5692,7 +5797,7 @@ weechat_lua_api_info_get (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("info_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "info_get"); LUA_RETURN_EMPTY; } @@ -5718,7 +5823,7 @@ weechat_lua_api_infolist_new (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_new"); LUA_RETURN_EMPTY; } @@ -5744,7 +5849,7 @@ weechat_lua_api_infolist_new_var_integer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); LUA_RETURN_EMPTY; } @@ -5756,7 +5861,7 @@ weechat_lua_api_infolist_new_var_integer (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); LUA_RETURN_EMPTY; } @@ -5788,7 +5893,7 @@ weechat_lua_api_infolist_new_var_string (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_new_var_string"); LUA_RETURN_EMPTY; } @@ -5800,7 +5905,7 @@ weechat_lua_api_infolist_new_var_string (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_new_var_string"); LUA_RETURN_EMPTY; } @@ -5832,7 +5937,7 @@ weechat_lua_api_infolist_new_var_pointer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer"); LUA_RETURN_EMPTY; } @@ -5844,7 +5949,7 @@ weechat_lua_api_infolist_new_var_pointer (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer"); LUA_RETURN_EMPTY; } @@ -5875,7 +5980,7 @@ weechat_lua_api_infolist_new_var_time (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); LUA_RETURN_EMPTY; } @@ -5887,7 +5992,7 @@ weechat_lua_api_infolist_new_var_time (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); LUA_RETURN_EMPTY; } @@ -5918,7 +6023,7 @@ weechat_lua_api_infolist_get (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_get"); LUA_RETURN_EMPTY; } @@ -5930,7 +6035,7 @@ weechat_lua_api_infolist_get (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_get"); LUA_RETURN_EMPTY; } @@ -5960,7 +6065,7 @@ weechat_lua_api_infolist_next (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_next"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_next"); LUA_RETURN_INT(0); } @@ -5970,7 +6075,7 @@ weechat_lua_api_infolist_next (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_next"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_next"); LUA_RETURN_INT(0); } @@ -5996,7 +6101,7 @@ weechat_lua_api_infolist_prev (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_prev"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_prev"); LUA_RETURN_INT(0); } @@ -6006,7 +6111,7 @@ weechat_lua_api_infolist_prev (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_prev"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_prev"); LUA_RETURN_INT(0); } @@ -6032,7 +6137,7 @@ weechat_lua_api_infolist_fields (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_fields"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_fields"); LUA_RETURN_EMPTY; } @@ -6042,7 +6147,7 @@ weechat_lua_api_infolist_fields (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_fields"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_fields"); LUA_RETURN_EMPTY; } @@ -6068,7 +6173,7 @@ weechat_lua_api_infolist_integer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_integer"); LUA_RETURN_INT(0); } @@ -6079,7 +6184,7 @@ weechat_lua_api_infolist_integer (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_integer"); LUA_RETURN_INT(0); } @@ -6107,7 +6212,7 @@ weechat_lua_api_infolist_string (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_string"); LUA_RETURN_EMPTY; } @@ -6118,7 +6223,7 @@ weechat_lua_api_infolist_string (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_string"); LUA_RETURN_EMPTY; } @@ -6147,7 +6252,7 @@ weechat_lua_api_infolist_pointer (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_pointer"); LUA_RETURN_EMPTY; } @@ -6158,7 +6263,7 @@ weechat_lua_api_infolist_pointer (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_pointer"); LUA_RETURN_EMPTY; } @@ -6188,7 +6293,7 @@ weechat_lua_api_infolist_time (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_time"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_time"); LUA_RETURN_EMPTY; } @@ -6199,7 +6304,7 @@ weechat_lua_api_infolist_time (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_time"); LUA_RETURN_EMPTY; } @@ -6229,7 +6334,7 @@ weechat_lua_api_infolist_free (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "infolist_free"); LUA_RETURN_ERROR; } @@ -6239,7 +6344,7 @@ weechat_lua_api_infolist_free (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "infolist_free"); LUA_RETURN_ERROR; } @@ -6266,7 +6371,7 @@ weechat_lua_api_upgrade_new (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "upgrade_new"); LUA_RETURN_EMPTY; } @@ -6277,7 +6382,7 @@ weechat_lua_api_upgrade_new (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "upgrade_new"); LUA_RETURN_EMPTY; } @@ -6304,7 +6409,7 @@ weechat_lua_api_upgrade_write_object (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "upgrade_write_object"); LUA_RETURN_INT(0); } @@ -6316,7 +6421,7 @@ weechat_lua_api_upgrade_write_object (lua_State *L) if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "upgrade_write_object"); LUA_RETURN_INT(0); } @@ -6342,7 +6447,7 @@ weechat_lua_api_upgrade_read_cb (void *data, struct t_infolist *infolist) { struct t_script_callback *script_callback; - char *lua_argv[4], str_object_id[32]; + char *lua_argv[5], empty_arg[1] = { '\0' }, str_object_id[32]; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -6351,10 +6456,11 @@ weechat_lua_api_upgrade_read_cb (void *data, { snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); - lua_argv[0] = script_ptr2str (upgrade_file); - lua_argv[1] = str_object_id; - lua_argv[2] = script_ptr2str (infolist); - lua_argv[3] = NULL; + lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + lua_argv[1] = script_ptr2str (upgrade_file); + lua_argv[2] = str_object_id; + lua_argv[3] = script_ptr2str (infolist); + lua_argv[4] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -6368,10 +6474,10 @@ weechat_lua_api_upgrade_read_cb (void *data, ret = *rc; free (rc); } - if (lua_argv[0]) - free (lua_argv[0]); - if (lua_argv[2]) - free (lua_argv[2]); + if (lua_argv[1]) + free (lua_argv[1]); + if (lua_argv[3]) + free (lua_argv[3]); return ret; } @@ -6386,7 +6492,7 @@ weechat_lua_api_upgrade_read_cb (void *data, static int weechat_lua_api_upgrade_read (lua_State *L) { - const char *upgrade_file, *function_read; + const char *upgrade_file, *function, *data; int n, rc; /* make C compiler happy */ @@ -6394,29 +6500,32 @@ weechat_lua_api_upgrade_read (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_read"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "upgrade_read"); LUA_RETURN_EMPTY; } upgrade_file = NULL; - function_read = NULL; + function = NULL; + data = NULL; n = lua_gettop (lua_current_interpreter); - if (n < 2) + if (n < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_read"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "upgrade_read"); LUA_RETURN_EMPTY; } - upgrade_file = lua_tostring (lua_current_interpreter, -2); - function_read = lua_tostring (lua_current_interpreter, -1); + upgrade_file = lua_tostring (lua_current_interpreter, -3); + function = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); rc = script_api_upgrade_read (weechat_lua_plugin, lua_current_script, script_str2ptr (upgrade_file), &weechat_lua_api_upgrade_read_cb, - function_read); + function, + data); LUA_RETURN_INT(rc); } @@ -6436,7 +6545,7 @@ weechat_lua_api_upgrade_close (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_close"); + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "upgrade_close"); LUA_RETURN_ERROR; } @@ -6446,7 +6555,7 @@ weechat_lua_api_upgrade_close (lua_State *L) if (n < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "upgrade_close"); LUA_RETURN_INT(0); } diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c index 71a76b62e..7020034dc 100644 --- a/src/plugins/scripts/lua/weechat-lua.c +++ b/src/plugins/scripts/lua/weechat-lua.c @@ -113,6 +113,12 @@ weechat_lua_exec (struct t_plugin_script *script, argc = 7; lua_pushstring (lua_current_interpreter, argv[6]); + if (argv[7]) + { + argc = 8; + lua_pushstring (lua_current_interpreter, + argv[7]); + } } } } @@ -145,7 +151,7 @@ weechat_lua_exec (struct t_plugin_script *script, } else { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS(function); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, function); lua_current_script = old_lua_current_script; return NULL; } diff --git a/src/plugins/scripts/lua/weechat-lua.h b/src/plugins/scripts/lua/weechat-lua.h index e26c16763..271b62f3d 100644 --- a/src/plugins/scripts/lua/weechat-lua.h +++ b/src/plugins/scripts/lua/weechat-lua.h @@ -23,6 +23,8 @@ #define weechat_plugin weechat_lua_plugin #define LUA_PLUGIN_NAME "lua" +#define LUA_CURRENT_SCRIPT_NAME ((lua_current_script) ? lua_current_script->name : "-") + extern struct t_weechat_plugin *weechat_lua_plugin; extern int lua_quiet; diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 38c035031..0b99bc2cf 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -79,7 +79,7 @@ static XS (XS_weechat_api_register) if (items < 7) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("register"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(perl_current_script_filename, "register"); PERL_RETURN_ERROR; } @@ -141,13 +141,13 @@ static XS (XS_weechat_api_plugin_get_name) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "plugin_get_name"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "plugin_get_name"); PERL_RETURN_EMPTY; } @@ -169,13 +169,13 @@ static XS (XS_weechat_api_charset_set) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("charset_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "charset_set"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("charset_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "charset_set"); PERL_RETURN_ERROR; } @@ -199,18 +199,19 @@ static XS (XS_weechat_api_iconv_to_internal) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_to_internal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "iconv_to_internal"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_to_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "iconv_to_internal"); PERL_RETURN_EMPTY; } charset = SvPV (ST (0), PL_na); string = SvPV (ST (1), PL_na); + result = weechat_iconv_to_internal (charset, string); PERL_RETURN_STRING_FREE(result); @@ -231,18 +232,19 @@ static XS (XS_weechat_api_iconv_from_internal) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_from_internal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "iconv_from_internal"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_from_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "iconv_from_internal"); PERL_RETURN_EMPTY; } charset = SvPV (ST (0), PL_na); string = SvPV (ST (1), PL_na); + result = weechat_iconv_from_internal (charset, string); PERL_RETURN_STRING_FREE(result); @@ -262,13 +264,13 @@ static XS (XS_weechat_api_gettext) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("gettext"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "gettext"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("gettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "gettext"); PERL_RETURN_EMPTY; } @@ -292,18 +294,19 @@ static XS (XS_weechat_api_ngettext) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("ngettext"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "ngettext"); PERL_RETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("ngettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "ngettext"); PERL_RETURN_EMPTY; } single = SvPV (ST (0), PL_na); plural = SvPV (ST (1), PL_na); + result = weechat_ngettext (single, plural, SvIV (ST (2))); /* count */ @@ -324,18 +327,19 @@ static XS (XS_weechat_api_string_remove_color) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("string_remove_color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "string_remove_color"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "string_remove_color"); PERL_RETURN_EMPTY; } string = SvPV (ST (0), PL_na); replacement = SvPV (ST (1), PL_na); + result = weechat_string_remove_color (string, replacement); PERL_RETURN_STRING_FREE(result); @@ -354,13 +358,13 @@ static XS (XS_weechat_api_mkdir_home) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_home"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "mkdir_home"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_home"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "mkdir_home"); PERL_RETURN_ERROR; } @@ -384,13 +388,13 @@ static XS (XS_weechat_api_mkdir) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "mkdir"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "mkdir"); PERL_RETURN_ERROR; } @@ -415,13 +419,13 @@ static XS (XS_weechat_api_mkdir_parents) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_parents"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "mkdir_parents"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_parents"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "mkdir_parents"); PERL_RETURN_ERROR; } @@ -447,7 +451,7 @@ static XS (XS_weechat_api_list_new) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_new"); PERL_RETURN_EMPTY; } @@ -470,13 +474,13 @@ static XS (XS_weechat_api_list_add) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_add"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_add"); PERL_RETURN_EMPTY; } if (items < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_add"); PERL_RETURN_EMPTY; } @@ -484,6 +488,7 @@ static XS (XS_weechat_api_list_add) data = SvPV (ST (1), PL_na); where = SvPV (ST (2), PL_na); user_data = SvPV (ST (3), PL_na); + result = script_ptr2str (weechat_list_add (script_str2ptr (weelist), data, where, @@ -506,18 +511,19 @@ static XS (XS_weechat_api_list_search) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_search"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_search"); PERL_RETURN_EMPTY; } weelist = SvPV (ST (0), PL_na); data = SvPV (ST (1), PL_na); + result = script_ptr2str (weechat_list_search (script_str2ptr (weelist), data)); @@ -538,18 +544,19 @@ static XS (XS_weechat_api_list_casesearch) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_casesearch"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_casesearch"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_casesearch"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_casesearch"); PERL_RETURN_EMPTY; } weelist = SvPV (ST (0), PL_na); data = SvPV (ST (1), PL_na); + result = script_ptr2str (weechat_list_casesearch (script_str2ptr (weelist), data)); @@ -570,13 +577,13 @@ static XS (XS_weechat_api_list_get) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_get"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_get"); PERL_RETURN_EMPTY; } @@ -600,18 +607,19 @@ static XS (XS_weechat_api_list_set) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_set"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_set"); PERL_RETURN_ERROR; } item = SvPV (ST (0), PL_na); new_value = SvPV (ST (1), PL_na); + weechat_list_set (script_str2ptr (item), new_value); PERL_RETURN_OK; @@ -631,13 +639,13 @@ static XS (XS_weechat_api_list_next) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_next"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_next"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_next"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_next"); PERL_RETURN_EMPTY; } @@ -660,13 +668,13 @@ static XS (XS_weechat_api_list_prev) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_prev"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_prev"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_prev"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_prev"); PERL_RETURN_EMPTY; } @@ -689,13 +697,13 @@ static XS (XS_weechat_api_list_string) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_string"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_string"); PERL_RETURN_EMPTY; } @@ -718,13 +726,13 @@ static XS (XS_weechat_api_list_size) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_size"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_size"); PERL_RETURN_INT(0); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_size"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_size"); PERL_RETURN_INT(0); } @@ -747,18 +755,19 @@ static XS (XS_weechat_api_list_remove) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_remove"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_remove"); PERL_RETURN_ERROR; } weelist = SvPV (ST (0), PL_na); item = SvPV (ST (1), PL_na); + weechat_list_remove (script_str2ptr (weelist), script_str2ptr (item)); PERL_RETURN_OK; @@ -777,13 +786,13 @@ static XS (XS_weechat_api_list_remove_all) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_remove_all"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_remove_all"); PERL_RETURN_ERROR; } @@ -805,13 +814,13 @@ static XS (XS_weechat_api_list_free) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_free"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_free"); PERL_RETURN_ERROR; } @@ -829,15 +838,16 @@ weechat_perl_api_config_reload_cb (void *data, struct t_config_file *config_file) { struct t_script_callback *script_callback; - char *perl_argv[2]; + char *perl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (config_file); - perl_argv[1] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (config_file); + perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -851,8 +861,8 @@ weechat_perl_api_config_reload_cb (void *data, ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); + if (perl_argv[1]) + free (perl_argv[1]); return ret; } @@ -866,7 +876,7 @@ weechat_perl_api_config_reload_cb (void *data, static XS (XS_weechat_api_config_new) { - char *result, *name, *function; + char *result, *name, *function, *data; dXSARGS; /* make C compiler happy */ @@ -874,23 +884,26 @@ static XS (XS_weechat_api_config_new) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_new"); PERL_RETURN_EMPTY; } - if (items < 2) + if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_new"); PERL_RETURN_EMPTY; } name = SvPV (ST (0), PL_na); function = SvPV (ST (1), PL_na); + data = SvPV (ST (2), PL_na); + result = script_ptr2str (script_api_config_new (weechat_perl_plugin, perl_current_script, name, &weechat_perl_api_config_reload_cb, - function)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -907,18 +920,19 @@ weechat_perl_api_config_section_read_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *perl_argv[5], empty_arg[1] = { '\0' }; + char *perl_argv[6], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (config_file); - perl_argv[1] = script_ptr2str (section); - perl_argv[2] = (option_name) ? (char *)option_name : empty_arg; - perl_argv[3] = (value) ? (char *)value : empty_arg; - perl_argv[4] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (config_file); + perl_argv[2] = script_ptr2str (section); + perl_argv[3] = (option_name) ? (char *)option_name : empty_arg; + perl_argv[4] = (value) ? (char *)value : empty_arg; + perl_argv[5] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -932,10 +946,10 @@ weechat_perl_api_config_section_read_cb (void *data, ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); if (perl_argv[1]) free (perl_argv[1]); + if (perl_argv[2]) + free (perl_argv[2]); return ret; } @@ -953,16 +967,17 @@ weechat_perl_api_config_section_write_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *perl_argv[3], empty_arg[1] = { '\0' }; + char *perl_argv[4], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (config_file); - perl_argv[1] = (section_name) ? (char *)section_name : empty_arg; - perl_argv[2] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (config_file); + perl_argv[2] = (section_name) ? (char *)section_name : empty_arg; + perl_argv[3] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -971,8 +986,8 @@ weechat_perl_api_config_section_write_cb (void *data, if (rc) free (rc); - if (perl_argv[0]) - free (perl_argv[0]); + if (perl_argv[1]) + free (perl_argv[1]); } } @@ -987,16 +1002,17 @@ weechat_perl_api_config_section_write_default_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *perl_argv[3], empty_arg[1] = { '\0' }; + char *perl_argv[4], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (config_file); - perl_argv[1] = (section_name) ? (char *)section_name : empty_arg; - perl_argv[2] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (config_file); + perl_argv[2] = (section_name) ? (char *)section_name : empty_arg; + perl_argv[3] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1005,8 +1021,8 @@ weechat_perl_api_config_section_write_default_cb (void *data, if (rc) free (rc); - if (perl_argv[0]) - free (perl_argv[0]); + if (perl_argv[1]) + free (perl_argv[1]); } } @@ -1022,18 +1038,19 @@ weechat_perl_api_config_section_create_option_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *perl_argv[5], empty_arg[1] = { '\0' }; + char *perl_argv[6], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (config_file); - perl_argv[1] = script_ptr2str (section); - perl_argv[2] = (option_name) ? (char *)option_name : empty_arg; - perl_argv[3] = (value) ? (char *)value : empty_arg; - perl_argv[4] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (config_file); + perl_argv[2] = script_ptr2str (section); + perl_argv[3] = (option_name) ? (char *)option_name : empty_arg; + perl_argv[4] = (value) ? (char *)value : empty_arg; + perl_argv[5] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1047,10 +1064,10 @@ weechat_perl_api_config_section_create_option_cb (void *data, ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); if (perl_argv[1]) free (perl_argv[1]); + if (perl_argv[2]) + free (perl_argv[2]); return ret; } @@ -1069,17 +1086,18 @@ weechat_perl_api_config_section_delete_option_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *perl_argv[4]; + char *perl_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (config_file); - perl_argv[1] = script_ptr2str (section); - perl_argv[2] = script_ptr2str (option); - perl_argv[3] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (config_file); + perl_argv[2] = script_ptr2str (section); + perl_argv[3] = script_ptr2str (option); + perl_argv[4] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1093,12 +1111,12 @@ weechat_perl_api_config_section_delete_option_cb (void *data, ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); if (perl_argv[1]) free (perl_argv[1]); if (perl_argv[2]) free (perl_argv[2]); + if (perl_argv[3]) + free (perl_argv[3]); return ret; } @@ -1112,9 +1130,11 @@ weechat_perl_api_config_section_delete_option_cb (void *data, static XS (XS_weechat_api_config_new_section) { - char *result, *cfg_file, *name, *function_read, *function_write; - char *function_write_default, *function_create_option; - char *function_delete_option; + char *result, *cfg_file, *name, *function_read, *data_read; + char *function_write, *data_write, *function_write_default; + char *data_write_default, *function_create_option, *data_create_option; + char *function_delete_option, *data_delete_option; + dXSARGS; /* make C compiler happy */ @@ -1122,23 +1142,29 @@ static XS (XS_weechat_api_config_new_section) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new_section"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_new_section"); PERL_RETURN_EMPTY; } - if (items < 9) + if (items < 14) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_new_section"); PERL_RETURN_EMPTY; } cfg_file = SvPV (ST (0), PL_na); name = SvPV (ST (1), PL_na); function_read = SvPV (ST (4), PL_na); - function_write = SvPV (ST (5), PL_na); - function_write_default = SvPV (ST (6), PL_na); - function_create_option = SvPV (ST (7), PL_na); - function_delete_option = SvPV (ST (8), PL_na); + data_read = SvPV (ST (5), PL_na); + function_write = SvPV (ST (6), PL_na); + data_write = SvPV (ST (7), PL_na); + function_write_default = SvPV (ST (8), PL_na); + data_write_default = SvPV (ST (9), PL_na); + function_create_option = SvPV (ST (10), PL_na); + data_create_option = SvPV (ST (11), PL_na); + function_delete_option = SvPV (ST (12), PL_na); + data_delete_option = SvPV (ST (13), PL_na); + result = script_ptr2str (script_api_config_new_section (weechat_perl_plugin, perl_current_script, script_str2ptr (cfg_file), @@ -1147,14 +1173,19 @@ static XS (XS_weechat_api_config_new_section) SvIV (ST (3)), /* user_can_delete_options */ &weechat_perl_api_config_section_read_cb, function_read, + data_read, &weechat_perl_api_config_section_write_cb, function_write, + data_write, &weechat_perl_api_config_section_write_default_cb, function_write_default, + data_write_default, &weechat_perl_api_config_section_create_option_cb, function_create_option, + data_create_option, &weechat_perl_api_config_section_delete_option_cb, - function_delete_option)); + function_delete_option, + data_delete_option)); PERL_RETURN_STRING_FREE(result); } @@ -1173,18 +1204,19 @@ static XS (XS_weechat_api_config_search_section) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_search_section"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_search_section"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_search_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_search_section"); PERL_RETURN_EMPTY; } config_file = SvPV (ST (0), PL_na); section_name = SvPV (ST (1), PL_na); + result = script_ptr2str (weechat_config_search_section (script_str2ptr (config_file), section_name)); @@ -1202,16 +1234,17 @@ weechat_perl_api_config_option_check_value_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *perl_argv[3], empty_arg[1] = { '\0' }; + char *perl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (option); - perl_argv[1] = (value) ? (char *)value : empty_arg; - perl_argv[2] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (option); + perl_argv[2] = (value) ? (char *)value : empty_arg; + perl_argv[3] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1225,8 +1258,8 @@ weechat_perl_api_config_option_check_value_cb (void *data, ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); + if (perl_argv[1]) + free (perl_argv[1]); return ret; } @@ -1243,23 +1276,24 @@ weechat_perl_api_config_option_change_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *perl_argv[2]; + char *perl_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (option); - perl_argv[1] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (option); + perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, script_callback->function, perl_argv); - if (perl_argv[0]) - free (perl_argv[0]); + if (perl_argv[1]) + free (perl_argv[1]); if (rc) free (rc); @@ -1275,23 +1309,24 @@ weechat_perl_api_config_option_delete_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *perl_argv[2]; + char *perl_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (option); - perl_argv[1] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (option); + perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, script_callback->function, perl_argv); - if (perl_argv[0]) - free (perl_argv[0]); + if (perl_argv[1]) + free (perl_argv[1]); if (rc) free (rc); @@ -1306,7 +1341,8 @@ static XS (XS_weechat_api_config_new_option) { char *result, *config_file, *section, *name, *type; char *description, *string_values, *default_value, *value; - char *function_check_value, *function_change, *function_delete; + char *function_check_value, *data_check_value, *function_change; + char *data_change, *function_delete, *data_delete; dXSARGS; /* make C compiler happy */ @@ -1314,13 +1350,13 @@ static XS (XS_weechat_api_config_new_option) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_new_option"); PERL_RETURN_EMPTY; } - if (items < 14) + if (items < 17) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_new_option"); PERL_RETURN_EMPTY; } @@ -1333,8 +1369,12 @@ static XS (XS_weechat_api_config_new_option) default_value = SvPV (ST (8), PL_na); value = SvPV (ST (9), PL_na); function_check_value = SvPV (ST (11), PL_na); - function_change = SvPV (ST (12), PL_na); - function_delete = SvPV (ST (13), PL_na); + data_check_value = SvPV (ST (12), PL_na); + function_change = SvPV (ST (13), PL_na); + data_change = SvPV (ST (14), PL_na); + function_delete = SvPV (ST (15), PL_na); + data_delete = SvPV (ST (16), PL_na); + result = script_ptr2str (script_api_config_new_option (weechat_perl_plugin, perl_current_script, script_str2ptr (config_file), @@ -1350,10 +1390,13 @@ static XS (XS_weechat_api_config_new_option) SvIV (ST (10)), /* null_value_allowed */ &weechat_perl_api_config_option_check_value_cb, function_check_value, + data_check_value, &weechat_perl_api_config_option_change_cb, function_change, + data_change, &weechat_perl_api_config_option_delete_cb, - function_delete)); + function_delete, + data_delete)); PERL_RETURN_STRING_FREE(result); } @@ -1372,19 +1415,20 @@ static XS (XS_weechat_api_config_search_option) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_search_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_search_option"); PERL_RETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_search_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_search_option"); PERL_RETURN_EMPTY; } config_file = SvPV (ST (0), PL_na); section = SvPV (ST (1), PL_na); option_name = SvPV (ST (2), PL_na); + result = script_ptr2str (weechat_config_search_option (script_str2ptr (config_file), script_str2ptr (section), option_name)); @@ -1406,13 +1450,13 @@ static XS (XS_weechat_api_config_string_to_boolean) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string_to_boolean"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_string_to_boolean"); PERL_RETURN_INT(0); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string_to_boolean"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_string_to_boolean"); PERL_RETURN_INT(0); } @@ -1436,17 +1480,18 @@ static XS (XS_weechat_api_config_option_reset) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_reset"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_option_reset"); PERL_RETURN_INT(0); } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_option_reset"); PERL_RETURN_INT(0); } option = SvPV (ST (0), PL_na); + rc = weechat_config_option_reset (script_str2ptr (option), SvIV (ST (1))); /* run_callback */ @@ -1468,18 +1513,19 @@ static XS (XS_weechat_api_config_option_set) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_option_set"); PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_option_set"); PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } option = SvPV (ST (0), PL_na); new_value = SvPV (ST (1), PL_na); + rc = weechat_config_option_set (script_str2ptr (option), new_value, SvIV (ST (2))); /* run_callback */ @@ -1502,17 +1548,18 @@ static XS (XS_weechat_api_config_option_set_null) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_option_set_null"); PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_option_set_null"); PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } option = SvPV (ST (0), PL_na); + rc = weechat_config_option_set_null (script_str2ptr (option), SvIV (ST (1))); /* run_callback */ @@ -1534,17 +1581,18 @@ static XS (XS_weechat_api_config_option_unset) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_option_unset"); PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_option_unset"); PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } option = SvPV (ST (0), PL_na); + rc = weechat_config_option_unset (script_str2ptr (option)); PERL_RETURN_INT(rc); @@ -1564,18 +1612,19 @@ static XS (XS_weechat_api_config_option_rename) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_option_rename"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_rename"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_option_rename"); PERL_RETURN_ERROR; } option = SvPV (ST (0), PL_na); new_name = SvPV (ST (1), PL_na); + weechat_config_option_rename (script_str2ptr (option), new_name); @@ -1596,13 +1645,13 @@ static XS (XS_weechat_api_config_option_is_null) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_option_is_null"); PERL_RETURN_INT(1); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_option_is_null"); PERL_RETURN_INT(1); } @@ -1626,13 +1675,13 @@ static XS (XS_weechat_api_config_option_default_is_null) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_option_default_is_null"); PERL_RETURN_INT(1); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_option_default_is_null"); PERL_RETURN_INT(1); } @@ -1655,13 +1704,13 @@ static XS (XS_weechat_api_config_boolean) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_boolean"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_boolean"); PERL_RETURN_INT(0); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_boolean"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_boolean"); PERL_RETURN_INT(0); } @@ -1684,13 +1733,13 @@ static XS (XS_weechat_api_config_boolean_default) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_boolean_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_boolean_default"); PERL_RETURN_INT(0); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_boolean_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_boolean_default"); PERL_RETURN_INT(0); } @@ -1713,13 +1762,13 @@ static XS (XS_weechat_api_config_integer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_integer"); PERL_RETURN_INT(0); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_integer"); PERL_RETURN_INT(0); } @@ -1742,13 +1791,13 @@ static XS (XS_weechat_api_config_integer_default) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_integer_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_integer_default"); PERL_RETURN_INT(0); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_integer_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_integer_default"); PERL_RETURN_INT(0); } @@ -1771,13 +1820,13 @@ static XS (XS_weechat_api_config_string) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_string"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_string"); PERL_RETURN_EMPTY; } @@ -1800,13 +1849,13 @@ static XS (XS_weechat_api_config_string_default) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_string_default"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_string_default"); PERL_RETURN_EMPTY; } @@ -1829,13 +1878,13 @@ static XS (XS_weechat_api_config_color) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_color"); PERL_RETURN_INT(0); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_color"); PERL_RETURN_INT(0); } @@ -1858,13 +1907,13 @@ static XS (XS_weechat_api_config_color_default) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_color_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_color_default"); PERL_RETURN_INT(0); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_color_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_color_default"); PERL_RETURN_INT(0); } @@ -1887,18 +1936,19 @@ static XS (XS_weechat_api_config_write_option) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_write_option"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_write_option"); PERL_RETURN_ERROR; } config_file = SvPV (ST (0), PL_na); option = SvPV (ST (1), PL_na); + weechat_config_write_option (script_str2ptr (config_file), script_str2ptr (option)); @@ -1919,19 +1969,20 @@ static XS (XS_weechat_api_config_write_line) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_line"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_write_line"); PERL_RETURN_ERROR; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_line"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_write_line"); PERL_RETURN_ERROR; } config_file = SvPV (ST (0), PL_na); option_name = SvPV (ST (1), PL_na); value = SvPV (ST (2), PL_na); + weechat_config_write_line (script_str2ptr (config_file), option_name, "%s", value); @@ -1952,13 +2003,13 @@ static XS (XS_weechat_api_config_write) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_write"); PERL_RETURN_INT(-1); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_write"); PERL_RETURN_INT(-1); } @@ -1981,13 +2032,13 @@ static XS (XS_weechat_api_config_read) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_read"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_read"); PERL_RETURN_INT(-1); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_read"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_read"); PERL_RETURN_INT(-1); } @@ -2010,13 +2061,13 @@ static XS (XS_weechat_api_config_reload) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_reload"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_reload"); PERL_RETURN_INT(-1); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_reload"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_reload"); PERL_RETURN_INT(-1); } @@ -2038,13 +2089,13 @@ static XS (XS_weechat_api_config_option_free) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_option_free"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_option_free"); PERL_RETURN_ERROR; } @@ -2069,13 +2120,13 @@ static XS (XS_weechat_api_config_section_free_options) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free_options"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_section_free_options"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free_options"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_section_free_options"); PERL_RETURN_ERROR; } @@ -2099,13 +2150,13 @@ static XS (XS_weechat_api_config_section_free) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_section_free"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_section_free"); PERL_RETURN_ERROR; } @@ -2129,13 +2180,13 @@ static XS (XS_weechat_api_config_free) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_free"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_free"); PERL_RETURN_ERROR; } @@ -2160,13 +2211,13 @@ static XS (XS_weechat_api_config_get) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_get"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_get"); PERL_RETURN_EMPTY; } @@ -2189,13 +2240,13 @@ static XS (XS_weechat_api_config_get_plugin) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_get_plugin"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_get_plugin"); PERL_RETURN_EMPTY; } @@ -2221,18 +2272,19 @@ static XS (XS_weechat_api_config_set_plugin) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_set_plugin"); PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_set_plugin"); PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } option = SvPV (ST (0), PL_na); value = SvPV (ST (1), PL_na); + rc = script_api_config_set_plugin (weechat_perl_plugin, perl_current_script, option, @@ -2256,17 +2308,18 @@ static XS (XS_weechat_api_config_unset_plugin) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_unset_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_unset_plugin"); PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_unset_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_unset_plugin"); PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } option = SvPV (ST (0), PL_na); + rc = script_api_config_unset_plugin (weechat_perl_plugin, perl_current_script, option); @@ -2288,13 +2341,13 @@ static XS (XS_weechat_api_prefix) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("prefix"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "prefix"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prefix"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "prefix"); PERL_RETURN_EMPTY; } @@ -2317,13 +2370,13 @@ static XS (XS_weechat_api_color) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "color"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "color"); PERL_RETURN_EMPTY; } @@ -2346,12 +2399,13 @@ static XS (XS_weechat_api_print) if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "print"); PERL_RETURN_ERROR; } buffer = SvPV (ST (0), PL_na); message = SvPV (ST (1), PL_na); + script_api_printf (weechat_perl_plugin, perl_current_script, script_str2ptr (buffer), @@ -2375,19 +2429,20 @@ static XS (XS_weechat_api_print_date_tags) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print_date_tags"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "print_date_tags"); PERL_RETURN_ERROR; } if (items < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_date_tags"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "print_date_tags"); PERL_RETURN_ERROR; } buffer = SvPV (ST (0), PL_na); tags = SvPV (ST (2), PL_na); message = SvPV (ST (3), PL_na); + script_api_printf_date_tags (weechat_perl_plugin, perl_current_script, script_str2ptr (buffer), @@ -2412,18 +2467,19 @@ static XS (XS_weechat_api_print_y) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print_y"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "print_y"); PERL_RETURN_ERROR; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_y"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "print_y"); PERL_RETURN_ERROR; } buffer = SvPV (ST (0), PL_na); message = SvPV (ST (2), PL_na); + script_api_printf_y (weechat_perl_plugin, perl_current_script, script_str2ptr (buffer), @@ -2446,13 +2502,13 @@ static XS (XS_weechat_api_log_print) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("log_print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "log_print"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("log_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "log_print"); PERL_RETURN_ERROR; } @@ -2472,7 +2528,7 @@ weechat_perl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { struct t_script_callback *script_callback; - char *perl_argv[3], empty_arg[1] = { '\0' }; + char *perl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; /* make C compiler happy */ @@ -2482,9 +2538,10 @@ weechat_perl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (buffer); - perl_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg; - perl_argv[2] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (buffer); + perl_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; + perl_argv[3] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2498,8 +2555,8 @@ weechat_perl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); + if (perl_argv[1]) + free (perl_argv[1]); return ret; } @@ -2514,7 +2571,7 @@ weechat_perl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, static XS (XS_weechat_api_hook_command) { char *result, *command, *description, *args, *args_description; - char *completion, *function; + char *completion, *function, *data; dXSARGS; /* make C compiler happy */ @@ -2522,22 +2579,24 @@ static XS (XS_weechat_api_hook_command) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_command"); PERL_RETURN_EMPTY; } - if (items < 6) + if (items < 7) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_command"); PERL_RETURN_EMPTY; } - + command = SvPV (ST (0), PL_na); description = SvPV (ST (1), PL_na); args = SvPV (ST (2), PL_na); args_description = SvPV (ST (3), PL_na); completion = SvPV (ST (4), PL_na); function = SvPV (ST (5), PL_na); + data = SvPV (ST (6), PL_na); + result = script_ptr2str (script_api_hook_command (weechat_perl_plugin, perl_current_script, command, @@ -2546,7 +2605,8 @@ static XS (XS_weechat_api_hook_command) args_description, completion, &weechat_perl_api_hook_command_cb, - function)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -2560,16 +2620,17 @@ weechat_perl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, const char *command) { struct t_script_callback *script_callback; - char *perl_argv[3], empty_arg[1] = { '\0' }; + char *perl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (buffer); - perl_argv[1] = (command) ? (char *)command : empty_arg; - perl_argv[2] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (buffer); + perl_argv[2] = (command) ? (char *)command : empty_arg; + perl_argv[3] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2583,8 +2644,8 @@ weechat_perl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); + if (perl_argv[1]) + free (perl_argv[1]); return ret; } @@ -2598,7 +2659,7 @@ weechat_perl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, static XS (XS_weechat_api_hook_command_run) { - char *result, *command, *function; + char *result, *command, *function, *data; dXSARGS; /* make C compiler happy */ @@ -2606,23 +2667,26 @@ static XS (XS_weechat_api_hook_command_run) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command_run"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_command_run"); PERL_RETURN_EMPTY; } - if (items < 2) + if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command_run"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_command_run"); PERL_RETURN_EMPTY; } command = SvPV (ST (0), PL_na); function = SvPV (ST (1), PL_na); + data = SvPV (ST (2), PL_na); + result = script_ptr2str (script_api_hook_command_run (weechat_perl_plugin, perl_current_script, command, &weechat_perl_api_hook_command_run_cb, - function)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -2635,7 +2699,7 @@ int weechat_perl_api_hook_timer_cb (void *data, int remaining_calls) { struct t_script_callback *script_callback; - char *perl_argv[2], str_remaining_calls[32]; + char *perl_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -2645,8 +2709,9 @@ weechat_perl_api_hook_timer_cb (void *data, int remaining_calls) snprintf (str_remaining_calls, sizeof (str_remaining_calls), "%d", remaining_calls); - perl_argv[0] = str_remaining_calls; - perl_argv[1] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = str_remaining_calls; + perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2681,13 +2746,13 @@ static XS (XS_weechat_api_hook_timer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_timer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_timer"); PERL_RETURN_EMPTY; } - if (items < 4) + if (items < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_timer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_timer"); PERL_RETURN_EMPTY; } @@ -2697,7 +2762,8 @@ static XS (XS_weechat_api_hook_timer) SvIV (ST (1)), /* align_second */ SvIV (ST (2)), /* max_calls */ &weechat_perl_api_hook_timer_cb, - SvPV (ST (3), PL_na))); /* perl function */ + SvPV (ST (3), PL_na), /* perl function */ + SvPV (ST (4), PL_na))); /* data */ PERL_RETURN_STRING_FREE(result); } @@ -2710,7 +2776,7 @@ int weechat_perl_api_hook_fd_cb (void *data, int fd) { struct t_script_callback *script_callback; - char *perl_argv[2], str_fd[32]; + char *perl_argv[3], str_fd[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -2719,8 +2785,9 @@ weechat_perl_api_hook_fd_cb (void *data, int fd) { snprintf (str_fd, sizeof (str_fd), "%d", fd); - perl_argv[0] = str_fd; - perl_argv[1] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = str_fd; + perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2755,13 +2822,13 @@ static XS (XS_weechat_api_hook_fd) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_fd"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_fd"); PERL_RETURN_EMPTY; } - if (items < 5) + if (items < 6) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_fd"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_fd"); PERL_RETURN_EMPTY; } @@ -2772,7 +2839,8 @@ static XS (XS_weechat_api_hook_fd) SvIV (ST (2)), /* write */ SvIV (ST (3)), /* exception */ &weechat_perl_api_hook_fd_cb, - SvPV (ST (4), PL_na))); /* perl function */ + SvPV (ST (4), PL_na), /* perl function */ + SvPV (ST (5), PL_na))); /* data */ PERL_RETURN_STRING_FREE(result); } @@ -2787,7 +2855,7 @@ weechat_perl_api_hook_process_cb (void *data, const char *stdout, const char *stderr) { struct t_script_callback *script_callback; - char *perl_argv[5], str_rc[32], empty_arg[1] = { '\0' }; + char *perl_argv[6], str_rc[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -2796,11 +2864,12 @@ weechat_perl_api_hook_process_cb (void *data, { snprintf (str_rc, sizeof (str_rc), "%d", return_code); - perl_argv[0] = (command) ? (char *)command : empty_arg; - perl_argv[1] = str_rc; - perl_argv[2] = (stdout) ? (char *)stdout : empty_arg; - perl_argv[3] = (stderr) ? (char *)stderr : empty_arg; - perl_argv[4] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = (command) ? (char *)command : empty_arg; + perl_argv[2] = str_rc; + perl_argv[3] = (stdout) ? (char *)stdout : empty_arg; + perl_argv[4] = (stderr) ? (char *)stderr : empty_arg; + perl_argv[5] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2827,7 +2896,7 @@ weechat_perl_api_hook_process_cb (void *data, static XS (XS_weechat_api_hook_process) { - char *command, *function, *result; + char *command, *function, *data, *result; dXSARGS; /* make C compiler happy */ @@ -2835,25 +2904,27 @@ static XS (XS_weechat_api_hook_process) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_process"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_process"); PERL_RETURN_EMPTY; } - if (items < 3) + if (items < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_process"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_process"); PERL_RETURN_EMPTY; } command = SvPV (ST (0), PL_na); function = SvPV (ST (2), PL_na); + data = SvPV (ST (3), PL_na); result = script_ptr2str (script_api_hook_process (weechat_perl_plugin, perl_current_script, command, SvIV (ST (1)), /* timeout */ &weechat_perl_api_hook_process_cb, - function)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -2867,7 +2938,7 @@ weechat_perl_api_hook_connect_cb (void *data, int status, const char *error, const char *ip_address) { struct t_script_callback *script_callback; - char *perl_argv[4], str_status[32], empty_arg[1] = { '\0' }; + char *perl_argv[5], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -2876,10 +2947,11 @@ weechat_perl_api_hook_connect_cb (void *data, int status, { snprintf (str_status, sizeof (str_status), "%d", status); - perl_argv[0] = str_status; - perl_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; - perl_argv[2] = (error) ? (char *)error : empty_arg; - perl_argv[3] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = str_status; + perl_argv[2] = (ip_address) ? (char *)ip_address : empty_arg; + perl_argv[3] = (error) ? (char *)error : empty_arg; + perl_argv[4] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2906,7 +2978,7 @@ weechat_perl_api_hook_connect_cb (void *data, int status, static XS (XS_weechat_api_hook_connect) { - char *proxy, *address, *local_hostname, *result; + char *proxy, *address, *local_hostname, *function, *data, *result; dXSARGS; /* make C compiler happy */ @@ -2914,19 +2986,21 @@ static XS (XS_weechat_api_hook_connect) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_connect"); PERL_RETURN_EMPTY; } - if (items < 7) + if (items < 8) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_connect"); PERL_RETURN_EMPTY; } proxy = SvPV (ST (0), PL_na); address = SvPV (ST (1), PL_na); local_hostname = SvPV (ST (5), PL_na); + function = SvPV (ST (6), PL_na); + data = SvPV (ST (7), PL_na); result = script_ptr2str (script_api_hook_connect (weechat_perl_plugin, perl_current_script, @@ -2938,7 +3012,8 @@ static XS (XS_weechat_api_hook_connect) NULL, /* gnutls session */ local_hostname, &weechat_perl_api_hook_connect_cb, - SvPV (ST (6), PL_na))); /* perl function */ + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -2955,7 +3030,7 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *perl_argv[8], empty_arg[1] = { '\0' }; + char *perl_argv[9], empty_arg[1] = { '\0' }; static char timebuffer[64]; int *rc, ret; @@ -2968,16 +3043,17 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, { snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); - perl_argv[0] = script_ptr2str (buffer); - perl_argv[1] = timebuffer; - perl_argv[2] = weechat_string_build_with_exploded (tags, ","); - if (!perl_argv[2]) - perl_argv[2] = strdup (""); - perl_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); - perl_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); - perl_argv[5] = (prefix) ? (char *)prefix : empty_arg; - perl_argv[6] = (message) ? (char *)message : empty_arg; - perl_argv[7] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (buffer); + perl_argv[2] = timebuffer; + perl_argv[3] = weechat_string_build_with_exploded (tags, ","); + if (!perl_argv[3]) + perl_argv[3] = strdup (""); + perl_argv[4] = (displayed) ? strdup ("1") : strdup ("0"); + perl_argv[5] = (highlight) ? strdup ("1") : strdup ("0"); + perl_argv[6] = (prefix) ? (char *)prefix : empty_arg; + perl_argv[7] = (message) ? (char *)message : empty_arg; + perl_argv[8] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2991,14 +3067,14 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); - if (perl_argv[2]) - free (perl_argv[2]); + if (perl_argv[1]) + free (perl_argv[1]); if (perl_argv[3]) free (perl_argv[3]); if (perl_argv[4]) free (perl_argv[4]); + if (perl_argv[5]) + free (perl_argv[5]); return ret; } @@ -3012,7 +3088,7 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, static XS (XS_weechat_api_hook_print) { - char *result, *buffer, *tags, *message, *function; + char *result, *buffer, *tags, *message, *function, *data; dXSARGS; /* make C compiler happy */ @@ -3020,13 +3096,13 @@ static XS (XS_weechat_api_hook_print) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_print"); PERL_RETURN_EMPTY; } - if (items < 5) + if (items < 6) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_print"); PERL_RETURN_EMPTY; } @@ -3034,6 +3110,8 @@ static XS (XS_weechat_api_hook_print) tags = SvPV (ST (1), PL_na); message = SvPV (ST (2), PL_na); function = SvPV (ST (4), PL_na); + data = SvPV (ST (5), PL_na); + result = script_ptr2str (script_api_hook_print (weechat_perl_plugin, perl_current_script, script_str2ptr (buffer), @@ -3041,7 +3119,8 @@ static XS (XS_weechat_api_hook_print) message, SvIV (ST (3)), /* strip_colors */ &weechat_perl_api_hook_print_cb, - function)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -3055,34 +3134,35 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ void *signal_data) { struct t_script_callback *script_callback; - char *perl_argv[3], empty_arg[1] = { '\0' }; + char *perl_argv[4], empty_arg[1] = { '\0' }; static char value_str[64]; int *rc, ret, free_needed; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (signal) ? (char *)signal : empty_arg; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = (signal) ? (char *)signal : empty_arg; free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { - perl_argv[1] = (signal_data) ? (char *)signal_data : empty_arg; + perl_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { snprintf (value_str, sizeof (value_str) - 1, "%d", *((int *)signal_data)); - perl_argv[1] = value_str; + perl_argv[2] = value_str; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - perl_argv[1] = script_ptr2str (signal_data); + perl_argv[2] = script_ptr2str (signal_data); free_needed = 1; } else - perl_argv[1] = empty_arg; - perl_argv[2] = NULL; + perl_argv[2] = empty_arg; + perl_argv[3] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3096,8 +3176,8 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ ret = *rc; free (rc); } - if (free_needed && perl_argv[1]) - free (perl_argv[1]); + if (free_needed && perl_argv[2]) + free (perl_argv[2]); return ret; } @@ -3111,7 +3191,7 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ static XS (XS_weechat_api_hook_signal) { - char *result, *signal, *function; + char *result, *signal, *function, *data; dXSARGS; /* make C compiler happy */ @@ -3119,23 +3199,26 @@ static XS (XS_weechat_api_hook_signal) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_signal"); PERL_RETURN_EMPTY; } - if (items < 2) + if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_signal"); PERL_RETURN_EMPTY; } signal = SvPV (ST (0), PL_na); function = SvPV (ST (1), PL_na); + data = SvPV (ST (2), PL_na); + result = script_ptr2str (script_api_hook_signal (weechat_perl_plugin, perl_current_script, signal, &weechat_perl_api_hook_signal_cb, - function)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -3155,13 +3238,13 @@ static XS (XS_weechat_api_hook_signal_send) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal_send"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_signal_send"); PERL_RETURN_ERROR; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal_send"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_signal_send"); PERL_RETURN_ERROR; } @@ -3201,16 +3284,17 @@ int weechat_perl_api_hook_config_cb (void *data, const char *option, const char *value) { struct t_script_callback *script_callback; - char *perl_argv[3], empty_arg[1] = { '\0' }; + char *perl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (option) ? (char *)option : empty_arg; - perl_argv[1] = (value) ? (char *)value : empty_arg; - perl_argv[2] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = (option) ? (char *)option : empty_arg; + perl_argv[2] = (value) ? (char *)value : empty_arg; + perl_argv[3] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3237,7 +3321,7 @@ weechat_perl_api_hook_config_cb (void *data, const char *option, const char *val static XS (XS_weechat_api_hook_config) { - char *result, *option, *function; + char *result, *option, *function, *data; dXSARGS; /* make C compiler happy */ @@ -3245,23 +3329,26 @@ static XS (XS_weechat_api_hook_config) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_config"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_config"); PERL_RETURN_EMPTY; } - if (items < 2) + if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_config"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_config"); PERL_RETURN_EMPTY; } option = SvPV (ST (0), PL_na); function = SvPV (ST (1), PL_na); + data = SvPV (ST (2), PL_na); + result = script_ptr2str (script_api_hook_config (weechat_perl_plugin, perl_current_script, option, &weechat_perl_api_hook_config_cb, - function)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -3276,17 +3363,18 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_script_callback *script_callback; - char *perl_argv[4], empty_arg[1] = { '\0' }; + char *perl_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (completion_item) ? (char *)completion_item : empty_arg; - perl_argv[1] = script_ptr2str (buffer); - perl_argv[2] = script_ptr2str (completion); - perl_argv[3] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; + perl_argv[2] = script_ptr2str (buffer); + perl_argv[3] = script_ptr2str (completion); + perl_argv[4] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3300,10 +3388,10 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion_item, ret = *rc; free (rc); } - if (perl_argv[1]) - free (perl_argv[1]); if (perl_argv[2]) free (perl_argv[2]); + if (perl_argv[3]) + free (perl_argv[3]); return ret; } @@ -3317,7 +3405,7 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion_item, static XS (XS_weechat_api_hook_completion) { - char *result, *completion, *description, *function; + char *result, *completion, *description, *function, *data; dXSARGS; /* make C compiler happy */ @@ -3325,25 +3413,28 @@ static XS (XS_weechat_api_hook_completion) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_completion"); PERL_RETURN_EMPTY; } - if (items < 3) + if (items < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_completion"); PERL_RETURN_EMPTY; } completion = SvPV (ST (0), PL_na); description = SvPV (ST (1), PL_na); function = SvPV (ST (2), PL_na); + data = SvPV (ST (3), PL_na); + result = script_ptr2str (script_api_hook_completion (weechat_perl_plugin, perl_current_script, completion, description, &weechat_perl_api_hook_completion_cb, - function)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -3362,13 +3453,13 @@ static XS (XS_weechat_api_hook_completion_list_add) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); PERL_RETURN_ERROR; } if (items < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); PERL_RETURN_ERROR; } @@ -3393,16 +3484,17 @@ weechat_perl_api_hook_modifier_cb (void *data, const char *modifier, const char *modifier_data, const char *string) { struct t_script_callback *script_callback; - char *perl_argv[4], empty_arg[1] = { '\0' }; + char *perl_argv[5], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (modifier) ? (char *)modifier : empty_arg; - perl_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg; - perl_argv[2] = (string) ? (char *)string : empty_arg; - perl_argv[3] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = (modifier) ? (char *)modifier : empty_arg; + perl_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg; + perl_argv[3] = (string) ? (char *)string : empty_arg; + perl_argv[4] = NULL; return (char *)weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -3419,7 +3511,7 @@ weechat_perl_api_hook_modifier_cb (void *data, const char *modifier, static XS (XS_weechat_api_hook_modifier) { - char *result, *modifier, *perl_fn; + char *result, *modifier, *function, *data; dXSARGS; /* make C compiler happy */ @@ -3427,23 +3519,26 @@ static XS (XS_weechat_api_hook_modifier) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_modifier"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_modifier"); PERL_RETURN_EMPTY; } - if (items < 2) + if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_modifier"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_modifier"); PERL_RETURN_EMPTY; } modifier = SvPV (ST (0), PL_na); - perl_fn = SvPV (ST (1), PL_na); + function = SvPV (ST (1), PL_na); + data = SvPV (ST (2), PL_na); + result = script_ptr2str (script_api_hook_modifier (weechat_perl_plugin, perl_current_script, modifier, &weechat_perl_api_hook_modifier_cb, - perl_fn)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -3462,19 +3557,20 @@ static XS (XS_weechat_api_hook_modifier_exec) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_modifier_exec"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_modifier_exec"); PERL_RETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_modifier_exec"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_modifier_exec"); PERL_RETURN_EMPTY; } modifier = SvPV (ST (0), PL_na); modifier_data = SvPV (ST (1), PL_na); string = SvPV (ST (2), PL_na); + result = weechat_hook_modifier_exec (modifier, modifier_data, string); PERL_RETURN_STRING_FREE(result); @@ -3489,15 +3585,16 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name, const char *arguments) { struct t_script_callback *script_callback; - char *perl_argv[3], empty_arg[1] = { '\0' }; + char *perl_argv[4], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (info_name) ? (char *)info_name : empty_arg; - perl_argv[1] = (arguments) ? (char *)arguments : empty_arg; - perl_argv[2] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = (info_name) ? (char *)info_name : empty_arg; + perl_argv[2] = (arguments) ? (char *)arguments : empty_arg; + perl_argv[3] = NULL; return (const char *)weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -3514,7 +3611,7 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name, static XS (XS_weechat_api_hook_info) { - char *result, *info_name, *description, *perl_fn; + char *result, *info_name, *description, *function, *data; dXSARGS; /* make C compiler happy */ @@ -3522,25 +3619,28 @@ static XS (XS_weechat_api_hook_info) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_info"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_info"); PERL_RETURN_EMPTY; } - if (items < 3) + if (items < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_info"); PERL_RETURN_EMPTY; } info_name = SvPV (ST (0), PL_na); description = SvPV (ST (1), PL_na); - perl_fn = SvPV (ST (2), PL_na); + function = SvPV (ST (2), PL_na); + data = SvPV (ST (3), PL_na); + result = script_ptr2str (script_api_hook_info (weechat_perl_plugin, perl_current_script, info_name, description, &weechat_perl_api_hook_info_cb, - perl_fn)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -3554,25 +3654,26 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_script_callback *script_callback; - char *perl_argv[4], empty_arg[1] = { '\0' }; + char *perl_argv[5], empty_arg[1] = { '\0' }; struct t_infolist *result; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = (infolist_name) ? (char *)infolist_name : empty_arg; - perl_argv[1] = script_ptr2str (pointer); - perl_argv[2] = (arguments) ? (char *)arguments : empty_arg; - perl_argv[3] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; + perl_argv[2] = script_ptr2str (pointer); + perl_argv[3] = (arguments) ? (char *)arguments : empty_arg; + perl_argv[4] = NULL; result = (struct t_infolist *)weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, script_callback->function, perl_argv); - if (perl_argv[1]) - free (perl_argv[1]); + if (perl_argv[2]) + free (perl_argv[2]); return result; } @@ -3586,7 +3687,7 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name, static XS (XS_weechat_api_hook_infolist) { - char *result, *infolist_name, *description, *perl_fn; + char *result, *infolist_name, *description, *function, *data; dXSARGS; /* make C compiler happy */ @@ -3594,25 +3695,28 @@ static XS (XS_weechat_api_hook_infolist) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_infolist"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_infolist"); PERL_RETURN_EMPTY; } - if (items < 3) + if (items < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_infolist"); PERL_RETURN_EMPTY; } infolist_name = SvPV (ST (0), PL_na); description = SvPV (ST (1), PL_na); - perl_fn = SvPV (ST (2), PL_na); + function = SvPV (ST (2), PL_na); + data = SvPV (ST (3), PL_na); + result = script_ptr2str (script_api_hook_infolist (weechat_perl_plugin, perl_current_script, infolist_name, description, &weechat_perl_api_hook_infolist_cb, - perl_fn)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -3630,13 +3734,13 @@ static XS (XS_weechat_api_unhook) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "unhook"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("unhook"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "unhook"); PERL_RETURN_ERROR; } @@ -3661,7 +3765,7 @@ static XS (XS_weechat_api_unhook_all) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "unhook_all"); PERL_RETURN_ERROR; } @@ -3679,16 +3783,17 @@ weechat_perl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { struct t_script_callback *script_callback; - char *perl_argv[3], empty_arg[1] = { '\0' }; + char *perl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (buffer); - perl_argv[1] = (input_data) ? (char *)input_data : empty_arg; - perl_argv[2] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (buffer); + perl_argv[2] = (input_data) ? (char *)input_data : empty_arg; + perl_argv[3] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3701,8 +3806,8 @@ weechat_perl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); + if (perl_argv[1]) + free (perl_argv[1]); return ret; } @@ -3718,15 +3823,16 @@ int weechat_perl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) { struct t_script_callback *script_callback; - char *perl_argv[2]; + char *perl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (buffer); - perl_argv[1] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (buffer); + perl_argv[2] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3739,8 +3845,8 @@ weechat_perl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); + if (perl_argv[1]) + free (perl_argv[1]); return ret; } @@ -3754,7 +3860,8 @@ weechat_perl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) static XS (XS_weechat_api_buffer_new) { - char *result, *name, *function_input, *function_close; + char *result, *name, *function_input, *data_input, *function_close; + char *data_close; dXSARGS; /* make C compiler happy */ @@ -3762,26 +3869,31 @@ static XS (XS_weechat_api_buffer_new) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_new"); PERL_RETURN_EMPTY; } - if (items < 3) + if (items < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_new"); PERL_RETURN_EMPTY; } name = SvPV (ST (0), PL_na); function_input = SvPV (ST (1), PL_na); - function_close = SvPV (ST (2), PL_na); + data_input = SvPV (ST (2), PL_na); + function_close = SvPV (ST (3), PL_na); + data_close = SvPV (ST (4), PL_na); + result = script_ptr2str (script_api_buffer_new (weechat_perl_plugin, perl_current_script, name, &weechat_perl_api_buffer_input_data_cb, function_input, + data_input, &weechat_perl_api_buffer_close_cb, - function_close)); + function_close, + data_close)); PERL_RETURN_STRING_FREE(result); } @@ -3800,18 +3912,19 @@ static XS (XS_weechat_api_buffer_search) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_search"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_search"); PERL_RETURN_EMPTY; } plugin = SvPV (ST (0), PL_na); name = SvPV (ST (1), PL_na); + result = script_ptr2str (weechat_buffer_search (plugin, name)); PERL_RETURN_STRING_FREE(result); @@ -3832,7 +3945,7 @@ static XS (XS_weechat_api_current_buffer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_buffer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "current_buffer"); PERL_RETURN_EMPTY; } @@ -3854,13 +3967,13 @@ static XS (XS_weechat_api_buffer_clear) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_clear"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_clear"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_clear"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_clear"); PERL_RETURN_ERROR; } @@ -3882,13 +3995,13 @@ static XS (XS_weechat_api_buffer_close) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_close"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_close"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_close"); PERL_RETURN_ERROR; } @@ -3914,18 +4027,19 @@ static XS (XS_weechat_api_buffer_get_integer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_get_integer"); PERL_RETURN_INT(-1); } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_get_integer"); PERL_RETURN_INT(-1); } buffer = SvPV (ST (0), PL_na); - property = SvPV (ST (1), PL_na); + property = SvPV (ST (1), PL_na); + value = weechat_buffer_get_integer (script_str2ptr (buffer), property); PERL_RETURN_INT(value); @@ -3946,18 +4060,19 @@ static XS (XS_weechat_api_buffer_get_string) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_get_string"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_get_string"); PERL_RETURN_EMPTY; } buffer = SvPV (ST (0), PL_na); - property = SvPV (ST (1), PL_na); + property = SvPV (ST (1), PL_na); + result = weechat_buffer_get_string (script_str2ptr (buffer), property); PERL_RETURN_STRING(result); @@ -3977,18 +4092,19 @@ static XS (XS_weechat_api_buffer_get_pointer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_get_pointer"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_get_pointer"); PERL_RETURN_EMPTY; } buffer = SvPV (ST (0), PL_na); - property = SvPV (ST (1), PL_na); + property = SvPV (ST (1), PL_na); + result = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (buffer), property)); @@ -4009,19 +4125,20 @@ static XS (XS_weechat_api_buffer_set) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_set"); PERL_RETURN_ERROR; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_set"); PERL_RETURN_ERROR; } buffer = SvPV (ST (0), PL_na); property = SvPV (ST (1), PL_na); value = SvPV (ST (2), PL_na); + weechat_buffer_set (script_str2ptr (buffer), property, value); PERL_RETURN_OK; @@ -4042,7 +4159,7 @@ static XS (XS_weechat_api_current_window) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_window"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "current_window"); PERL_RETURN_EMPTY; } @@ -4066,18 +4183,19 @@ static XS (XS_weechat_api_window_get_integer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "window_get_integer"); PERL_RETURN_INT(-1); } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "window_get_integer"); PERL_RETURN_INT(-1); } window = SvPV (ST (0), PL_na); - property = SvPV (ST (1), PL_na); + property = SvPV (ST (1), PL_na); + value = weechat_window_get_integer (script_str2ptr (window), property); PERL_RETURN_INT(value); @@ -4098,18 +4216,19 @@ static XS (XS_weechat_api_window_get_string) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "window_get_string"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "window_get_string"); PERL_RETURN_EMPTY; } window = SvPV (ST (0), PL_na); - property = SvPV (ST (1), PL_na); + property = SvPV (ST (1), PL_na); + result = weechat_window_get_string (script_str2ptr (window), property); PERL_RETURN_STRING(result); @@ -4129,18 +4248,19 @@ static XS (XS_weechat_api_window_get_pointer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "window_get_pointer"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "window_get_pointer"); PERL_RETURN_EMPTY; } window = SvPV (ST (0), PL_na); - property = SvPV (ST (1), PL_na); + property = SvPV (ST (1), PL_na); + result = script_ptr2str (weechat_window_get_pointer (script_str2ptr (window), property)); @@ -4161,13 +4281,13 @@ static XS (XS_weechat_api_nicklist_add_group) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "nicklist_add_group"); PERL_RETURN_EMPTY; } if (items < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "nicklist_add_group"); PERL_RETURN_EMPTY; } @@ -4175,6 +4295,7 @@ static XS (XS_weechat_api_nicklist_add_group) parent_group = SvPV (ST (1), PL_na); name = SvPV (ST (2), PL_na); color = SvPV (ST (3), PL_na); + result = script_ptr2str (weechat_nicklist_add_group (script_str2ptr (buffer), script_str2ptr (parent_group), name, @@ -4198,19 +4319,20 @@ static XS (XS_weechat_api_nicklist_search_group) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "nicklist_search_group"); PERL_RETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "nicklist_search_group"); PERL_RETURN_EMPTY; } buffer = SvPV (ST (0), PL_na); from_group = SvPV (ST (1), PL_na); name = SvPV (ST (2), PL_na); + result = script_ptr2str (weechat_nicklist_search_group (script_str2ptr (buffer), script_str2ptr (from_group), name)); @@ -4232,13 +4354,13 @@ static XS (XS_weechat_api_nicklist_add_nick) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); PERL_RETURN_EMPTY; } if (items < 7) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); PERL_RETURN_EMPTY; } @@ -4248,6 +4370,7 @@ static XS (XS_weechat_api_nicklist_add_nick) color = SvPV (ST (3), PL_na); prefix = SvPV(ST (4), PL_na); prefix_color = SvPV (ST (5), PL_na); + result = script_ptr2str (weechat_nicklist_add_nick (script_str2ptr (buffer), script_str2ptr (group), name, @@ -4273,19 +4396,20 @@ static XS (XS_weechat_api_nicklist_search_nick) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "nicklist_search_nick"); PERL_RETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "nicklist_search_nick"); PERL_RETURN_EMPTY; } buffer = SvPV (ST (0), PL_na); from_group = SvPV (ST (1), PL_na); name = SvPV (ST (2), PL_na); + result = script_ptr2str (weechat_nicklist_search_nick (script_str2ptr (buffer), script_str2ptr (from_group), name)); @@ -4307,18 +4431,19 @@ static XS (XS_weechat_api_nicklist_remove_group) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "nicklist_remove_group"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "nicklist_remove_group"); PERL_RETURN_ERROR; } buffer = SvPV (ST (0), PL_na); group = SvPV (ST (1), PL_na); + weechat_nicklist_remove_group (script_str2ptr (buffer), script_str2ptr (group)); @@ -4339,18 +4464,19 @@ static XS (XS_weechat_api_nicklist_remove_nick) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "nicklist_remove_nick"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "nicklist_remove_nick"); PERL_RETURN_ERROR; } buffer = SvPV (ST (0), PL_na); nick = SvPV (ST (1), PL_na); + weechat_nicklist_remove_nick (script_str2ptr (buffer), script_str2ptr (nick)); @@ -4370,13 +4496,13 @@ static XS (XS_weechat_api_nicklist_remove_all) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "nicklist_remove_all"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "nicklist_remove_all"); PERL_RETURN_ERROR; } @@ -4399,13 +4525,13 @@ static XS (XS_weechat_api_bar_item_search) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "bar_item_search"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "bar_item_search"); PERL_RETURN_EMPTY; } @@ -4423,25 +4549,26 @@ weechat_perl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, struct t_gui_window *window) { struct t_script_callback *script_callback; - char *perl_argv[3], *ret; + char *perl_argv[4], empty_arg[1] = { '\0' }, *ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - perl_argv[0] = script_ptr2str (item); - perl_argv[1] = script_ptr2str (window); - perl_argv[2] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (item); + perl_argv[2] = script_ptr2str (window); + perl_argv[3] = NULL; ret = (char *)weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, script_callback->function, perl_argv); - if (perl_argv[0]) - free (perl_argv[0]); if (perl_argv[1]) free (perl_argv[1]); + if (perl_argv[2]) + free (perl_argv[2]); return ret; } @@ -4455,7 +4582,7 @@ weechat_perl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, static XS (XS_weechat_api_bar_item_new) { - char *result, *name, *function_build; + char *result, *name, *function, *data; dXSARGS; /* make C compiler happy */ @@ -4463,23 +4590,26 @@ static XS (XS_weechat_api_bar_item_new) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "bar_item_new"); PERL_RETURN_EMPTY; } - if (items < 2) + if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "bar_item_new"); PERL_RETURN_EMPTY; } name = SvPV (ST (0), PL_na); - function_build = SvPV (ST (1), PL_na); + function = SvPV (ST (1), PL_na); + data = SvPV (ST (2), PL_na); + result = script_ptr2str (script_api_bar_item_new (weechat_perl_plugin, perl_current_script, name, &weechat_perl_api_bar_item_build_cb, - function_build)); + function, + data)); PERL_RETURN_STRING_FREE(result); } @@ -4497,13 +4627,13 @@ static XS (XS_weechat_api_bar_item_update) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_update"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "bar_item_update"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_update"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "bar_item_update"); PERL_RETURN_ERROR; } @@ -4525,13 +4655,13 @@ static XS (XS_weechat_api_bar_item_remove) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "bar_item_remove"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "bar_item_remove"); PERL_RETURN_ERROR; } @@ -4556,13 +4686,13 @@ static XS (XS_weechat_api_bar_search) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "bar_search"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "bar_search"); PERL_RETURN_EMPTY; } @@ -4587,13 +4717,13 @@ static XS (XS_weechat_api_bar_new) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "bar_new"); PERL_RETURN_EMPTY; } if (items < 15) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "bar_new"); PERL_RETURN_EMPTY; } @@ -4612,6 +4742,7 @@ static XS (XS_weechat_api_bar_new) color_bg = SvPV (ST (12), PL_na); separator = SvPV (ST (13), PL_na); bar_items = SvPV (ST (14), PL_na); + result = script_ptr2str (weechat_bar_new (name, hidden, priority, @@ -4645,19 +4776,20 @@ static XS (XS_weechat_api_bar_set) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "bar_set"); PERL_RETURN_ERROR; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "bar_set"); PERL_RETURN_ERROR; } bar = SvPV (ST (0), PL_na); property = SvPV (ST (1), PL_na); value = SvPV (ST (2), PL_na); + weechat_bar_set (script_str2ptr (bar), property, value); PERL_RETURN_OK; @@ -4676,13 +4808,13 @@ static XS (XS_weechat_api_bar_update) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_update"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "bar_update"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_update"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "bar_update"); PERL_RETURN_ERROR; } @@ -4704,13 +4836,13 @@ static XS (XS_weechat_api_bar_remove) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "bar_remove"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "bar_remove"); PERL_RETURN_ERROR; } @@ -4733,18 +4865,19 @@ static XS (XS_weechat_api_command) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("command"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "command"); PERL_RETURN_ERROR; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "command"); PERL_RETURN_ERROR; } buffer = SvPV (ST (0), PL_na); command = SvPV (ST (1), PL_na); + script_api_command (weechat_perl_plugin, perl_current_script, script_str2ptr (buffer), @@ -4768,13 +4901,13 @@ static XS (XS_weechat_api_info_get) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("info_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "info_get"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("info_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "info_get"); PERL_RETURN_EMPTY; } @@ -4801,7 +4934,7 @@ static XS (XS_weechat_api_infolist_new) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_new"); PERL_RETURN_EMPTY; } @@ -4824,13 +4957,13 @@ static XS (XS_weechat_api_infolist_new_var_integer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); PERL_RETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); PERL_RETURN_EMPTY; } @@ -4858,13 +4991,13 @@ static XS (XS_weechat_api_infolist_new_var_string) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_new_var_string"); PERL_RETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_new_var_string"); PERL_RETURN_EMPTY; } @@ -4893,13 +5026,13 @@ static XS (XS_weechat_api_infolist_new_var_pointer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer"); PERL_RETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer"); PERL_RETURN_EMPTY; } @@ -4928,13 +5061,13 @@ static XS (XS_weechat_api_infolist_new_var_time) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); PERL_RETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); PERL_RETURN_EMPTY; } @@ -4962,19 +5095,20 @@ static XS (XS_weechat_api_infolist_get) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_get"); PERL_RETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_get"); PERL_RETURN_EMPTY; } name = SvPV (ST (0), PL_na); pointer = SvPV (ST (1), PL_na); arguments = SvPV (ST (2), PL_na); + result = script_ptr2str (weechat_infolist_get (name, script_str2ptr (pointer), arguments)); @@ -4996,13 +5130,13 @@ static XS (XS_weechat_api_infolist_next) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_next"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_next"); PERL_RETURN_INT(0); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_next"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_next"); PERL_RETURN_INT(0); } @@ -5025,13 +5159,13 @@ static XS (XS_weechat_api_infolist_prev) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_prev"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_prev"); PERL_RETURN_INT(0); } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_prev"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_prev"); PERL_RETURN_INT(0); } @@ -5054,13 +5188,13 @@ static XS (XS_weechat_api_infolist_fields) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_fields"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_fields"); PERL_RETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_fields"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_fields"); PERL_RETURN_EMPTY; } @@ -5084,18 +5218,19 @@ static XS (XS_weechat_api_infolist_integer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_integer"); PERL_RETURN_INT(0); } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_integer"); PERL_RETURN_INT(0); } infolist = SvPV (ST (0), PL_na); variable = SvPV (ST (1), PL_na); + value = weechat_infolist_integer (script_str2ptr (infolist), variable); PERL_RETURN_INT(value); @@ -5116,18 +5251,19 @@ static XS (XS_weechat_api_infolist_string) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_string"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_string"); PERL_RETURN_EMPTY; } infolist = SvPV (ST (0), PL_na); variable = SvPV (ST (1), PL_na); + result = weechat_infolist_string (script_str2ptr (infolist), variable); PERL_RETURN_STRING(result); @@ -5148,18 +5284,19 @@ static XS (XS_weechat_api_infolist_pointer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_pointer"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_pointer"); PERL_RETURN_EMPTY; } infolist = SvPV (ST (0), PL_na); variable = SvPV (ST (1), PL_na); + result = script_ptr2str (weechat_infolist_pointer (script_str2ptr (infolist), variable)); PERL_RETURN_STRING_FREE(result); @@ -5180,13 +5317,13 @@ static XS (XS_weechat_api_infolist_time) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_time"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_time"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_time"); PERL_RETURN_EMPTY; } @@ -5212,13 +5349,13 @@ static XS (XS_weechat_api_infolist_free) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "infolist_free"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "infolist_free"); PERL_RETURN_ERROR; } @@ -5241,17 +5378,18 @@ static XS (XS_weechat_api_upgrade_new) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "upgrade_new"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "upgrade_new"); PERL_RETURN_EMPTY; } filename = SvPV (ST (0), PL_na); + result = script_ptr2str (weechat_upgrade_new (filename, SvIV (ST (1)))); /* write */ @@ -5273,18 +5411,19 @@ static XS (XS_weechat_api_upgrade_write_object) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "upgrade_write_object"); PERL_RETURN_INT(0); } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "upgrade_write_object"); PERL_RETURN_INT(0); } upgrade_file = SvPV (ST (0), PL_na); infolist = SvPV (ST (2), PL_na); + rc = weechat_upgrade_write_object (script_str2ptr (upgrade_file), SvIV (ST (1)), /* object_id */ script_str2ptr (infolist)); @@ -5303,7 +5442,7 @@ weechat_perl_api_upgrade_read_cb (void *data, struct t_infolist *infolist) { struct t_script_callback *script_callback; - char *perl_argv[4], str_object_id[32]; + char *perl_argv[5], empty_arg[1] = { '\0' }, str_object_id[32]; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -5312,10 +5451,11 @@ weechat_perl_api_upgrade_read_cb (void *data, { snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); - perl_argv[0] = script_ptr2str (upgrade_file); - perl_argv[1] = str_object_id; - perl_argv[2] = script_ptr2str (infolist); - perl_argv[3] = NULL; + perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + perl_argv[1] = script_ptr2str (upgrade_file); + perl_argv[2] = str_object_id; + perl_argv[3] = script_ptr2str (infolist); + perl_argv[4] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -5329,10 +5469,10 @@ weechat_perl_api_upgrade_read_cb (void *data, ret = *rc; free (rc); } - if (perl_argv[0]) - free (perl_argv[0]); - if (perl_argv[2]) - free (perl_argv[2]); + if (perl_argv[1]) + free (perl_argv[1]); + if (perl_argv[3]) + free (perl_argv[3]); return ret; } @@ -5346,7 +5486,7 @@ weechat_perl_api_upgrade_read_cb (void *data, static XS (XS_weechat_api_upgrade_read) { - char *upgrade_file, *function_read; + char *upgrade_file, *function, *data; int rc; dXSARGS; @@ -5355,23 +5495,26 @@ static XS (XS_weechat_api_upgrade_read) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_read"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "upgrade_read"); PERL_RETURN_INT(0); } - if (items < 2) + if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_read"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "upgrade_read"); PERL_RETURN_INT(0); } upgrade_file = SvPV (ST (0), PL_na); - function_read = SvPV (ST (1), PL_na); + function = SvPV (ST (1), PL_na); + data = SvPV (ST (2), PL_na); + rc = script_api_upgrade_read (weechat_perl_plugin, perl_current_script, script_str2ptr (upgrade_file), &weechat_perl_api_upgrade_read_cb, - function_read); + function, + data); PERL_RETURN_INT(rc); } @@ -5390,13 +5533,13 @@ static XS (XS_weechat_api_upgrade_close) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_close"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "upgrade_close"); PERL_RETURN_ERROR; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "upgrade_close"); PERL_RETURN_ERROR; } diff --git a/src/plugins/scripts/perl/weechat-perl.h b/src/plugins/scripts/perl/weechat-perl.h index 23c9deccf..4d0626617 100644 --- a/src/plugins/scripts/perl/weechat-perl.h +++ b/src/plugins/scripts/perl/weechat-perl.h @@ -23,6 +23,8 @@ #define weechat_plugin weechat_perl_plugin #define PERL_PLUGIN_NAME "perl" +#define PERL_CURRENT_SCRIPT_NAME ((perl_current_script) ? perl_current_script->name : "-") + extern struct t_weechat_plugin *weechat_perl_plugin; extern int perl_quiet; diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index e9c43ae02..de6e44742 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -78,7 +78,7 @@ weechat_python_api_register (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sssssss", &name, &author, &version, &license, &description, &shutdown_func, &charset)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("register"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(python_current_script_filename, "register"); PYTHON_RETURN_ERROR; } @@ -134,7 +134,7 @@ weechat_python_api_plugin_get_name (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "plugin_get_name"); PYTHON_RETURN_EMPTY; } @@ -142,7 +142,7 @@ weechat_python_api_plugin_get_name (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &plugin)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "plugin_get_name"); PYTHON_RETURN_EMPTY; } @@ -165,7 +165,7 @@ weechat_python_api_charset_set (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("charset_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "charset_set"); PYTHON_RETURN_ERROR; } @@ -173,7 +173,7 @@ weechat_python_api_charset_set (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &charset)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("charset_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "charset_set"); PYTHON_RETURN_ERROR; } @@ -198,7 +198,7 @@ weechat_python_api_iconv_to_internal (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_to_internal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "iconv_to_internal"); PYTHON_RETURN_EMPTY; } @@ -207,7 +207,7 @@ weechat_python_api_iconv_to_internal (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &charset, &string)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_to_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "iconv_to_internal"); PYTHON_RETURN_EMPTY; } @@ -232,7 +232,7 @@ weechat_python_api_iconv_from_internal (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_from_internal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "iconv_from_internal"); PYTHON_RETURN_EMPTY; } @@ -241,7 +241,7 @@ weechat_python_api_iconv_from_internal (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &charset, &string)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_from_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "iconv_from_internal"); PYTHON_RETURN_EMPTY; } @@ -265,7 +265,7 @@ weechat_python_api_gettext (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("gettext"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "gettext"); PYTHON_RETURN_EMPTY; } @@ -273,7 +273,7 @@ weechat_python_api_gettext (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &string)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("gettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "gettext"); PYTHON_RETURN_EMPTY; } @@ -298,7 +298,7 @@ weechat_python_api_ngettext (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("ngettext"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "ngettext"); PYTHON_RETURN_EMPTY; } @@ -308,7 +308,7 @@ weechat_python_api_ngettext (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssi", &single, &plural, &count)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("ngettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "ngettext"); PYTHON_RETURN_EMPTY; } @@ -332,7 +332,7 @@ weechat_python_api_string_remove_color (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("string_remove_color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "string_remove_color"); PYTHON_RETURN_EMPTY; } @@ -341,7 +341,7 @@ weechat_python_api_string_remove_color (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &string, &replacement)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "string_remove_color"); PYTHON_RETURN_EMPTY; } @@ -365,7 +365,7 @@ weechat_python_api_mkdir_home (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_home"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "mkdir_home"); PYTHON_RETURN_ERROR; } @@ -374,7 +374,7 @@ weechat_python_api_mkdir_home (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "si", &directory, &mode)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_home"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "mkdir_home"); PYTHON_RETURN_ERROR; } @@ -399,7 +399,7 @@ weechat_python_api_mkdir (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "mkdir"); PYTHON_RETURN_ERROR; } @@ -408,7 +408,7 @@ weechat_python_api_mkdir (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "si", &directory, &mode)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "mkdir"); PYTHON_RETURN_ERROR; } @@ -434,7 +434,7 @@ weechat_python_api_mkdir_parents (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_parents"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "mkdir_parents"); PYTHON_RETURN_ERROR; } @@ -443,7 +443,7 @@ weechat_python_api_mkdir_parents (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "si", &directory, &mode)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_parents"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "mkdir_parents"); PYTHON_RETURN_ERROR; } @@ -469,7 +469,7 @@ weechat_python_api_list_new (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_new"); PYTHON_RETURN_EMPTY; } @@ -493,7 +493,7 @@ weechat_python_api_list_add (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_add"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_add"); PYTHON_RETURN_EMPTY; } @@ -504,7 +504,7 @@ weechat_python_api_list_add (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssss", &weelist, &data, &where, &user_data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_add"); PYTHON_RETURN_EMPTY; } @@ -531,7 +531,7 @@ weechat_python_api_list_search (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_search"); PYTHON_RETURN_EMPTY; } @@ -540,7 +540,7 @@ weechat_python_api_list_search (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &weelist, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_search"); PYTHON_RETURN_EMPTY; } @@ -565,7 +565,7 @@ weechat_python_api_list_casesearch (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_casesearch"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_casesearch"); PYTHON_RETURN_EMPTY; } @@ -574,7 +574,7 @@ weechat_python_api_list_casesearch (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &weelist, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_casesearch"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_casesearch"); PYTHON_RETURN_EMPTY; } @@ -600,7 +600,7 @@ weechat_python_api_list_get (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_get"); PYTHON_RETURN_EMPTY; } @@ -609,7 +609,7 @@ weechat_python_api_list_get (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "si", &weelist, &position)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_get"); PYTHON_RETURN_EMPTY; } @@ -632,7 +632,7 @@ weechat_python_api_list_set (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_set"); PYTHON_RETURN_ERROR; } @@ -641,7 +641,7 @@ weechat_python_api_list_set (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &item, &new_value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_set"); PYTHON_RETURN_ERROR; } @@ -666,7 +666,7 @@ weechat_python_api_list_next (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_next"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_next"); PYTHON_RETURN_EMPTY; } @@ -674,7 +674,7 @@ weechat_python_api_list_next (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &item)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_next"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_next"); PYTHON_RETURN_EMPTY; } @@ -698,7 +698,7 @@ weechat_python_api_list_prev (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_prev"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_prev"); PYTHON_RETURN_EMPTY; } @@ -706,7 +706,7 @@ weechat_python_api_list_prev (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &item)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_prev"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_prev"); PYTHON_RETURN_EMPTY; } @@ -730,7 +730,7 @@ weechat_python_api_list_string (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_string"); PYTHON_RETURN_EMPTY; } @@ -738,7 +738,7 @@ weechat_python_api_list_string (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &item)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_string"); PYTHON_RETURN_EMPTY; } @@ -762,7 +762,7 @@ weechat_python_api_list_size (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_size"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_size"); PYTHON_RETURN_INT(0); } @@ -770,7 +770,7 @@ weechat_python_api_list_size (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &weelist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_size"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_size"); PYTHON_RETURN_INT(0); } @@ -793,7 +793,7 @@ weechat_python_api_list_remove (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_remove"); PYTHON_RETURN_ERROR; } @@ -802,7 +802,7 @@ weechat_python_api_list_remove (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &weelist, &item)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_remove"); PYTHON_RETURN_ERROR; } @@ -826,7 +826,7 @@ weechat_python_api_list_remove_all (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_remove_all"); PYTHON_RETURN_ERROR; } @@ -834,7 +834,7 @@ weechat_python_api_list_remove_all (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &weelist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_remove_all"); PYTHON_RETURN_ERROR; } @@ -857,7 +857,7 @@ weechat_python_api_list_free (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_free"); PYTHON_RETURN_ERROR; } @@ -865,7 +865,7 @@ weechat_python_api_list_free (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &weelist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_free"); PYTHON_RETURN_ERROR; } @@ -883,15 +883,16 @@ weechat_python_api_config_reload_cb (void *data, struct t_config_file *config_file) { struct t_script_callback *script_callback; - char *python_argv[2]; + char *python_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (config_file); - python_argv[1] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (config_file); + python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -905,8 +906,8 @@ weechat_python_api_config_reload_cb (void *data, ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); + if (python_argv[1]) + free (python_argv[1]); return ret; } @@ -921,7 +922,7 @@ weechat_python_api_config_reload_cb (void *data, static PyObject * weechat_python_api_config_new (PyObject *self, PyObject *args) { - char *name, *function, *result; + char *name, *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -929,16 +930,17 @@ weechat_python_api_config_new (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_new"); PYTHON_RETURN_EMPTY; } name = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "ss", &name, &function)) + if (!PyArg_ParseTuple (args, "sss", &name, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_new"); PYTHON_RETURN_EMPTY; } @@ -946,7 +948,8 @@ weechat_python_api_config_new (PyObject *self, PyObject *args) python_current_script, name, &weechat_python_api_config_reload_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -962,18 +965,19 @@ weechat_python_api_config_read_cb (void *data, const char *option_name, const char *value) { struct t_script_callback *script_callback; - char *python_argv[5], empty_arg[1] = { '\0' }; + char *python_argv[6], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (config_file); - python_argv[1] = script_ptr2str (section); - python_argv[2] = (option_name) ? (char *)option_name : empty_arg; - python_argv[3] = (value) ? (char *)value : empty_arg; - python_argv[4] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (config_file); + python_argv[2] = script_ptr2str (section); + python_argv[3] = (option_name) ? (char *)option_name : empty_arg; + python_argv[4] = (value) ? (char *)value : empty_arg; + python_argv[5] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -987,10 +991,10 @@ weechat_python_api_config_read_cb (void *data, ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); if (python_argv[1]) free (python_argv[1]); + if (python_argv[2]) + free (python_argv[2]); return ret; } @@ -1008,16 +1012,17 @@ weechat_python_api_config_section_write_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *python_argv[3], empty_arg[1] = { '\0' }; + char *python_argv[4], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (config_file); - python_argv[1] = (section_name) ? (char *)section_name : empty_arg; - python_argv[2] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (config_file); + python_argv[2] = (section_name) ? (char *)section_name : empty_arg; + python_argv[3] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1026,8 +1031,8 @@ weechat_python_api_config_section_write_cb (void *data, if (rc) free (rc); - if (python_argv[0]) - free (python_argv[0]); + if (python_argv[1]) + free (python_argv[1]); } } @@ -1042,16 +1047,17 @@ weechat_python_api_config_section_write_default_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *python_argv[3], empty_arg[1] = { '\0' }; + char *python_argv[4], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (config_file); - python_argv[1] = (section_name) ? (char *)section_name : empty_arg; - python_argv[2] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (config_file); + python_argv[2] = (section_name) ? (char *)section_name : empty_arg; + python_argv[3] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1060,8 +1066,8 @@ weechat_python_api_config_section_write_default_cb (void *data, if (rc) free (rc); - if (python_argv[0]) - free (python_argv[0]); + if (python_argv[1]) + free (python_argv[1]); } } @@ -1077,18 +1083,19 @@ weechat_python_api_config_section_create_option_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *python_argv[5], empty_arg[1] = { '\0' }; + char *python_argv[6], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (config_file); - python_argv[1] = script_ptr2str (section); - python_argv[2] = (option_name) ? (char *)option_name : empty_arg; - python_argv[3] = (value) ? (char *)value : empty_arg; - python_argv[4] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (config_file); + python_argv[2] = script_ptr2str (section); + python_argv[3] = (option_name) ? (char *)option_name : empty_arg; + python_argv[4] = (value) ? (char *)value : empty_arg; + python_argv[5] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1102,10 +1109,10 @@ weechat_python_api_config_section_create_option_cb (void *data, ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); if (python_argv[1]) free (python_argv[1]); + if (python_argv[2]) + free (python_argv[2]); return ret; } @@ -1124,17 +1131,18 @@ weechat_python_api_config_section_delete_option_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *python_argv[4]; + char *python_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (config_file); - python_argv[1] = script_ptr2str (section); - python_argv[2] = script_ptr2str (option); - python_argv[3] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (config_file); + python_argv[2] = script_ptr2str (section); + python_argv[3] = script_ptr2str (option); + python_argv[4] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1148,12 +1156,12 @@ weechat_python_api_config_section_delete_option_cb (void *data, ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); if (python_argv[1]) free (python_argv[1]); if (python_argv[2]) free (python_argv[2]); + if (python_argv[3]) + free (python_argv[3]); return ret; } @@ -1168,10 +1176,10 @@ weechat_python_api_config_section_delete_option_cb (void *data, static PyObject * weechat_python_api_config_new_section (PyObject *self, PyObject *args) { - char *config_file, *name, *function_read, *function_write; - char *function_write_default, *function_create_option; - char *function_delete_option; - char *result; + char *config_file, *name, *function_read, *data_read, *function_write; + char *data_write, *function_write_default, *data_write_default; + char *function_create_option, *data_create_option, *function_delete_option; + char *data_delete_option, *result; int user_can_add_options, user_can_delete_options; PyObject *object; @@ -1180,7 +1188,7 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new_section"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_new_section"); PYTHON_RETURN_EMPTY; } @@ -1189,18 +1197,25 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args) user_can_add_options = 0; user_can_delete_options = 0; function_read = NULL; + data_read = NULL; function_write = NULL; + data_write = NULL; function_write_default = NULL; + data_write_default = NULL; function_create_option = NULL; + data_create_option = NULL; function_delete_option = NULL; + data_delete_option = NULL; - if (!PyArg_ParseTuple (args, "ssiisssss", &config_file, &name, + if (!PyArg_ParseTuple (args, "ssiissssssssss", &config_file, &name, &user_can_add_options, &user_can_delete_options, - &function_read, &function_write, - &function_write_default, &function_create_option, - &function_delete_option)) + &function_read, &data_read, &function_write, + &data_write, &function_write_default, + &data_write_default, &function_create_option, + &data_create_option, &function_delete_option, + &data_delete_option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_new_section"); PYTHON_RETURN_EMPTY; } @@ -1212,14 +1227,19 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args) user_can_delete_options, &weechat_python_api_config_read_cb, function_read, + data_read, &weechat_python_api_config_section_write_cb, function_write, + data_write, &weechat_python_api_config_section_write_default_cb, function_write_default, + data_write_default, &weechat_python_api_config_section_create_option_cb, function_create_option, + data_create_option, &weechat_python_api_config_section_delete_option_cb, - function_delete_option)); + function_delete_option, + data_delete_option)); PYTHON_RETURN_STRING_FREE(result); } @@ -1239,7 +1259,7 @@ weechat_python_api_config_search_section (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_search_section"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_search_section"); PYTHON_RETURN_EMPTY; } @@ -1248,7 +1268,7 @@ weechat_python_api_config_search_section (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &config_file, §ion_name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_search_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_search_section"); PYTHON_RETURN_EMPTY; } @@ -1269,16 +1289,17 @@ weechat_python_api_config_option_check_value_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *python_argv[3], empty_arg[1] = { '\0' }; + char *python_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (option); - python_argv[1] = (value) ? (char *)value : empty_arg; - python_argv[2] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (option); + python_argv[2] = (value) ? (char *)value : empty_arg; + python_argv[3] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1292,8 +1313,8 @@ weechat_python_api_config_option_check_value_cb (void *data, ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); + if (python_argv[1]) + free (python_argv[1]); return ret; } @@ -1310,23 +1331,24 @@ weechat_python_api_config_option_change_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *python_argv[2]; + char *python_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (option); - python_argv[1] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (option); + python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, script_callback->function, python_argv); - if (python_argv[0]) - free (python_argv[0]); + if (python_argv[1]) + free (python_argv[1]); if (rc) free (rc); @@ -1342,23 +1364,24 @@ weechat_python_api_config_option_delete_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *python_argv[2]; + char *python_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (option); - python_argv[1] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (option); + python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, script_callback->function, python_argv); - if (python_argv[0]) - free (python_argv[0]); + if (python_argv[1]) + free (python_argv[1]); if (rc) free (rc); @@ -1374,7 +1397,8 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args) { char *config_file, *section, *name, *type, *description, *string_values; char *default_value, *value, *result; - char *function_check_value, *function_change, *function_delete; + char *function_check_value, *data_check_value, *function_change; + char *data_change, *function_delete, *data_delete; int min, max, null_value_allowed; PyObject *object; @@ -1383,7 +1407,7 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_new_option"); PYTHON_RETURN_EMPTY; } @@ -1396,16 +1420,20 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args) default_value = NULL; value = NULL; function_check_value = NULL; + data_check_value = NULL; function_change = NULL; + data_change = NULL; function_delete = NULL; + data_delete = NULL; - if (!PyArg_ParseTuple (args, "ssssssiississs", &config_file, §ion, &name, + if (!PyArg_ParseTuple (args, "ssssssiississssss", &config_file, §ion, &name, &type, &description, &string_values, &min, &max, &default_value, &value, &null_value_allowed, - &function_check_value, &function_change, - &function_delete)) + &function_check_value, &data_check_value, + &function_change, &data_change, &function_delete, + &data_delete)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_new_option"); PYTHON_RETURN_EMPTY; } @@ -1424,10 +1452,13 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args) null_value_allowed, &weechat_python_api_config_option_check_value_cb, function_check_value, + data_check_value, &weechat_python_api_config_option_change_cb, function_change, + data_change, &weechat_python_api_config_option_delete_cb, - function_delete)); + function_delete, + data_delete)); PYTHON_RETURN_STRING_FREE(result); } @@ -1447,7 +1478,7 @@ weechat_python_api_config_search_option (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_search_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_search_option"); PYTHON_RETURN_EMPTY; } @@ -1457,7 +1488,7 @@ weechat_python_api_config_search_option (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &config_file, §ion, &option_name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_search_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_search_option"); PYTHON_RETURN_EMPTY; } @@ -1483,7 +1514,7 @@ weechat_python_api_config_string_to_boolean (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string_to_boolean"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_string_to_boolean"); PYTHON_RETURN_INT(0); } @@ -1491,7 +1522,7 @@ weechat_python_api_config_string_to_boolean (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &text)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string_to_boolean"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_string_to_boolean"); PYTHON_RETURN_INT(0); } @@ -1515,7 +1546,7 @@ weechat_python_api_config_option_reset (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_reset"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_reset"); PYTHON_RETURN_INT(0); } @@ -1524,7 +1555,7 @@ weechat_python_api_config_option_reset (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "si", &option, &run_callback)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_reset"); PYTHON_RETURN_INT(0); } @@ -1549,7 +1580,7 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_set"); PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1559,7 +1590,7 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssi", &option, &new_value, &run_callback)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_set"); PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1586,7 +1617,7 @@ weechat_python_api_config_option_set_null (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_set_null"); PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1595,7 +1626,7 @@ weechat_python_api_config_option_set_null (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "si", &option, &run_callback)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_set_null"); PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1620,7 +1651,7 @@ weechat_python_api_config_option_unset (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_unset"); PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -1628,7 +1659,7 @@ weechat_python_api_config_option_unset (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_unset"); PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -1651,7 +1682,7 @@ weechat_python_api_config_option_rename (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_rename"); PYTHON_RETURN_ERROR; } @@ -1660,7 +1691,7 @@ weechat_python_api_config_option_rename (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &option, &new_name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_rename"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_rename"); PYTHON_RETURN_ERROR; } @@ -1685,7 +1716,7 @@ weechat_python_api_config_option_is_null (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_is_null"); PYTHON_RETURN_INT(1); } @@ -1693,7 +1724,7 @@ weechat_python_api_config_option_is_null (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_is_null"); PYTHON_RETURN_INT(1); } @@ -1718,7 +1749,7 @@ weechat_python_api_config_option_default_is_null (PyObject *self, PyObject *args if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_default_is_null"); PYTHON_RETURN_INT(1); } @@ -1726,7 +1757,7 @@ weechat_python_api_config_option_default_is_null (PyObject *self, PyObject *args if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_default_is_null"); PYTHON_RETURN_INT(1); } @@ -1750,7 +1781,7 @@ weechat_python_api_config_boolean (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_boolean"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_boolean"); PYTHON_RETURN_INT(0); } @@ -1758,7 +1789,7 @@ weechat_python_api_config_boolean (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_boolean"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_boolean"); PYTHON_RETURN_INT(0); } @@ -1782,7 +1813,7 @@ weechat_python_api_config_boolean_default (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_boolean_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_boolean_default"); PYTHON_RETURN_INT(0); } @@ -1790,7 +1821,7 @@ weechat_python_api_config_boolean_default (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_boolean_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_boolean_default"); PYTHON_RETURN_INT(0); } @@ -1814,7 +1845,7 @@ weechat_python_api_config_integer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_integer"); PYTHON_RETURN_INT(0); } @@ -1822,7 +1853,7 @@ weechat_python_api_config_integer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_integer"); PYTHON_RETURN_INT(0); } @@ -1846,7 +1877,7 @@ weechat_python_api_config_integer_default (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_integer_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_integer_default"); PYTHON_RETURN_INT(0); } @@ -1854,7 +1885,7 @@ weechat_python_api_config_integer_default (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_integer_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_integer_default"); PYTHON_RETURN_INT(0); } @@ -1878,7 +1909,7 @@ weechat_python_api_config_string (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_string"); PYTHON_RETURN_EMPTY; } @@ -1886,7 +1917,7 @@ weechat_python_api_config_string (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_string"); PYTHON_RETURN_EMPTY; } @@ -1910,7 +1941,7 @@ weechat_python_api_config_string_default (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_string_default"); PYTHON_RETURN_EMPTY; } @@ -1918,7 +1949,7 @@ weechat_python_api_config_string_default (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_string_default"); PYTHON_RETURN_EMPTY; } @@ -1942,7 +1973,7 @@ weechat_python_api_config_color (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_color"); PYTHON_RETURN_INT(0); } @@ -1950,7 +1981,7 @@ weechat_python_api_config_color (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_color"); PYTHON_RETURN_INT(0); } @@ -1974,7 +2005,7 @@ weechat_python_api_config_color_default (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_color_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_color_default"); PYTHON_RETURN_INT(0); } @@ -1982,7 +2013,7 @@ weechat_python_api_config_color_default (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_color_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_color_default"); PYTHON_RETURN_INT(0); } @@ -2005,7 +2036,7 @@ weechat_python_api_config_write_option (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_write_option"); PYTHON_RETURN_ERROR; } @@ -2014,7 +2045,7 @@ weechat_python_api_config_write_option (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &config_file, &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_write_option"); PYTHON_RETURN_ERROR; } @@ -2038,7 +2069,7 @@ weechat_python_api_config_write_line (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_line"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_write_line"); PYTHON_RETURN_ERROR; } @@ -2048,7 +2079,7 @@ weechat_python_api_config_write_line (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &config_file, &option_name, &value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_line"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_write_line"); PYTHON_RETURN_ERROR; } @@ -2075,7 +2106,7 @@ weechat_python_api_config_write (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_write"); PYTHON_RETURN_INT(-1); } @@ -2083,7 +2114,7 @@ weechat_python_api_config_write (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &config_file)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_write"); PYTHON_RETURN_INT(-1); } @@ -2107,7 +2138,7 @@ weechat_python_api_config_read (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_read"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_read"); PYTHON_RETURN_INT(-1); } @@ -2115,7 +2146,7 @@ weechat_python_api_config_read (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &config_file)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_read"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_read"); PYTHON_RETURN_INT(-1); } @@ -2139,7 +2170,7 @@ weechat_python_api_config_reload (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_reload"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_reload"); PYTHON_RETURN_INT(-1); } @@ -2147,7 +2178,7 @@ weechat_python_api_config_reload (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &config_file)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_reload"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_reload"); PYTHON_RETURN_INT(-1); } @@ -2170,7 +2201,7 @@ weechat_python_api_config_option_free (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_free"); PYTHON_RETURN_ERROR; } @@ -2178,7 +2209,7 @@ weechat_python_api_config_option_free (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_free"); PYTHON_RETURN_ERROR; } @@ -2204,7 +2235,7 @@ weechat_python_api_config_section_free_options (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free_options"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_section_free_options"); PYTHON_RETURN_ERROR; } @@ -2212,7 +2243,7 @@ weechat_python_api_config_section_free_options (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", §ion)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free_options"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_section_free_options"); PYTHON_RETURN_ERROR; } @@ -2237,7 +2268,7 @@ weechat_python_api_config_section_free (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_section_free"); PYTHON_RETURN_ERROR; } @@ -2245,7 +2276,7 @@ weechat_python_api_config_section_free (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", §ion)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_section_free"); PYTHON_RETURN_ERROR; } @@ -2270,7 +2301,7 @@ weechat_python_api_config_free (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_free"); PYTHON_RETURN_ERROR; } @@ -2278,7 +2309,7 @@ weechat_python_api_config_free (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &config_file)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_free"); PYTHON_RETURN_ERROR; } @@ -2304,7 +2335,7 @@ weechat_python_api_config_get (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_get"); PYTHON_RETURN_EMPTY; } @@ -2312,7 +2343,7 @@ weechat_python_api_config_get (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_get"); PYTHON_RETURN_EMPTY; } @@ -2336,7 +2367,7 @@ weechat_python_api_config_get_plugin (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_get_plugin"); PYTHON_RETURN_EMPTY; } @@ -2344,7 +2375,7 @@ weechat_python_api_config_get_plugin (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_get_plugin"); PYTHON_RETURN_EMPTY; } @@ -2370,7 +2401,7 @@ weechat_python_api_config_set_plugin (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_set_plugin"); PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -2379,7 +2410,7 @@ weechat_python_api_config_set_plugin (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &option, &value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_set_plugin"); PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -2406,7 +2437,7 @@ weechat_python_api_config_unset_plugin (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_unset_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_unset_plugin"); PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -2414,7 +2445,7 @@ weechat_python_api_config_unset_plugin (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_unset_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_unset_plugin"); PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -2440,7 +2471,7 @@ weechat_python_api_prefix (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("prefix"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "prefix"); PYTHON_RETURN_EMPTY; } @@ -2448,7 +2479,7 @@ weechat_python_api_prefix (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &prefix)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prefix"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "prefix"); PYTHON_RETURN_EMPTY; } @@ -2472,7 +2503,7 @@ weechat_python_api_color (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "color"); PYTHON_RETURN_EMPTY; } @@ -2480,7 +2511,7 @@ weechat_python_api_color (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &color)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "color"); PYTHON_RETURN_EMPTY; } @@ -2506,7 +2537,7 @@ weechat_python_api_prnt (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &message)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prnt"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "prnt"); PYTHON_RETURN_ERROR; } @@ -2534,7 +2565,7 @@ weechat_python_api_prnt_date_tags (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("prnt_date_tags"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "prnt_date_tags"); PYTHON_RETURN_ERROR; } @@ -2545,7 +2576,7 @@ weechat_python_api_prnt_date_tags (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "siss", &buffer, &date, &tags, &message)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prnt_date_tags"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "prnt_date_tags"); PYTHON_RETURN_ERROR; } @@ -2574,7 +2605,7 @@ weechat_python_api_prnt_y (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("prnt_y"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "prnt_y"); PYTHON_RETURN_ERROR; } @@ -2584,7 +2615,7 @@ weechat_python_api_prnt_y (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sis", &buffer, &y, &message)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prnt_y"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "prnt_y"); PYTHON_RETURN_ERROR; } @@ -2611,7 +2642,7 @@ weechat_python_api_log_print (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("log_print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "log_print"); PYTHON_RETURN_ERROR; } @@ -2619,7 +2650,7 @@ weechat_python_api_log_print (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &message)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("log_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "log_print"); PYTHON_RETURN_ERROR; } @@ -2639,7 +2670,7 @@ weechat_python_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { struct t_script_callback *script_callback; - char *python_argv[3], empty_arg[1] = { '\0' }; + char *python_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; /* make C compiler happy */ @@ -2649,9 +2680,10 @@ weechat_python_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (buffer); - python_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg; - python_argv[2] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (buffer); + python_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; + python_argv[3] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2665,8 +2697,8 @@ weechat_python_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); + if (python_argv[1]) + free (python_argv[1]); return ret; } @@ -2682,7 +2714,7 @@ static PyObject * weechat_python_api_hook_command (PyObject *self, PyObject *args) { char *command, *description, *arguments, *args_description, *completion; - char *function, *result; + char *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -2690,7 +2722,7 @@ weechat_python_api_hook_command (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_command"); PYTHON_RETURN_EMPTY; } @@ -2700,11 +2732,12 @@ weechat_python_api_hook_command (PyObject *self, PyObject *args) args_description = NULL; completion = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "ssssss", &command, &description, &arguments, - &args_description, &completion, &function)) + if (!PyArg_ParseTuple (args, "sssssss", &command, &description, &arguments, + &args_description, &completion, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_command"); PYTHON_RETURN_EMPTY; } @@ -2716,7 +2749,8 @@ weechat_python_api_hook_command (PyObject *self, PyObject *args) args_description, completion, &weechat_python_api_hook_command_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -2730,16 +2764,17 @@ weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, const char *command) { struct t_script_callback *script_callback; - char *python_argv[3], empty_arg[1] = { '\0' }; + char *python_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (buffer); - python_argv[1] = (command) ? (char *)command : empty_arg; - python_argv[2] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (buffer); + python_argv[2] = (command) ? (char *)command : empty_arg; + python_argv[3] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2753,8 +2788,8 @@ weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); + if (python_argv[1]) + free (python_argv[1]); return ret; } @@ -2769,7 +2804,7 @@ weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, static PyObject * weechat_python_api_hook_command_run (PyObject *self, PyObject *args) { - char *command, *function, *result; + char *command, *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -2777,16 +2812,17 @@ weechat_python_api_hook_command_run (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command_run"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_command_run"); PYTHON_RETURN_EMPTY; } command = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "ss", &command, &function)) + if (!PyArg_ParseTuple (args, "sss", &command, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command_run"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_command_run"); PYTHON_RETURN_EMPTY; } @@ -2794,7 +2830,8 @@ weechat_python_api_hook_command_run (PyObject *self, PyObject *args) python_current_script, command, &weechat_python_api_hook_command_run_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -2807,7 +2844,7 @@ int weechat_python_api_hook_timer_cb (void *data, int remaining_calls) { struct t_script_callback *script_callback; - char *python_argv[2], str_remaining_calls[32]; + char *python_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -2816,9 +2853,10 @@ weechat_python_api_hook_timer_cb (void *data, int remaining_calls) { snprintf (str_remaining_calls, sizeof (str_remaining_calls), "%d", remaining_calls); - - python_argv[0] = str_remaining_calls; - python_argv[1] = NULL; + + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = str_remaining_calls; + python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2847,7 +2885,7 @@ static PyObject * weechat_python_api_hook_timer (PyObject *self, PyObject *args) { int interval, align_second, max_calls; - char *function, *result; + char *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -2855,7 +2893,7 @@ weechat_python_api_hook_timer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_timer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_timer"); PYTHON_RETURN_EMPTY; } @@ -2863,11 +2901,12 @@ weechat_python_api_hook_timer (PyObject *self, PyObject *args) align_second = 0; max_calls = 0; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "iiis", &interval, &align_second, &max_calls, - &function)) + if (!PyArg_ParseTuple (args, "iiiss", &interval, &align_second, &max_calls, + &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_timer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_timer"); PYTHON_RETURN_EMPTY; } @@ -2877,7 +2916,8 @@ weechat_python_api_hook_timer (PyObject *self, PyObject *args) align_second, max_calls, &weechat_python_api_hook_timer_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -2890,7 +2930,7 @@ int weechat_python_api_hook_fd_cb (void *data, int fd) { struct t_script_callback *script_callback; - char *python_argv[2], str_fd[32]; + char *python_argv[3], str_fd[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -2899,8 +2939,9 @@ weechat_python_api_hook_fd_cb (void *data, int fd) { snprintf (str_fd, sizeof (str_fd), "%d", fd); - python_argv[0] = str_fd; - python_argv[1] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = str_fd; + python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2929,7 +2970,7 @@ static PyObject * weechat_python_api_hook_fd (PyObject *self, PyObject *args) { int fd, read, write, exception; - char *function, *result; + char *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -2937,7 +2978,7 @@ weechat_python_api_hook_fd (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_fd"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_fd"); PYTHON_RETURN_EMPTY; } @@ -2946,11 +2987,12 @@ weechat_python_api_hook_fd (PyObject *self, PyObject *args) write = 0; exception = 0; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "iiiis", &fd, &read, &write, &exception, - &function)) + if (!PyArg_ParseTuple (args, "iiiiss", &fd, &read, &write, &exception, + &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_fd"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_fd"); PYTHON_RETURN_EMPTY; } @@ -2961,7 +3003,8 @@ weechat_python_api_hook_fd (PyObject *self, PyObject *args) write, exception, &weechat_python_api_hook_fd_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -2976,7 +3019,7 @@ weechat_python_api_hook_process_cb (void *data, const char *stdout, const char *stderr) { struct t_script_callback *script_callback; - char *python_argv[5], str_rc[32], empty_arg[1] = { '\0' }; + char *python_argv[6], str_rc[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -2985,11 +3028,12 @@ weechat_python_api_hook_process_cb (void *data, { snprintf (str_rc, sizeof (str_rc), "%d", return_code); - python_argv[0] = (command) ? (char *)command : empty_arg; - python_argv[1] = str_rc; - python_argv[2] = (stdout) ? (char *)stdout : empty_arg; - python_argv[3] = (stderr) ? (char *)stderr : empty_arg; - python_argv[4] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = (command) ? (char *)command : empty_arg; + python_argv[2] = str_rc; + python_argv[3] = (stdout) ? (char *)stdout : empty_arg; + python_argv[4] = (stderr) ? (char *)stderr : empty_arg; + python_argv[5] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3017,7 +3061,7 @@ weechat_python_api_hook_process_cb (void *data, static PyObject * weechat_python_api_hook_process (PyObject *self, PyObject *args) { - char *command, *function, *result; + char *command, *function, *data, *result; int timeout; PyObject *object; @@ -3026,17 +3070,18 @@ weechat_python_api_hook_process (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_process"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_process"); PYTHON_RETURN_EMPTY; } command = NULL; timeout = 0; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "sis", &command, &timeout, &function)) + if (!PyArg_ParseTuple (args, "siss", &command, &timeout, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_process"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_process"); PYTHON_RETURN_EMPTY; } @@ -3045,7 +3090,8 @@ weechat_python_api_hook_process (PyObject *self, PyObject *args) command, timeout, &weechat_python_api_hook_process_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -3059,7 +3105,7 @@ weechat_python_api_hook_connect_cb (void *data, int status, const char *error, const char *ip_address) { struct t_script_callback *script_callback; - char *python_argv[4], str_status[32], empty_arg[1] = { '\0' }; + char *python_argv[5], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3068,10 +3114,11 @@ weechat_python_api_hook_connect_cb (void *data, int status, { snprintf (str_status, sizeof (str_status), "%d", status); - python_argv[0] = str_status; - python_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; - python_argv[2] = (error) ? (char *)error : empty_arg; - python_argv[3] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = str_status; + python_argv[2] = (ip_address) ? (char *)ip_address : empty_arg; + python_argv[3] = (error) ? (char *)error : empty_arg; + python_argv[4] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3099,7 +3146,7 @@ weechat_python_api_hook_connect_cb (void *data, int status, static PyObject * weechat_python_api_hook_connect (PyObject *self, PyObject *args) { - char *proxy, *address, *local_hostname, *function, *result; + char *proxy, *address, *local_hostname, *function, *data, *result; int port, sock, ipv6; PyObject *object; @@ -3108,7 +3155,7 @@ weechat_python_api_hook_connect (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_connect"); PYTHON_RETURN_EMPTY; } @@ -3119,11 +3166,12 @@ weechat_python_api_hook_connect (PyObject *self, PyObject *args) ipv6 = 0; local_hostname = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "ssiiiss", &proxy, &address, &port, &sock, - &ipv6, &local_hostname, &function)) + if (!PyArg_ParseTuple (args, "ssiiisss", &proxy, &address, &port, &sock, + &ipv6, &local_hostname, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_connect"); PYTHON_RETURN_EMPTY; } @@ -3137,7 +3185,8 @@ weechat_python_api_hook_connect (PyObject *self, PyObject *args) NULL, /* gnutls session */ local_hostname, &weechat_python_api_hook_connect_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -3154,7 +3203,7 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *python_argv[8], empty_arg[1] = { '\0' }; + char *python_argv[9], empty_arg[1] = { '\0' }; static char timebuffer[64]; int *rc, ret; @@ -3167,16 +3216,17 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, { snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); - python_argv[0] = script_ptr2str (buffer); - python_argv[1] = timebuffer; - python_argv[2] = weechat_string_build_with_exploded (tags, ","); - if (!python_argv[2]) - python_argv[2] = strdup (""); - python_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); - python_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); - python_argv[5] = (prefix) ? (char *)prefix : empty_arg; - python_argv[6] = (message) ? (char *)message : empty_arg; - python_argv[7] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (buffer); + python_argv[2] = timebuffer; + python_argv[3] = weechat_string_build_with_exploded (tags, ","); + if (!python_argv[3]) + python_argv[3] = strdup (""); + python_argv[4] = (displayed) ? strdup ("1") : strdup ("0"); + python_argv[5] = (highlight) ? strdup ("1") : strdup ("0"); + python_argv[6] = (prefix) ? (char *)prefix : empty_arg; + python_argv[7] = (message) ? (char *)message : empty_arg; + python_argv[8] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3190,14 +3240,14 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); - if (python_argv[2]) - free (python_argv[2]); + if (python_argv[1]) + free (python_argv[1]); if (python_argv[3]) free (python_argv[3]); if (python_argv[4]) free (python_argv[4]); + if (python_argv[5]) + free (python_argv[5]); return ret; } @@ -3212,7 +3262,7 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, static PyObject * weechat_python_api_hook_print (PyObject *self, PyObject *args) { - char *buffer, *tags, *message, *function, *result; + char *buffer, *tags, *message, *function, *data, *result; int strip_colors; PyObject *object; @@ -3221,7 +3271,7 @@ weechat_python_api_hook_print (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_print"); PYTHON_RETURN_EMPTY; } @@ -3230,11 +3280,12 @@ weechat_python_api_hook_print (PyObject *self, PyObject *args) message = NULL; strip_colors = 0; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "sssis", &buffer, &tags, &message, - &strip_colors, &function)) + if (!PyArg_ParseTuple (args, "sssiss", &buffer, &tags, &message, + &strip_colors, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_print"); PYTHON_RETURN_EMPTY; } @@ -3245,7 +3296,8 @@ weechat_python_api_hook_print (PyObject *self, PyObject *args) message, strip_colors, &weechat_python_api_hook_print_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -3259,7 +3311,7 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t void *signal_data) { struct t_script_callback *script_callback; - char *python_argv[3], empty_arg[1] = { '\0' }; + char *python_argv[4], empty_arg[1] = { '\0' }; static char value_str[64]; int *rc, ret, free_needed; @@ -3267,26 +3319,27 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (signal) ? (char *)signal : empty_arg; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = (signal) ? (char *)signal : empty_arg; free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { - python_argv[1] = (signal_data) ? (char *)signal_data : empty_arg; + python_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { snprintf (value_str, sizeof (value_str) - 1, "%d", *((int *)signal_data)); - python_argv[1] = value_str; + python_argv[2] = value_str; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - python_argv[1] = script_ptr2str (signal_data); + python_argv[2] = script_ptr2str (signal_data); free_needed = 1; } else - python_argv[1] = empty_arg; - python_argv[2] = NULL; + python_argv[2] = empty_arg; + python_argv[3] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3300,8 +3353,8 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t ret = *rc; free (rc); } - if (free_needed && python_argv[1]) - free (python_argv[1]); + if (free_needed && python_argv[2]) + free (python_argv[2]); return ret; } @@ -3316,7 +3369,7 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t static PyObject * weechat_python_api_hook_signal (PyObject *self, PyObject *args) { - char *signal, *function, *result; + char *signal, *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -3324,16 +3377,17 @@ weechat_python_api_hook_signal (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_signal"); PYTHON_RETURN_EMPTY; } signal = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "ss", &signal, &function)) + if (!PyArg_ParseTuple (args, "sss", &signal, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_signal"); PYTHON_RETURN_EMPTY; } @@ -3341,7 +3395,8 @@ weechat_python_api_hook_signal (PyObject *self, PyObject *args) python_current_script, signal, &weechat_python_api_hook_signal_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -3361,7 +3416,7 @@ weechat_python_api_hook_signal_send (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal_send"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_signal_send"); PYTHON_RETURN_ERROR; } @@ -3371,7 +3426,7 @@ weechat_python_api_hook_signal_send (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &signal, &type_data, &signal_data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal_send"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_signal_send"); PYTHON_RETURN_ERROR; } @@ -3408,16 +3463,17 @@ int weechat_python_api_hook_config_cb (void *data, const char *option, const char *value) { struct t_script_callback *script_callback; - char *python_argv[3], empty_arg[1] = { '\0' }; + char *python_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (option) ? (char *)option : empty_arg; - python_argv[1] = (value) ? (char *)value : empty_arg; - python_argv[2] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = (option) ? (char *)option : empty_arg; + python_argv[2] = (value) ? (char *)value : empty_arg; + python_argv[3] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3445,7 +3501,7 @@ weechat_python_api_hook_config_cb (void *data, const char *option, const char *v static PyObject * weechat_python_api_hook_config (PyObject *self, PyObject *args) { - char *option, *function, *result; + char *option, *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -3453,16 +3509,17 @@ weechat_python_api_hook_config (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_config"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_config"); PYTHON_RETURN_EMPTY; } option = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "ss", &option, &function)) + if (!PyArg_ParseTuple (args, "sss", &option, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_config"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_config"); PYTHON_RETURN_EMPTY; } @@ -3470,7 +3527,8 @@ weechat_python_api_hook_config (PyObject *self, PyObject *args) python_current_script, option, &weechat_python_api_hook_config_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -3485,17 +3543,18 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_script_callback *script_callback; - char *python_argv[4], empty_arg[1] = { '\0' }; + char *python_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (completion_item) ? (char *)completion_item : empty_arg; - python_argv[1] = script_ptr2str (buffer); - python_argv[2] = script_ptr2str (completion); - python_argv[3] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; + python_argv[2] = script_ptr2str (buffer); + python_argv[3] = script_ptr2str (completion); + python_argv[4] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3509,10 +3568,10 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion_item, ret = *rc; free (rc); } - if (python_argv[1]) - free (python_argv[1]); if (python_argv[2]) free (python_argv[2]); + if (python_argv[3]) + free (python_argv[3]); return ret; } @@ -3527,7 +3586,7 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion_item, static PyObject * weechat_python_api_hook_completion (PyObject *self, PyObject *args) { - char *completion, *description, *function, *result; + char *completion, *description, *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -3535,17 +3594,19 @@ weechat_python_api_hook_completion (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_completion"); PYTHON_RETURN_EMPTY; } completion = NULL; description = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "sss", &completion, &description, &function)) + if (!PyArg_ParseTuple (args, "ssss", &completion, &description, &function, + &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_completion"); PYTHON_RETURN_EMPTY; } @@ -3554,7 +3615,8 @@ weechat_python_api_hook_completion (PyObject *self, PyObject *args) completion, description, &weechat_python_api_hook_completion_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -3574,7 +3636,7 @@ weechat_python_api_hook_completion_list_add (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); PYTHON_RETURN_ERROR; } @@ -3586,7 +3648,7 @@ weechat_python_api_hook_completion_list_add (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssis", &completion, &word, &nick_completion, &where)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); PYTHON_RETURN_ERROR; } @@ -3607,16 +3669,17 @@ weechat_python_api_hook_modifier_cb (void *data, const char *modifier, const char *modifier_data, const char *string) { struct t_script_callback *script_callback; - char *python_argv[4], empty_arg[1] = { '\0' }; + char *python_argv[5], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (modifier) ? (char *)modifier : empty_arg; - python_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg; - python_argv[2] = (string) ? (char *)string : empty_arg; - python_argv[3] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = (modifier) ? (char *)modifier : empty_arg; + python_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg; + python_argv[3] = (string) ? (char *)string : empty_arg; + python_argv[4] = NULL; return (char *)weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -3634,7 +3697,7 @@ weechat_python_api_hook_modifier_cb (void *data, const char *modifier, static PyObject * weechat_python_api_hook_modifier (PyObject *self, PyObject *args) { - char *modifier, *function, *result; + char *modifier, *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -3642,16 +3705,17 @@ weechat_python_api_hook_modifier (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_modifier"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_modifier"); PYTHON_RETURN_EMPTY; } modifier = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "ss", &modifier, &function)) + if (!PyArg_ParseTuple (args, "sss", &modifier, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_modifier"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_modifier"); PYTHON_RETURN_EMPTY; } @@ -3659,7 +3723,8 @@ weechat_python_api_hook_modifier (PyObject *self, PyObject *args) python_current_script, modifier, &weechat_python_api_hook_modifier_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -3679,7 +3744,7 @@ weechat_python_api_hook_modifier_exec (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_modifier_exec"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_modifier_exec"); PYTHON_RETURN_EMPTY; } @@ -3689,7 +3754,7 @@ weechat_python_api_hook_modifier_exec (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &modifier, &modifier_data, &string)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_modifier_exec"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_modifier_exec"); PYTHON_RETURN_EMPTY; } @@ -3707,15 +3772,16 @@ weechat_python_api_hook_info_cb (void *data, const char *info_name, const char *arguments) { struct t_script_callback *script_callback; - char *python_argv[3], empty_arg[1] = { '\0' }; + char *python_argv[4], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (info_name) ? (char *)info_name : empty_arg; - python_argv[1] = (arguments) ? (char *)arguments : empty_arg; - python_argv[2] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = (info_name) ? (char *)info_name : empty_arg; + python_argv[2] = (arguments) ? (char *)arguments : empty_arg; + python_argv[3] = NULL; return (const char *)weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -3733,7 +3799,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, *result; + char *info_name, *description, *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -3741,17 +3807,19 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_info"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_info"); PYTHON_RETURN_EMPTY; } info_name = NULL; description = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "sss", &info_name, &description, &function)) + if (!PyArg_ParseTuple (args, "ssss", &info_name, &description, &function, + &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_info"); PYTHON_RETURN_EMPTY; } @@ -3760,7 +3828,8 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args) info_name, description, &weechat_python_api_hook_info_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -3774,25 +3843,26 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_script_callback *script_callback; - char *python_argv[4], empty_arg[1] = { '\0' }; + char *python_argv[5], empty_arg[1] = { '\0' }; struct t_infolist *result; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = (infolist_name) ? (char *)infolist_name : empty_arg; - python_argv[1] = script_ptr2str (pointer); - python_argv[2] = (arguments) ? (char *)arguments : empty_arg; - python_argv[3] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; + python_argv[2] = script_ptr2str (pointer); + python_argv[3] = (arguments) ? (char *)arguments : empty_arg; + python_argv[4] = NULL; result = (struct t_infolist *)weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, script_callback->function, python_argv); - if (python_argv[1]) - free (python_argv[1]); + if (python_argv[2]) + free (python_argv[2]); return result; } @@ -3807,7 +3877,7 @@ 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, *result; + char *infolist_name, *description, *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -3815,17 +3885,19 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_infolist"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_infolist"); PYTHON_RETURN_EMPTY; } infolist_name = NULL; description = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "sss", &infolist_name, &description, &function)) + if (!PyArg_ParseTuple (args, "ssss", &infolist_name, &description, + &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_infolist"); PYTHON_RETURN_EMPTY; } @@ -3834,7 +3906,8 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args) infolist_name, description, &weechat_python_api_hook_infolist_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -3853,7 +3926,7 @@ weechat_python_api_unhook (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "unhook"); PYTHON_RETURN_ERROR; } @@ -3861,7 +3934,7 @@ weechat_python_api_unhook (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &hook)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("unhook"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "unhook"); PYTHON_RETURN_ERROR; } @@ -3885,7 +3958,7 @@ weechat_python_api_unhook_all (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "unhook_all"); PYTHON_RETURN_ERROR; } @@ -3903,16 +3976,17 @@ weechat_python_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer const char *input_data) { struct t_script_callback *script_callback; - char *python_argv[3], empty_arg[1] = { '\0' }; + char *python_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (buffer); - python_argv[1] = (input_data) ? (char *)input_data : empty_arg; - python_argv[2] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (buffer); + python_argv[2] = (input_data) ? (char *)input_data : empty_arg; + python_argv[3] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3925,8 +3999,8 @@ weechat_python_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); + if (python_argv[1]) + free (python_argv[1]); return ret; } @@ -3942,15 +4016,16 @@ int weechat_python_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) { struct t_script_callback *script_callback; - char *python_argv[2]; + char *python_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (buffer); - python_argv[1] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (buffer); + python_argv[2] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3963,8 +4038,8 @@ weechat_python_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); + if (python_argv[1]) + free (python_argv[1]); return ret; } @@ -3979,7 +4054,8 @@ weechat_python_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) static PyObject * weechat_python_api_buffer_new (PyObject *self, PyObject *args) { - char *name, *function_input, *function_close, *result; + char *name, *function_input, *data_input, *function_close, *data_close; + char *result; PyObject *object; /* make C compiler happy */ @@ -3987,18 +4063,20 @@ weechat_python_api_buffer_new (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_new"); PYTHON_RETURN_EMPTY; } name = NULL; function_input = NULL; + data_input = NULL; function_close = NULL; + data_close = NULL; - if (!PyArg_ParseTuple (args, "sss", &name, &function_input, - &function_close)) + if (!PyArg_ParseTuple (args, "sssss", &name, &function_input, &data_input, + &function_close, &data_close)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_new"); PYTHON_RETURN_EMPTY; } @@ -4007,8 +4085,10 @@ weechat_python_api_buffer_new (PyObject *self, PyObject *args) name, &weechat_python_api_buffer_input_data_cb, function_input, + data_input, &weechat_python_api_buffer_close_cb, - function_close)); + function_close, + data_close)); PYTHON_RETURN_STRING_FREE(result); } @@ -4029,7 +4109,7 @@ weechat_python_api_buffer_search (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_search"); PYTHON_RETURN_EMPTY; } @@ -4038,7 +4118,7 @@ weechat_python_api_buffer_search (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &plugin, &name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_search"); PYTHON_RETURN_EMPTY; } @@ -4063,7 +4143,7 @@ weechat_python_api_current_buffer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_buffer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "current_buffer"); PYTHON_RETURN_EMPTY; } @@ -4086,7 +4166,7 @@ weechat_python_api_buffer_clear (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_clear"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_clear"); PYTHON_RETURN_ERROR; } @@ -4094,7 +4174,7 @@ weechat_python_api_buffer_clear (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &buffer)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_clear"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_clear"); PYTHON_RETURN_ERROR; } @@ -4117,7 +4197,7 @@ weechat_python_api_buffer_close (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_close"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_close"); PYTHON_RETURN_ERROR; } @@ -4125,7 +4205,7 @@ weechat_python_api_buffer_close (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &buffer)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_close"); PYTHON_RETURN_ERROR; } @@ -4151,7 +4231,7 @@ weechat_python_api_buffer_get_integer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_integer"); PYTHON_RETURN_INT(-1); } @@ -4160,7 +4240,7 @@ weechat_python_api_buffer_get_integer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_integer"); PYTHON_RETURN_INT(-1); } @@ -4184,7 +4264,7 @@ weechat_python_api_buffer_get_string (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_string"); PYTHON_RETURN_ERROR; } @@ -4193,7 +4273,7 @@ weechat_python_api_buffer_get_string (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_string"); PYTHON_RETURN_EMPTY; } @@ -4217,7 +4297,7 @@ weechat_python_api_buffer_get_pointer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_pointer"); PYTHON_RETURN_ERROR; } @@ -4226,7 +4306,7 @@ weechat_python_api_buffer_get_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_pointer"); PYTHON_RETURN_EMPTY; } @@ -4250,7 +4330,7 @@ weechat_python_api_buffer_set (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_set"); PYTHON_RETURN_ERROR; } @@ -4260,7 +4340,7 @@ weechat_python_api_buffer_set (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &buffer, &property, &value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_set"); PYTHON_RETURN_ERROR; } @@ -4287,7 +4367,7 @@ weechat_python_api_current_window (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_window"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "current_window"); PYTHON_RETURN_EMPTY; } @@ -4311,7 +4391,7 @@ weechat_python_api_window_get_integer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "window_get_integer"); PYTHON_RETURN_INT(-1); } @@ -4320,7 +4400,7 @@ weechat_python_api_window_get_integer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &window, &property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "window_get_integer"); PYTHON_RETURN_INT(-1); } @@ -4344,7 +4424,7 @@ weechat_python_api_window_get_string (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "window_get_string"); PYTHON_RETURN_ERROR; } @@ -4353,7 +4433,7 @@ weechat_python_api_window_get_string (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &window, &property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "window_get_string"); PYTHON_RETURN_EMPTY; } @@ -4377,7 +4457,7 @@ weechat_python_api_window_get_pointer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "window_get_pointer"); PYTHON_RETURN_ERROR; } @@ -4386,7 +4466,7 @@ weechat_python_api_window_get_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &window, &property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "window_get_pointer"); PYTHON_RETURN_EMPTY; } @@ -4412,7 +4492,7 @@ weechat_python_api_nicklist_add_group (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_add_group"); PYTHON_RETURN_EMPTY; } @@ -4425,7 +4505,7 @@ weechat_python_api_nicklist_add_group (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssssi", &buffer, &parent_group, &name, &color, &visible)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_add_group"); PYTHON_RETURN_EMPTY; } @@ -4453,7 +4533,7 @@ weechat_python_api_nicklist_search_group (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_search_group"); PYTHON_RETURN_EMPTY; } @@ -4463,7 +4543,7 @@ weechat_python_api_nicklist_search_group (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &buffer, &from_group, &name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_search_group"); PYTHON_RETURN_EMPTY; } @@ -4490,7 +4570,7 @@ weechat_python_api_nicklist_add_nick (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); PYTHON_RETURN_EMPTY; } @@ -4505,7 +4585,7 @@ weechat_python_api_nicklist_add_nick (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssssssi", &buffer, &group, &name, &color, &prefix, &prefix_color, &visible)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); PYTHON_RETURN_EMPTY; } @@ -4535,7 +4615,7 @@ weechat_python_api_nicklist_search_nick (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_search_nick"); PYTHON_RETURN_EMPTY; } @@ -4545,7 +4625,7 @@ weechat_python_api_nicklist_search_nick (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &buffer, &from_group, &name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_search_nick"); PYTHON_RETURN_EMPTY; } @@ -4570,7 +4650,7 @@ weechat_python_api_nicklist_remove_group (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_group"); PYTHON_RETURN_ERROR; } @@ -4579,7 +4659,7 @@ weechat_python_api_nicklist_remove_group (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &group)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_group"); PYTHON_RETURN_ERROR; } @@ -4603,7 +4683,7 @@ weechat_python_api_nicklist_remove_nick (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_nick"); PYTHON_RETURN_ERROR; } @@ -4612,7 +4692,7 @@ weechat_python_api_nicklist_remove_nick (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &nick)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_nick"); PYTHON_RETURN_ERROR; } @@ -4636,7 +4716,7 @@ weechat_python_api_nicklist_remove_all (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_all"); PYTHON_RETURN_ERROR; } @@ -4644,7 +4724,7 @@ weechat_python_api_nicklist_remove_all (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &buffer)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_all"); PYTHON_RETURN_ERROR; } @@ -4668,7 +4748,7 @@ weechat_python_api_bar_item_search (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_search"); PYTHON_RETURN_EMPTY; } @@ -4676,7 +4756,7 @@ weechat_python_api_bar_item_search (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_search"); PYTHON_RETURN_EMPTY; } @@ -4694,25 +4774,26 @@ weechat_python_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, struct t_gui_window *window) { struct t_script_callback *script_callback; - char *python_argv[3], *ret; + char *python_argv[4], empty_arg[1] = { '\0' }, *ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - python_argv[0] = script_ptr2str (item); - python_argv[1] = script_ptr2str (window); - python_argv[2] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (item); + python_argv[2] = script_ptr2str (window); + python_argv[3] = NULL; ret = (char *)weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, script_callback->function, python_argv); - if (python_argv[0]) - free (python_argv[0]); if (python_argv[1]) free (python_argv[1]); + if (python_argv[2]) + free (python_argv[2]); return ret; } @@ -4727,7 +4808,7 @@ weechat_python_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, static PyObject * weechat_python_api_bar_item_new (PyObject *self, PyObject *args) { - char *name, *function, *result; + char *name, *function, *data, *result; PyObject *object; /* make C compiler happy */ @@ -4735,16 +4816,17 @@ weechat_python_api_bar_item_new (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_new"); PYTHON_RETURN_EMPTY; } name = NULL; function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "ss", &name, &function)) + if (!PyArg_ParseTuple (args, "sss", &name, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_new"); PYTHON_RETURN_EMPTY; } @@ -4752,7 +4834,8 @@ weechat_python_api_bar_item_new (PyObject *self, PyObject *args) python_current_script, name, &weechat_python_api_bar_item_build_cb, - function)); + function, + data)); PYTHON_RETURN_STRING_FREE(result); } @@ -4771,7 +4854,7 @@ weechat_python_api_bar_item_update (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_update"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_update"); PYTHON_RETURN_ERROR; } @@ -4779,7 +4862,7 @@ weechat_python_api_bar_item_update (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_update"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_update"); PYTHON_RETURN_ERROR; } @@ -4802,7 +4885,7 @@ weechat_python_api_bar_item_remove (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_remove"); PYTHON_RETURN_ERROR; } @@ -4810,7 +4893,7 @@ weechat_python_api_bar_item_remove (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &item)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_remove"); PYTHON_RETURN_ERROR; } @@ -4836,7 +4919,7 @@ weechat_python_api_bar_search (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_search"); PYTHON_RETURN_EMPTY; } @@ -4844,7 +4927,7 @@ weechat_python_api_bar_search (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_search"); PYTHON_RETURN_EMPTY; } @@ -4870,7 +4953,7 @@ weechat_python_api_bar_new (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_new"); PYTHON_RETURN_EMPTY; } @@ -4895,7 +4978,7 @@ weechat_python_api_bar_new (PyObject *self, PyObject *args) &filling_left_right, &size, &size_max, &color_fg, &color_delim, &color_bg, &separator, &items)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_new"); PYTHON_RETURN_EMPTY; } @@ -4932,7 +5015,7 @@ weechat_python_api_bar_set (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_set"); PYTHON_RETURN_ERROR; } @@ -4942,7 +5025,7 @@ weechat_python_api_bar_set (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &bar, &property, &value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_set"); PYTHON_RETURN_ERROR; } @@ -4967,7 +5050,7 @@ weechat_python_api_bar_update (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_item"); PYTHON_RETURN_ERROR; } @@ -4975,7 +5058,7 @@ weechat_python_api_bar_update (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_item"); PYTHON_RETURN_ERROR; } @@ -4998,7 +5081,7 @@ weechat_python_api_bar_remove (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_remove"); PYTHON_RETURN_ERROR; } @@ -5006,7 +5089,7 @@ weechat_python_api_bar_remove (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &bar)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_remove"); PYTHON_RETURN_ERROR; } @@ -5029,7 +5112,7 @@ weechat_python_api_command (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("command"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "command"); PYTHON_RETURN_ERROR; } @@ -5038,7 +5121,7 @@ weechat_python_api_command (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &command)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "command"); PYTHON_RETURN_ERROR; } @@ -5065,7 +5148,7 @@ weechat_python_api_info_get (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("info_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "info_get"); PYTHON_RETURN_EMPTY; } @@ -5073,7 +5156,7 @@ weechat_python_api_info_get (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &info_name, &arguments)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("info_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "info_get"); PYTHON_RETURN_EMPTY; } @@ -5098,7 +5181,7 @@ weechat_python_api_infolist_new (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new"); PYTHON_RETURN_EMPTY; } @@ -5124,7 +5207,7 @@ weechat_python_api_infolist_new_var_integer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); PYTHON_RETURN_EMPTY; } @@ -5134,7 +5217,7 @@ weechat_python_api_infolist_new_var_integer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssi", &infolist, &name, &value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); PYTHON_RETURN_EMPTY; } @@ -5161,7 +5244,7 @@ weechat_python_api_infolist_new_var_string (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_string"); PYTHON_RETURN_EMPTY; } @@ -5171,7 +5254,7 @@ weechat_python_api_infolist_new_var_string (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &infolist, &name, &value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_string"); PYTHON_RETURN_EMPTY; } @@ -5198,7 +5281,7 @@ weechat_python_api_infolist_new_var_pointer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer"); PYTHON_RETURN_EMPTY; } @@ -5208,7 +5291,7 @@ weechat_python_api_infolist_new_var_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &infolist, &name, &value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer"); PYTHON_RETURN_EMPTY; } @@ -5236,7 +5319,7 @@ weechat_python_api_infolist_new_var_time (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); PYTHON_RETURN_EMPTY; } @@ -5246,7 +5329,7 @@ weechat_python_api_infolist_new_var_time (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ssi", &infolist, &name, &value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); PYTHON_RETURN_EMPTY; } @@ -5272,7 +5355,7 @@ weechat_python_api_infolist_get (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_get"); PYTHON_RETURN_EMPTY; } @@ -5282,7 +5365,7 @@ weechat_python_api_infolist_get (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &name, &pointer, &arguments)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_get"); PYTHON_RETURN_EMPTY; } @@ -5308,7 +5391,7 @@ weechat_python_api_infolist_next (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_next"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_next"); PYTHON_RETURN_INT(0); } @@ -5316,7 +5399,7 @@ weechat_python_api_infolist_next (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &infolist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_next"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_next"); PYTHON_RETURN_INT(0); } @@ -5340,7 +5423,7 @@ weechat_python_api_infolist_prev (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_prev"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_prev"); PYTHON_RETURN_INT(0); } @@ -5348,7 +5431,7 @@ weechat_python_api_infolist_prev (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &infolist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_prev"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_prev"); PYTHON_RETURN_INT(0); } @@ -5372,7 +5455,7 @@ weechat_python_api_infolist_fields (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_fields"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_fields"); PYTHON_RETURN_EMPTY; } @@ -5380,7 +5463,7 @@ weechat_python_api_infolist_fields (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &infolist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_fields"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_fields"); PYTHON_RETURN_EMPTY; } @@ -5404,7 +5487,7 @@ weechat_python_api_infolist_integer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_integer"); PYTHON_RETURN_INT(0); } @@ -5413,7 +5496,7 @@ weechat_python_api_infolist_integer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &infolist, &variable)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_integer"); PYTHON_RETURN_INT(0); } @@ -5438,7 +5521,7 @@ weechat_python_api_infolist_string (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_string"); PYTHON_RETURN_EMPTY; } @@ -5447,7 +5530,7 @@ weechat_python_api_infolist_string (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &infolist, &variable)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_string"); PYTHON_RETURN_EMPTY; } @@ -5472,7 +5555,7 @@ weechat_python_api_infolist_pointer (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_pointer"); PYTHON_RETURN_EMPTY; } @@ -5481,7 +5564,7 @@ weechat_python_api_infolist_pointer (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &infolist, &variable)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_pointer"); PYTHON_RETURN_EMPTY; } @@ -5507,7 +5590,7 @@ weechat_python_api_infolist_time (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_time"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_time"); PYTHON_RETURN_EMPTY; } @@ -5516,7 +5599,7 @@ weechat_python_api_infolist_time (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &infolist, &variable)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_time"); PYTHON_RETURN_EMPTY; } @@ -5542,7 +5625,7 @@ weechat_python_api_infolist_free (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_free"); PYTHON_RETURN_ERROR; } @@ -5550,7 +5633,7 @@ weechat_python_api_infolist_free (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &infolist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_free"); PYTHON_RETURN_ERROR; } @@ -5575,7 +5658,7 @@ weechat_python_api_upgrade_new (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_new"); PYTHON_RETURN_EMPTY; } @@ -5584,7 +5667,7 @@ weechat_python_api_upgrade_new (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "si", &filename, &write)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_new"); PYTHON_RETURN_EMPTY; } @@ -5608,7 +5691,7 @@ weechat_python_api_upgrade_write_object (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_write_object"); PYTHON_RETURN_INT(0); } @@ -5618,7 +5701,7 @@ weechat_python_api_upgrade_write_object (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sis", &upgrade_file, &object_id, &infolist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_write_object"); PYTHON_RETURN_INT(0); } @@ -5640,7 +5723,7 @@ weechat_python_api_upgrade_read_cb (void *data, struct t_infolist *infolist) { struct t_script_callback *script_callback; - char *python_argv[4], str_object_id[32]; + char *python_argv[5], empty_arg[1] = { '\0' }, str_object_id[32]; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -5649,10 +5732,11 @@ weechat_python_api_upgrade_read_cb (void *data, { snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); - python_argv[0] = script_ptr2str (upgrade_file); - python_argv[1] = str_object_id; - python_argv[2] = script_ptr2str (infolist); - python_argv[3] = NULL; + python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + python_argv[1] = script_ptr2str (upgrade_file); + python_argv[2] = str_object_id; + python_argv[3] = script_ptr2str (infolist); + python_argv[4] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -5666,10 +5750,10 @@ weechat_python_api_upgrade_read_cb (void *data, ret = *rc; free (rc); } - if (python_argv[0]) - free (python_argv[0]); - if (python_argv[2]) - free (python_argv[2]); + if (python_argv[1]) + free (python_argv[1]); + if (python_argv[3]) + free (python_argv[3]); return ret; } @@ -5684,7 +5768,7 @@ weechat_python_api_upgrade_read_cb (void *data, static PyObject * weechat_python_api_upgrade_read (PyObject *self, PyObject *args) { - char *upgrade_file, *function_read; + char *upgrade_file, *function, *data; int rc; /* make C compiler happy */ @@ -5692,16 +5776,17 @@ weechat_python_api_upgrade_read (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_read"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_read"); PYTHON_RETURN_INT(0); } upgrade_file = NULL; - function_read = NULL; + function = NULL; + data = NULL; - if (!PyArg_ParseTuple (args, "ss", &upgrade_file, &function_read)) + if (!PyArg_ParseTuple (args, "sss", &upgrade_file, &function, &data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_read"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_read"); PYTHON_RETURN_INT(0); } @@ -5709,7 +5794,8 @@ weechat_python_api_upgrade_read (PyObject *self, PyObject *args) python_current_script, script_str2ptr (upgrade_file), &weechat_python_api_upgrade_read_cb, - function_read); + function, + data); PYTHON_RETURN_INT(rc); } @@ -5728,7 +5814,7 @@ weechat_python_api_upgrade_close (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_close"); + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_close"); PYTHON_RETURN_ERROR; } @@ -5736,7 +5822,7 @@ weechat_python_api_upgrade_close (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &upgrade_file)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_close"); PYTHON_RETURN_ERROR; } diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 67c7b9834..46cfbbc80 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -120,11 +120,22 @@ weechat_python_exec (struct t_plugin_script *script, { if (argv[6]) { - rc = PyObject_CallFunction (evFunc, "sssssss", - argv[0], argv[1], - argv[2], argv[3], - argv[4], argv[5], - argv[6]); + if (argv[7]) + { + rc = PyObject_CallFunction (evFunc, "ssssssss", + argv[0], argv[1], + argv[2], argv[3], + argv[4], argv[5], + argv[6], argv[7]); + } + else + { + rc = PyObject_CallFunction (evFunc, "sssssss", + argv[0], argv[1], + argv[2], argv[3], + argv[4], argv[5], + argv[6]); + } } else { diff --git a/src/plugins/scripts/python/weechat-python.h b/src/plugins/scripts/python/weechat-python.h index d69b93591..00ec225d3 100644 --- a/src/plugins/scripts/python/weechat-python.h +++ b/src/plugins/scripts/python/weechat-python.h @@ -23,6 +23,8 @@ #define weechat_plugin weechat_python_plugin #define PYTHON_PLUGIN_NAME "python" +#define PYTHON_CURRENT_SCRIPT_NAME ((python_current_script) ? python_current_script->name : "-") + extern struct t_weechat_plugin *weechat_python_plugin; extern int python_quiet; diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index d3ba648c7..103d80ed3 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -78,7 +78,7 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author, || NIL_P (license) || NIL_P (description) || NIL_P (shutdown_func) || NIL_P (charset)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("register"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(ruby_current_script_filename, "register"); RUBY_RETURN_ERROR; } @@ -152,7 +152,7 @@ weechat_ruby_api_plugin_get_name (VALUE class, VALUE plugin) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "plugin_get_name"); RUBY_RETURN_EMPTY; } @@ -160,7 +160,7 @@ weechat_ruby_api_plugin_get_name (VALUE class, VALUE plugin) if (NIL_P (plugin)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "plugin_get_name"); RUBY_RETURN_EMPTY; } @@ -187,7 +187,7 @@ weechat_ruby_api_charset_set (VALUE class, VALUE charset) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("charset_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "charset_set"); RUBY_RETURN_ERROR; } @@ -195,7 +195,7 @@ weechat_ruby_api_charset_set (VALUE class, VALUE charset) if (NIL_P (charset)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("charset_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "charset_set"); RUBY_RETURN_ERROR; } @@ -223,7 +223,7 @@ weechat_ruby_api_iconv_to_internal (VALUE class, VALUE charset, VALUE string) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_to_internal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "iconv_to_internal"); RUBY_RETURN_EMPTY; } @@ -232,7 +232,7 @@ weechat_ruby_api_iconv_to_internal (VALUE class, VALUE charset, VALUE string) if (NIL_P (charset) || NIL_P (string)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_to_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "iconv_to_internal"); RUBY_RETURN_EMPTY; } @@ -263,7 +263,7 @@ weechat_ruby_api_iconv_from_internal (VALUE class, VALUE charset, VALUE string) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_from_internal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "iconv_from_internal"); RUBY_RETURN_EMPTY; } @@ -272,7 +272,7 @@ weechat_ruby_api_iconv_from_internal (VALUE class, VALUE charset, VALUE string) if (NIL_P (charset) || NIL_P (string)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_from_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "iconv_from_internal"); RUBY_RETURN_EMPTY; } @@ -302,7 +302,7 @@ weechat_ruby_api_gettext (VALUE class, VALUE string) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("gettext"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "gettext"); RUBY_RETURN_EMPTY; } @@ -310,7 +310,7 @@ weechat_ruby_api_gettext (VALUE class, VALUE string) if (NIL_P (string)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("gettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "gettext"); RUBY_RETURN_EMPTY; } @@ -340,7 +340,7 @@ weechat_ruby_api_ngettext (VALUE class, VALUE single, VALUE plural, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("ngettext"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "ngettext"); RUBY_RETURN_EMPTY; } @@ -350,7 +350,7 @@ weechat_ruby_api_ngettext (VALUE class, VALUE single, VALUE plural, if (NIL_P (single) || NIL_P (plural) || NIL_P (count)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("ngettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "ngettext"); RUBY_RETURN_EMPTY; } @@ -383,7 +383,7 @@ weechat_ruby_api_string_remove_color (VALUE class, VALUE string, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("string_remove_color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "string_remove_color"); RUBY_RETURN_EMPTY; } @@ -392,7 +392,7 @@ weechat_ruby_api_string_remove_color (VALUE class, VALUE string, if (NIL_P (string) || NIL_P (replacement)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "string_remove_color"); RUBY_RETURN_EMPTY; } @@ -422,7 +422,7 @@ weechat_ruby_api_mkdir_home (VALUE class, VALUE directory, VALUE mode) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_home"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "mkdir_home"); RUBY_RETURN_ERROR; } @@ -431,7 +431,7 @@ weechat_ruby_api_mkdir_home (VALUE class, VALUE directory, VALUE mode) if (NIL_P (directory) || NIL_P (mode)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_home"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "mkdir_home"); RUBY_RETURN_ERROR; } @@ -462,7 +462,7 @@ weechat_ruby_api_mkdir (VALUE class, VALUE directory, VALUE mode) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "mkdir"); RUBY_RETURN_ERROR; } @@ -471,7 +471,7 @@ weechat_ruby_api_mkdir (VALUE class, VALUE directory, VALUE mode) if (NIL_P (directory) || NIL_P (mode)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "mkdir"); RUBY_RETURN_ERROR; } @@ -503,7 +503,7 @@ weechat_ruby_api_mkdir_parents (VALUE class, VALUE directory, VALUE mode) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_parents"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "mkdir_parents"); RUBY_RETURN_ERROR; } @@ -512,7 +512,7 @@ weechat_ruby_api_mkdir_parents (VALUE class, VALUE directory, VALUE mode) if (NIL_P (directory) || NIL_P (mode)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_parents"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "mkdir_parents"); RUBY_RETURN_ERROR; } @@ -542,7 +542,7 @@ weechat_ruby_api_list_new (VALUE class) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_new"); RUBY_RETURN_EMPTY; } @@ -566,7 +566,7 @@ weechat_ruby_api_list_add (VALUE class, VALUE weelist, VALUE data, VALUE where, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_add"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_add"); RUBY_RETURN_EMPTY; } @@ -577,7 +577,7 @@ weechat_ruby_api_list_add (VALUE class, VALUE weelist, VALUE data, VALUE where, if (NIL_P (weelist) || NIL_P (data) || NIL_P (where) || NIL_P (user_data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_add"); RUBY_RETURN_EMPTY; } @@ -613,7 +613,7 @@ weechat_ruby_api_list_search (VALUE class, VALUE weelist, VALUE data) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_search"); RUBY_RETURN_EMPTY; } @@ -622,7 +622,7 @@ weechat_ruby_api_list_search (VALUE class, VALUE weelist, VALUE data) if (NIL_P (weelist) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_search"); RUBY_RETURN_EMPTY; } @@ -652,7 +652,7 @@ weechat_ruby_api_list_casesearch (VALUE class, VALUE weelist, VALUE data) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_casesearch"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_casesearch"); RUBY_RETURN_EMPTY; } @@ -661,7 +661,7 @@ weechat_ruby_api_list_casesearch (VALUE class, VALUE weelist, VALUE data) if (NIL_P (weelist) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_casesearch"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_casesearch"); RUBY_RETURN_EMPTY; } @@ -692,7 +692,7 @@ weechat_ruby_api_list_get (VALUE class, VALUE weelist, VALUE position) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_get"); RUBY_RETURN_EMPTY; } @@ -701,7 +701,7 @@ weechat_ruby_api_list_get (VALUE class, VALUE weelist, VALUE position) if (NIL_P (weelist) || NIL_P (position)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_get"); RUBY_RETURN_EMPTY; } @@ -731,7 +731,7 @@ weechat_ruby_api_list_set (VALUE class, VALUE item, VALUE new_value) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_set"); RUBY_RETURN_ERROR; } @@ -740,7 +740,7 @@ weechat_ruby_api_list_set (VALUE class, VALUE item, VALUE new_value) if (NIL_P (item) || NIL_P (new_value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_set"); RUBY_RETURN_ERROR; } @@ -770,7 +770,7 @@ weechat_ruby_api_list_next (VALUE class, VALUE item) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_next"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_next"); RUBY_RETURN_EMPTY; } @@ -778,7 +778,7 @@ weechat_ruby_api_list_next (VALUE class, VALUE item) if (NIL_P (item)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_next"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_next"); RUBY_RETURN_EMPTY; } @@ -805,7 +805,7 @@ weechat_ruby_api_list_prev (VALUE class, VALUE item) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_prev"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_prev"); RUBY_RETURN_EMPTY; } @@ -813,7 +813,7 @@ weechat_ruby_api_list_prev (VALUE class, VALUE item) if (NIL_P (item)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_prev"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_prev"); RUBY_RETURN_EMPTY; } @@ -841,7 +841,7 @@ weechat_ruby_api_list_string (VALUE class, VALUE item) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_string"); RUBY_RETURN_EMPTY; } @@ -849,7 +849,7 @@ weechat_ruby_api_list_string (VALUE class, VALUE item) if (NIL_P (item)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_string"); RUBY_RETURN_EMPTY; } @@ -877,7 +877,7 @@ weechat_ruby_api_list_size (VALUE class, VALUE weelist) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_size"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_size"); RUBY_RETURN_INT(0); } @@ -885,7 +885,7 @@ weechat_ruby_api_list_size (VALUE class, VALUE weelist) if (NIL_P (weelist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_size"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_size"); RUBY_RETURN_INT(0); } @@ -912,7 +912,7 @@ weechat_ruby_api_list_remove (VALUE class, VALUE weelist, VALUE item) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_remove"); RUBY_RETURN_ERROR; } @@ -921,7 +921,7 @@ weechat_ruby_api_list_remove (VALUE class, VALUE weelist, VALUE item) if (NIL_P (weelist) || NIL_P (item)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_remove"); RUBY_RETURN_ERROR; } @@ -951,7 +951,7 @@ weechat_ruby_api_list_remove_all (VALUE class, VALUE weelist) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_remove_all"); RUBY_RETURN_ERROR; } @@ -959,7 +959,7 @@ weechat_ruby_api_list_remove_all (VALUE class, VALUE weelist) if (NIL_P (weelist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_remove_all"); RUBY_RETURN_ERROR; } @@ -986,7 +986,7 @@ weechat_ruby_api_list_free (VALUE class, VALUE weelist) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_free"); RUBY_RETURN_ERROR; } @@ -994,7 +994,7 @@ weechat_ruby_api_list_free (VALUE class, VALUE weelist) if (NIL_P (weelist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_free"); RUBY_RETURN_ERROR; } @@ -1016,15 +1016,16 @@ weechat_ruby_api_config_reload_cb (void *data, struct t_config_file *config_file) { struct t_script_callback *script_callback; - char *ruby_argv[2]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (config_file); - ruby_argv[1] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (config_file); + ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1038,8 +1039,8 @@ weechat_ruby_api_config_reload_cb (void *data, ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); + if (ruby_argv[1]) + free (ruby_argv[1]); return ret; } @@ -1052,9 +1053,10 @@ weechat_ruby_api_config_reload_cb (void *data, */ static VALUE -weechat_ruby_api_config_new (VALUE class, VALUE name, VALUE function) +weechat_ruby_api_config_new (VALUE class, VALUE name, VALUE function, + VALUE data) { - char *c_name, *c_function, *result; + char *c_name, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -1062,30 +1064,34 @@ weechat_ruby_api_config_new (VALUE class, VALUE name, VALUE function) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_new"); RUBY_RETURN_EMPTY; } c_name = NULL; c_function = NULL; + c_data = NULL; - if (NIL_P (name) || NIL_P (function)) + if (NIL_P (name) || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_new"); RUBY_RETURN_EMPTY; } Check_Type (name, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_name = STR2CSTR (name); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_config_new (weechat_ruby_plugin, ruby_current_script, c_name, &weechat_ruby_api_config_reload_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -1101,18 +1107,19 @@ weechat_ruby_api_config_read_cb (void *data, const char *option_name, const char *value) { struct t_script_callback *script_callback; - char *ruby_argv[5], empty_arg[1] = { '\0' }; + char *ruby_argv[6], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (config_file); - ruby_argv[1] = script_ptr2str (section); - ruby_argv[2] = (option_name) ? (char *)option_name : empty_arg; - ruby_argv[3] = (value) ? (char *)value : empty_arg; - ruby_argv[4] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (config_file); + ruby_argv[2] = script_ptr2str (section); + ruby_argv[3] = (option_name) ? (char *)option_name : empty_arg; + ruby_argv[4] = (value) ? (char *)value : empty_arg; + ruby_argv[5] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1126,10 +1133,10 @@ weechat_ruby_api_config_read_cb (void *data, ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); if (ruby_argv[1]) free (ruby_argv[1]); + if (ruby_argv[2]) + free (ruby_argv[2]); return ret; } @@ -1147,16 +1154,17 @@ weechat_ruby_api_config_section_write_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *ruby_argv[3], empty_arg[1] = { '\0' }; + char *ruby_argv[4], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (config_file); - ruby_argv[1] = (section_name) ? (char *)section_name : empty_arg; - ruby_argv[2] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (config_file); + ruby_argv[2] = (section_name) ? (char *)section_name : empty_arg; + ruby_argv[3] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1165,8 +1173,8 @@ weechat_ruby_api_config_section_write_cb (void *data, if (rc) free (rc); - if (ruby_argv[0]) - free (ruby_argv[0]); + if (ruby_argv[1]) + free (ruby_argv[1]); } } @@ -1181,16 +1189,17 @@ weechat_ruby_api_config_section_write_default_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *ruby_argv[3], empty_arg[1] = { '\0' }; + char *ruby_argv[4], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (config_file); - ruby_argv[1] = (section_name) ? (char *)section_name : empty_arg; - ruby_argv[2] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (config_file); + ruby_argv[2] = (section_name) ? (char *)section_name : empty_arg; + ruby_argv[3] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1199,8 +1208,8 @@ weechat_ruby_api_config_section_write_default_cb (void *data, if (rc) free (rc); - if (ruby_argv[0]) - free (ruby_argv[0]); + if (ruby_argv[1]) + free (ruby_argv[1]); } } @@ -1216,18 +1225,19 @@ weechat_ruby_api_config_section_create_option_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *ruby_argv[5], empty_arg[1] = { '\0' }; + char *ruby_argv[6], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (config_file); - ruby_argv[1] = script_ptr2str (section); - ruby_argv[2] = (option_name) ? (char *)option_name : empty_arg; - ruby_argv[3] = (value) ? (char *)value : empty_arg; - ruby_argv[4] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (config_file); + ruby_argv[2] = script_ptr2str (section); + ruby_argv[3] = (option_name) ? (char *)option_name : empty_arg; + ruby_argv[4] = (value) ? (char *)value : empty_arg; + ruby_argv[5] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1241,10 +1251,10 @@ weechat_ruby_api_config_section_create_option_cb (void *data, ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); if (ruby_argv[1]) free (ruby_argv[1]); + if (ruby_argv[2]) + free (ruby_argv[2]); return ret; } @@ -1263,17 +1273,18 @@ weechat_ruby_api_config_section_delete_option_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *ruby_argv[4]; + char *ruby_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (config_file); - ruby_argv[1] = script_ptr2str (section); - ruby_argv[2] = script_ptr2str (option); - ruby_argv[3] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (config_file); + ruby_argv[2] = script_ptr2str (section); + ruby_argv[3] = script_ptr2str (option); + ruby_argv[4] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1287,12 +1298,12 @@ weechat_ruby_api_config_section_delete_option_cb (void *data, ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); if (ruby_argv[1]) free (ruby_argv[1]); if (ruby_argv[2]) free (ruby_argv[2]); + if (ruby_argv[3]) + free (ruby_argv[3]); return ret; } @@ -1309,15 +1320,21 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file, VALUE name, VALUE user_can_add_options, VALUE user_can_delete_options, VALUE function_read, + VALUE data_read, VALUE function_write, + VALUE data_write, VALUE function_write_default, + VALUE data_write_default, VALUE function_create_option, - VALUE function_delete_option) -{ - char *c_config_file, *c_name, *c_function_read, *c_function_write; - char *c_function_write_default, *c_function_create_option; - char *c_function_delete_option; - char *result; + VALUE data_create_option, + VALUE function_delete_option, + VALUE data_delete_option) +{ + char *c_config_file, *c_name, *c_function_read, *c_data_read; + char *c_function_write, *c_data_write, *c_function_write_default; + char *c_data_write_default, *c_function_create_option; + char *c_data_create_option, *c_function_delete_option; + char *c_data_delete_option, *result; int c_user_can_add_options, c_user_can_delete_options; VALUE return_value; @@ -1326,7 +1343,7 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new_section"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_new_section"); RUBY_RETURN_EMPTY; } @@ -1335,17 +1352,24 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file, c_user_can_add_options = 0; c_user_can_delete_options = 0; c_function_read = NULL; + c_data_read = NULL; c_function_write = NULL; + c_data_write = NULL; c_function_write_default = NULL; + c_data_write_default = NULL; c_function_create_option = NULL; + c_data_create_option = NULL; c_function_delete_option = NULL; + c_data_delete_option = NULL; if (NIL_P (config_file) || NIL_P (name) || NIL_P (user_can_add_options) || NIL_P (user_can_delete_options) || NIL_P (function_read) - || NIL_P (function_write) || NIL_P (function_write_default) - || NIL_P (function_create_option) || NIL_P (function_delete_option)) + || NIL_P (data_read) || NIL_P (function_write) || NIL_P (data_write) + || NIL_P (function_write_default) || NIL_P (data_write_default) + || NIL_P (function_create_option) || NIL_P (data_create_option) + || NIL_P (function_delete_option) || NIL_P (data_delete_option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_new_section"); RUBY_RETURN_EMPTY; } @@ -1354,20 +1378,30 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file, Check_Type (user_can_add_options, T_FIXNUM); Check_Type (user_can_delete_options, T_FIXNUM); Check_Type (function_read, T_STRING); + Check_Type (data_read, T_STRING); Check_Type (function_write, T_STRING); + Check_Type (data_write, T_STRING); Check_Type (function_write_default, T_STRING); + Check_Type (data_write_default, T_STRING); Check_Type (function_create_option, T_STRING); + Check_Type (data_create_option, T_STRING); Check_Type (function_delete_option, T_STRING); + Check_Type (data_delete_option, T_STRING); c_config_file = STR2CSTR (config_file); c_name = STR2CSTR (name); c_user_can_add_options = FIX2INT (user_can_add_options); c_user_can_delete_options = FIX2INT (user_can_delete_options); c_function_read = STR2CSTR (function_read); + c_data_read = STR2CSTR (data_read); c_function_write = STR2CSTR (function_write); + c_data_write = STR2CSTR (data_write); c_function_write_default = STR2CSTR (function_write_default); + c_data_write_default = STR2CSTR (data_write_default); c_function_create_option = STR2CSTR (function_create_option); + c_data_create_option = STR2CSTR (data_create_option); c_function_delete_option = STR2CSTR (function_delete_option); + c_data_delete_option = STR2CSTR (data_delete_option); result = script_ptr2str (script_api_config_new_section (weechat_ruby_plugin, ruby_current_script, @@ -1377,14 +1411,19 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file, c_user_can_delete_options, &weechat_ruby_api_config_read_cb, c_function_read, + c_data_read, &weechat_ruby_api_config_section_write_cb, c_function_write, + c_data_write, &weechat_ruby_api_config_section_write_default_cb, c_function_write_default, + c_data_write_default, &weechat_ruby_api_config_section_create_option_cb, c_function_create_option, + c_data_create_option, &weechat_ruby_api_config_section_delete_option_cb, - c_function_delete_option)); + c_function_delete_option, + c_data_delete_option)); RUBY_RETURN_STRING_FREE(result); } @@ -1405,7 +1444,7 @@ weechat_ruby_api_config_search_section (VALUE class, VALUE config_file, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_search_section"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_search_section"); RUBY_RETURN_EMPTY; } @@ -1414,7 +1453,7 @@ weechat_ruby_api_config_search_section (VALUE class, VALUE config_file, if (NIL_P (config_file) || NIL_P (section_name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_search_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_search_section"); RUBY_RETURN_EMPTY; } @@ -1441,16 +1480,17 @@ weechat_ruby_api_config_option_check_value_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *ruby_argv[3], empty_arg[1] = { '\0' }; + char *ruby_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (option); - ruby_argv[1] = (value) ? (char *)value : empty_arg; - ruby_argv[2] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (option); + ruby_argv[2] = (value) ? (char *)value : empty_arg; + ruby_argv[3] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1464,8 +1504,8 @@ weechat_ruby_api_config_option_check_value_cb (void *data, ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); + if (ruby_argv[1]) + free (ruby_argv[1]); return ret; } @@ -1482,23 +1522,24 @@ weechat_ruby_api_config_option_change_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *ruby_argv[2]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (option); - ruby_argv[1] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (option); + ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, script_callback->function, ruby_argv); - if (ruby_argv[0]) - free (ruby_argv[0]); + if (ruby_argv[1]) + free (ruby_argv[1]); if (rc) free (rc); @@ -1514,23 +1555,24 @@ weechat_ruby_api_config_option_delete_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *ruby_argv[2]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (option); - ruby_argv[1] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (option); + ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, script_callback->function, ruby_argv); - if (ruby_argv[0]) - free (ruby_argv[0]); + if (ruby_argv[1]) + free (ruby_argv[1]); if (rc) free (rc); @@ -1548,12 +1590,16 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file, VALUE min, VALUE max, VALUE default_value, VALUE value, VALUE null_value_allowed, VALUE function_check_value, + VALUE data_check_value, VALUE function_change, - VALUE function_delete) + VALUE data_change, + VALUE function_delete, + VALUE data_delete) { char *c_config_file, *c_section, *c_name, *c_type, *c_description; char *c_string_values, *c_default_value, *c_value, *result; - char *c_function_check_value, *c_function_change, *c_function_delete; + char *c_function_check_value, *c_data_check_value, *c_function_change; + char *c_data_change, *c_function_delete, *c_data_delete; int c_min, c_max, c_null_value_allowed; VALUE return_value; @@ -1562,7 +1608,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_new_option"); RUBY_RETURN_EMPTY; } @@ -1578,16 +1624,20 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file, c_value = NULL; c_null_value_allowed = 0; c_function_check_value = NULL; + c_data_check_value = NULL; c_function_change = NULL; + c_data_change = NULL; c_function_delete = NULL; + c_data_delete = NULL; if (NIL_P (config_file) || NIL_P (section) || NIL_P (name) || NIL_P (type) || NIL_P (description) || NIL_P (string_values) || NIL_P (default_value) || NIL_P (value) || NIL_P (null_value_allowed) - || NIL_P (function_check_value) || NIL_P (function_change) - || NIL_P (function_delete)) + || NIL_P (function_check_value) || NIL_P (data_check_value) + || NIL_P (function_change) || NIL_P (data_change) + || NIL_P (function_delete) || NIL_P (data_delete)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_new_option"); RUBY_RETURN_EMPTY; } @@ -1603,8 +1653,11 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file, Check_Type (value, T_STRING); Check_Type (null_value_allowed, T_FIXNUM); Check_Type (function_check_value, T_STRING); + Check_Type (data_check_value, T_STRING); Check_Type (function_change, T_STRING); + Check_Type (data_change, T_STRING); Check_Type (function_delete, T_STRING); + Check_Type (data_delete, T_STRING); c_config_file = STR2CSTR (config_file); c_section = STR2CSTR (section); @@ -1618,8 +1671,11 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file, c_value = STR2CSTR (value); c_null_value_allowed = FIX2INT (null_value_allowed); c_function_check_value = STR2CSTR (function_check_value); + c_data_check_value = STR2CSTR (data_check_value); c_function_change = STR2CSTR (function_change); + c_data_change = STR2CSTR (data_change); c_function_delete = STR2CSTR (function_delete); + c_data_delete = STR2CSTR (data_delete); result = script_ptr2str (script_api_config_new_option (weechat_ruby_plugin, ruby_current_script, @@ -1636,10 +1692,13 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file, c_null_value_allowed, &weechat_ruby_api_config_option_check_value_cb, c_function_check_value, + c_data_check_value, &weechat_ruby_api_config_option_change_cb, c_function_change, + c_data_change, &weechat_ruby_api_config_option_delete_cb, - c_function_delete)); + c_function_delete, + c_data_delete)); RUBY_RETURN_STRING_FREE(result); } @@ -1660,7 +1719,7 @@ weechat_ruby_api_config_search_option (VALUE class, VALUE config_file, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_search_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_search_option"); RUBY_RETURN_EMPTY; } @@ -1670,7 +1729,7 @@ weechat_ruby_api_config_search_option (VALUE class, VALUE config_file, if (NIL_P (config_file) || NIL_P (section) || NIL_P (option_name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_search_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_search_option"); RUBY_RETURN_EMPTY; } @@ -1704,7 +1763,7 @@ weechat_ruby_api_config_string_to_boolean (VALUE class, VALUE text) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string_to_boolean"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_string_to_boolean"); RUBY_RETURN_INT(0); } @@ -1712,7 +1771,7 @@ weechat_ruby_api_config_string_to_boolean (VALUE class, VALUE text) if (NIL_P (text)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string_to_boolean"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_string_to_boolean"); RUBY_RETURN_INT(0); } @@ -1741,7 +1800,7 @@ weechat_ruby_api_config_option_reset (VALUE class, VALUE option, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_reset"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_option_reset"); RUBY_RETURN_INT(0); } @@ -1750,7 +1809,7 @@ weechat_ruby_api_config_option_reset (VALUE class, VALUE option, if (NIL_P (option) || NIL_P (run_callback)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_option_reset"); RUBY_RETURN_INT(0); } @@ -1782,7 +1841,7 @@ weechat_ruby_api_config_option_set (VALUE class, VALUE option, VALUE new_value, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_option_set"); RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1792,7 +1851,7 @@ weechat_ruby_api_config_option_set (VALUE class, VALUE option, VALUE new_value, if (NIL_P (option) || NIL_P (new_value) || NIL_P (run_callback)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_option_set"); RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1828,7 +1887,7 @@ weechat_ruby_api_config_option_set_null (VALUE class, VALUE option, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_option_set_null"); RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1837,7 +1896,7 @@ weechat_ruby_api_config_option_set_null (VALUE class, VALUE option, if (NIL_P (option) || NIL_P (run_callback)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_option_set_null"); RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -1868,7 +1927,7 @@ weechat_ruby_api_config_option_unset (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_option_unset"); RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -1876,7 +1935,7 @@ weechat_ruby_api_config_option_unset (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_option_unset"); RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -1904,7 +1963,7 @@ weechat_ruby_api_config_option_rename (VALUE class, VALUE option, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_option_rename"); RUBY_RETURN_ERROR; } @@ -1913,7 +1972,7 @@ weechat_ruby_api_config_option_rename (VALUE class, VALUE option, if (NIL_P (option) || NIL_P (new_name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_rename"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_option_rename"); RUBY_RETURN_ERROR; } @@ -1944,7 +2003,7 @@ weechat_ruby_api_config_option_is_null (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_option_is_null"); RUBY_RETURN_INT(1); } @@ -1952,7 +2011,7 @@ weechat_ruby_api_config_option_is_null (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_option_is_null"); RUBY_RETURN_INT(1); } @@ -1980,7 +2039,7 @@ weechat_ruby_api_config_option_default_is_null (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_option_default_is_null"); RUBY_RETURN_INT(1); } @@ -1988,7 +2047,7 @@ weechat_ruby_api_config_option_default_is_null (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_option_default_is_null"); RUBY_RETURN_INT(1); } @@ -2016,7 +2075,7 @@ weechat_ruby_api_config_boolean (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_boolean"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_boolean"); RUBY_RETURN_INT(0); } @@ -2024,7 +2083,7 @@ weechat_ruby_api_config_boolean (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_boolean"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_boolean"); RUBY_RETURN_INT(0); } @@ -2052,7 +2111,7 @@ weechat_ruby_api_config_boolean_default (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_boolean_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_boolean_default"); RUBY_RETURN_INT(0); } @@ -2060,7 +2119,7 @@ weechat_ruby_api_config_boolean_default (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_boolean_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_boolean_default"); RUBY_RETURN_INT(0); } @@ -2088,7 +2147,7 @@ weechat_ruby_api_config_integer (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_integer"); RUBY_RETURN_INT(0); } @@ -2096,7 +2155,7 @@ weechat_ruby_api_config_integer (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_integer"); RUBY_RETURN_INT(0); } @@ -2124,7 +2183,7 @@ weechat_ruby_api_config_integer_default (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_integer_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_integer_default"); RUBY_RETURN_INT(0); } @@ -2132,7 +2191,7 @@ weechat_ruby_api_config_integer_default (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_integer_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_integer_default"); RUBY_RETURN_INT(0); } @@ -2160,7 +2219,7 @@ weechat_ruby_api_config_string (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_string"); RUBY_RETURN_EMPTY; } @@ -2168,7 +2227,7 @@ weechat_ruby_api_config_string (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_string"); RUBY_RETURN_EMPTY; } @@ -2196,7 +2255,7 @@ weechat_ruby_api_config_string_default (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_string_default"); RUBY_RETURN_EMPTY; } @@ -2204,7 +2263,7 @@ weechat_ruby_api_config_string_default (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_string_default"); RUBY_RETURN_EMPTY; } @@ -2232,7 +2291,7 @@ weechat_ruby_api_config_color (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_color"); RUBY_RETURN_INT(0); } @@ -2240,7 +2299,7 @@ weechat_ruby_api_config_color (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_color"); RUBY_RETURN_INT(0); } @@ -2268,7 +2327,7 @@ weechat_ruby_api_config_color_default (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_color_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_color_default"); RUBY_RETURN_INT(0); } @@ -2276,7 +2335,7 @@ weechat_ruby_api_config_color_default (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_color_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_color_default"); RUBY_RETURN_INT(0); } @@ -2304,7 +2363,7 @@ weechat_ruby_api_config_write_option (VALUE class, VALUE config_file, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_write_option"); RUBY_RETURN_ERROR; } @@ -2313,7 +2372,7 @@ weechat_ruby_api_config_write_option (VALUE class, VALUE config_file, if (NIL_P (config_file) || NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_write_option"); RUBY_RETURN_ERROR; } @@ -2344,7 +2403,7 @@ weechat_ruby_api_config_write_line (VALUE class, VALUE config_file, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_line"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_write_line"); RUBY_RETURN_ERROR; } @@ -2354,7 +2413,7 @@ weechat_ruby_api_config_write_line (VALUE class, VALUE config_file, if (NIL_P (config_file) || NIL_P (option_name) || NIL_P (value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_line"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_write_line"); RUBY_RETURN_ERROR; } @@ -2389,7 +2448,7 @@ weechat_ruby_api_config_write (VALUE class, VALUE config_file) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_write"); RUBY_RETURN_INT(-1); } @@ -2397,7 +2456,7 @@ weechat_ruby_api_config_write (VALUE class, VALUE config_file) if (NIL_P (config_file)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_write"); RUBY_RETURN_INT(-1); } @@ -2425,7 +2484,7 @@ weechat_ruby_api_config_read (VALUE class, VALUE config_file) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_read"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_read"); RUBY_RETURN_INT(-1); } @@ -2433,7 +2492,7 @@ weechat_ruby_api_config_read (VALUE class, VALUE config_file) if (NIL_P (config_file)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_read"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_read"); RUBY_RETURN_INT(-1); } @@ -2461,7 +2520,7 @@ weechat_ruby_api_config_reload (VALUE class, VALUE config_file) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_reload"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_reload"); RUBY_RETURN_INT(-1); } @@ -2469,7 +2528,7 @@ weechat_ruby_api_config_reload (VALUE class, VALUE config_file) if (NIL_P (config_file)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_reload"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_reload"); RUBY_RETURN_INT(-1); } @@ -2496,7 +2555,7 @@ weechat_ruby_api_config_option_free (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_option_free"); RUBY_RETURN_ERROR; } @@ -2504,7 +2563,7 @@ weechat_ruby_api_config_option_free (VALUE class, VALUE option) if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_option_free"); RUBY_RETURN_ERROR; } @@ -2534,7 +2593,7 @@ weechat_ruby_api_config_section_free_options (VALUE class, VALUE section) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free_options"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_section_free_options"); RUBY_RETURN_ERROR; } @@ -2542,7 +2601,7 @@ weechat_ruby_api_config_section_free_options (VALUE class, VALUE section) if (NIL_P (section)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free_options"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_section_free_options"); RUBY_RETURN_ERROR; } @@ -2571,7 +2630,7 @@ weechat_ruby_api_config_section_free (VALUE class, VALUE section) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_section_free"); RUBY_RETURN_ERROR; } @@ -2579,7 +2638,7 @@ weechat_ruby_api_config_section_free (VALUE class, VALUE section) if (NIL_P (section)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_section_free"); RUBY_RETURN_ERROR; } @@ -2608,7 +2667,7 @@ weechat_ruby_api_config_free (VALUE class, VALUE config_file) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_free"); RUBY_RETURN_ERROR; } @@ -2616,7 +2675,7 @@ weechat_ruby_api_config_free (VALUE class, VALUE config_file) if (NIL_P (config_file)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_free"); RUBY_RETURN_ERROR; } @@ -2646,13 +2705,13 @@ weechat_ruby_api_config_get (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_get"); RUBY_RETURN_EMPTY; } if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_get"); RUBY_RETURN_EMPTY; } @@ -2680,13 +2739,13 @@ weechat_ruby_api_config_get_plugin (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_get_plugin"); RUBY_RETURN_EMPTY; } if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_get_plugin"); RUBY_RETURN_EMPTY; } @@ -2716,13 +2775,13 @@ weechat_ruby_api_config_set_plugin (VALUE class, VALUE option, VALUE value) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_set_plugin"); RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } if (NIL_P (option) || NIL_P (value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_set_plugin"); RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -2755,13 +2814,13 @@ weechat_ruby_api_config_unset_plugin (VALUE class, VALUE option) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_unset_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_unset_plugin"); RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } if (NIL_P (option)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_unset_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_unset_plugin"); RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -2791,7 +2850,7 @@ weechat_ruby_api_prefix (VALUE class, VALUE prefix) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("prefix"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "prefix"); RUBY_RETURN_EMPTY; } @@ -2799,7 +2858,7 @@ weechat_ruby_api_prefix (VALUE class, VALUE prefix) if (NIL_P (prefix)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prefix"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "prefix"); RUBY_RETURN_EMPTY; } @@ -2827,7 +2886,7 @@ weechat_ruby_api_color (VALUE class, VALUE color) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "color"); RUBY_RETURN_EMPTY; } @@ -2835,7 +2894,7 @@ weechat_ruby_api_color (VALUE class, VALUE color) if (NIL_P (color)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "color"); RUBY_RETURN_EMPTY; } @@ -2865,7 +2924,7 @@ weechat_ruby_api_print (VALUE class, VALUE buffer, VALUE message) if (NIL_P (buffer) || NIL_P (message)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "print"); RUBY_RETURN_ERROR; } @@ -2900,7 +2959,7 @@ weechat_ruby_api_print_date_tags (VALUE class, VALUE buffer, VALUE date, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print_date_tags"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "print_date_tags"); RUBY_RETURN_ERROR; } @@ -2911,7 +2970,7 @@ weechat_ruby_api_print_date_tags (VALUE class, VALUE buffer, VALUE date, if (NIL_P (buffer) || NIL_P (date) || NIL_P (tags) || NIL_P (message)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_date_tags"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "print_date_tags"); RUBY_RETURN_ERROR; } @@ -2950,7 +3009,7 @@ weechat_ruby_api_print_y (VALUE class, VALUE buffer, VALUE y, VALUE message) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print_y"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "print_y"); RUBY_RETURN_ERROR; } @@ -2960,7 +3019,7 @@ weechat_ruby_api_print_y (VALUE class, VALUE buffer, VALUE y, VALUE message) if (NIL_P (buffer) || NIL_P (message)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_y"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "print_y"); RUBY_RETURN_ERROR; } @@ -2995,7 +3054,7 @@ weechat_ruby_api_log_print (VALUE class, VALUE message) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("log_print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "log_print"); RUBY_RETURN_ERROR; } @@ -3003,7 +3062,7 @@ weechat_ruby_api_log_print (VALUE class, VALUE message) if (NIL_P (message)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("log_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "log_print"); RUBY_RETURN_ERROR; } @@ -3027,7 +3086,7 @@ weechat_ruby_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { struct t_script_callback *script_callback; - char *ruby_argv[3], empty_arg[1] = { '\0' }; + char *ruby_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; /* make C compiler happy */ @@ -3037,9 +3096,10 @@ weechat_ruby_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (buffer); - ruby_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg; - ruby_argv[2] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (buffer); + ruby_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; + ruby_argv[3] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3053,8 +3113,8 @@ weechat_ruby_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); + if (ruby_argv[1]) + free (ruby_argv[1]); return ret; } @@ -3069,10 +3129,10 @@ weechat_ruby_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, static VALUE weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description, VALUE args, VALUE args_description, - VALUE completion, VALUE function) + VALUE completion, VALUE function, VALUE data) { char *c_command, *c_description, *c_args, *c_args_description; - char *c_completion, *c_function, *result; + char *c_completion, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -3080,7 +3140,7 @@ weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_command"); RUBY_RETURN_EMPTY; } @@ -3090,11 +3150,13 @@ weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description, c_args_description = NULL; c_completion = NULL; c_function = NULL; + c_data = NULL; if (NIL_P (command) || NIL_P (description) || NIL_P (args) - || NIL_P (args_description) || NIL_P (completion) || NIL_P (function)) + || NIL_P (args_description) || NIL_P (completion) || NIL_P (function) + || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_command"); RUBY_RETURN_EMPTY; } @@ -3104,6 +3166,7 @@ weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description, Check_Type (args_description, T_STRING); Check_Type (completion, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_command = STR2CSTR (command); c_description = STR2CSTR (description); @@ -3111,6 +3174,7 @@ weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description, c_args_description = STR2CSTR (args_description); c_completion = STR2CSTR (completion); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_command (weechat_ruby_plugin, ruby_current_script, @@ -3120,7 +3184,8 @@ weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description, c_args_description, c_completion, &weechat_ruby_api_hook_command_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -3134,16 +3199,17 @@ weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, const char *command) { struct t_script_callback *script_callback; - char *ruby_argv[3], empty_arg[1] = { '\0' }; + char *ruby_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (buffer); - ruby_argv[1] = (command) ? (char *)command : empty_arg; - ruby_argv[2] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (buffer); + ruby_argv[2] = (command) ? (char *)command : empty_arg; + ruby_argv[3] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3157,8 +3223,8 @@ weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); + if (ruby_argv[1]) + free (ruby_argv[1]); return ret; } @@ -3171,9 +3237,10 @@ weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, */ static VALUE -weechat_ruby_api_hook_command_run (VALUE class, VALUE command, VALUE function) +weechat_ruby_api_hook_command_run (VALUE class, VALUE command, VALUE function, + VALUE data) { - char *c_command, *c_function, *result; + char *c_command, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -3181,30 +3248,34 @@ weechat_ruby_api_hook_command_run (VALUE class, VALUE command, VALUE function) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command_run"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_command_run"); RUBY_RETURN_EMPTY; } c_command = NULL; c_function = NULL; + c_data = NULL; - if (NIL_P (command) || NIL_P (function)) + if (NIL_P (command) || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command_run"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_command_run"); RUBY_RETURN_EMPTY; } Check_Type (command, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_command = STR2CSTR (command); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_command_run (weechat_ruby_plugin, ruby_current_script, c_command, &weechat_ruby_api_hook_command_run_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -3217,7 +3288,7 @@ int weechat_ruby_api_hook_timer_cb (void *data, int remaining_calls) { struct t_script_callback *script_callback; - char *ruby_argv[2], str_remaining_calls[32]; + char *ruby_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3227,8 +3298,9 @@ weechat_ruby_api_hook_timer_cb (void *data, int remaining_calls) snprintf (str_remaining_calls, sizeof (str_remaining_calls), "%d", remaining_calls); - ruby_argv[0] = str_remaining_calls; - ruby_argv[1] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = str_remaining_calls; + ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3255,10 +3327,10 @@ weechat_ruby_api_hook_timer_cb (void *data, int remaining_calls) static VALUE weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second, - VALUE max_calls, VALUE function) + VALUE max_calls, VALUE function, VALUE data) { int c_interval, c_align_second, c_max_calls; - char *c_function, *result; + char *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -3266,7 +3338,7 @@ weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_timer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_timer"); RUBY_RETURN_EMPTY; } @@ -3274,11 +3346,12 @@ weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second, c_align_second = 0; c_max_calls = 0; c_function = NULL; + c_data = NULL; if (NIL_P (interval) || NIL_P (align_second) || NIL_P (max_calls) - || NIL_P (function)) + || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_timer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_timer"); RUBY_RETURN_EMPTY; } @@ -3286,11 +3359,13 @@ weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second, Check_Type (align_second, T_FIXNUM); Check_Type (max_calls, T_FIXNUM); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_interval = FIX2INT (interval); c_align_second = FIX2INT (align_second); c_max_calls = FIX2INT (max_calls); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_timer (weechat_ruby_plugin, ruby_current_script, @@ -3298,7 +3373,8 @@ weechat_ruby_api_hook_timer (VALUE class, VALUE interval, VALUE align_second, c_align_second, c_max_calls, &weechat_ruby_api_hook_timer_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -3311,7 +3387,7 @@ int weechat_ruby_api_hook_fd_cb (void *data, int fd) { struct t_script_callback *script_callback; - char *ruby_argv[2], str_fd[32]; + char *ruby_argv[3], str_fd[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3320,8 +3396,9 @@ weechat_ruby_api_hook_fd_cb (void *data, int fd) { snprintf (str_fd, sizeof (str_fd), "%d", fd); - ruby_argv[0] = str_fd; - ruby_argv[1] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = str_fd; + ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3348,10 +3425,10 @@ weechat_ruby_api_hook_fd_cb (void *data, int fd) static VALUE weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write, - VALUE exception, VALUE function) + VALUE exception, VALUE function, VALUE data) { int c_fd, c_read, c_write, c_exception; - char *c_function, *result; + char *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -3359,7 +3436,7 @@ weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_fd"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_fd"); RUBY_RETURN_EMPTY; } @@ -3368,11 +3445,12 @@ weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write, c_write = 0; c_exception = 0; c_function = NULL; + c_data = NULL; if (NIL_P (fd) || NIL_P (read) || NIL_P (write) || NIL_P (exception) - || NIL_P (function)) + || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_fd"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_fd"); RUBY_RETURN_EMPTY; } @@ -3381,12 +3459,14 @@ weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write, Check_Type (write, T_FIXNUM); Check_Type (exception, T_FIXNUM); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_fd = FIX2INT (fd); c_read = FIX2INT (read); c_write = FIX2INT (write); c_exception = FIX2INT (exception); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_fd (weechat_ruby_plugin, ruby_current_script, @@ -3395,7 +3475,8 @@ weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write, c_write, c_exception, &weechat_ruby_api_hook_fd_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -3410,7 +3491,7 @@ weechat_ruby_api_hook_process_cb (void *data, const char *stdout, const char *stderr) { struct t_script_callback *script_callback; - char *ruby_argv[5], str_rc[32], empty_arg[1] = { '\0' }; + char *ruby_argv[6], str_rc[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3419,11 +3500,12 @@ weechat_ruby_api_hook_process_cb (void *data, { snprintf (str_rc, sizeof (str_rc), "%d", return_code); - ruby_argv[0] = (command) ? (char *)command : empty_arg; - ruby_argv[1] = str_rc; - ruby_argv[2] = (stdout) ? (char *)stdout : empty_arg; - ruby_argv[3] = (stderr) ? (char *)stderr : empty_arg; - ruby_argv[4] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = (command) ? (char *)command : empty_arg; + ruby_argv[2] = str_rc; + ruby_argv[3] = (stdout) ? (char *)stdout : empty_arg; + ruby_argv[4] = (stderr) ? (char *)stderr : empty_arg; + ruby_argv[5] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3450,9 +3532,9 @@ weechat_ruby_api_hook_process_cb (void *data, static VALUE weechat_ruby_api_hook_process (VALUE class, VALUE command, VALUE timeout, - VALUE function) + VALUE function, VALUE data) { - char *c_command, *c_function, *result; + char *c_command, *c_function, *c_data, *result; int c_timeout; VALUE return_value; @@ -3461,34 +3543,38 @@ weechat_ruby_api_hook_process (VALUE class, VALUE command, VALUE timeout, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_process"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_process"); RUBY_RETURN_EMPTY; } c_command = NULL; c_timeout = 0; c_function = NULL; + c_data = NULL; - if (NIL_P (command) || NIL_P (timeout) || NIL_P (function)) + if (NIL_P (command) || NIL_P (timeout) || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_process"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_process"); RUBY_RETURN_EMPTY; } Check_Type (command, T_STRING); Check_Type (timeout, T_FIXNUM); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_command = STR2CSTR (command); c_timeout = FIX2INT (timeout); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_process (weechat_ruby_plugin, ruby_current_script, c_command, c_timeout, &weechat_ruby_api_hook_process_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -3502,7 +3588,7 @@ weechat_ruby_api_hook_connect_cb (void *data, int status, const char *error, const char *ip_address) { struct t_script_callback *script_callback; - char *ruby_argv[4], str_status[32], empty_arg[1] = { '\0' }; + char *ruby_argv[5], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3511,10 +3597,11 @@ weechat_ruby_api_hook_connect_cb (void *data, int status, { snprintf (str_status, sizeof (str_status), "%d", status); - ruby_argv[0] = str_status; - ruby_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; - ruby_argv[2] = (error) ? (char *)error : empty_arg; - ruby_argv[3] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = str_status; + ruby_argv[2] = (ip_address) ? (char *)ip_address : empty_arg; + ruby_argv[3] = (error) ? (char *)error : empty_arg; + ruby_argv[4] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3542,9 +3629,10 @@ weechat_ruby_api_hook_connect_cb (void *data, int status, static VALUE weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address, VALUE port, VALUE sock, VALUE ipv6, - VALUE local_hostname, VALUE function) + VALUE local_hostname, VALUE function, + VALUE data) { - char *c_proxy, *c_address, *c_local_hostname, *c_function, *result; + char *c_proxy, *c_address, *c_local_hostname, *c_function, *c_data, *result; int c_port, c_sock, c_ipv6; VALUE return_value; @@ -3553,7 +3641,7 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_connect"); RUBY_RETURN_EMPTY; } @@ -3564,11 +3652,13 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address, c_ipv6 = 0; c_local_hostname = NULL; c_function = NULL; + c_data = NULL; if (NIL_P (proxy) || NIL_P (address) || NIL_P (port) || NIL_P (sock) - || NIL_P (ipv6) || NIL_P (local_hostname) || NIL_P (function)) + || NIL_P (ipv6) || NIL_P (local_hostname) || NIL_P (function) + || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_connect"); RUBY_RETURN_EMPTY; } @@ -3579,6 +3669,7 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address, Check_Type (ipv6, T_FIXNUM); Check_Type (local_hostname, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_proxy = STR2CSTR (proxy); c_address = STR2CSTR (address); @@ -3587,6 +3678,7 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address, c_ipv6 = FIX2INT (ipv6); c_local_hostname = STR2CSTR (local_hostname); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_connect (weechat_ruby_plugin, ruby_current_script, @@ -3598,7 +3690,8 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address, NULL, /* gnutls session */ c_local_hostname, &weechat_ruby_api_hook_connect_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -3615,7 +3708,7 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *ruby_argv[8], empty_arg[1] = { '\0' }; + char *ruby_argv[9], empty_arg[1] = { '\0' }; static char timebuffer[64]; int *rc, ret; @@ -3628,16 +3721,17 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, { snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); - ruby_argv[0] = script_ptr2str (buffer); - ruby_argv[1] = timebuffer; - ruby_argv[2] = weechat_string_build_with_exploded (tags, ","); - if (!ruby_argv[2]) - ruby_argv[2] = strdup (""); - ruby_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); - ruby_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); - ruby_argv[5] = (prefix) ? (char *)prefix : empty_arg; - ruby_argv[6] = (message) ? (char *)message : empty_arg; - ruby_argv[7] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (buffer); + ruby_argv[2] = timebuffer; + ruby_argv[3] = weechat_string_build_with_exploded (tags, ","); + if (!ruby_argv[3]) + ruby_argv[3] = strdup (""); + ruby_argv[4] = (displayed) ? strdup ("1") : strdup ("0"); + ruby_argv[5] = (highlight) ? strdup ("1") : strdup ("0"); + ruby_argv[6] = (prefix) ? (char *)prefix : empty_arg; + ruby_argv[7] = (message) ? (char *)message : empty_arg; + ruby_argv[8] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3651,14 +3745,14 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); - if (ruby_argv[2]) - free (ruby_argv[2]); + if (ruby_argv[1]) + free (ruby_argv[1]); if (ruby_argv[3]) free (ruby_argv[3]); if (ruby_argv[4]) free (ruby_argv[4]); + if (ruby_argv[5]) + free (ruby_argv[5]); return ret; } @@ -3672,9 +3766,10 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, static VALUE weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE tags, - VALUE message, VALUE strip_colors, VALUE function) + VALUE message, VALUE strip_colors, VALUE function, + VALUE data) { - char *c_buffer, *c_tags, *c_message, *c_function, *result; + char *c_buffer, *c_tags, *c_message, *c_function, *c_data, *result; int c_strip_colors; VALUE return_value; @@ -3683,7 +3778,7 @@ weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE tags, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_print"); RUBY_RETURN_EMPTY; } @@ -3692,11 +3787,12 @@ weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE tags, c_message = NULL; c_strip_colors = 0; c_function = NULL; + c_data = NULL; if (NIL_P (buffer) || NIL_P (tags) || NIL_P (message) - || NIL_P (strip_colors) || NIL_P (function)) + || NIL_P (strip_colors) || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_print"); RUBY_RETURN_EMPTY; } @@ -3705,12 +3801,14 @@ weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE tags, Check_Type (message, T_STRING); Check_Type (strip_colors, T_FIXNUM); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_buffer = STR2CSTR (buffer); c_tags = STR2CSTR (tags); c_message = STR2CSTR (message); c_strip_colors = FIX2INT (strip_colors); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_print (weechat_ruby_plugin, ruby_current_script, @@ -3719,7 +3817,8 @@ weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE tags, c_message, c_strip_colors, &weechat_ruby_api_hook_print_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -3733,7 +3832,7 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ void *signal_data) { struct t_script_callback *script_callback; - char *ruby_argv[3], empty_arg[1] = { '\0' }; + char *ruby_argv[4], empty_arg[1] = { '\0' }; static char value_str[64]; int *rc, ret, free_needed; @@ -3741,26 +3840,27 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (char *)signal; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = (signal) ? (char *)signal : empty_arg; free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { - ruby_argv[1] = (signal_data) ? (char *)signal_data : empty_arg; + ruby_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { snprintf (value_str, sizeof (value_str) - 1, "%d", *((int *)signal_data)); - ruby_argv[1] = value_str; + ruby_argv[2] = value_str; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - ruby_argv[1] = script_ptr2str (signal_data); + ruby_argv[2] = script_ptr2str (signal_data); free_needed = 1; } else - ruby_argv[1] = empty_arg; - ruby_argv[2] = NULL; + ruby_argv[2] = empty_arg; + ruby_argv[3] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3774,8 +3874,8 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ ret = *rc; free (rc); } - if (free_needed && ruby_argv[1]) - free (ruby_argv[1]); + if (free_needed && ruby_argv[2]) + free (ruby_argv[2]); return ret; } @@ -3788,9 +3888,10 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ */ static VALUE -weechat_ruby_api_hook_signal (VALUE class, VALUE signal, VALUE function) +weechat_ruby_api_hook_signal (VALUE class, VALUE signal, VALUE function, + VALUE data) { - char *c_signal, *c_function, *result; + char *c_signal, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -3798,30 +3899,34 @@ weechat_ruby_api_hook_signal (VALUE class, VALUE signal, VALUE function) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_signal"); RUBY_RETURN_EMPTY; } c_signal = NULL; c_function = NULL; + c_data = NULL; - if (NIL_P (signal) || NIL_P (function)) + if (NIL_P (signal) || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_signal"); RUBY_RETURN_EMPTY; } Check_Type (signal, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_signal = STR2CSTR (signal); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_signal (weechat_ruby_plugin, ruby_current_script, c_signal, &weechat_ruby_api_hook_signal_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -3842,7 +3947,7 @@ weechat_ruby_api_hook_signal_send (VALUE class, VALUE signal, VALUE type_data, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal_send"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_signal_send"); RUBY_RETURN_ERROR; } @@ -3852,7 +3957,7 @@ weechat_ruby_api_hook_signal_send (VALUE class, VALUE signal, VALUE type_data, if (NIL_P (signal) || NIL_P (type_data) || NIL_P (signal_data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal_send"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_signal_send"); RUBY_RETURN_ERROR; } @@ -3896,16 +4001,17 @@ int weechat_ruby_api_hook_config_cb (void *data, const char *option, const char *value) { struct t_script_callback *script_callback; - char *ruby_argv[3], empty_arg[1] = { '\0' }; + char *ruby_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (option) ? (char *)option : empty_arg; - ruby_argv[1] = (value) ? (char *)value : empty_arg; - ruby_argv[2] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = (option) ? (char *)option : empty_arg; + ruby_argv[2] = (value) ? (char *)value : empty_arg; + ruby_argv[3] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3931,9 +4037,10 @@ weechat_ruby_api_hook_config_cb (void *data, const char *option, const char *val */ static VALUE -weechat_ruby_api_hook_config (VALUE class, VALUE option, VALUE function) +weechat_ruby_api_hook_config (VALUE class, VALUE option, VALUE function, + VALUE data) { - char *c_option, *c_function, *result; + char *c_option, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -3941,30 +4048,34 @@ weechat_ruby_api_hook_config (VALUE class, VALUE option, VALUE function) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_config"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_config"); RUBY_RETURN_EMPTY; } c_option = NULL; c_function = NULL; + c_data = NULL; - if (NIL_P (option) || NIL_P (function)) + if (NIL_P (option) || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_config"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_config"); RUBY_RETURN_EMPTY; } Check_Type (option, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_option = STR2CSTR (option); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_config (weechat_ruby_plugin, ruby_current_script, c_option, &weechat_ruby_api_hook_config_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -3979,17 +4090,18 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_script_callback *script_callback; - char *ruby_argv[4], empty_arg[1] = { '\0' }; + char *ruby_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (completion_item) ? (char *)completion_item : empty_arg; - ruby_argv[1] = script_ptr2str (buffer); - ruby_argv[2] = script_ptr2str (completion); - ruby_argv[3] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; + ruby_argv[2] = script_ptr2str (buffer); + ruby_argv[3] = script_ptr2str (completion); + ruby_argv[4] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -4003,10 +4115,10 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item, ret = *rc; free (rc); } - if (ruby_argv[1]) - free (ruby_argv[1]); if (ruby_argv[2]) free (ruby_argv[2]); + if (ruby_argv[3]) + free (ruby_argv[3]); return ret; } @@ -4020,9 +4132,10 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item, static VALUE weechat_ruby_api_hook_completion (VALUE class, VALUE completion, - VALUE description, VALUE function) + VALUE description, VALUE function, + VALUE data) { - char *c_completion, *c_description, *c_function, *result; + char *c_completion, *c_description, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -4030,34 +4143,39 @@ weechat_ruby_api_hook_completion (VALUE class, VALUE completion, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_completion"); RUBY_RETURN_EMPTY; } c_completion = NULL; c_description = NULL; c_function = NULL; + c_data = NULL; - if (NIL_P (completion) || NIL_P (description) || NIL_P (function)) + if (NIL_P (completion) || NIL_P (description) || NIL_P (function) + || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_completion"); RUBY_RETURN_EMPTY; } Check_Type (completion, T_STRING); Check_Type (description, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_completion = STR2CSTR (completion); c_description = STR2CSTR (description); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_completion (weechat_ruby_plugin, ruby_current_script, c_completion, c_description, &weechat_ruby_api_hook_completion_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -4079,7 +4197,7 @@ weechat_ruby_api_hook_completion_list_add (VALUE class, VALUE completion, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); RUBY_RETURN_ERROR; } @@ -4091,7 +4209,7 @@ weechat_ruby_api_hook_completion_list_add (VALUE class, VALUE completion, if (NIL_P (completion) || NIL_P (word) || NIL_P (nick_completion) || NIL_P (where)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); RUBY_RETURN_ERROR; } @@ -4122,16 +4240,17 @@ weechat_ruby_api_hook_modifier_cb (void *data, const char *modifier, const char *modifier_data, const char *string) { struct t_script_callback *script_callback; - char *ruby_argv[4], empty_arg[1] = { '\0' }; + char *ruby_argv[5], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (modifier) ? (char *)modifier : empty_arg; - ruby_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg; - ruby_argv[2] = (string) ? (char *)string : empty_arg; - ruby_argv[3] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = (modifier) ? (char *)modifier : empty_arg; + ruby_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg; + ruby_argv[3] = (string) ? (char *)string : empty_arg; + ruby_argv[4] = NULL; return (char *)weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -4147,9 +4266,10 @@ weechat_ruby_api_hook_modifier_cb (void *data, const char *modifier, */ static VALUE -weechat_ruby_api_hook_modifier (VALUE class, VALUE modifier, VALUE function) +weechat_ruby_api_hook_modifier (VALUE class, VALUE modifier, VALUE function, + VALUE data) { - char *c_modifier, *c_function, *result; + char *c_modifier, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -4157,30 +4277,34 @@ weechat_ruby_api_hook_modifier (VALUE class, VALUE modifier, VALUE function) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_modifier"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_modifier"); RUBY_RETURN_EMPTY; } c_modifier = NULL; c_function = NULL; + c_data = NULL; - if (NIL_P (modifier) || NIL_P (function)) + if (NIL_P (modifier) || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_modifier"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_modifier"); RUBY_RETURN_EMPTY; } Check_Type (modifier, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_modifier = STR2CSTR (modifier); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_modifier (weechat_ruby_plugin, ruby_current_script, c_modifier, &weechat_ruby_api_hook_modifier_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -4201,7 +4325,7 @@ weechat_ruby_api_hook_modifier_exec (VALUE class, VALUE modifier, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_modifier_exec"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_modifier_exec"); RUBY_RETURN_EMPTY; } @@ -4211,7 +4335,7 @@ weechat_ruby_api_hook_modifier_exec (VALUE class, VALUE modifier, if (NIL_P (modifier) || NIL_P (modifier_data) || NIL_P (string)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_modifier_exec"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_modifier_exec"); RUBY_RETURN_EMPTY; } @@ -4237,15 +4361,16 @@ weechat_ruby_api_hook_info_cb (void *data, const char *info_name, const char *arguments) { struct t_script_callback *script_callback; - char *ruby_argv[3], empty_arg[1] = { '\0' }; + char *ruby_argv[4], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (info_name) ? (char *)info_name : empty_arg; - ruby_argv[1] = (arguments) ? (char *)arguments : empty_arg; - ruby_argv[2] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = (info_name) ? (char *)info_name : empty_arg; + ruby_argv[2] = (arguments) ? (char *)arguments : empty_arg; + ruby_argv[3] = NULL; return (const char *)weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -4262,9 +4387,9 @@ 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 function, VALUE data) { - char *c_info_name, *c_description, *c_function, *result; + char *c_info_name, *c_description, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -4272,34 +4397,39 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_info"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_info"); RUBY_RETURN_EMPTY; } c_info_name = NULL; c_description = NULL; c_function = NULL; + c_data = NULL; - if (NIL_P (info_name) || NIL_P (description) || NIL_P (function)) + if (NIL_P (info_name) || NIL_P (description) || NIL_P (function) + || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_info"); RUBY_RETURN_EMPTY; } Check_Type (info_name, T_STRING); Check_Type (description, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_info_name = STR2CSTR (info_name); c_description = STR2CSTR (description); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_info (weechat_ruby_plugin, ruby_current_script, c_info_name, c_description, &weechat_ruby_api_hook_info_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -4313,25 +4443,26 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_script_callback *script_callback; - char *ruby_argv[4], empty_arg[1] = { '\0' }; + char *ruby_argv[5], empty_arg[1] = { '\0' }; struct t_infolist *result; script_callback = (struct t_script_callback *)data; - + if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = (infolist_name) ? (char *)infolist_name : empty_arg; - ruby_argv[1] = script_ptr2str (pointer); - ruby_argv[2] = (arguments) ? (char *)arguments : empty_arg; - ruby_argv[3] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; + ruby_argv[2] = script_ptr2str (pointer); + ruby_argv[3] = (arguments) ? (char *)arguments : empty_arg; + ruby_argv[4] = NULL; result = (struct t_infolist *)weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, script_callback->function, ruby_argv); - if (ruby_argv[1]) - free (ruby_argv[1]); + if (ruby_argv[2]) + free (ruby_argv[2]); return result; } @@ -4345,9 +4476,10 @@ 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 function, + VALUE data) { - char *c_infolist_name, *c_description, *c_function, *result; + char *c_infolist_name, *c_description, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -4355,34 +4487,39 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_infolist"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_infolist"); RUBY_RETURN_EMPTY; } c_infolist_name = NULL; c_description = NULL; c_function = NULL; + c_data = NULL; - if (NIL_P (infolist_name) || NIL_P (description) || NIL_P (function)) + if (NIL_P (infolist_name) || NIL_P (description) || NIL_P (function) + || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_infolist"); RUBY_RETURN_EMPTY; } Check_Type (infolist_name, T_STRING); Check_Type (description, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_infolist_name = STR2CSTR (infolist_name); c_description = STR2CSTR (description); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_hook_infolist (weechat_ruby_plugin, ruby_current_script, c_infolist_name, c_description, &weechat_ruby_api_hook_infolist_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -4401,7 +4538,7 @@ weechat_ruby_api_unhook (VALUE class, VALUE hook) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "unhook"); RUBY_RETURN_ERROR; } @@ -4409,7 +4546,7 @@ weechat_ruby_api_unhook (VALUE class, VALUE hook) if (NIL_P (hook)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("unhook"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "unhook"); RUBY_RETURN_ERROR; } @@ -4436,7 +4573,7 @@ weechat_ruby_api_unhook_all (VALUE class) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "unhook_all"); RUBY_RETURN_ERROR; } @@ -4454,16 +4591,17 @@ weechat_ruby_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { struct t_script_callback *script_callback; - char *ruby_argv[3], empty_arg[1] = { '\0' }; + char *ruby_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (buffer); - ruby_argv[1] = (input_data) ? (char *)input_data : empty_arg; - ruby_argv[2] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (buffer); + ruby_argv[2] = (input_data) ? (char *)input_data : empty_arg; + ruby_argv[3] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -4477,8 +4615,8 @@ weechat_ruby_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); + if (ruby_argv[1]) + free (ruby_argv[1]); return ret; } @@ -4494,15 +4632,16 @@ int weechat_ruby_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) { struct t_script_callback *script_callback; - char *ruby_argv[2]; + char *ruby_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (buffer); - ruby_argv[1] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (buffer); + ruby_argv[2] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -4516,8 +4655,8 @@ weechat_ruby_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); + if (ruby_argv[1]) + free (ruby_argv[1]); return ret; } @@ -4531,9 +4670,11 @@ weechat_ruby_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) static VALUE weechat_ruby_api_buffer_new (VALUE class, VALUE name, VALUE function_input, - VALUE function_close) + VALUE data_input, VALUE function_close, + VALUE data_close) { - char *c_name, *c_function_input, *c_function_close, *result; + char *c_name, *c_function_input, *c_data_input, *c_function_close; + char *c_data_close, *result; VALUE return_value; /* make C compiler happy */ @@ -4541,35 +4682,44 @@ weechat_ruby_api_buffer_new (VALUE class, VALUE name, VALUE function_input, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_new"); RUBY_RETURN_EMPTY; } c_name = NULL; c_function_input = NULL; + c_data_input = NULL; c_function_close = NULL; + c_data_close = NULL; - if (NIL_P (name) || NIL_P (function_input) || NIL_P (function_close)) + if (NIL_P (name) || NIL_P (function_input) || NIL_P (data_input) + || NIL_P (function_close) || NIL_P (data_close)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_new"); RUBY_RETURN_EMPTY; } Check_Type (name, T_STRING); Check_Type (function_input, T_STRING); + Check_Type (data_input, T_STRING); Check_Type (function_close, T_STRING); + Check_Type (data_close, T_STRING); c_name = STR2CSTR (name); c_function_input = STR2CSTR (function_input); + c_data_input = STR2CSTR (data_input); c_function_close = STR2CSTR (function_close); + c_data_close = STR2CSTR (data_close); result = script_ptr2str (script_api_buffer_new (weechat_ruby_plugin, ruby_current_script, c_name, &weechat_ruby_api_buffer_input_data_cb, c_function_input, + c_data_input, &weechat_ruby_api_buffer_close_cb, - c_function_close)); + c_function_close, + c_data_close)); RUBY_RETURN_STRING_FREE(result); } @@ -4589,7 +4739,7 @@ weechat_ruby_api_buffer_search (VALUE class, VALUE plugin, VALUE name) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_search"); RUBY_RETURN_EMPTY; } @@ -4598,7 +4748,7 @@ weechat_ruby_api_buffer_search (VALUE class, VALUE plugin, VALUE name) if (NIL_P (plugin) || NIL_P (name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_search"); RUBY_RETURN_EMPTY; } @@ -4628,7 +4778,7 @@ weechat_ruby_api_current_buffer (VALUE class) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_buffer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "current_buffer"); RUBY_RETURN_EMPTY; } @@ -4651,7 +4801,7 @@ weechat_ruby_api_buffer_clear (VALUE class, VALUE buffer) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_clear"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_clear"); RUBY_RETURN_ERROR; } @@ -4659,7 +4809,7 @@ weechat_ruby_api_buffer_clear (VALUE class, VALUE buffer) if (NIL_P (buffer)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_clear"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_clear"); RUBY_RETURN_ERROR; } @@ -4686,7 +4836,7 @@ weechat_ruby_api_buffer_close (VALUE class, VALUE buffer) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_close"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_close"); RUBY_RETURN_ERROR; } @@ -4694,7 +4844,7 @@ weechat_ruby_api_buffer_close (VALUE class, VALUE buffer) if (NIL_P (buffer)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_close"); RUBY_RETURN_ERROR; } @@ -4724,13 +4874,13 @@ weechat_ruby_api_buffer_get_integer (VALUE class, VALUE buffer, VALUE property) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_get_integer"); RUBY_RETURN_INT(-1); } if (NIL_P (buffer) || NIL_P (property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_get_integer"); RUBY_RETURN_INT(-1); } @@ -4761,13 +4911,13 @@ weechat_ruby_api_buffer_get_string (VALUE class, VALUE buffer, VALUE property) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_get_string"); RUBY_RETURN_EMPTY; } if (NIL_P (buffer) || NIL_P (property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_get_string"); RUBY_RETURN_EMPTY; } @@ -4798,13 +4948,13 @@ weechat_ruby_api_buffer_get_pointer (VALUE class, VALUE buffer, VALUE property) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_get_pointer"); RUBY_RETURN_EMPTY; } if (NIL_P (buffer) || NIL_P (property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_get_pointer"); RUBY_RETURN_EMPTY; } @@ -4835,13 +4985,13 @@ weechat_ruby_api_buffer_set (VALUE class, VALUE buffer, VALUE property, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_set"); RUBY_RETURN_ERROR; } if (NIL_P (buffer) || NIL_P (property) || NIL_P (value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_set"); RUBY_RETURN_ERROR; } @@ -4875,7 +5025,7 @@ weechat_ruby_api_current_window (VALUE class) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_window"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "current_window"); RUBY_RETURN_EMPTY; } @@ -4899,13 +5049,13 @@ weechat_ruby_api_window_get_integer (VALUE class, VALUE window, VALUE property) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "window_get_integer"); RUBY_RETURN_INT(-1); } if (NIL_P (window) || NIL_P (property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "window_get_integer"); RUBY_RETURN_INT(-1); } @@ -4936,13 +5086,13 @@ weechat_ruby_api_window_get_string (VALUE class, VALUE window, VALUE property) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "window_get_string"); RUBY_RETURN_EMPTY; } if (NIL_P (window) || NIL_P (property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "window_get_string"); RUBY_RETURN_EMPTY; } @@ -4973,13 +5123,13 @@ weechat_ruby_api_window_get_pointer (VALUE class, VALUE window, VALUE property) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "window_get_pointer"); RUBY_RETURN_EMPTY; } if (NIL_P (window) || NIL_P (property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "window_get_pointer"); RUBY_RETURN_EMPTY; } @@ -5013,7 +5163,7 @@ weechat_ruby_api_nicklist_add_group (VALUE class, VALUE buffer, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "nicklist_add_group"); RUBY_RETURN_EMPTY; } @@ -5026,7 +5176,7 @@ weechat_ruby_api_nicklist_add_group (VALUE class, VALUE buffer, if (NIL_P (buffer) || NIL_P (parent_group) || NIL_P (name) || NIL_P (color) || NIL_P (visible)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "nicklist_add_group"); RUBY_RETURN_EMPTY; } @@ -5067,7 +5217,7 @@ weechat_ruby_api_nicklist_search_group (VALUE class, VALUE buffer, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "nicklist_search_group"); RUBY_RETURN_EMPTY; } @@ -5077,7 +5227,7 @@ weechat_ruby_api_nicklist_search_group (VALUE class, VALUE buffer, if (NIL_P (buffer) || NIL_P (from_group) || NIL_P (name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "nicklist_search_group"); RUBY_RETURN_EMPTY; } @@ -5115,7 +5265,7 @@ weechat_ruby_api_nicklist_add_nick (VALUE class, VALUE buffer, VALUE group, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); RUBY_RETURN_EMPTY; } @@ -5130,7 +5280,7 @@ weechat_ruby_api_nicklist_add_nick (VALUE class, VALUE buffer, VALUE group, if (NIL_P (buffer) || NIL_P (group) || NIL_P (name) || NIL_P (color) || NIL_P (prefix) || NIL_P (prefix_color) || NIL_P (visible)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); RUBY_RETURN_EMPTY; } @@ -5177,7 +5327,7 @@ weechat_ruby_api_nicklist_search_nick (VALUE class, VALUE buffer, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "nicklist_search_nick"); RUBY_RETURN_EMPTY; } @@ -5187,7 +5337,7 @@ weechat_ruby_api_nicklist_search_nick (VALUE class, VALUE buffer, if (NIL_P (buffer) || NIL_P (from_group) || NIL_P (name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "nicklist_search_nick"); RUBY_RETURN_EMPTY; } @@ -5220,13 +5370,13 @@ weechat_ruby_api_nicklist_remove_group (VALUE class, VALUE buffer, VALUE group) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "nicklist_remove_group"); RUBY_RETURN_ERROR; } if (NIL_P (buffer) || NIL_P (group)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "nicklist_remove_group"); RUBY_RETURN_ERROR; } @@ -5256,13 +5406,13 @@ weechat_ruby_api_nicklist_remove_nick (VALUE class, VALUE buffer, VALUE nick) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "nicklist_remove_nick"); RUBY_RETURN_ERROR; } if (NIL_P (buffer) || NIL_P (nick)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "nicklist_remove_nick"); RUBY_RETURN_ERROR; } @@ -5292,13 +5442,13 @@ weechat_ruby_api_nicklist_remove_all (VALUE class, VALUE buffer) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "nicklist_remove_all"); RUBY_RETURN_ERROR; } if (NIL_P (buffer)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "nicklist_remove_all"); RUBY_RETURN_ERROR; } @@ -5326,7 +5476,7 @@ weechat_ruby_api_bar_item_search (VALUE class, VALUE name) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "bar_item_search"); RUBY_RETURN_EMPTY; } @@ -5334,7 +5484,7 @@ weechat_ruby_api_bar_item_search (VALUE class, VALUE name) if (NIL_P (name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "bar_item_search"); RUBY_RETURN_EMPTY; } @@ -5356,25 +5506,26 @@ weechat_ruby_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, struct t_gui_window *window) { struct t_script_callback *script_callback; - char *ruby_argv[3], *ret; + char *ruby_argv[4], empty_arg[1] = { '\0' }, *ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - ruby_argv[0] = script_ptr2str (item); - ruby_argv[1] = script_ptr2str (window); - ruby_argv[2] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (item); + ruby_argv[2] = script_ptr2str (window); + ruby_argv[3] = NULL; ret = (char *)weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, script_callback->function, ruby_argv); - if (ruby_argv[0]) - free (ruby_argv[0]); if (ruby_argv[1]) free (ruby_argv[1]); + if (ruby_argv[2]) + free (ruby_argv[2]); return ret; } @@ -5387,9 +5538,10 @@ weechat_ruby_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, */ static VALUE -weechat_ruby_api_bar_item_new (VALUE class, VALUE name, VALUE function) +weechat_ruby_api_bar_item_new (VALUE class, VALUE name, VALUE function, + VALUE data) { - char *c_name, *c_function, *result; + char *c_name, *c_function, *c_data, *result; VALUE return_value; /* make C compiler happy */ @@ -5397,30 +5549,34 @@ weechat_ruby_api_bar_item_new (VALUE class, VALUE name, VALUE function) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "bar_item_new"); RUBY_RETURN_EMPTY; } c_name = NULL; c_function = NULL; + c_data = NULL; - if (NIL_P (name) || NIL_P (function)) + if (NIL_P (name) || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "bar_item_new"); RUBY_RETURN_EMPTY; } Check_Type (name, T_STRING); Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_name = STR2CSTR (name); c_function = STR2CSTR (function); + c_data = STR2CSTR (data); result = script_ptr2str (script_api_bar_item_new (weechat_ruby_plugin, ruby_current_script, c_name, &weechat_ruby_api_bar_item_build_cb, - c_function)); + c_function, + c_data)); RUBY_RETURN_STRING_FREE(result); } @@ -5439,13 +5595,13 @@ weechat_ruby_api_bar_item_update (VALUE class, VALUE name) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_update"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "bar_item_update"); RUBY_RETURN_ERROR; } if (NIL_P (name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_update"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "bar_item_update"); RUBY_RETURN_ERROR; } @@ -5472,13 +5628,13 @@ weechat_ruby_api_bar_item_remove (VALUE class, VALUE item) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "bar_item_remove"); RUBY_RETURN_ERROR; } if (NIL_P (item)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "bar_item_remove"); RUBY_RETURN_ERROR; } @@ -5508,7 +5664,7 @@ weechat_ruby_api_bar_search (VALUE class, VALUE name) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "bar_search"); RUBY_RETURN_EMPTY; } @@ -5516,7 +5672,7 @@ weechat_ruby_api_bar_search (VALUE class, VALUE name) if (NIL_P (name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "bar_search"); RUBY_RETURN_EMPTY; } @@ -5552,7 +5708,7 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE hidden, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "bar_new"); RUBY_RETURN_EMPTY; } @@ -5578,7 +5734,7 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE hidden, || NIL_P (color_fg) || NIL_P (color_delim) || NIL_P (color_bg) || NIL_P (separator) || NIL_P (items)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "bar_new"); RUBY_RETURN_EMPTY; } @@ -5647,13 +5803,13 @@ weechat_ruby_api_bar_set (VALUE class, VALUE bar, VALUE property, VALUE value) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "bar_set"); RUBY_RETURN_ERROR; } if (NIL_P (bar) || NIL_P (property) || NIL_P (value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "bar_set"); RUBY_RETURN_ERROR; } @@ -5686,13 +5842,13 @@ weechat_ruby_api_bar_update (VALUE class, VALUE name) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_update"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "bar_update"); RUBY_RETURN_ERROR; } if (NIL_P (name)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_update"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "bar_update"); RUBY_RETURN_ERROR; } @@ -5719,13 +5875,13 @@ weechat_ruby_api_bar_remove (VALUE class, VALUE bar) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "bar_remove"); RUBY_RETURN_ERROR; } if (NIL_P (bar)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "bar_remove"); RUBY_RETURN_ERROR; } @@ -5752,13 +5908,13 @@ weechat_ruby_api_command (VALUE class, VALUE buffer, VALUE command) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("command"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "command"); RUBY_RETURN_ERROR; } if (NIL_P (buffer) || NIL_P (command)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "command"); RUBY_RETURN_ERROR; } @@ -5791,13 +5947,13 @@ weechat_ruby_api_info_get (VALUE class, VALUE info_name, VALUE arguments) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("info_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "info_get"); RUBY_RETURN_EMPTY; } if (NIL_P (info_name) || NIL_P (arguments)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("info_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "info_get"); RUBY_RETURN_EMPTY; } @@ -5827,7 +5983,7 @@ weechat_ruby_api_infolist_new (VALUE class) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_new"); RUBY_RETURN_EMPTY; } @@ -5854,13 +6010,13 @@ weechat_ruby_api_infolist_new_var_integer (VALUE class, VALUE infolist, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); RUBY_RETURN_EMPTY; } if (NIL_P (infolist) || NIL_P (name) || NIL_P (value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); RUBY_RETURN_EMPTY; } @@ -5896,13 +6052,13 @@ weechat_ruby_api_infolist_new_var_string (VALUE class, VALUE infolist, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_new_var_string"); RUBY_RETURN_EMPTY; } if (NIL_P (infolist) || NIL_P (name) || NIL_P (value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_new_var_string"); RUBY_RETURN_EMPTY; } @@ -5938,13 +6094,13 @@ weechat_ruby_api_infolist_new_var_pointer (VALUE class, VALUE infolist, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer"); RUBY_RETURN_EMPTY; } if (NIL_P (infolist) || NIL_P (name) || NIL_P (value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer"); RUBY_RETURN_EMPTY; } @@ -5980,13 +6136,13 @@ weechat_ruby_api_infolist_new_var_time (VALUE class, VALUE infolist, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); RUBY_RETURN_EMPTY; } if (NIL_P (infolist) || NIL_P (name) || NIL_P (value)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); RUBY_RETURN_EMPTY; } @@ -6021,13 +6177,13 @@ weechat_ruby_api_infolist_get (VALUE class, VALUE name, VALUE pointer, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_get"); RUBY_RETURN_EMPTY; } if (NIL_P (name) || NIL_P (pointer)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_get"); RUBY_RETURN_EMPTY; } @@ -6061,13 +6217,13 @@ weechat_ruby_api_infolist_next (VALUE class, VALUE infolist) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_next"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_next"); RUBY_RETURN_INT(0); } if (NIL_P (infolist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_next"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_next"); RUBY_RETURN_INT(0); } @@ -6095,13 +6251,13 @@ weechat_ruby_api_infolist_prev (VALUE class, VALUE infolist) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_prev"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_prev"); RUBY_RETURN_INT(0); } if (NIL_P (infolist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_prev"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_prev"); RUBY_RETURN_INT(0); } @@ -6129,13 +6285,13 @@ weechat_ruby_api_infolist_fields (VALUE class, VALUE infolist) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_fields"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_fields"); RUBY_RETURN_EMPTY; } if (NIL_P (infolist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_fields"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_fields"); RUBY_RETURN_EMPTY; } @@ -6163,13 +6319,13 @@ weechat_ruby_api_infolist_integer (VALUE class, VALUE infolist, VALUE variable) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_integer"); RUBY_RETURN_INT(0); } if (NIL_P (infolist) || NIL_P (variable)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_integer"); RUBY_RETURN_INT(0); } @@ -6199,13 +6355,13 @@ weechat_ruby_api_infolist_string (VALUE class, VALUE infolist, VALUE variable) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_string"); RUBY_RETURN_EMPTY; } if (NIL_P (infolist) || NIL_P (variable)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_string"); RUBY_RETURN_EMPTY; } @@ -6235,13 +6391,13 @@ weechat_ruby_api_infolist_pointer (VALUE class, VALUE infolist, VALUE variable) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_pointer"); RUBY_RETURN_EMPTY; } if (NIL_P (infolist) || NIL_P (variable)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_pointer"); RUBY_RETURN_EMPTY; } @@ -6272,13 +6428,13 @@ weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_time"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_time"); RUBY_RETURN_EMPTY; } if (NIL_P (infolist) || NIL_P (variable)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_time"); RUBY_RETURN_EMPTY; } @@ -6309,13 +6465,13 @@ weechat_ruby_api_infolist_free (VALUE class, VALUE infolist) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "infolist_free"); RUBY_RETURN_ERROR; } if (NIL_P (infolist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "infolist_free"); RUBY_RETURN_ERROR; } @@ -6344,7 +6500,7 @@ weechat_ruby_api_upgrade_new (VALUE class, VALUE filename, VALUE write) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "upgrade_new"); RUBY_RETURN_EMPTY; } @@ -6353,7 +6509,7 @@ weechat_ruby_api_upgrade_new (VALUE class, VALUE filename, VALUE write) if (NIL_P (filename) || NIL_P (write)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "upgrade_new"); RUBY_RETURN_EMPTY; } @@ -6385,13 +6541,13 @@ weechat_ruby_api_upgrade_write_object (VALUE class, VALUE upgrade_file, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "upgrade_write_object"); RUBY_RETURN_INT(0); } if (NIL_P (upgrade_file) || NIL_P (object_id) || NIL_P (infolist)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "upgrade_write_object"); RUBY_RETURN_INT(0); } @@ -6421,7 +6577,7 @@ weechat_ruby_api_upgrade_read_cb (void *data, struct t_infolist *infolist) { struct t_script_callback *script_callback; - char *ruby_argv[4], str_object_id[32]; + char *ruby_argv[5], empty_arg[1] = { '\0' }, str_object_id[32]; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -6430,10 +6586,11 @@ weechat_ruby_api_upgrade_read_cb (void *data, { snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); - ruby_argv[0] = script_ptr2str (upgrade_file); - ruby_argv[1] = str_object_id; - ruby_argv[2] = script_ptr2str (infolist); - ruby_argv[3] = NULL; + ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + ruby_argv[1] = script_ptr2str (upgrade_file); + ruby_argv[2] = str_object_id; + ruby_argv[3] = script_ptr2str (infolist); + ruby_argv[4] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -6447,10 +6604,10 @@ weechat_ruby_api_upgrade_read_cb (void *data, ret = *rc; free (rc); } - if (ruby_argv[0]) - free (ruby_argv[0]); - if (ruby_argv[2]) - free (ruby_argv[2]); + if (ruby_argv[1]) + free (ruby_argv[1]); + if (ruby_argv[3]) + free (ruby_argv[3]); return ret; } @@ -6464,9 +6621,9 @@ weechat_ruby_api_upgrade_read_cb (void *data, static VALUE weechat_ruby_api_upgrade_read (VALUE class, VALUE upgrade_file, - VALUE function_read) + VALUE function, VALUE data) { - char *c_upgrade_file, *c_function_read; + char *c_upgrade_file, *c_function, *c_data; int rc; /* make C compiler happy */ @@ -6474,30 +6631,34 @@ weechat_ruby_api_upgrade_read (VALUE class, VALUE upgrade_file, if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_read"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "upgrade_read"); RUBY_RETURN_INT(0); } c_upgrade_file = NULL; - c_function_read = NULL; + c_function = NULL; + c_data = NULL; - if (NIL_P (upgrade_file) || NIL_P (function_read)) + if (NIL_P (upgrade_file) || NIL_P (function) || NIL_P (data)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_read"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "upgrade_read"); RUBY_RETURN_INT(0); } Check_Type (upgrade_file, T_STRING); - Check_Type (function_read, T_STRING); + Check_Type (function, T_STRING); + Check_Type (data, T_STRING); c_upgrade_file = STR2CSTR (upgrade_file); - c_function_read = STR2CSTR (function_read); + c_function = STR2CSTR (function); + c_data = STR2CSTR (data); rc = script_api_upgrade_read (weechat_ruby_plugin, ruby_current_script, script_str2ptr (c_upgrade_file), &weechat_ruby_api_upgrade_read_cb, - c_function_read); + c_function, + c_data); RUBY_RETURN_INT(rc); } @@ -6516,13 +6677,13 @@ weechat_ruby_api_upgrade_close (VALUE class, VALUE upgrade_file) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_close"); + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "upgrade_close"); RUBY_RETURN_ERROR; } if (NIL_P (upgrade_file)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "upgrade_close"); RUBY_RETURN_ERROR; } @@ -6611,10 +6772,10 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "list_remove", &weechat_ruby_api_list_remove, 2); rb_define_module_function (ruby_mWeechat, "list_remove_all", &weechat_ruby_api_list_remove_all, 1); rb_define_module_function (ruby_mWeechat, "list_free", &weechat_ruby_api_list_free, 1); - rb_define_module_function (ruby_mWeechat, "config_new", &weechat_ruby_api_config_new, 2); - rb_define_module_function (ruby_mWeechat, "config_new_section", &weechat_ruby_api_config_new_section, 9); + rb_define_module_function (ruby_mWeechat, "config_new", &weechat_ruby_api_config_new, 3); + rb_define_module_function (ruby_mWeechat, "config_new_section", &weechat_ruby_api_config_new_section, 14); rb_define_module_function (ruby_mWeechat, "config_search_section", &weechat_ruby_api_config_search_section, 2); - rb_define_module_function (ruby_mWeechat, "config_new_option", &weechat_ruby_api_config_new_option, 14); + rb_define_module_function (ruby_mWeechat, "config_new_option", &weechat_ruby_api_config_new_option, 17); rb_define_module_function (ruby_mWeechat, "config_search_option", &weechat_ruby_api_config_search_option, 3); rb_define_module_function (ruby_mWeechat, "config_string_to_boolean", &weechat_ruby_api_config_string_to_boolean, 1); rb_define_module_function (ruby_mWeechat, "config_option_reset", &weechat_ruby_api_config_option_reset, 2); @@ -6651,25 +6812,25 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "print_date_tags", &weechat_ruby_api_print_date_tags, 4); rb_define_module_function (ruby_mWeechat, "print_y", &weechat_ruby_api_print_y, 3); rb_define_module_function (ruby_mWeechat, "log_print", &weechat_ruby_api_log_print, 1); - rb_define_module_function (ruby_mWeechat, "hook_command", &weechat_ruby_api_hook_command, 6); - rb_define_module_function (ruby_mWeechat, "hook_command_run", &weechat_ruby_api_hook_command_run, 2); - rb_define_module_function (ruby_mWeechat, "hook_timer", &weechat_ruby_api_hook_timer, 4); - rb_define_module_function (ruby_mWeechat, "hook_fd", &weechat_ruby_api_hook_fd, 5); - rb_define_module_function (ruby_mWeechat, "hook_process", &weechat_ruby_api_hook_process, 3); - rb_define_module_function (ruby_mWeechat, "hook_connect", &weechat_ruby_api_hook_connect, 7); - rb_define_module_function (ruby_mWeechat, "hook_print", &weechat_ruby_api_hook_print, 5); - rb_define_module_function (ruby_mWeechat, "hook_signal", &weechat_ruby_api_hook_signal, 2); + rb_define_module_function (ruby_mWeechat, "hook_command", &weechat_ruby_api_hook_command, 7); + rb_define_module_function (ruby_mWeechat, "hook_command_run", &weechat_ruby_api_hook_command_run, 3); + rb_define_module_function (ruby_mWeechat, "hook_timer", &weechat_ruby_api_hook_timer, 5); + rb_define_module_function (ruby_mWeechat, "hook_fd", &weechat_ruby_api_hook_fd, 6); + rb_define_module_function (ruby_mWeechat, "hook_process", &weechat_ruby_api_hook_process, 4); + rb_define_module_function (ruby_mWeechat, "hook_connect", &weechat_ruby_api_hook_connect, 8); + rb_define_module_function (ruby_mWeechat, "hook_print", &weechat_ruby_api_hook_print, 6); + rb_define_module_function (ruby_mWeechat, "hook_signal", &weechat_ruby_api_hook_signal, 3); rb_define_module_function (ruby_mWeechat, "hook_signal_send", &weechat_ruby_api_hook_signal_send, 3); - rb_define_module_function (ruby_mWeechat, "hook_config", &weechat_ruby_api_hook_config, 2); - rb_define_module_function (ruby_mWeechat, "hook_completion", &weechat_ruby_api_hook_completion, 3); + rb_define_module_function (ruby_mWeechat, "hook_config", &weechat_ruby_api_hook_config, 3); + rb_define_module_function (ruby_mWeechat, "hook_completion", &weechat_ruby_api_hook_completion, 4); 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, 2); + 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, 3); - rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 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, "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, 3); + rb_define_module_function (ruby_mWeechat, "buffer_new", &weechat_ruby_api_buffer_new, 5); rb_define_module_function (ruby_mWeechat, "buffer_search", &weechat_ruby_api_buffer_search, 2); rb_define_module_function (ruby_mWeechat, "current_buffer", &weechat_ruby_api_current_buffer, 0); rb_define_module_function (ruby_mWeechat, "buffer_clear", &weechat_ruby_api_buffer_clear, 1); @@ -6690,7 +6851,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "nicklist_remove_nick", &weechat_ruby_api_nicklist_remove_nick, 2); rb_define_module_function (ruby_mWeechat, "nicklist_remove_all", &weechat_ruby_api_nicklist_remove_all, 1); rb_define_module_function (ruby_mWeechat, "bar_item_search", &weechat_ruby_api_bar_item_search, 1); - rb_define_module_function (ruby_mWeechat, "bar_item_new", &weechat_ruby_api_bar_item_new, 2); + rb_define_module_function (ruby_mWeechat, "bar_item_new", &weechat_ruby_api_bar_item_new, 3); rb_define_module_function (ruby_mWeechat, "bar_item_update", &weechat_ruby_api_bar_item_update, 1); rb_define_module_function (ruby_mWeechat, "bar_item_remove", &weechat_ruby_api_bar_item_remove, 1); rb_define_module_function (ruby_mWeechat, "bar_search", &weechat_ruby_api_bar_search, 1); @@ -6716,6 +6877,6 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "infolist_free", &weechat_ruby_api_infolist_free, 1); rb_define_module_function (ruby_mWeechat, "upgrade_new", &weechat_ruby_api_upgrade_new, 2); rb_define_module_function (ruby_mWeechat, "upgrade_write_object", &weechat_ruby_api_upgrade_write_object, 3); - rb_define_module_function (ruby_mWeechat, "upgrade_read", &weechat_ruby_api_upgrade_read, 2); + rb_define_module_function (ruby_mWeechat, "upgrade_read", &weechat_ruby_api_upgrade_read, 3); rb_define_module_function (ruby_mWeechat, "upgrade_close", &weechat_ruby_api_upgrade_close, 1); } diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index f4b10c8ba..5d3c7db14 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -148,15 +148,31 @@ weechat_ruby_exec (struct t_plugin_script *script, { if (argv[6]) { - rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), - &ruby_error, 7, - rb_str_new2(argv[0]), - rb_str_new2(argv[1]), - rb_str_new2(argv[2]), - rb_str_new2(argv[3]), - rb_str_new2(argv[4]), - rb_str_new2(argv[5]), - rb_str_new2(argv[6])); + if (argv[7]) + { + rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), + &ruby_error, 8, + rb_str_new2(argv[0]), + rb_str_new2(argv[1]), + rb_str_new2(argv[2]), + rb_str_new2(argv[3]), + rb_str_new2(argv[4]), + rb_str_new2(argv[5]), + rb_str_new2(argv[6]), + rb_str_new2(argv[7])); + } + else + { + rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), + &ruby_error, 7, + rb_str_new2(argv[0]), + rb_str_new2(argv[1]), + rb_str_new2(argv[2]), + rb_str_new2(argv[3]), + rb_str_new2(argv[4]), + rb_str_new2(argv[5]), + rb_str_new2(argv[6])); + } } else { diff --git a/src/plugins/scripts/ruby/weechat-ruby.h b/src/plugins/scripts/ruby/weechat-ruby.h index 337ccb3c3..65a903718 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.h +++ b/src/plugins/scripts/ruby/weechat-ruby.h @@ -23,6 +23,8 @@ #define weechat_plugin weechat_ruby_plugin #define RUBY_PLUGIN_NAME "ruby" +#define RUBY_CURRENT_SCRIPT_NAME ((ruby_current_script) ? ruby_current_script->name : "-") + extern struct t_weechat_plugin *weechat_ruby_plugin; extern int ruby_quiet; diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c index 18fdab1fe..38bbec75c 100644 --- a/src/plugins/scripts/script-api.c +++ b/src/plugins/scripts/script-api.c @@ -55,7 +55,8 @@ script_api_config_new (struct t_weechat_plugin *weechat_plugin, const char *name, int (*callback_reload)(void *data, struct t_config_file *config_file), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_config_file *new_config_file; @@ -75,8 +76,7 @@ script_api_config_new (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->config_file = new_config_file; script_callback_add (script, new_script_callback); @@ -107,25 +107,30 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, const char *option_name, const char *value), const char *function_read, + const char *data_read, void (*callback_write)(void *data, struct t_config_file *config_file, const char *section_name), const char *function_write, + const char *data_write, void (*callback_write_default)(void *data, struct t_config_file *config_file, const char *section_name), const char *function_write_default, + const char *data_write_default, int (*callback_create_option)(void *data, struct t_config_file *config_file, struct t_config_section *section, const char *option_name, const char *value), const char *function_create_option, + const char *data_create_option, int (*callback_delete_option)(void *data, struct t_config_file *config_file, struct t_config_section *section, struct t_config_option *option), - const char *function_delete_option) + const char *function_delete_option, + const char *data_delete_option) { struct t_script_callback *new_script_callback1, *new_script_callback2; struct t_script_callback *new_script_callback3, *new_script_callback4; @@ -288,8 +293,8 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, if (new_script_callback1) { - new_script_callback1->script = script; - new_script_callback1->function = strdup (function_read); + script_callback_init (new_script_callback1, script, + function_read, data_read); new_script_callback1->config_file = config_file; new_script_callback1->config_section = new_section; script_callback_add (script, new_script_callback1); @@ -297,8 +302,8 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, if (new_script_callback2) { - new_script_callback2->script = script; - new_script_callback2->function = strdup (function_write); + script_callback_init (new_script_callback2, script, + function_write, data_write); new_script_callback2->config_file = config_file; new_script_callback2->config_section = new_section; script_callback_add (script, new_script_callback2); @@ -306,8 +311,8 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, if (new_script_callback3) { - new_script_callback3->script = script; - new_script_callback3->function = strdup (function_write_default); + script_callback_init (new_script_callback3, script, + function_write_default, data_write_default); new_script_callback3->config_file = config_file; new_script_callback3->config_section = new_section; script_callback_add (script, new_script_callback3); @@ -315,8 +320,8 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, if (new_script_callback4) { - new_script_callback4->script = script; - new_script_callback4->function = strdup (function_create_option); + script_callback_init (new_script_callback4, script, + function_create_option, data_create_option); new_script_callback4->config_file = config_file; new_script_callback4->config_section = new_section; script_callback_add (script, new_script_callback4); @@ -324,8 +329,8 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, if (new_script_callback5) { - new_script_callback5->script = script; - new_script_callback5->function = strdup (function_delete_option); + script_callback_init (new_script_callback5, script, + function_delete_option, data_delete_option); new_script_callback5->config_file = config_file; new_script_callback5->config_section = new_section; script_callback_add (script, new_script_callback5); @@ -354,12 +359,15 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin, struct t_config_option *option, const char *value), const char *function_check_value, + const char *data_check_value, void (*callback_change)(void *data, struct t_config_option *option), const char *function_change, + const char *data_change, void (*callback_delete)(void *data, struct t_config_option *option), - const char *function_delete) + const char *function_delete, + const char *data_delete) { struct t_script_callback *new_script_callback1, *new_script_callback2; struct t_script_callback *new_script_callback3; @@ -445,8 +453,8 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin, if (new_script_callback1) { - new_script_callback1->script = script; - new_script_callback1->function = strdup (function_check_value); + script_callback_init (new_script_callback1, script, + function_check_value, data_check_value); new_script_callback1->config_file = config_file; new_script_callback1->config_section = section; new_script_callback1->config_option = new_option; @@ -455,8 +463,8 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin, if (new_script_callback2) { - new_script_callback2->script = script; - new_script_callback2->function = strdup (function_change); + script_callback_init (new_script_callback2, script, + function_change, data_change); new_script_callback2->config_file = config_file; new_script_callback2->config_section = section; new_script_callback2->config_option = new_option; @@ -465,8 +473,8 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin, if (new_script_callback3) { - new_script_callback3->script = script; - new_script_callback3->function = strdup (function_delete); + script_callback_init (new_script_callback3, script, + function_delete, data_delete); new_script_callback3->config_file = config_file; new_script_callback3->config_section = section; new_script_callback3->config_option = new_option; @@ -723,7 +731,8 @@ script_api_hook_command (struct t_weechat_plugin *weechat_plugin, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -741,9 +750,8 @@ script_api_hook_command (struct t_weechat_plugin *weechat_plugin, free (new_script_callback); return NULL; } - - new_script_callback->script = script; - new_script_callback->function = strdup (function); + + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -763,7 +771,8 @@ script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin, int (*callback)(void *data, struct t_gui_buffer *buffer, const char *command), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -781,8 +790,7 @@ script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -799,8 +807,10 @@ struct t_hook * script_api_hook_timer (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, int interval, int align_second, int max_calls, - int (*callback)(void *data, int remaining_calls), - const char *function) + int (*callback)(void *data, + int remaining_calls), + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -818,8 +828,7 @@ script_api_hook_timer (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -838,11 +847,12 @@ script_api_hook_fd (struct t_weechat_plugin *weechat_plugin, int fd, int flag_read, int flag_write, int flag_exception, int (*callback)(void *data, int fd), - const char *function) + 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; @@ -856,8 +866,7 @@ script_api_hook_fd (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -880,7 +889,8 @@ script_api_hook_process (struct t_weechat_plugin *weechat_plugin, int return_code, const char *stdout, const char *stderr), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -889,8 +899,7 @@ script_api_hook_process (struct t_weechat_plugin *weechat_plugin, if (!new_script_callback) return NULL; - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); script_callback_add (script, new_script_callback); new_hook = weechat_hook_process (command, timeout, callback, @@ -921,7 +930,8 @@ script_api_hook_connect (struct t_weechat_plugin *weechat_plugin, int (*callback)(void *data, int status, const char *error, const char *ip_address), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -940,8 +950,7 @@ script_api_hook_connect (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -966,7 +975,8 @@ script_api_hook_print (struct t_weechat_plugin *weechat_plugin, int displayed, int highlight, const char *prefix, const char *message), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -984,8 +994,7 @@ script_api_hook_print (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -1005,7 +1014,8 @@ script_api_hook_signal (struct t_weechat_plugin *weechat_plugin, int (*callback)(void *data, const char *signal, const char *type_data, void *signal_data), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -1022,8 +1032,7 @@ script_api_hook_signal (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -1042,7 +1051,8 @@ script_api_hook_config (struct t_weechat_plugin *weechat_plugin, const char *option, int (*callback)(void *data, const char *option, const char *value), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -1059,8 +1069,7 @@ script_api_hook_config (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -1082,7 +1091,8 @@ script_api_hook_completion (struct t_weechat_plugin *weechat_plugin, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -1100,8 +1110,7 @@ script_api_hook_completion (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -1121,7 +1130,8 @@ script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin, char *(*callback)(void *data, const char *modifier, const char *modifier_data, const char *string), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -1138,8 +1148,7 @@ script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -1160,7 +1169,8 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin, const char *(*callback)(void *data, const char *info_name, const char *arguments), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -1178,8 +1188,7 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -1201,7 +1210,8 @@ script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin, const char *infolist_name, void *pointer, const char *arguments), - const char *function) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_hook *new_hook; @@ -1219,8 +1229,7 @@ script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin, return NULL; } - new_script_callback->script = script; - new_script_callback->function = strdup (function); + script_callback_init (new_script_callback, script, function, data); new_script_callback->hook = new_hook; script_callback_add (script, new_script_callback); @@ -1288,9 +1297,11 @@ script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, struct t_gui_buffer *buffer, const char *input_data), const char *function_input, + const char *data_input, int (*close_callback)(void *data, struct t_gui_buffer *buffer), - const char *function_close) + const char *function_close, + const char *data_close) { struct t_script_callback *new_script_callback_input; struct t_script_callback *new_script_callback_close; @@ -1350,26 +1361,31 @@ script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, if (new_script_callback_input) { - new_script_callback_input->script = script; - new_script_callback_input->function = strdup (function_input); + script_callback_init (new_script_callback_input, + script, function_input, data_input); new_script_callback_input->buffer = new_buffer; script_callback_add (script, new_script_callback_input); } if (new_script_callback_close) { - new_script_callback_close->script = script; - new_script_callback_close->function = strdup (function_close); + script_callback_init (new_script_callback_close, + script, function_close, data_close); new_script_callback_close->buffer = new_buffer; script_callback_add (script, new_script_callback_close); } - + + /* used when upgrading weechat, to set callbacks */ weechat_buffer_set (new_buffer, "localvar_set_script_name", script->name); weechat_buffer_set (new_buffer, "localvar_set_script_input_cb", function_input); + weechat_buffer_set (new_buffer, "localvar_set_script_input_cb_data", + data_input); weechat_buffer_set (new_buffer, "localvar_set_script_close_cb", function_close); + weechat_buffer_set (new_buffer, "localvar_set_script_close_cb_data", + data_close); return new_buffer; } @@ -1413,7 +1429,8 @@ script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin, char *(*build_callback)(void *data, struct t_gui_bar_item *item, struct t_gui_window *window), - const char *function_build) + const char *function, + const char *data) { struct t_script_callback *new_script_callback; struct t_gui_bar_item *new_item; @@ -1422,14 +1439,12 @@ script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin, if (!new_script_callback) return NULL; - new_script_callback->script = script; - new_script_callback->function = (function_build && function_build[0]) ? - strdup (function_build) : NULL; + script_callback_init (new_script_callback, script, function, data); new_item = weechat_bar_item_new (name, - (function_build && function_build[0]) ? + (function && function[0]) ? build_callback : NULL, - (function_build && function_build[0]) ? + (function && function[0]) ? new_script_callback : NULL); if (!new_item) { @@ -1589,28 +1604,28 @@ script_api_upgrade_read (struct t_weechat_plugin *weechat_plugin, struct t_upgrade_file *upgrade_file, int object_id, struct t_infolist *infolist), - const char *function_read) + const char *function, + const char *data) { - struct t_script_callback *script_callback; + struct t_script_callback *new_script_callback; int rc; - if (!function_read || !function_read[0]) + if (!function || !function[0]) return 0; - script_callback = script_callback_alloc (); - if (!script_callback) + new_script_callback = script_callback_alloc (); + if (!new_script_callback) return 0; - script_callback->script = script; - script_callback->function = strdup (function_read); - script_callback->upgrade_file = upgrade_file; - script_callback_add (script, script_callback); + script_callback_init (new_script_callback, script, function, data); + new_script_callback->upgrade_file = upgrade_file; + script_callback_add (script, new_script_callback); rc = weechat_upgrade_read (upgrade_file, callback_read, - script_callback); + new_script_callback); - script_callback_remove (script, script_callback); + script_callback_remove (script, new_script_callback); return rc; } diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h index e769bc583..bfedeab4a 100644 --- a/src/plugins/scripts/script-api.h +++ b/src/plugins/scripts/script-api.h @@ -26,7 +26,8 @@ extern struct t_config_file *script_api_config_new (struct t_weechat_plugin *wee const char *name, int (*callback_reload)(void *data, struct t_config_file *config_file), - const char *function); + const char *function, + const char *data); extern struct t_config_section *script_api_config_new_section (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, struct t_config_file *config_file, @@ -39,25 +40,30 @@ extern struct t_config_section *script_api_config_new_section (struct t_weechat_ const char *option_name, const char *value), const char *function_read, + const char *data_read, void (*callback_write)(void *data, struct t_config_file *config_file, const char *section_name), const char *function_write, + const char *data_write, void (*callback_write_default)(void *data, struct t_config_file *config_file, const char *section_name), const char *function_write_default, + const char *data_write_default, int (*callback_create_option)(void *data, struct t_config_file *config_file, struct t_config_section *section, const char *option_name, const char *value), const char *function_create_option, + const char *data_create_option, int (*callback_delete_option)(void *data, struct t_config_file *config_file, struct t_config_section *section, struct t_config_option *option), - const char *function_delete_option); + const char *function_delete_option, + const char *data_delete_option); extern struct t_config_option *script_api_config_new_option (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, struct t_config_file *config_file, @@ -74,12 +80,15 @@ extern struct t_config_option *script_api_config_new_option (struct t_weechat_pl struct t_config_option *option, const char *value), const char *function_check_value, + const char *data_check_value, void (*callback_change)(void *data, struct t_config_option *option), const char *function_change, + const char *data_change, void (*callback_delete)(void *data, struct t_config_option *option), - const char *function_delete); + const char *function_delete, + const char *data_delete); extern void script_api_config_option_free (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, struct t_config_option *option); @@ -117,27 +126,31 @@ extern struct t_hook *script_api_hook_command (struct t_weechat_plugin *weechat_ struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *command, int (*callback)(void *data, struct t_gui_buffer *buffer, const char *command), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_timer (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, int interval, int align_second, int max_calls, int (*callback)(void *data, int remaining_calls), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_fd (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, int fd, int flag_read, int flag_write, int flag_exception, int (*callback)(void *data, int fd), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_process (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *command, @@ -147,7 +160,8 @@ extern struct t_hook *script_api_hook_process (struct t_weechat_plugin *weechat_ int return_code, const char *stdout, const char *stderr), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_connect (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *proxy, @@ -161,7 +175,8 @@ extern struct t_hook *script_api_hook_connect (struct t_weechat_plugin *weechat_ int status, const char *error, const char *ip_address), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_print (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, struct t_gui_buffer *buffer, @@ -177,7 +192,8 @@ extern struct t_hook *script_api_hook_print (struct t_weechat_plugin *weechat_pl int highlight, const char *prefix, const char *message), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_signal (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *signal, @@ -185,14 +201,16 @@ extern struct t_hook *script_api_hook_signal (struct t_weechat_plugin *weechat_p const char *signal, const char *type_data, void *signal_data), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_config (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *option, int (*callback)(void *data, const char *option, const char *value), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_completion (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *completion, @@ -201,7 +219,8 @@ extern struct t_hook *script_api_hook_completion (struct t_weechat_plugin *weech const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_modifier (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *modifier, @@ -209,7 +228,8 @@ extern struct t_hook *script_api_hook_modifier (struct t_weechat_plugin *weechat const char *modifier, const char *modifier_data, const char *string), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *info_name, @@ -217,7 +237,8 @@ extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plu const char *(*callback)(void *data, const char *info_name, const char *arguments), - const char *function); + const char *function, + const char *data); extern struct t_hook *script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *infolist_name, @@ -226,7 +247,8 @@ extern struct t_hook *script_api_hook_infolist (struct t_weechat_plugin *weechat const char *infolist_name, void *pointer, const char *arguments), - const char *function); + const char *function, + const char *data); extern void script_api_unhook (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, struct t_hook *hook); @@ -238,9 +260,11 @@ extern struct t_gui_buffer *script_api_buffer_new (struct t_weechat_plugin *weec struct t_gui_buffer *buffer, const char *input_data), const char *function_input, + const char *data_input, int (*close_callback)(void *data, struct t_gui_buffer *buffer), - const char *function_close); + const char *function_close, + const char *data_close); extern void script_api_buffer_close (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, struct t_gui_buffer *buffer); @@ -250,7 +274,8 @@ extern struct t_gui_bar_item *script_api_bar_item_new (struct t_weechat_plugin * char *(*build_callback)(void *data, struct t_gui_bar_item *item, struct t_gui_window *window), - const char *function_build); + const char *function, + const char *data); extern void script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, struct t_gui_bar_item *item); @@ -274,6 +299,7 @@ extern int script_api_upgrade_read (struct t_weechat_plugin *weechat_plugin, struct t_upgrade_file *upgrade_file, int object_id, struct t_infolist *infolist), - const char *function_read); + const char *function, + const char *data); #endif /* script-api.h */ diff --git a/src/plugins/scripts/script-callback.c b/src/plugins/scripts/script-callback.c index 934f40bd8..7ead08310 100644 --- a/src/plugins/scripts/script-callback.c +++ b/src/plugins/scripts/script-callback.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <unistd.h> +#include <string.h> #include "../weechat-plugin.h" #include "script.h" @@ -41,6 +42,7 @@ script_callback_alloc () { new_script_callback->script = NULL; new_script_callback->function = NULL; + new_script_callback->data = NULL; new_script_callback->config_file = NULL; new_script_callback->config_section = NULL; new_script_callback->config_option = NULL; @@ -55,6 +57,24 @@ script_callback_alloc () } /* + * script_callback_init: initialize callback with script, function and data + */ + +void +script_callback_init (struct t_script_callback *script_callback, + struct t_plugin_script *script, + const char *function, + const char *data) +{ + if (script_callback) + { + script_callback->script = script; + script_callback->function = (function) ? strdup (function) : NULL; + script_callback->data = (data) ? strdup (data) : NULL; + } +} + +/* * script_callback_add: add a callback to list */ @@ -78,6 +98,8 @@ script_callback_free_data (struct t_script_callback *script_callback) { if (script_callback->function) free (script_callback->function); + if (script_callback->data) + free (script_callback->data); } /* @@ -128,6 +150,7 @@ script_callback_print_log (struct t_weechat_plugin *weechat_plugin, weechat_log_printf (" [callback (addr:0x%lx)]", script_callback); weechat_log_printf (" script. . . . . . . : 0x%lx", script_callback->script); weechat_log_printf (" function. . . . . . : '%s'", script_callback->function); + weechat_log_printf (" data. . . . . . . . : '%s'", script_callback->data); weechat_log_printf (" config_file . . . . : 0x%lx", script_callback->config_file); weechat_log_printf (" config_section. . . : 0x%lx", script_callback->config_section); weechat_log_printf (" config_option . . . : 0x%lx", script_callback->config_option); diff --git a/src/plugins/scripts/script-callback.h b/src/plugins/scripts/script-callback.h index a37beec19..3c49946b0 100644 --- a/src/plugins/scripts/script-callback.h +++ b/src/plugins/scripts/script-callback.h @@ -23,6 +23,7 @@ struct t_script_callback { void *script; /* pointer to script */ char *function; /* script function called */ + char *data; /* data string for callback */ struct t_config_file *config_file; /* not NULL for config file */ struct t_config_section *config_section; /* not NULL for config section */ struct t_config_option *config_option; /* not NULL for config option */ @@ -35,6 +36,10 @@ struct t_script_callback }; extern struct t_script_callback *script_callback_alloc (); +extern void script_callback_init (struct t_script_callback *script_callback, + struct t_plugin_script *script, + const char *function, + const char *data); extern void script_callback_add (struct t_plugin_script *script, struct t_script_callback *callback); extern void script_callback_free_data (struct t_script_callback *script_callback); diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c index 2ebb4862b..85f6a4093 100644 --- a/src/plugins/scripts/script.c +++ b/src/plugins/scripts/script.c @@ -94,7 +94,8 @@ script_upgrade_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, { struct t_infolist *infolist; struct t_gui_buffer *ptr_buffer; - const char *script_name, *script_input_cb, *script_close_cb; + const char *script_name, *script_input_cb, *script_input_cb_data; + const char *script_close_cb, *script_close_cb_data; struct t_plugin_script *ptr_script; struct t_script_callback *new_script_callback_input; struct t_script_callback *new_script_callback_close; @@ -122,8 +123,10 @@ script_upgrade_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, new_script_callback_input = script_callback_alloc (); if (new_script_callback_input) { - new_script_callback_input->script = ptr_script; - new_script_callback_input->function = strdup (script_input_cb); + script_callback_init (new_script_callback_input, + ptr_script, + script_input_cb, + script_input_cb_data); new_script_callback_input->buffer = ptr_buffer; script_callback_add (ptr_script, new_script_callback_input); @@ -140,8 +143,10 @@ script_upgrade_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin, new_script_callback_close = script_callback_alloc (); if (new_script_callback_close) { - new_script_callback_close->script = ptr_script; - new_script_callback_close->function = strdup (script_close_cb); + script_callback_init (new_script_callback_close, + ptr_script, + script_close_cb, + script_close_cb_data); new_script_callback_close->buffer = ptr_buffer; script_callback_add (ptr_script, new_script_callback_close); diff --git a/src/plugins/scripts/script.h b/src/plugins/scripts/script.h index 1b0f094fd..f2682a89d 100644 --- a/src/plugins/scripts/script.h +++ b/src/plugins/scripts/script.h @@ -23,19 +23,23 @@ #define WEECHAT_SCRIPT_EXEC_INT 1 #define WEECHAT_SCRIPT_EXEC_STRING 2 -#define WEECHAT_SCRIPT_MSG_NOT_INITIALIZED(__function) \ +#define WEECHAT_SCRIPT_MSG_NOT_INIT(__current_script, \ + __function) \ weechat_printf (NULL, \ weechat_gettext("%s%s: unable to call function " \ "\"%s\", script is not " \ - "initialized"), \ + "initialized (script: %s)"), \ weechat_prefix ("error"), weechat_plugin->name, \ - __function) -#define WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS(__function) \ + __function, \ + (__current_script) ? __current_script : "-"); +#define WEECHAT_SCRIPT_MSG_WRONG_ARGS(__current_script, \ + __function) \ weechat_printf (NULL, \ weechat_gettext("%s%s: wrong arguments for " \ - "function \"%s\""), \ + "function \"%s\" (script: %s)"), \ weechat_prefix ("error"), weechat_plugin->name, \ - __function) + __function, \ + (__current_script) ? __current_script : "-"); struct t_plugin_script { diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index 9517aef7b..92f247abc 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -173,7 +173,7 @@ weechat_tcl_api_register (ClientData clientData, Tcl_Interp *interp, int objc, if (objc < 8) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("register"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(tcl_current_script_filename, "register"); TCL_RETURN_ERROR; } @@ -241,13 +241,13 @@ weechat_tcl_api_plugin_get_name (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "plugin_get_name"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "plugin_get_name"); TCL_RETURN_EMPTY; } @@ -274,13 +274,13 @@ weechat_tcl_api_charset_set (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("charset_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "charset_set"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("charset_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "charset_set"); TCL_RETURN_ERROR; } @@ -308,18 +308,19 @@ weechat_tcl_api_iconv_to_internal (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_to_internal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "iconv_to_internal"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_to_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "iconv_to_internal"); TCL_RETURN_EMPTY; } charset = Tcl_GetStringFromObj (objv[1], &i); string = Tcl_GetStringFromObj (objv[2], &i); + result = weechat_iconv_to_internal (charset, string); TCL_RETURN_STRING_FREE(result); @@ -343,18 +344,19 @@ weechat_tcl_api_iconv_from_internal (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_from_internal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "iconv_from_internal"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_from_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "iconv_from_internal"); TCL_RETURN_EMPTY; } charset = Tcl_GetStringFromObj (objv[1], &i); string = Tcl_GetStringFromObj (objv[2], &i); + result = weechat_iconv_from_internal (charset, string); TCL_RETURN_STRING_FREE(result); @@ -377,13 +379,13 @@ weechat_tcl_api_gettext (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("gettext"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "gettext"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("gettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "gettext"); TCL_RETURN_EMPTY; } @@ -410,13 +412,13 @@ weechat_tcl_api_ngettext (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("ngettext"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "ngettext"); TCL_RETURN_EMPTY; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("ngettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "ngettext"); TCL_RETURN_EMPTY; } @@ -425,7 +427,7 @@ weechat_tcl_api_ngettext (ClientData clientData, Tcl_Interp *interp, if (Tcl_GetIntFromObj (interp, objv[3], &count) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("ngettext"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "ngettext"); TCL_RETURN_EMPTY; } @@ -451,18 +453,19 @@ weechat_tcl_api_string_remove_color (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("string_remove_color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "string_remove_color"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "string_remove_color"); TCL_RETURN_EMPTY; } string = Tcl_GetStringFromObj (objv[1], &i); replacement = Tcl_GetStringFromObj (objv[2], &i); + result = weechat_string_remove_color (string, replacement); TCL_RETURN_STRING_FREE(result); @@ -484,19 +487,19 @@ weechat_tcl_api_mkdir_home (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_home"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "mkdir_home"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_home"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "mkdir_home"); TCL_RETURN_ERROR; } if (Tcl_GetIntFromObj (interp, objv[2], &mode) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_home"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "mkdir_home"); TCL_RETURN_EMPTY; } @@ -523,19 +526,19 @@ weechat_tcl_api_mkdir (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "mkdir"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "mkdir"); TCL_RETURN_ERROR; } if (Tcl_GetIntFromObj (interp, objv[2], &mode) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "mkdir"); TCL_RETURN_EMPTY; } @@ -563,19 +566,19 @@ weechat_tcl_api_mkdir_parents (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_parents"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "mkdir_parents"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_parents"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "mkdir_parents"); TCL_RETURN_ERROR; } if (Tcl_GetIntFromObj (interp, objv[2], &mode) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_parents"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "mkdir_parents"); TCL_RETURN_EMPTY; } @@ -604,7 +607,7 @@ weechat_tcl_api_list_new (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_new"); TCL_RETURN_EMPTY; } @@ -631,13 +634,13 @@ weechat_tcl_api_list_add (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_add"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_add"); TCL_RETURN_EMPTY; } if (objc < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_add"); TCL_RETURN_EMPTY; } @@ -645,6 +648,7 @@ weechat_tcl_api_list_add (ClientData clientData, Tcl_Interp *interp, data = Tcl_GetStringFromObj (objv[2], &i); where = Tcl_GetStringFromObj (objv[3], &i); user_data = Tcl_GetStringFromObj (objv[4], &i); + result = script_ptr2str (weechat_list_add (script_str2ptr (weelist), data, where, @@ -670,18 +674,19 @@ weechat_tcl_api_list_search (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_search"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_search"); TCL_RETURN_EMPTY; } weelist = Tcl_GetStringFromObj (objv[1], &i); data = Tcl_GetStringFromObj (objv[2], &i); + result = script_ptr2str (weechat_list_search (script_str2ptr (weelist), data)); @@ -705,18 +710,19 @@ weechat_tcl_api_list_casesearch (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_casesearch"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_casesearch"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_casesearch"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_casesearch"); TCL_RETURN_EMPTY; } weelist = Tcl_GetStringFromObj (objv[1], &i); data = Tcl_GetStringFromObj (objv[2], &i); + result = script_ptr2str (weechat_list_casesearch (script_str2ptr (weelist), data)); @@ -740,19 +746,19 @@ weechat_tcl_api_list_get (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_get"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_get"); TCL_RETURN_EMPTY; } if (Tcl_GetIntFromObj (interp, objv[2], &position) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_get"); TCL_RETURN_EMPTY; } @@ -779,18 +785,19 @@ weechat_tcl_api_list_set (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_set"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_set"); TCL_RETURN_ERROR; } item = Tcl_GetStringFromObj (objv[1], &i); new_value = Tcl_GetStringFromObj (objv[2], &i); + weechat_list_set (script_str2ptr (item), new_value); TCL_RETURN_OK; @@ -813,13 +820,13 @@ weechat_tcl_api_list_next (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_next"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_next"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_next"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_next"); TCL_RETURN_EMPTY; } @@ -845,13 +852,13 @@ weechat_tcl_api_list_prev (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_prev"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_prev"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_prev"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_prev"); TCL_RETURN_EMPTY; } @@ -877,13 +884,13 @@ weechat_tcl_api_list_string (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_string"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_string"); TCL_RETURN_EMPTY; } @@ -909,13 +916,13 @@ weechat_tcl_api_list_size (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_size"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_size"); TCL_RETURN_INT(0); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_size"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_size"); TCL_RETURN_INT(0); } @@ -941,18 +948,19 @@ weechat_tcl_api_list_remove (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_remove"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_remove"); TCL_RETURN_ERROR; } weelist = Tcl_GetStringFromObj (objv[1], &i); item = Tcl_GetStringFromObj (objv[2], &i); + weechat_list_remove (script_str2ptr (weelist), script_str2ptr (item)); TCL_RETURN_OK; @@ -973,13 +981,13 @@ weechat_tcl_api_list_remove_all (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_remove_all"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_remove_all"); TCL_RETURN_ERROR; } @@ -1004,13 +1012,13 @@ weechat_tcl_api_list_free (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("list_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_free"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("list_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_free"); TCL_RETURN_ERROR; } @@ -1025,10 +1033,10 @@ weechat_tcl_api_list_free (ClientData clientData, Tcl_Interp *interp, int weechat_tcl_api_config_reload_cb (void *data, - struct t_config_file *config_file) + struct t_config_file *config_file) { struct t_script_callback *script_callback; - char *tcl_argv[2]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -1036,8 +1044,9 @@ weechat_tcl_api_config_reload_cb (void *data, if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (config_file); - tcl_argv[1] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (config_file); + tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1051,8 +1060,8 @@ weechat_tcl_api_config_reload_cb (void *data, ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); + if (tcl_argv[1]) + free (tcl_argv[1]); return ret; } @@ -1069,31 +1078,34 @@ weechat_tcl_api_config_new (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj* objp; - char *result, *name, *function; + char *result, *name, *function, *data; int i; - + /* make C compiler happy */ (void) clientData; if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_new"); TCL_RETURN_EMPTY; } - if (objc < 3) + if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_new"); TCL_RETURN_EMPTY; } name = Tcl_GetStringFromObj (objv[1], &i); function = Tcl_GetStringFromObj (objv[2], &i); + data = Tcl_GetStringFromObj (objv[3], &i); + result = script_ptr2str (script_api_config_new (weechat_tcl_plugin, tcl_current_script, name, &weechat_tcl_api_config_reload_cb, - function)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -1110,18 +1122,19 @@ weechat_tcl_api_config_section_read_cb (void *data, const char *option_name, const char *value) { struct t_script_callback *script_callback; - char *tcl_argv[5], empty_arg[1] = { '\0' }; + char *tcl_argv[6], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (config_file); - tcl_argv[1] = script_ptr2str (section); - tcl_argv[2] = (option_name) ? (char *)option_name : empty_arg; - tcl_argv[3] = (value) ? (char *)value : empty_arg; - tcl_argv[4] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (config_file); + tcl_argv[2] = script_ptr2str (section); + tcl_argv[3] = (option_name) ? (char *)option_name : empty_arg; + tcl_argv[4] = (value) ? (char *)value : empty_arg; + tcl_argv[5] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1135,10 +1148,10 @@ weechat_tcl_api_config_section_read_cb (void *data, ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); if (tcl_argv[1]) free (tcl_argv[1]); + if (tcl_argv[2]) + free (tcl_argv[2]); return ret; } @@ -1156,16 +1169,17 @@ weechat_tcl_api_config_section_write_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *tcl_argv[3], empty_arg[1] = { '\0' }; + char *tcl_argv[4], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (config_file); - tcl_argv[1] = (section_name) ? (char *)section_name : empty_arg; - tcl_argv[2] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (config_file); + tcl_argv[2] = (section_name) ? (char *)section_name : empty_arg; + tcl_argv[3] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1174,8 +1188,8 @@ weechat_tcl_api_config_section_write_cb (void *data, if (rc) free (rc); - if (tcl_argv[0]) - free (tcl_argv[0]); + if (tcl_argv[1]) + free (tcl_argv[1]); } } @@ -1190,16 +1204,17 @@ weechat_tcl_api_config_section_write_default_cb (void *data, const char *section_name) { struct t_script_callback *script_callback; - char *tcl_argv[3], empty_arg[1] = { '\0' }; + char *tcl_argv[4], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (config_file); - tcl_argv[1] = (section_name) ? (char *)section_name : empty_arg; - tcl_argv[2] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (config_file); + tcl_argv[2] = (section_name) ? (char *)section_name : empty_arg; + tcl_argv[3] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1208,8 +1223,8 @@ weechat_tcl_api_config_section_write_default_cb (void *data, if (rc) free (rc); - if (tcl_argv[0]) - free (tcl_argv[0]); + if (tcl_argv[1]) + free (tcl_argv[1]); } } @@ -1226,18 +1241,19 @@ weechat_tcl_api_config_section_create_option_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *tcl_argv[5], empty_arg[1] = { '\0' }; + char *tcl_argv[6], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (config_file); - tcl_argv[1] = script_ptr2str (section); - tcl_argv[2] = (option_name) ? (char *)option_name : empty_arg; - tcl_argv[3] = (value) ? (char *)value : empty_arg; - tcl_argv[4] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (config_file); + tcl_argv[2] = script_ptr2str (section); + tcl_argv[3] = (option_name) ? (char *)option_name : empty_arg; + tcl_argv[4] = (value) ? (char *)value : empty_arg; + tcl_argv[5] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1251,10 +1267,10 @@ weechat_tcl_api_config_section_create_option_cb (void *data, ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); if (tcl_argv[1]) free (tcl_argv[1]); + if (tcl_argv[2]) + free (tcl_argv[2]); return ret; } @@ -1274,17 +1290,18 @@ weechat_tcl_api_config_section_delete_option_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *tcl_argv[4]; + char *tcl_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (config_file); - tcl_argv[1] = script_ptr2str (section); - tcl_argv[2] = script_ptr2str (option); - tcl_argv[3] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (config_file); + tcl_argv[2] = script_ptr2str (section); + tcl_argv[3] = script_ptr2str (option); + tcl_argv[4] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1298,12 +1315,12 @@ weechat_tcl_api_config_section_delete_option_cb (void *data, ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); if (tcl_argv[1]) free (tcl_argv[1]); if (tcl_argv[2]) free (tcl_argv[2]); + if (tcl_argv[3]) + free (tcl_argv[3]); return ret; } @@ -1321,9 +1338,10 @@ weechat_tcl_api_config_new_section (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj* objp; - char *result, *cfg_file, *name, *function_read, *function_write; - char *function_write_default, *function_create_option; - char *function_delete_option; + char *result, *cfg_file, *name, *function_read, *data_read; + char *function_write, *data_write, *function_write_default; + char *data_write_default, *function_create_option, *data_create_option; + char *function_delete_option, *data_delete_option; int i, can_add, can_delete; /* make C compiler happy */ @@ -1331,30 +1349,36 @@ weechat_tcl_api_config_new_section (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new_section"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_new_section"); TCL_RETURN_EMPTY; } - if (objc < 10) + if (objc < 15) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_new_section"); TCL_RETURN_EMPTY; } if ((Tcl_GetIntFromObj (interp, objv[3], &can_add) != TCL_OK) || (Tcl_GetIntFromObj (interp, objv[4], &can_delete) != TCL_OK)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_new_section"); TCL_RETURN_EMPTY; } cfg_file = Tcl_GetStringFromObj (objv[1], &i); name = Tcl_GetStringFromObj (objv[2], &i); function_read = Tcl_GetStringFromObj (objv[5], &i); - function_write = Tcl_GetStringFromObj (objv[6], &i); - function_write_default = Tcl_GetStringFromObj (objv[7], &i); - function_create_option = Tcl_GetStringFromObj (objv[8], &i); - function_delete_option = Tcl_GetStringFromObj (objv[9], &i); + data_read = Tcl_GetStringFromObj (objv[6], &i); + function_write = Tcl_GetStringFromObj (objv[7], &i); + data_write = Tcl_GetStringFromObj (objv[8], &i); + function_write_default = Tcl_GetStringFromObj (objv[9], &i); + data_write_default = Tcl_GetStringFromObj (objv[10], &i); + function_create_option = Tcl_GetStringFromObj (objv[11], &i); + data_create_option = Tcl_GetStringFromObj (objv[12], &i); + function_delete_option = Tcl_GetStringFromObj (objv[13], &i); + data_delete_option = Tcl_GetStringFromObj (objv[14], &i); + result = script_ptr2str (script_api_config_new_section (weechat_tcl_plugin, tcl_current_script, script_str2ptr (cfg_file), @@ -1363,14 +1387,19 @@ weechat_tcl_api_config_new_section (ClientData clientData, Tcl_Interp *interp, can_delete, /* user_can_delete_options */ &weechat_tcl_api_config_section_read_cb, function_read, + data_read, &weechat_tcl_api_config_section_write_cb, function_write, + data_write, &weechat_tcl_api_config_section_write_default_cb, function_write_default, + data_write_default, &weechat_tcl_api_config_section_create_option_cb, function_create_option, + data_create_option, &weechat_tcl_api_config_section_delete_option_cb, - function_delete_option)); + function_delete_option, + data_delete_option)); TCL_RETURN_STRING_FREE(result); } @@ -1392,18 +1421,19 @@ weechat_tcl_api_config_search_section (ClientData clientData, Tcl_Interp *interp if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_search_section"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_search_section"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_search_section"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_search_section"); TCL_RETURN_EMPTY; } config_file = Tcl_GetStringFromObj (objv[1], &i); section_name = Tcl_GetStringFromObj (objv[2], &i); + result = script_ptr2str (weechat_config_search_section (script_str2ptr (config_file), section_name)); @@ -1422,16 +1452,17 @@ weechat_tcl_api_config_option_check_value_cb (void *data, const char *value) { struct t_script_callback *script_callback; - char *tcl_argv[3], empty_arg[1] = { '\0' }; + char *tcl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (option); - tcl_argv[1] = (value) ? (char *)value : empty_arg; - tcl_argv[2] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (option); + tcl_argv[2] = (value) ? (char *)value : empty_arg; + tcl_argv[3] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1445,8 +1476,8 @@ weechat_tcl_api_config_option_check_value_cb (void *data, ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); + if (tcl_argv[1]) + free (tcl_argv[1]); return ret; } @@ -1463,23 +1494,24 @@ weechat_tcl_api_config_option_change_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *tcl_argv[2]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (option); - tcl_argv[1] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (option); + tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, script_callback->function, tcl_argv); - if (tcl_argv[0]) - free (tcl_argv[0]); + if (tcl_argv[1]) + free (tcl_argv[1]); if (rc) free (rc); @@ -1495,23 +1527,24 @@ weechat_tcl_api_config_option_delete_cb (void *data, struct t_config_option *option) { struct t_script_callback *script_callback; - char *tcl_argv[2]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; int *rc; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (option); - tcl_argv[1] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (option); + tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, script_callback->function, tcl_argv); - if (tcl_argv[0]) - free (tcl_argv[0]); + if (tcl_argv[1]) + free (tcl_argv[1]); if (rc) free (rc); @@ -1529,7 +1562,8 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp, Tcl_Obj* objp; char *result, *config_file, *section, *name, *type; char *description, *string_values, *default_value, *value; - char *function_check_value, *function_change, *function_delete; + char *function_check_value, *data_check_value, *function_change; + char *data_change, *function_delete, *data_delete; int i, min, max, null_value_allowed; /* make C compiler happy */ @@ -1537,13 +1571,13 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_new_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_new_option"); TCL_RETURN_EMPTY; } - if (objc < 15) + if (objc < 18) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_new_option"); TCL_RETURN_EMPTY; } @@ -1551,7 +1585,7 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp, || (Tcl_GetIntFromObj (interp, objv[8], &max) != TCL_OK) || (Tcl_GetIntFromObj (interp, objv[11], &null_value_allowed) != TCL_OK)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_new_option"); TCL_RETURN_EMPTY; } @@ -1564,9 +1598,12 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp, default_value = Tcl_GetStringFromObj (objv[9], &i); value = Tcl_GetStringFromObj (objv[10], &i); function_check_value = Tcl_GetStringFromObj (objv[12], &i); - function_change = Tcl_GetStringFromObj (objv[13], &i); - function_delete = Tcl_GetStringFromObj (objv[14], &i); - + data_check_value = Tcl_GetStringFromObj (objv[13], &i); + function_change = Tcl_GetStringFromObj (objv[14], &i); + data_change = Tcl_GetStringFromObj (objv[15], &i); + function_delete = Tcl_GetStringFromObj (objv[16], &i); + data_delete = Tcl_GetStringFromObj (objv[17], &i); + result = script_ptr2str (script_api_config_new_option (weechat_tcl_plugin, tcl_current_script, script_str2ptr (config_file), @@ -1582,10 +1619,13 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp, null_value_allowed, &weechat_tcl_api_config_option_check_value_cb, function_check_value, + data_check_value, &weechat_tcl_api_config_option_change_cb, function_change, + data_change, &weechat_tcl_api_config_option_delete_cb, - function_delete)); + function_delete, + data_delete)); TCL_RETURN_STRING_FREE(result); } @@ -1608,19 +1648,20 @@ weechat_tcl_api_config_search_option (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_search_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_search_option"); TCL_RETURN_EMPTY; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_search_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_search_option"); TCL_RETURN_EMPTY; } config_file = Tcl_GetStringFromObj (objv[1], &i); section = Tcl_GetStringFromObj (objv[2], &i); option_name = Tcl_GetStringFromObj (objv[3], &i); + result = script_ptr2str (weechat_config_search_option (script_str2ptr (config_file), script_str2ptr (section), option_name)); @@ -1644,13 +1685,13 @@ weechat_tcl_api_config_string_to_boolean (ClientData clientData, Tcl_Interp *int if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string_to_boolean"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_string_to_boolean"); TCL_RETURN_INT(0); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string_to_boolean"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_string_to_boolean"); TCL_RETURN_INT(0); } @@ -1677,23 +1718,24 @@ weechat_tcl_api_config_option_reset (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_reset"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_option_reset"); TCL_RETURN_INT(0); } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_reset"); TCL_RETURN_INT(0); } if (Tcl_GetIntFromObj (interp, objv[2], &run_callback) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_reset"); TCL_RETURN_INT(0); } option = Tcl_GetStringFromObj (objv[1], &i); + rc = weechat_config_option_reset (script_str2ptr (option), run_callback); @@ -1718,24 +1760,25 @@ weechat_tcl_api_config_option_set (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_option_set"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_set"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } if (Tcl_GetIntFromObj (interp, objv[3], &run_callback) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_set"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } option = Tcl_GetStringFromObj (objv[1], &i); new_value = Tcl_GetStringFromObj (objv[2], &i); + rc = weechat_config_option_set (script_str2ptr (option), new_value, run_callback); @@ -1761,23 +1804,24 @@ weechat_tcl_api_config_option_set_null (ClientData clientData, Tcl_Interp *inter if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_option_set_null"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_set_null"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } if (Tcl_GetIntFromObj (interp, objv[2], &run_callback) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_set_null"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } option = Tcl_GetStringFromObj (objv[1], &i); + rc = weechat_config_option_set_null (script_str2ptr (option), run_callback); @@ -1802,17 +1846,18 @@ weechat_tcl_api_config_option_unset (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_option_unset"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_unset"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } option = Tcl_GetStringFromObj (objv[1], &i); + rc = weechat_config_option_unset (script_str2ptr (option)); TCL_RETURN_INT(rc); @@ -1835,13 +1880,13 @@ weechat_tcl_api_config_option_rename (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_option_rename"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_rename"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_rename"); TCL_RETURN_ERROR; } @@ -1870,13 +1915,13 @@ weechat_tcl_api_config_option_is_null (ClientData clientData, Tcl_Interp *interp if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_option_is_null"); TCL_RETURN_INT(1); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_is_null"); TCL_RETURN_INT(1); } @@ -1903,13 +1948,13 @@ weechat_tcl_api_config_option_default_is_null (ClientData clientData, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_option_default_is_null"); TCL_RETURN_INT(1); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_default_is_null"); TCL_RETURN_INT(1); } @@ -1934,13 +1979,13 @@ weechat_tcl_api_config_boolean (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_boolean"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_boolean"); TCL_RETURN_INT(0); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_boolean"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_boolean"); TCL_RETURN_INT(0); } @@ -1965,13 +2010,13 @@ weechat_tcl_api_config_boolean_default (ClientData clientData, Tcl_Interp *inter if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_boolean_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_boolean_default"); TCL_RETURN_INT(0); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_boolean_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_boolean_default"); TCL_RETURN_INT(0); } @@ -1996,13 +2041,13 @@ weechat_tcl_api_config_integer (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_integer"); TCL_RETURN_INT(0); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_integer"); TCL_RETURN_INT(0); } @@ -2027,13 +2072,13 @@ weechat_tcl_api_config_integer_default (ClientData clientData, Tcl_Interp *inter if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_integer_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_integer_default"); TCL_RETURN_INT(0); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_integer_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_integer_default"); TCL_RETURN_INT(0); } @@ -2059,13 +2104,13 @@ weechat_tcl_api_config_string (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_string"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_string"); TCL_RETURN_EMPTY; } @@ -2091,13 +2136,13 @@ weechat_tcl_api_config_string_default (ClientData clientData, Tcl_Interp *interp if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_string_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_string_default"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_string_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_string_default"); TCL_RETURN_EMPTY; } @@ -2123,13 +2168,13 @@ weechat_tcl_api_config_color (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_color"); TCL_RETURN_INT(0); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_color"); TCL_RETURN_INT(0); } @@ -2155,13 +2200,13 @@ weechat_tcl_api_config_color_default (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_color_default"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_color_default"); TCL_RETURN_INT(0); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_color_default"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_color_default"); TCL_RETURN_INT(0); } @@ -2187,18 +2232,19 @@ weechat_tcl_api_config_write_option (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_write_option"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_write_option"); TCL_RETURN_ERROR; } config_file = Tcl_GetStringFromObj (objv[1], &i); option = Tcl_GetStringFromObj (objv[2], &i); + weechat_config_write_option (script_str2ptr (config_file), script_str2ptr (option)); @@ -2222,19 +2268,20 @@ weechat_tcl_api_config_write_line (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_line"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_write_line"); TCL_RETURN_ERROR; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_line"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_write_line"); TCL_RETURN_ERROR; } config_file = Tcl_GetStringFromObj (objv[1], &i); option_name = Tcl_GetStringFromObj (objv[2], &i); value = Tcl_GetStringFromObj (objv[3], &i); + weechat_config_write_line (script_str2ptr (config_file), option_name, "%s", value); @@ -2258,13 +2305,13 @@ weechat_tcl_api_config_write (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_write"); TCL_RETURN_INT(-1); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_write"); TCL_RETURN_INT(-1); } @@ -2290,13 +2337,13 @@ weechat_tcl_api_config_read (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_read"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_read"); TCL_RETURN_INT(-1); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_read"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_read"); TCL_RETURN_INT(-1); } @@ -2322,13 +2369,13 @@ weechat_tcl_api_config_reload (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_reload"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_reload"); TCL_RETURN_INT(-1); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_reload"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_reload"); TCL_RETURN_INT(-1); } @@ -2353,13 +2400,13 @@ weechat_tcl_api_config_option_free (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_option_free"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_option_free"); TCL_RETURN_ERROR; } @@ -2387,13 +2434,13 @@ weechat_tcl_api_config_section_free_options (ClientData clientData, Tcl_Interp * if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free_options"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_section_free_options"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free_options"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_section_free_options"); TCL_RETURN_ERROR; } @@ -2420,13 +2467,13 @@ weechat_tcl_api_config_section_free (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_section_free"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_section_free"); TCL_RETURN_ERROR; } @@ -2453,13 +2500,13 @@ weechat_tcl_api_config_free (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_free"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_free"); TCL_RETURN_ERROR; } @@ -2487,13 +2534,13 @@ weechat_tcl_api_config_get (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_get"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_get"); TCL_RETURN_EMPTY; } @@ -2519,13 +2566,13 @@ weechat_tcl_api_config_get_plugin (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_get_plugin"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_get_plugin"); TCL_RETURN_EMPTY; } @@ -2553,13 +2600,13 @@ weechat_tcl_api_config_set_plugin (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_set_plugin"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_set_plugin"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } @@ -2591,13 +2638,13 @@ weechat_tcl_api_config_unset_plugin (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_unset_plugin"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_unset_plugin"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_unset_plugin"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_unset_plugin"); TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); } @@ -2627,13 +2674,13 @@ weechat_tcl_api_prefix (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("prefix"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "prefix"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prefix"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "prefix"); TCL_RETURN_EMPTY; } @@ -2659,13 +2706,13 @@ weechat_tcl_api_color (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("color"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "color"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "color"); TCL_RETURN_EMPTY; } @@ -2691,18 +2738,19 @@ weechat_tcl_api_print (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "print"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "print"); TCL_RETURN_ERROR; } buffer = Tcl_GetStringFromObj (objv[1], &i); message = Tcl_GetStringFromObj (objv[2], &i); + script_api_printf (weechat_tcl_plugin, tcl_current_script, script_str2ptr (buffer), @@ -2729,25 +2777,26 @@ weechat_tcl_api_print_date_tags (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print_date_tags"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "print_date_tags"); TCL_RETURN_ERROR; } if (objc < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_date_tags"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "print_date_tags"); TCL_RETURN_ERROR; } if (Tcl_GetIntFromObj (interp, objv[2], &tdate) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_date_tags"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "print_date_tags"); TCL_RETURN_EMPTY; } buffer = Tcl_GetStringFromObj (objv[1], &i); tags = Tcl_GetStringFromObj (objv[3], &i); message = Tcl_GetStringFromObj (objv[4], &i); + script_api_printf_date_tags (weechat_tcl_plugin, tcl_current_script, script_str2ptr (buffer), @@ -2775,24 +2824,25 @@ weechat_tcl_api_print_y (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print_y"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "print_y"); TCL_RETURN_ERROR; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_y"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "print_y"); TCL_RETURN_ERROR; } if (Tcl_GetIntFromObj (interp, objv[2], &y) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print_y"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "print_y"); TCL_RETURN_ERROR; } buffer = Tcl_GetStringFromObj (objv[1], &i); message = Tcl_GetStringFromObj (objv[3], &i); + script_api_printf_y (weechat_tcl_plugin, tcl_current_script, script_str2ptr (buffer), @@ -2818,13 +2868,13 @@ weechat_tcl_api_log_print (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("log_print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "log_print"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("log_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "log_print"); TCL_RETURN_ERROR; } @@ -2841,10 +2891,10 @@ weechat_tcl_api_log_print (ClientData clientData, Tcl_Interp *interp, int weechat_tcl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, - int argc, char **argv, char **argv_eol) + int argc, char **argv, char **argv_eol) { struct t_script_callback *script_callback; - char *tcl_argv[3], empty_arg[1] = { '\0' }; + char *tcl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; /* make C compiler happy */ @@ -2854,9 +2904,10 @@ weechat_tcl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (buffer); - tcl_argv[1] = (argc > 1) ? argv_eol[1] : empty_arg; - tcl_argv[2] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (buffer); + tcl_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg; + tcl_argv[3] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2870,8 +2921,8 @@ weechat_tcl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); + if (tcl_argv[1]) + free (tcl_argv[1]); return ret; } @@ -2889,7 +2940,7 @@ weechat_tcl_api_hook_command (ClientData clientData, Tcl_Interp *interp, { Tcl_Obj *objp; char *result, *command, *description, *args, *args_description; - char *completion, *function; + char *completion, *function, *data; int i; /* make C compiler happy */ @@ -2897,13 +2948,13 @@ weechat_tcl_api_hook_command (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_command"); TCL_RETURN_EMPTY; } - if (objc < 7) + if (objc < 8) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_command"); TCL_RETURN_EMPTY; } @@ -2913,6 +2964,8 @@ weechat_tcl_api_hook_command (ClientData clientData, Tcl_Interp *interp, args_description = Tcl_GetStringFromObj (objv[4], &i); completion = Tcl_GetStringFromObj (objv[5], &i); function = Tcl_GetStringFromObj (objv[6], &i); + data = Tcl_GetStringFromObj (objv[7], &i); + result = script_ptr2str (script_api_hook_command (weechat_tcl_plugin, tcl_current_script, command, @@ -2921,7 +2974,8 @@ weechat_tcl_api_hook_command (ClientData clientData, Tcl_Interp *interp, args_description, completion, &weechat_tcl_api_hook_command_cb, - function)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -2935,16 +2989,17 @@ weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, const char *command) { struct t_script_callback *script_callback; - char *tcl_argv[3], empty_arg[1] = { '\0' }; + char *tcl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (buffer); - tcl_argv[1] = (command) ? (char *)command : empty_arg; - tcl_argv[2] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (buffer); + tcl_argv[2] = (command) ? (char *)command : empty_arg; + tcl_argv[3] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2958,8 +3013,8 @@ weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); + if (tcl_argv[1]) + free (tcl_argv[1]); return ret; } @@ -2976,7 +3031,7 @@ weechat_tcl_api_hook_command_run (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *command, *function; + char *result, *command, *function, *data; int i; /* make C compiler happy */ @@ -2984,23 +3039,26 @@ weechat_tcl_api_hook_command_run (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command_run"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_command_run"); TCL_RETURN_EMPTY; } - if (objc < 3) + if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command_run"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_command_run"); TCL_RETURN_EMPTY; } - + command = Tcl_GetStringFromObj (objv[1], &i); function = Tcl_GetStringFromObj (objv[2], &i); + data = Tcl_GetStringFromObj (objv[3], &i); + result = script_ptr2str (script_api_hook_command_run (weechat_tcl_plugin, tcl_current_script, command, &weechat_tcl_api_hook_command_run_cb, - function)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -3013,7 +3071,7 @@ int weechat_tcl_api_hook_timer_cb (void *data, int remaining_calls) { struct t_script_callback *script_callback; - char *tcl_argv[2], str_remaining_calls[32]; + char *tcl_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3023,8 +3081,9 @@ weechat_tcl_api_hook_timer_cb (void *data, int remaining_calls) snprintf (str_remaining_calls, sizeof (str_remaining_calls), "%d", remaining_calls); - tcl_argv[0] = str_remaining_calls; - tcl_argv[1] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = str_remaining_calls; + tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3056,20 +3115,19 @@ weechat_tcl_api_hook_timer (ClientData clientData, Tcl_Interp *interp, Tcl_Obj *objp; char *result; int i, interval, align_second, max_calls; - /* make C compiler happy */ (void) clientData; if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_timer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_timer"); TCL_RETURN_EMPTY; } - if (objc < 5) + if (objc < 6) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_timer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_timer"); TCL_RETURN_EMPTY; } @@ -3077,7 +3135,7 @@ weechat_tcl_api_hook_timer (ClientData clientData, Tcl_Interp *interp, || (Tcl_GetIntFromObj (interp, objv[2], &align_second) != TCL_OK) || (Tcl_GetIntFromObj (interp, objv[3], &max_calls) != TCL_OK)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_timer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_timer"); TCL_RETURN_EMPTY; } @@ -3088,7 +3146,8 @@ weechat_tcl_api_hook_timer (ClientData clientData, Tcl_Interp *interp, align_second, /* align_second */ max_calls, /* max_calls */ &weechat_tcl_api_hook_timer_cb, - Tcl_GetStringFromObj (objv[4], &i))); /* tcl function */ + Tcl_GetStringFromObj (objv[4], &i), /* tcl function */ + Tcl_GetStringFromObj (objv[5], &i))); /* data */ TCL_RETURN_STRING_FREE(result); } @@ -3101,7 +3160,7 @@ int weechat_tcl_api_hook_fd_cb (void *data, int fd) { struct t_script_callback *script_callback; - char *tcl_argv[2], str_fd[32]; + char *tcl_argv[3], str_fd[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3110,8 +3169,9 @@ weechat_tcl_api_hook_fd_cb (void *data, int fd) { snprintf (str_fd, sizeof (str_fd), "%d", fd); - tcl_argv[0] = str_fd; - tcl_argv[1] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = str_fd; + tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3149,13 +3209,13 @@ weechat_tcl_api_hook_fd (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_fd"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_fd"); TCL_RETURN_EMPTY; } - if (objc < 6) + if (objc < 7) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_fd"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_fd"); TCL_RETURN_EMPTY; } @@ -3164,7 +3224,7 @@ weechat_tcl_api_hook_fd (ClientData clientData, Tcl_Interp *interp, || (Tcl_GetIntFromObj (interp, objv[3], &write) != TCL_OK) || (Tcl_GetIntFromObj (interp, objv[4], &exception) != TCL_OK)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_fd"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_fd"); TCL_RETURN_EMPTY; } @@ -3175,7 +3235,8 @@ weechat_tcl_api_hook_fd (ClientData clientData, Tcl_Interp *interp, write, /* write */ exception, /* exception */ &weechat_tcl_api_hook_fd_cb, - Tcl_GetStringFromObj (objv[5], &i))); /* tcl function */ + Tcl_GetStringFromObj (objv[5], &i), /* tcl function */ + Tcl_GetStringFromObj (objv[6], &i))); /* data */ TCL_RETURN_STRING_FREE(result); } @@ -3190,7 +3251,7 @@ weechat_tcl_api_hook_process_cb (void *data, const char *stdout, const char *stderr) { struct t_script_callback *script_callback; - char *tcl_argv[5], str_rc[32], empty_arg[1] = { '\0' }; + char *tcl_argv[6], str_rc[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3199,11 +3260,12 @@ weechat_tcl_api_hook_process_cb (void *data, { snprintf (str_rc, sizeof (str_rc), "%d", return_code); - tcl_argv[0] = (command) ? (char *)command : empty_arg; - tcl_argv[1] = str_rc; - tcl_argv[2] = (stdout) ? (char *)stdout : empty_arg; - tcl_argv[3] = (stderr) ? (char *)stderr : empty_arg; - tcl_argv[4] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = (command) ? (char *)command : empty_arg; + tcl_argv[2] = str_rc; + tcl_argv[3] = (stdout) ? (char *)stdout : empty_arg; + tcl_argv[4] = (stderr) ? (char *)stderr : empty_arg; + tcl_argv[5] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3233,7 +3295,7 @@ weechat_tcl_api_hook_process (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *command, *function, *result; + char *command, *function, *data, *result; int i, timeout; /* make C compiler happy */ @@ -3241,31 +3303,33 @@ weechat_tcl_api_hook_process (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_process"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_process"); TCL_RETURN_EMPTY; } - if (objc < 4) + if (objc < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_process"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_process"); TCL_RETURN_EMPTY; } if ((Tcl_GetIntFromObj (interp, objv[2], &timeout) != TCL_OK)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_process"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_process"); TCL_RETURN_EMPTY; } command = Tcl_GetStringFromObj (objv[1], &i); function = Tcl_GetStringFromObj (objv[3], &i); + data = Tcl_GetStringFromObj (objv[4], &i); result = script_ptr2str (script_api_hook_process (weechat_tcl_plugin, tcl_current_script, command, timeout, &weechat_tcl_api_hook_process_cb, - function)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -3279,7 +3343,7 @@ weechat_tcl_api_hook_connect_cb (void *data, int status, const char *error, const char *ip_address) { struct t_script_callback *script_callback; - char *tcl_argv[4], str_status[32], empty_arg[1] = { '\0' }; + char *tcl_argv[5], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3288,10 +3352,11 @@ weechat_tcl_api_hook_connect_cb (void *data, int status, { snprintf (str_status, sizeof (str_status), "%d", status); - tcl_argv[0] = str_status; - tcl_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; - tcl_argv[2] = (error) ? (char *)error : empty_arg; - tcl_argv[3] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = str_status; + tcl_argv[2] = (ip_address) ? (char *)ip_address : empty_arg; + tcl_argv[3] = (error) ? (char *)error : empty_arg; + tcl_argv[4] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3321,7 +3386,7 @@ weechat_tcl_api_hook_connect (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *proxy, *address, *local_hostname, *function, *result; + char *proxy, *address, *local_hostname, *function, *data, *result; int i, port, sock, ipv6; /* make C compiler happy */ @@ -3329,13 +3394,13 @@ weechat_tcl_api_hook_connect (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_connect"); TCL_RETURN_EMPTY; } - if (objc < 8) + if (objc < 9) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_connect"); TCL_RETURN_EMPTY; } @@ -3343,7 +3408,7 @@ weechat_tcl_api_hook_connect (ClientData clientData, Tcl_Interp *interp, || (Tcl_GetIntFromObj (interp, objv[4], &sock) != TCL_OK) || (Tcl_GetIntFromObj (interp, objv[5], &ipv6) != TCL_OK)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_connect"); TCL_RETURN_EMPTY; } @@ -3351,6 +3416,7 @@ weechat_tcl_api_hook_connect (ClientData clientData, Tcl_Interp *interp, address = Tcl_GetStringFromObj (objv[2], &i); local_hostname = Tcl_GetStringFromObj (objv[6], &i); function = Tcl_GetStringFromObj (objv[7], &i); + data = Tcl_GetStringFromObj (objv[8], &i); result = script_ptr2str (script_api_hook_connect (weechat_tcl_plugin, tcl_current_script, @@ -3362,7 +3428,8 @@ weechat_tcl_api_hook_connect (ClientData clientData, Tcl_Interp *interp, NULL, /* gnutls session */ local_hostname, &weechat_tcl_api_hook_connect_cb, - function)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -3379,7 +3446,7 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, const char *prefix, const char *message) { struct t_script_callback *script_callback; - char *tcl_argv[8], empty_arg[1] = { '\0' }; + char *tcl_argv[9], empty_arg[1] = { '\0' }; static char timebuffer[64]; int *rc, ret; @@ -3392,16 +3459,17 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, { snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date); - tcl_argv[0] = script_ptr2str (buffer); - tcl_argv[1] = timebuffer; - tcl_argv[2] = weechat_string_build_with_exploded (tags, ","); - if (!tcl_argv[2]) - tcl_argv[2] = strdup (""); - tcl_argv[3] = (displayed) ? strdup ("1") : strdup ("0"); - tcl_argv[4] = (highlight) ? strdup ("1") : strdup ("0"); - tcl_argv[5] = (prefix) ? (char *)prefix : empty_arg; - tcl_argv[6] = (message) ? (char *)message : empty_arg; - tcl_argv[7] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (buffer); + tcl_argv[2] = timebuffer; + tcl_argv[3] = weechat_string_build_with_exploded (tags, ","); + if (!tcl_argv[3]) + tcl_argv[3] = strdup (""); + tcl_argv[4] = (displayed) ? strdup ("1") : strdup ("0"); + tcl_argv[5] = (highlight) ? strdup ("1") : strdup ("0"); + tcl_argv[6] = (prefix) ? (char *)prefix : empty_arg; + tcl_argv[7] = (message) ? (char *)message : empty_arg; + tcl_argv[8] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3415,14 +3483,14 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); - if (tcl_argv[2]) - free (tcl_argv[2]); + if (tcl_argv[1]) + free (tcl_argv[1]); if (tcl_argv[3]) free (tcl_argv[3]); if (tcl_argv[4]) free (tcl_argv[4]); + if (tcl_argv[5]) + free (tcl_argv[5]); return ret; } @@ -3439,7 +3507,7 @@ weechat_tcl_api_hook_print (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *buffer, *tags, *message, *function; + char *result, *buffer, *tags, *message, *function, *data; int i, strip_colors; /* make C compiler happy */ @@ -3447,19 +3515,19 @@ weechat_tcl_api_hook_print (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_print"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_print"); TCL_RETURN_EMPTY; } - if (objc < 6) + if (objc < 7) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_print"); TCL_RETURN_EMPTY; } if (Tcl_GetIntFromObj (interp, objv[4], &strip_colors) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_print"); TCL_RETURN_EMPTY; } @@ -3467,6 +3535,8 @@ weechat_tcl_api_hook_print (ClientData clientData, Tcl_Interp *interp, tags = Tcl_GetStringFromObj (objv[2], &i); message = Tcl_GetStringFromObj (objv[3], &i); function = Tcl_GetStringFromObj (objv[5], &i); + data = Tcl_GetStringFromObj (objv[6], &i); + result = script_ptr2str (script_api_hook_print (weechat_tcl_plugin, tcl_current_script, script_str2ptr (buffer), @@ -3474,7 +3544,8 @@ weechat_tcl_api_hook_print (ClientData clientData, Tcl_Interp *interp, message, strip_colors, /* strip_colors */ &weechat_tcl_api_hook_print_cb, - function)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -3488,7 +3559,7 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type void *signal_data) { struct t_script_callback *script_callback; - char *tcl_argv[3], empty_arg[1] = { '\0' }; + char *tcl_argv[4], empty_arg[1] = { '\0' }; static char value_str[64]; int *rc, ret, free_needed; @@ -3496,26 +3567,27 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (char *)signal; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = (signal) ? (char *)signal : empty_arg; free_needed = 0; if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0) { - tcl_argv[1] = (signal_data) ? (char *)signal_data : empty_arg; + tcl_argv[2] = (signal_data) ? (char *)signal_data : empty_arg; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0) { snprintf (value_str, sizeof (value_str) - 1, "%d", *((int *)signal_data)); - tcl_argv[1] = value_str; + tcl_argv[2] = value_str; } else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0) { - tcl_argv[1] = script_ptr2str (signal_data); + tcl_argv[2] = script_ptr2str (signal_data); free_needed = 1; } else - tcl_argv[1] = empty_arg; - tcl_argv[2] = NULL; + tcl_argv[2] = empty_arg; + tcl_argv[3] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3529,8 +3601,8 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type ret = *rc; free (rc); } - if (free_needed && tcl_argv[1]) - free (tcl_argv[1]); + if (free_needed && tcl_argv[2]) + free (tcl_argv[2]); return ret; } @@ -3547,7 +3619,7 @@ weechat_tcl_api_hook_signal (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *signal, *function; + char *result, *signal, *function, *data; int i; /* make C compiler happy */ @@ -3555,23 +3627,26 @@ weechat_tcl_api_hook_signal (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_signal"); TCL_RETURN_EMPTY; } - if (objc < 3) + if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_signal"); TCL_RETURN_EMPTY; } signal = Tcl_GetStringFromObj (objv[1], &i); function = Tcl_GetStringFromObj (objv[2], &i); + data = Tcl_GetStringFromObj (objv[3], &i); + result = script_ptr2str (script_api_hook_signal (weechat_tcl_plugin, tcl_current_script, signal, &weechat_tcl_api_hook_signal_cb, - function)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -3594,13 +3669,13 @@ weechat_tcl_api_hook_signal_send (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal_send"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_signal_send"); TCL_RETURN_ERROR; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal_send"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_signal_send"); TCL_RETURN_ERROR; } @@ -3643,16 +3718,17 @@ int weechat_tcl_api_hook_config_cb (void *data, const char *option, const char *value) { struct t_script_callback *script_callback; - char *tcl_argv[3], empty_arg[1] = { '\0' }; + char *tcl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (option) ? (char *)option : empty_arg; - tcl_argv[1] = (value) ? (char *)value : empty_arg; - tcl_argv[2] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = (option) ? (char *)option : empty_arg; + tcl_argv[2] = (value) ? (char *)value : empty_arg; + tcl_argv[3] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3682,7 +3758,7 @@ weechat_tcl_api_hook_config (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *option, *function; + char *result, *option, *function, *data; int i; /* make C compiler happy */ @@ -3690,23 +3766,26 @@ weechat_tcl_api_hook_config (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_config"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_config"); TCL_RETURN_EMPTY; } - if (objc < 3) + if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_config"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_config"); TCL_RETURN_EMPTY; } option = Tcl_GetStringFromObj (objv[1], &i); function = Tcl_GetStringFromObj (objv[2], &i); + data = Tcl_GetStringFromObj (objv[3], &i); + result = script_ptr2str (script_api_hook_config (weechat_tcl_plugin, tcl_current_script, option, &weechat_tcl_api_hook_config_cb, - function)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -3721,17 +3800,18 @@ weechat_tcl_api_hook_completion_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_script_callback *script_callback; - char *tcl_argv[4], empty_arg[1] = { '\0' }; + char *tcl_argv[5], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (completion_item) ? (char *)completion_item : empty_arg; - tcl_argv[1] = script_ptr2str (buffer); - tcl_argv[2] = script_ptr2str (completion); - tcl_argv[3] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = (completion_item) ? (char *)completion_item : empty_arg; + tcl_argv[2] = script_ptr2str (buffer); + tcl_argv[3] = script_ptr2str (completion); + tcl_argv[4] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -3745,10 +3825,10 @@ weechat_tcl_api_hook_completion_cb (void *data, const char *completion_item, ret = *rc; free (rc); } - if (tcl_argv[1]) - free (tcl_argv[1]); if (tcl_argv[2]) free (tcl_argv[2]); + if (tcl_argv[3]) + free (tcl_argv[3]); return ret; } @@ -3765,7 +3845,7 @@ weechat_tcl_api_hook_completion (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *completion, *description, *function; + char *result, *completion, *description, *function, *data; int i; /* make C compiler happy */ @@ -3773,25 +3853,28 @@ weechat_tcl_api_hook_completion (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_completion"); TCL_RETURN_EMPTY; } - if (objc < 4) + if (objc < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_completion"); TCL_RETURN_EMPTY; } completion = Tcl_GetStringFromObj (objv[1], &i); description = Tcl_GetStringFromObj (objv[2], &i); function = Tcl_GetStringFromObj (objv[3], &i); + data = Tcl_GetStringFromObj (objv[4], &i); + result = script_ptr2str (script_api_hook_completion (weechat_tcl_plugin, tcl_current_script, completion, description, &weechat_tcl_api_hook_completion_cb, - function)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -3813,19 +3896,19 @@ weechat_tcl_api_hook_completion_list_add (ClientData clientData, Tcl_Interp *int if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); TCL_RETURN_ERROR; } if (objc < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); TCL_RETURN_ERROR; } if (Tcl_GetIntFromObj (interp, objv[3], &nick_completion) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion_list_add"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_completion_list_add"); TCL_RETURN_ERROR; } @@ -3850,16 +3933,17 @@ weechat_tcl_api_hook_modifier_cb (void *data, const char *modifier, const char *modifier_data, const char *string) { struct t_script_callback *script_callback; - char *tcl_argv[4], empty_arg[1] = { '\0' }; + char *tcl_argv[5], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (modifier) ? (char *)modifier : empty_arg; - tcl_argv[1] = (modifier_data) ? (char *)modifier_data : empty_arg; - tcl_argv[2] = (string) ? (char *)string : empty_arg; - tcl_argv[3] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = (modifier) ? (char *)modifier : empty_arg; + tcl_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg; + tcl_argv[3] = (string) ? (char *)string : empty_arg; + tcl_argv[4] = NULL; return (char *)weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -3879,7 +3963,7 @@ weechat_tcl_api_hook_modifier (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *modifier, *tcl_fn; + char *result, *modifier, *function, *data; int i; /* make C compiler happy */ @@ -3887,23 +3971,26 @@ weechat_tcl_api_hook_modifier (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_modifier"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_modifier"); TCL_RETURN_EMPTY; } - if (objc < 3) + if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_modifier"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_modifier"); TCL_RETURN_EMPTY; } modifier = Tcl_GetStringFromObj (objv[1], &i); - tcl_fn = Tcl_GetStringFromObj (objv[2], &i); + function = Tcl_GetStringFromObj (objv[2], &i); + data = Tcl_GetStringFromObj (objv[3], &i); + result = script_ptr2str (script_api_hook_modifier (weechat_tcl_plugin, tcl_current_script, modifier, &weechat_tcl_api_hook_modifier_cb, - tcl_fn)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -3925,19 +4012,20 @@ weechat_tcl_api_hook_modifier_exec (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_modifier_exec"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_modifier_exec"); TCL_RETURN_EMPTY; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_modifier_exec"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_modifier_exec"); TCL_RETURN_EMPTY; } modifier = Tcl_GetStringFromObj (objv[1], &i); modifier_data = Tcl_GetStringFromObj (objv[2], &i); string = Tcl_GetStringFromObj (objv[3], &i); + result = weechat_hook_modifier_exec (modifier, modifier_data, string); TCL_RETURN_STRING_FREE(result); @@ -3952,15 +4040,16 @@ weechat_tcl_api_hook_info_cb (void *data, const char *info_name, const char *arguments) { struct t_script_callback *script_callback; - char *tcl_argv[3], empty_arg[1] = { '\0' }; + char *tcl_argv[4], empty_arg[1] = { '\0' }; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (info_name) ? (char *)info_name : empty_arg; - tcl_argv[1] = (arguments) ? (char *)arguments : empty_arg; - tcl_argv[2] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = (info_name) ? (char *)info_name : empty_arg; + tcl_argv[2] = (arguments) ? (char *)arguments : empty_arg; + tcl_argv[3] = NULL; return (const char *)weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, @@ -3980,7 +4069,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, *tcl_fn; + char *result, *info_name, *description, *function, *data; int i; /* make C compiler happy */ @@ -3988,25 +4077,28 @@ weechat_tcl_api_hook_info (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_info"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_info"); TCL_RETURN_EMPTY; } - if (objc < 4) + if (objc < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_info"); TCL_RETURN_EMPTY; } info_name = Tcl_GetStringFromObj (objv[1], &i); description = Tcl_GetStringFromObj (objv[2], &i); - tcl_fn = Tcl_GetStringFromObj (objv[3], &i); + function = Tcl_GetStringFromObj (objv[3], &i); + data = Tcl_GetStringFromObj (objv[4], &i); + result = script_ptr2str (script_api_hook_info (weechat_tcl_plugin, tcl_current_script, info_name, description, &weechat_tcl_api_hook_info_cb, - tcl_fn)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -4020,25 +4112,26 @@ weechat_tcl_api_hook_infolist_cb (void *data, const char *infolist_name, void *pointer, const char *arguments) { struct t_script_callback *script_callback; - char *tcl_argv[4], empty_arg[1] = { '\0' }; + char *tcl_argv[5], empty_arg[1] = { '\0' }; struct t_infolist *result; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = (infolist_name) ? (char *)infolist_name : empty_arg; - tcl_argv[1] = script_ptr2str (pointer); - tcl_argv[2] = (arguments) ? (char *)arguments : empty_arg; - tcl_argv[3] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg; + tcl_argv[2] = script_ptr2str (pointer); + tcl_argv[3] = (arguments) ? (char *)arguments : empty_arg; + tcl_argv[4] = NULL; result = (struct t_infolist *)weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, script_callback->function, tcl_argv); - if (tcl_argv[1]) - free (tcl_argv[1]); + if (tcl_argv[2]) + free (tcl_argv[2]); return result; } @@ -4055,7 +4148,7 @@ weechat_tcl_api_hook_infolist (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *infolist_name, *description, *tcl_fn; + char *result, *infolist_name, *description, *function, *data; int i; /* make C compiler happy */ @@ -4063,25 +4156,28 @@ weechat_tcl_api_hook_infolist (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_infolist"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_infolist"); TCL_RETURN_EMPTY; } - if (objc < 4) + if (objc < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_infolist"); TCL_RETURN_EMPTY; } infolist_name = Tcl_GetStringFromObj (objv[1], &i); description = Tcl_GetStringFromObj (objv[2], &i); - tcl_fn = Tcl_GetStringFromObj (objv[3], &i); + function = Tcl_GetStringFromObj (objv[3], &i); + data = Tcl_GetStringFromObj (objv[4], &i); + result = script_ptr2str (script_api_hook_infolist (weechat_tcl_plugin, tcl_current_script, infolist_name, description, &weechat_tcl_api_hook_infolist_cb, - tcl_fn)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -4102,13 +4198,13 @@ weechat_tcl_api_unhook (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "unhook"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("unhook"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "unhook"); TCL_RETURN_ERROR; } @@ -4136,7 +4232,7 @@ weechat_tcl_api_unhook_all (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "unhook_all"); TCL_RETURN_ERROR; } @@ -4154,16 +4250,17 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { struct t_script_callback *script_callback; - char *tcl_argv[3], empty_arg[1] = { '\0' }; + char *tcl_argv[4], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (buffer); - tcl_argv[1] = (input_data) ? (char *)input_data : empty_arg; - tcl_argv[2] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (buffer); + tcl_argv[2] = (input_data) ? (char *)input_data : empty_arg; + tcl_argv[3] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -4176,8 +4273,8 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); + if (tcl_argv[1]) + free (tcl_argv[1]); return ret; } @@ -4193,15 +4290,16 @@ int weechat_tcl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) { struct t_script_callback *script_callback; - char *tcl_argv[2]; + char *tcl_argv[3], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (buffer); - tcl_argv[1] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (buffer); + tcl_argv[2] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -4214,8 +4312,8 @@ weechat_tcl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer) ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); + if (tcl_argv[1]) + free (tcl_argv[1]); return ret; } @@ -4232,7 +4330,8 @@ weechat_tcl_api_buffer_new (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *name, *function_input, *function_close; + char *result, *name, *function_input, *data_input, *function_close; + char *data_close; int i; /* make C compiler happy */ @@ -4240,26 +4339,31 @@ weechat_tcl_api_buffer_new (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_new"); TCL_RETURN_EMPTY; } - if (objc < 4) + if (objc < 6) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_new"); TCL_RETURN_EMPTY; } name = Tcl_GetStringFromObj (objv[1], &i); function_input = Tcl_GetStringFromObj (objv[2], &i); - function_close = Tcl_GetStringFromObj (objv[3], &i); + data_input = Tcl_GetStringFromObj (objv[3], &i); + function_close = Tcl_GetStringFromObj (objv[4], &i); + data_close = Tcl_GetStringFromObj (objv[5], &i); + result = script_ptr2str (script_api_buffer_new (weechat_tcl_plugin, tcl_current_script, name, &weechat_tcl_api_buffer_input_data_cb, function_input, + data_input, &weechat_tcl_api_buffer_close_cb, - function_close)); + function_close, + data_close)); TCL_RETURN_STRING_FREE(result); } @@ -4281,18 +4385,19 @@ weechat_tcl_api_buffer_search (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_search"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_search"); TCL_RETURN_EMPTY; } plugin = Tcl_GetStringFromObj (objv[1], &i); name = Tcl_GetStringFromObj (objv[2], &i); + result = script_ptr2str (weechat_buffer_search (plugin, name)); TCL_RETURN_STRING_FREE(result); @@ -4316,7 +4421,7 @@ weechat_tcl_api_current_buffer (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_buffer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "current_buffer"); TCL_RETURN_EMPTY; } @@ -4341,13 +4446,13 @@ weechat_tcl_api_buffer_clear (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_clear"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_clear"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_clear"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_clear"); TCL_RETURN_ERROR; } @@ -4372,13 +4477,13 @@ weechat_tcl_api_buffer_close (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_close"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_close"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_close"); TCL_RETURN_ERROR; } @@ -4407,13 +4512,13 @@ weechat_tcl_api_buffer_get_integer (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_get_integer"); TCL_RETURN_INT(-1); } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_get_integer"); TCL_RETURN_INT(-1); } @@ -4443,13 +4548,13 @@ weechat_tcl_api_buffer_get_string (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_get_string"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_get_string"); TCL_RETURN_EMPTY; } @@ -4478,13 +4583,13 @@ weechat_tcl_api_buffer_get_pointer (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_get_pointer"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_get_pointer"); TCL_RETURN_EMPTY; } @@ -4514,13 +4619,13 @@ weechat_tcl_api_buffer_set (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_set"); TCL_RETURN_ERROR; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_set"); TCL_RETURN_ERROR; } @@ -4551,7 +4656,7 @@ weechat_tcl_api_current_window (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_window"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "current_window"); TCL_RETURN_EMPTY; } @@ -4578,13 +4683,13 @@ weechat_tcl_api_window_get_integer (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "window_get_integer"); TCL_RETURN_INT(-1); } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "window_get_integer"); TCL_RETURN_INT(-1); } @@ -4614,13 +4719,13 @@ weechat_tcl_api_window_get_string (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "window_get_string"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "window_get_string"); TCL_RETURN_EMPTY; } @@ -4649,13 +4754,13 @@ weechat_tcl_api_window_get_pointer (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "window_get_pointer"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "window_get_pointer"); TCL_RETURN_EMPTY; } @@ -4685,19 +4790,19 @@ weechat_tcl_api_nicklist_add_group (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "nicklist_add_group"); TCL_RETURN_EMPTY; } if (objc < 6) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "nicklist_add_group"); TCL_RETURN_EMPTY; } if (Tcl_GetIntFromObj (interp, objv[5], &visible) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "nicklist_add_group"); TCL_RETURN_EMPTY; } @@ -4705,6 +4810,7 @@ weechat_tcl_api_nicklist_add_group (ClientData clientData, Tcl_Interp *interp, parent_group = Tcl_GetStringFromObj (objv[2], &i); name = Tcl_GetStringFromObj (objv[3], &i); color = Tcl_GetStringFromObj (objv[4], &i); + result = script_ptr2str (weechat_nicklist_add_group (script_str2ptr (buffer), script_str2ptr (parent_group), name, @@ -4731,19 +4837,20 @@ weechat_tcl_api_nicklist_search_group (ClientData clientData, Tcl_Interp *interp if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "nicklist_search_group"); TCL_RETURN_EMPTY; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "nicklist_search_group"); TCL_RETURN_EMPTY; } buffer = Tcl_GetStringFromObj (objv[1], &i); from_group = Tcl_GetStringFromObj (objv[2], &i); name = Tcl_GetStringFromObj (objv[3], &i); + result = script_ptr2str (weechat_nicklist_search_group (script_str2ptr (buffer), script_str2ptr (from_group), name)); @@ -4768,19 +4875,19 @@ weechat_tcl_api_nicklist_add_nick (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); TCL_RETURN_EMPTY; } if (objc < 8) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); TCL_RETURN_EMPTY; } if (Tcl_GetIntFromObj (interp, objv[7], &visible) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "nicklist_add_nick"); TCL_RETURN_EMPTY; } @@ -4790,6 +4897,7 @@ weechat_tcl_api_nicklist_add_nick (ClientData clientData, Tcl_Interp *interp, color = Tcl_GetStringFromObj (objv[4], &i); prefix = Tcl_GetStringFromObj (objv[5], &i); prefix_color = Tcl_GetStringFromObj (objv[6], &i); + result = script_ptr2str (weechat_nicklist_add_nick (script_str2ptr (buffer), script_str2ptr (group), name, @@ -4818,19 +4926,20 @@ weechat_tcl_api_nicklist_search_nick (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "nicklist_search_nick"); TCL_RETURN_EMPTY; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "nicklist_search_nick"); TCL_RETURN_EMPTY; } buffer = Tcl_GetStringFromObj (objv[1], &i); from_group = Tcl_GetStringFromObj (objv[2], &i); name = Tcl_GetStringFromObj (objv[3], &i); + result = script_ptr2str (weechat_nicklist_search_nick (script_str2ptr (buffer), script_str2ptr (from_group), name)); @@ -4855,18 +4964,19 @@ weechat_tcl_api_nicklist_remove_group (ClientData clientData, Tcl_Interp *interp if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "nicklist_remove_group"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "nicklist_remove_group"); TCL_RETURN_ERROR; } buffer = Tcl_GetStringFromObj (objv[1], &i); group = Tcl_GetStringFromObj (objv[2], &i); + weechat_nicklist_remove_group (script_str2ptr (buffer), script_str2ptr (group)); @@ -4890,18 +5000,19 @@ weechat_tcl_api_nicklist_remove_nick (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "nicklist_remove_nick"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "nicklist_remove_nick"); TCL_RETURN_ERROR; } buffer = Tcl_GetStringFromObj (objv[1], &i); nick = Tcl_GetStringFromObj (objv[2], &i); + weechat_nicklist_remove_nick (script_str2ptr (buffer), script_str2ptr (nick)); @@ -4924,13 +5035,13 @@ weechat_tcl_api_nicklist_remove_all (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "nicklist_remove_all"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "nicklist_remove_all"); TCL_RETURN_ERROR; } @@ -4956,13 +5067,13 @@ weechat_tcl_api_bar_item_search (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "bar_item_search"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "bar_item_search"); TCL_RETURN_EMPTY; } @@ -4980,25 +5091,26 @@ weechat_tcl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, struct t_gui_window *window) { struct t_script_callback *script_callback; - char *tcl_argv[3], *ret; + char *tcl_argv[4], empty_arg[1] = { '\0' }, *ret; script_callback = (struct t_script_callback *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - tcl_argv[0] = script_ptr2str (item); - tcl_argv[1] = script_ptr2str (window); - tcl_argv[2] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (item); + tcl_argv[2] = script_ptr2str (window); + tcl_argv[3] = NULL; ret = (char *)weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_STRING, script_callback->function, tcl_argv); - if (tcl_argv[0]) - free (tcl_argv[0]); if (tcl_argv[1]) free (tcl_argv[1]); + if (tcl_argv[2]) + free (tcl_argv[2]); return ret; } @@ -5015,7 +5127,7 @@ weechat_tcl_api_bar_item_new (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *objp; - char *result, *name, *function_build; + char *result, *name, *function, *data; int i; /* make C compiler happy */ @@ -5023,23 +5135,26 @@ weechat_tcl_api_bar_item_new (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "bar_item_new"); TCL_RETURN_EMPTY; } - if (objc < 3) + if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "bar_item_new"); TCL_RETURN_EMPTY; } name = Tcl_GetStringFromObj (objv[1], &i); - function_build = Tcl_GetStringFromObj (objv[2], &i); + function = Tcl_GetStringFromObj (objv[2], &i); + data = Tcl_GetStringFromObj (objv[3], &i); + result = script_ptr2str (script_api_bar_item_new (weechat_tcl_plugin, tcl_current_script, name, &weechat_tcl_api_bar_item_build_cb, - function_build)); + function, + data)); TCL_RETURN_STRING_FREE(result); } @@ -5060,13 +5175,13 @@ weechat_tcl_api_bar_item_update (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_update"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "bar_item_update"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_update"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "bar_item_update"); TCL_RETURN_ERROR; } @@ -5091,13 +5206,13 @@ weechat_tcl_api_bar_item_remove (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "bar_item_remove"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "bar_item_remove"); TCL_RETURN_ERROR; } @@ -5125,13 +5240,13 @@ weechat_tcl_api_bar_search (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_search"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "bar_search"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "bar_search"); TCL_RETURN_EMPTY; } @@ -5159,13 +5274,13 @@ weechat_tcl_api_bar_new (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "bar_new"); TCL_RETURN_EMPTY; } if (objc < 16) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "bar_new"); TCL_RETURN_EMPTY; } @@ -5184,6 +5299,7 @@ weechat_tcl_api_bar_new (ClientData clientData, Tcl_Interp *interp, color_bg = Tcl_GetStringFromObj (objv[13], &i); separator = Tcl_GetStringFromObj (objv[14], &i); bar_items = Tcl_GetStringFromObj (objv[15], &i); + result = script_ptr2str (weechat_bar_new (name, hidden, priority, @@ -5220,13 +5336,13 @@ weechat_tcl_api_bar_set (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_set"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "bar_set"); TCL_RETURN_ERROR; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "bar_set"); TCL_RETURN_ERROR; } @@ -5255,13 +5371,13 @@ weechat_tcl_api_bar_update (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_update"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "bar_update"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_update"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "bar_update"); TCL_RETURN_ERROR; } @@ -5286,13 +5402,13 @@ weechat_tcl_api_bar_remove (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_remove"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "bar_remove"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_remove"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "bar_remove"); TCL_RETURN_ERROR; } @@ -5318,18 +5434,19 @@ weechat_tcl_api_command (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("command"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "command"); TCL_RETURN_ERROR; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "command"); TCL_RETURN_ERROR; } buffer = Tcl_GetStringFromObj (objv[1], &i); command = Tcl_GetStringFromObj (objv[2], &i); + script_api_command (weechat_tcl_plugin, tcl_current_script, script_str2ptr (buffer), @@ -5355,13 +5472,13 @@ weechat_tcl_api_info_get (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("info_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "info_get"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("info_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "info_get"); TCL_RETURN_EMPTY; } @@ -5389,7 +5506,7 @@ weechat_tcl_api_infolist_new (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_new"); TCL_RETURN_EMPTY; } @@ -5416,19 +5533,19 @@ weechat_tcl_api_infolist_new_var_integer (ClientData clientData, Tcl_Interp *int if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); TCL_RETURN_INT(0); } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); TCL_RETURN_INT(0); } if (Tcl_GetIntFromObj (interp, objv[3], &value) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_new_var_integer"); TCL_RETURN_EMPTY; } @@ -5457,13 +5574,13 @@ weechat_tcl_api_infolist_new_var_string (ClientData clientData, Tcl_Interp *inte if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_new_var_string"); TCL_RETURN_INT(0); } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_new_var_string"); TCL_RETURN_INT(0); } @@ -5491,13 +5608,13 @@ weechat_tcl_api_infolist_new_var_pointer (ClientData clientData, Tcl_Interp *int if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer"); TCL_RETURN_INT(0); } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer"); TCL_RETURN_INT(0); } @@ -5525,19 +5642,19 @@ weechat_tcl_api_infolist_new_var_time (ClientData clientData, Tcl_Interp *interp if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); TCL_RETURN_INT(0); } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); TCL_RETURN_INT(0); } if (Tcl_GetIntFromObj (interp, objv[3], &value) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_new_var_time"); TCL_RETURN_EMPTY; } @@ -5565,19 +5682,20 @@ weechat_tcl_api_infolist_get (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_get"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_get"); TCL_RETURN_EMPTY; } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_get"); TCL_RETURN_EMPTY; } name = Tcl_GetStringFromObj (objv[1], &i); pointer = Tcl_GetStringFromObj (objv[2], &i); arguments = Tcl_GetStringFromObj (objv[3], &i); + result = script_ptr2str (weechat_infolist_get (name, script_str2ptr (pointer), arguments)); @@ -5601,13 +5719,13 @@ weechat_tcl_api_infolist_next (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_next"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_next"); TCL_RETURN_INT(0); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_next"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_next"); TCL_RETURN_INT(0); } @@ -5633,13 +5751,13 @@ weechat_tcl_api_infolist_prev (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_prev"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_prev"); TCL_RETURN_INT(0); } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_prev"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_prev"); TCL_RETURN_INT(0); } @@ -5666,13 +5784,13 @@ weechat_tcl_api_infolist_fields (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_fields"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_fields"); TCL_RETURN_EMPTY; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_fields"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_fields"); TCL_RETURN_EMPTY; } @@ -5699,13 +5817,13 @@ weechat_tcl_api_infolist_integer (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_integer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_integer"); TCL_RETURN_INT(0); } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_integer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_integer"); TCL_RETURN_INT(0); } @@ -5735,13 +5853,13 @@ weechat_tcl_api_infolist_string (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_string"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_string"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_string"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_string"); TCL_RETURN_EMPTY; } @@ -5771,13 +5889,13 @@ weechat_tcl_api_infolist_pointer (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_pointer"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_pointer"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_pointer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_pointer"); TCL_RETURN_EMPTY; } @@ -5807,13 +5925,13 @@ weechat_tcl_api_infolist_time (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_time"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_time"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_time"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_time"); TCL_RETURN_EMPTY; } @@ -5843,13 +5961,13 @@ weechat_tcl_api_infolist_free (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_free"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "infolist_free"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_free"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "infolist_free"); TCL_RETURN_ERROR; } @@ -5875,23 +5993,24 @@ weechat_tcl_api_upgrade_new (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_new"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "upgrade_new"); TCL_RETURN_EMPTY; } if (objc < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "upgrade_new"); TCL_RETURN_EMPTY; } if (Tcl_GetIntFromObj (interp, objv[2], &write) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "upgrade_new"); TCL_RETURN_EMPTY; } filename = Tcl_GetStringFromObj (objv[1], &i); + result = script_ptr2str (weechat_upgrade_new (filename, write)); TCL_RETURN_STRING_FREE(result); @@ -5914,19 +6033,19 @@ weechat_tcl_api_upgrade_write_object (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "upgrade_write_object"); TCL_RETURN_INT(0); } if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "upgrade_write_object"); TCL_RETURN_INT(0); } if (Tcl_GetIntFromObj (interp, objv[2], &object_id) != TCL_OK) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_write_object"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "upgrade_write_object"); TCL_RETURN_EMPTY; } @@ -5951,7 +6070,7 @@ weechat_tcl_api_upgrade_read_cb (void *data, struct t_infolist *infolist) { struct t_script_callback *script_callback; - char *tcl_argv[4], str_object_id[32]; + char *tcl_argv[5], empty_arg[1] = { '\0' }, str_object_id[32]; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -5960,10 +6079,11 @@ weechat_tcl_api_upgrade_read_cb (void *data, { snprintf (str_object_id, sizeof (str_object_id), "%d", object_id); - tcl_argv[0] = script_ptr2str (upgrade_file); - tcl_argv[1] = str_object_id; - tcl_argv[2] = script_ptr2str (infolist); - tcl_argv[3] = NULL; + tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + tcl_argv[1] = script_ptr2str (upgrade_file); + tcl_argv[2] = str_object_id; + tcl_argv[3] = script_ptr2str (infolist); + tcl_argv[4] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -5977,10 +6097,10 @@ weechat_tcl_api_upgrade_read_cb (void *data, ret = *rc; free (rc); } - if (tcl_argv[0]) - free (tcl_argv[0]); - if (tcl_argv[2]) - free (tcl_argv[2]); + if (tcl_argv[1]) + free (tcl_argv[1]); + if (tcl_argv[3]) + free (tcl_argv[3]); return ret; } @@ -5997,7 +6117,7 @@ weechat_tcl_api_upgrade_read (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj* objp; - char *upgrade_file, *function_read; + char *upgrade_file, *function, *data; int i, rc; /* make C compiler happy */ @@ -6005,24 +6125,26 @@ weechat_tcl_api_upgrade_read (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_read"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "upgrade_read"); TCL_RETURN_EMPTY; } - if (objc < 3) + if (objc < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_read"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "upgrade_read"); TCL_RETURN_EMPTY; } upgrade_file = Tcl_GetStringFromObj (objv[1], &i); - function_read = Tcl_GetStringFromObj (objv[2], &i); + function = Tcl_GetStringFromObj (objv[2], &i); + data = Tcl_GetStringFromObj (objv[3], &i); rc = script_api_upgrade_read (weechat_tcl_plugin, tcl_current_script, script_str2ptr (upgrade_file), &weechat_tcl_api_upgrade_read_cb, - function_read); + function, + data); TCL_RETURN_INT(rc); } @@ -6044,13 +6166,13 @@ weechat_tcl_api_upgrade_close (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("upgrade_close"); + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "upgrade_close"); TCL_RETURN_ERROR; } if (objc < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("upgrade_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "upgrade_close"); TCL_RETURN_INT(0); } diff --git a/src/plugins/scripts/tcl/weechat-tcl.h b/src/plugins/scripts/tcl/weechat-tcl.h index 581030112..48d510747 100644 --- a/src/plugins/scripts/tcl/weechat-tcl.h +++ b/src/plugins/scripts/tcl/weechat-tcl.h @@ -23,6 +23,8 @@ #define weechat_plugin weechat_tcl_plugin #define TCL_PLUGIN_NAME "tcl" +#define TCL_CURRENT_SCRIPT_NAME ((tcl_current_script) ? tcl_current_script->name : "-") + extern struct t_weechat_plugin *weechat_tcl_plugin; extern int tcl_quiet; |