diff options
Diffstat (limited to 'src/plugins/scripts')
-rw-r--r-- | src/plugins/scripts/lua/lua.c | 3 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 171 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl.c | 51 | ||||
-rw-r--r-- | src/plugins/scripts/python/python.c | 5 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/ruby.c | 5 | ||||
-rw-r--r-- | src/plugins/scripts/script.c | 89 | ||||
-rw-r--r-- | src/plugins/scripts/script.h | 19 |
7 files changed, 222 insertions, 121 deletions
diff --git a/src/plugins/scripts/lua/lua.c b/src/plugins/scripts/lua/lua.c index 8ced9008b..36357ad02 100644 --- a/src/plugins/scripts/lua/lua.c +++ b/src/plugins/scripts/lua/lua.c @@ -2419,7 +2419,7 @@ weechat_lua_unload (t_weechat_plugin *plugin, t_plugin_script *script) "Unloading Lua script \"%s\"", script->name); - if (script->shutdown_func[0]) + if (script->shutdow_func && script->shutdown_func[0]) { r = weechat_lua_exec (plugin, script, SCRIPT_EXEC_INT, script->shutdown_func, NULL, NULL, NULL); @@ -2712,6 +2712,7 @@ weechat_plugin_init (t_weechat_plugin *plugin) plugin->mkdir_home (plugin, "lua"); plugin->mkdir_home (plugin, "lua/autoload"); + script_init (weechat_lua_plugin); weechat_script_auto_load (plugin, "lua", weechat_lua_load); /* init ok */ diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 14a0188f3..b532a44fc 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -44,7 +44,8 @@ extern void boot_DynaLoader (pTHX_ CV* cv); static XS (XS_weechat_register) { - char *name, *version, *shutdown_func, *description, *charset; + char *name, *author, *version, *license, *shutdown_func, *description; + char *charset; dXSARGS; /* make C compiler happy */ @@ -53,17 +54,25 @@ static XS (XS_weechat_register) perl_current_script = NULL; - if ((items < 4) || (items > 5)) + if (items < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "register"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("register"); XSRETURN_NO; } name = SvPV (ST (0), PL_na); - version = SvPV (ST (1), PL_na); - shutdown_func = SvPV (ST (2), PL_na); - description = SvPV (ST (3), PL_na); - charset = (items == 5) ? SvPV (ST (4), PL_na) : NULL; + author = SvPV (ST (1), PL_na); + version = SvPV (ST (2), PL_na); + license = SvPV (ST (3), PL_na); + description = SvPV (ST (4), PL_na); + shutdown_func = NULL; + charset = NULL; + if (items > 5) + { + shutdown_func = SvPV (ST (5), PL_na); + if (items > 6) + charset = SvPV (ST (6), PL_na); + } if (script_search (weechat_perl_plugin, &perl_scripts, name)) { @@ -72,7 +81,7 @@ static XS (XS_weechat_register) weechat_gettext ("%s%s: unable to register script " "\"%s\" (another script already " "exists with this name)"), - weechat_prefix ("error"), "Perl", name); + weechat_prefix ("error"), "perl", name); XSRETURN_NO; } @@ -81,14 +90,14 @@ static XS (XS_weechat_register) &perl_scripts, (perl_current_script_filename) ? perl_current_script_filename : "", - name, version, shutdown_func, - description, charset); + name, author, version, license, + shutdown_func, description, charset); if (perl_current_script) { weechat_printf (NULL, weechat_gettext ("%s%s: registered script \"%s\", " "version %s (%s)"), - weechat_prefix ("info"), "Perl", + weechat_prefix ("info"), "perl", name, version, description); } else @@ -112,13 +121,13 @@ static XS (XS_weechat_charset_set) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "charset_set"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("charset_set"); XSRETURN_NO; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "charset_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("charset_set"); XSRETURN_NO; } @@ -142,13 +151,13 @@ static XS (XS_weechat_iconv_to_internal) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "iconv_to_internal"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_to_internal"); XSRETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "iconv_to_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_to_internal"); XSRETURN_EMPTY; } @@ -190,13 +199,13 @@ static XS (XS_weechat_iconv_from_internal) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "iconv_from_internal"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("iconv_from_internal"); XSRETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "iconv_from_internal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("iconv_from_internal"); XSRETURN_EMPTY; } @@ -228,13 +237,13 @@ static XS (XS_weechat_mkdir_home) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "mkdir_home"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_home"); XSRETURN_NO; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "mkdir_home"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_home"); XSRETURN_NO; } @@ -256,13 +265,13 @@ static XS (XS_weechat_mkdir) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "mkdir"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir"); XSRETURN_NO; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "mkdir"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir"); XSRETURN_NO; } @@ -286,13 +295,13 @@ static XS (XS_weechat_prefix) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "prefix"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("prefix"); XSRETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "prefix"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("prefix"); XSRETURN_EMPTY; } @@ -321,13 +330,13 @@ static XS (XS_weechat_color) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "color"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("color"); XSRETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "color"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("color"); XSRETURN_EMPTY; } @@ -356,13 +365,13 @@ static XS (XS_weechat_print) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "print"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("print"); XSRETURN_NO; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("print"); XSRETURN_NO; } @@ -397,13 +406,13 @@ static XS (XS_weechat_infobar_print) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "infobar_print"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infobar_print"); XSRETURN_NO; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "infobar_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infobar_print"); XSRETURN_NO; } @@ -429,7 +438,7 @@ static XS (XS_weechat_infobar_remove) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "infobar_remove"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infobar_remove"); XSRETURN_NO; } @@ -451,13 +460,13 @@ static XS (XS_weechat_log_print) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "log_print"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("log_print"); XSRETURN_NO; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "log_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("log_print"); XSRETURN_NO; } @@ -524,13 +533,13 @@ static XS (XS_weechat_hook_command) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "hook_command"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command"); XSRETURN_NO; } if (items < 6) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "hook_command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command"); XSRETURN_NO; } @@ -589,13 +598,13 @@ static XS (XS_weechat_hook_timer) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "hook_timer"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_timer"); XSRETURN_NO; } if (items < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "hook_timer"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_timer"); XSRETURN_NO; } @@ -653,13 +662,13 @@ static XS (XS_weechat_hook_fd) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "hook_fd"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_fd"); XSRETURN_NO; } if (items < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "hook_fd"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_fd"); XSRETURN_NO; } @@ -729,13 +738,13 @@ static XS (XS_weechat_hook_print) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "hook_print"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_print"); XSRETURN_NO; } if (items < 4) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "hook_print"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_print"); XSRETURN_NO; } @@ -817,13 +826,13 @@ static XS (XS_weechat_hook_signal) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "hook_signal"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal"); XSRETURN_NO; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "hook_signal"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal"); XSRETURN_NO; } @@ -850,13 +859,13 @@ static XS (XS_weechat_hook_signal_send) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "hook_signal_send"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_signal_send"); XSRETURN_NO; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "hook_signal_send"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal_send"); XSRETURN_NO; } @@ -914,13 +923,13 @@ static XS (XS_weechat_hook_config) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "hook_config"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_config"); XSRETURN_NO; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "hook_config"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_config"); XSRETURN_NO; } @@ -987,13 +996,13 @@ static XS (XS_weechat_hook_completion) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "hook_completion"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_completion"); XSRETURN_NO; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "hook_completion"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_completion"); XSRETURN_NO; } @@ -1020,13 +1029,13 @@ static XS (XS_weechat_unhook) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "unhook"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook"); XSRETURN_NO; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "unhook"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("unhook"); XSRETURN_NO; } @@ -1050,7 +1059,7 @@ static XS (XS_weechat_unhook_all) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "unhook_all"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("unhook_all"); XSRETURN_NO; } @@ -1109,13 +1118,13 @@ static XS (XS_weechat_buffer_new) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "buffer_new"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_new"); XSRETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "buffer_new"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_new"); XSRETURN_EMPTY; } @@ -1153,13 +1162,13 @@ static XS (XS_weechat_buffer_search) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "buffer_search"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_search"); XSRETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "buffer_search"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_search"); XSRETURN_EMPTY; } @@ -1191,13 +1200,13 @@ static XS (XS_weechat_buffer_close) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "buffer_close"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_close"); XSRETURN_NO; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "buffer_close"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_close"); XSRETURN_NO; } @@ -1223,13 +1232,13 @@ static XS (XS_weechat_buffer_get) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "buffer_get"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get"); XSRETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "buffer_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get"); XSRETURN_EMPTY; } @@ -1258,13 +1267,13 @@ static XS (XS_weechat_buffer_set) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "buffer_set"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_set"); XSRETURN_NO; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "buffer_set"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_set"); XSRETURN_NO; } @@ -1290,13 +1299,13 @@ static XS (XS_weechat_nicklist_add_group) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "nicklist_add_group"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_group"); XSRETURN_EMPTY; } if (items < 5) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "nicklist_add_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_group"); XSRETURN_EMPTY; } @@ -1333,13 +1342,13 @@ static XS (XS_weechat_nicklist_search_group) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "nicklist_search_group"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_group"); XSRETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "nicklist_search_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_group"); XSRETURN_EMPTY; } @@ -1374,13 +1383,13 @@ static XS (XS_weechat_nicklist_add_nick) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_add_nick"); XSRETURN_EMPTY; } if (items < 7) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "nicklist_add_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_add_nick"); XSRETURN_EMPTY; } @@ -1424,13 +1433,13 @@ static XS (XS_weechat_nicklist_search_nick) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_search_nick"); XSRETURN_EMPTY; } if (items < 3) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "nicklist_search_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_search_nick"); XSRETURN_EMPTY; } @@ -1463,13 +1472,13 @@ static XS (XS_weechat_nicklist_remove_group) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_group"); XSRETURN_NO; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "nicklist_remove_group"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_group"); XSRETURN_NO; } @@ -1492,13 +1501,13 @@ static XS (XS_weechat_nicklist_remove_nick) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_nick"); XSRETURN_NO; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "nicklist_remove_nick"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_nick"); XSRETURN_NO; } @@ -1521,13 +1530,13 @@ static XS (XS_weechat_nicklist_remove_all) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("nicklist_remove_all"); XSRETURN_NO; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "nicklist_remove_all"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("nicklist_remove_all"); XSRETURN_NO; } @@ -1550,13 +1559,13 @@ static XS (XS_weechat_command) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "command"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("command"); XSRETURN_NO; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "command"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("command"); XSRETURN_NO; } @@ -1592,13 +1601,13 @@ static XS (XS_weechat_info_get) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "info_get"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("info_get"); XSRETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "info_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("info_get"); XSRETURN_EMPTY; } @@ -1697,13 +1706,13 @@ static XS (XS_weechat_config_get_weechat) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("Perl", "config_get_weechat"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get_weechat"); XSRETURN_EMPTY; } if (items < 1) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("Perl", "config_get_weechat"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get_weechat"); XSRETURN_EMPTY; } diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index 97d9870db..90b074e7d 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -149,7 +149,7 @@ weechat_perl_exec (struct t_plugin_script *script, { weechat_printf (NULL, weechat_gettext ("%s%s: error: %s"), - weechat_prefix ("error"), "Perl", SvPV_nolen (ERRSV)); + weechat_prefix ("error"), "perl", SvPV_nolen (ERRSV)); (void) POPs; /* poping the 'undef' */ mem_err = 0; } @@ -160,7 +160,7 @@ weechat_perl_exec (struct t_plugin_script *script, weechat_printf (NULL, weechat_gettext ("%s%s: function \"%s\" must " "return one valid value (%d)"), - weechat_prefix ("error"), "Perl", function, count); + weechat_prefix ("error"), "perl", function, count); mem_err = 0; } else @@ -183,7 +183,7 @@ weechat_perl_exec (struct t_plugin_script *script, weechat_printf (NULL, weechat_gettext ("%s%s: function \"%s\" is " "internally misused"), - weechat_prefix ("error"), "Perl", function); + weechat_prefix ("error"), "perl", function); mem_err = 0; } } @@ -202,7 +202,7 @@ weechat_perl_exec (struct t_plugin_script *script, weechat_printf (NULL, weechat_gettext ("%s%s: not enough memory in function " "\"%s\""), - weechat_prefix ("error"), "Perl", function); + weechat_prefix ("error"), "perl", function); return NULL; } @@ -231,13 +231,13 @@ weechat_perl_load (char *filename) weechat_printf (NULL, weechat_gettext ("%s%s: loading Perl script \"%s\""), - weechat_prefix ("info"), "Perl", filename); + weechat_prefix ("info"), "perl", filename); if (stat (filename, &buf) != 0) { weechat_printf (NULL, weechat_gettext ("%s%s: script \"%s\" not found"), - weechat_prefix ("error"), "Perl", filename); + weechat_prefix ("error"), "perl", filename); return 0; } @@ -261,7 +261,7 @@ weechat_perl_load (char *filename) weechat_printf (NULL, weechat_gettext ("%s%s: unable to create new " "sub-interpreter"), - weechat_prefix ("error"), "Perl"); + weechat_prefix ("error"), "perl"); return 0; } @@ -286,7 +286,7 @@ weechat_perl_load (char *filename) weechat_printf (NULL, weechat_gettext ("%s%s: not enough memory to parse " "file \"%s\""), - weechat_prefix ("error"), "Perl", filename); + weechat_prefix ("error"), "perl", filename); return 0; } @@ -297,10 +297,10 @@ weechat_perl_load (char *filename) weechat_printf (NULL, weechat_gettext ("%s%s: unable to parse file " "\"%s\""), - weechat_prefix ("error"), "Perl", filename); + weechat_prefix ("error"), "perl", filename); weechat_printf (NULL, weechat_gettext ("%s%s: error: %s"), - weechat_prefix ("error"), "Perl", + weechat_prefix ("error"), "perl", #ifndef MULTIPLICITY SvPV(perl_get_sv("WeechatPerlScriptLoader::" "weechat_perl_load_eval_file_error", @@ -315,14 +315,14 @@ weechat_perl_load (char *filename) { weechat_printf (NULL, weechat_gettext ("%s%s: unable to run file \"%s\""), - weechat_prefix ("error"), "Perl", filename); + weechat_prefix ("error"), "perl", filename); } else { weechat_printf (NULL, weechat_gettext ("%s%s: unknown error while " "loading file \"%s\""), - weechat_prefix ("error"), "Perl", filename); + weechat_prefix ("error"), "perl", filename); } #ifdef MULTIPLICITY perl_destruct (perl_current_interpreter); @@ -345,7 +345,7 @@ weechat_perl_load (char *filename) weechat_printf (NULL, weechat_gettext ("%s%s: function \"register\" not " "found (or failed) in file \"%s\""), - weechat_prefix ("error"), "Perl", filename); + weechat_prefix ("error"), "perl", filename); #ifdef MULTIPLICITY perl_destruct (perl_current_interpreter); perl_free (perl_current_interpreter); @@ -387,7 +387,7 @@ weechat_perl_unload (struct t_plugin_script *script) weechat_printf (NULL, weechat_gettext ("%s%s: unloading script \"%s\""), - weechat_prefix ("info"), "Perl", script->name); + weechat_prefix ("info"), "perl", script->name); #ifndef MULTIPLICITY eval_pv (script->interpreter, TRUE); @@ -395,7 +395,7 @@ weechat_perl_unload (struct t_plugin_script *script) PERL_SET_CONTEXT (script->interpreter); #endif - if (script->shutdown_func[0]) + if (script->shutdown_func && script->shutdown_func[0]) { r = (int *) weechat_perl_exec (script, WEECHAT_SCRIPT_EXEC_INT, @@ -431,13 +431,13 @@ weechat_perl_unload_name (char *name) weechat_perl_unload (ptr_script); weechat_printf (NULL, weechat_gettext ("%s%s: script \"%s\" unloaded"), - weechat_prefix ("info"), "Perl", name); + weechat_prefix ("info"), "perl", name); } else { weechat_printf (NULL, weechat_gettext ("%s%s: script \"%s\" not loaded"), - weechat_prefix ("error"), "Perl", name); + weechat_prefix ("error"), "perl", name); } } @@ -479,15 +479,17 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer, weechat_printf (NULL, weechat_gettext ("Registered Perl scripts:")); if (perl_scripts) { - for (ptr_script = perl_scripts; - ptr_script; ptr_script = ptr_script->next_script) + for (ptr_script = perl_scripts; ptr_script; + ptr_script = ptr_script->next_script) { weechat_printf (NULL, - " %s v%s%s%s", + weechat_gettext (" %s v%s (%s), by %s, " + "license %s"), ptr_script->name, ptr_script->version, - (ptr_script->description[0]) ? " - " : "", - ptr_script->description); + ptr_script->description, + ptr_script->author, + ptr_script->license); } } else @@ -654,7 +656,7 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer, weechat_printf (NULL, weechat_gettext ("%s%s: unknown option for " "command \"%s\""), - weechat_prefix ("error"), "Perl", "perl"); + weechat_prefix ("error"), "perl", "perl"); } } @@ -679,7 +681,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin) { weechat_printf (NULL, weechat_gettext ("%s%s: unable to initialize Perl"), - weechat_prefix ("error"), "Perl"); + weechat_prefix ("error"), "perl"); return WEECHAT_RC_ERROR; } @@ -703,6 +705,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin) weechat_mkdir_home ("perl", 0644); weechat_mkdir_home ("perl/autoload", 0644); + script_init (weechat_perl_plugin); script_auto_load (weechat_perl_plugin, "perl", &weechat_perl_load_cb); /* init ok */ diff --git a/src/plugins/scripts/python/python.c b/src/plugins/scripts/python/python.c index cdb6ad35c..6a243243e 100644 --- a/src/plugins/scripts/python/python.c +++ b/src/plugins/scripts/python/python.c @@ -2377,7 +2377,7 @@ weechat_python_unload (t_weechat_plugin *plugin, t_plugin_script *script) "Unloading Python script \"%s\"", script->name); - if (script->shutdown_func[0]) + if (script->shutdown_func && script->shutdown_func[0]) { r = (int *) weechat_python_exec (plugin, script, SCRIPT_EXEC_INT, script->shutdown_func, NULL, NULL, NULL); @@ -2694,7 +2694,8 @@ weechat_plugin_init (t_weechat_plugin *plugin) plugin->mkdir_home (plugin, "python"); plugin->mkdir_home (plugin, "python/autoload"); - + + script_init (weechat_python_plugin); weechat_script_auto_load (plugin, "python", weechat_python_load); /* init ok */ diff --git a/src/plugins/scripts/ruby/ruby.c b/src/plugins/scripts/ruby/ruby.c index fdf174c4d..f749465f3 100644 --- a/src/plugins/scripts/ruby/ruby.c +++ b/src/plugins/scripts/ruby/ruby.c @@ -2273,7 +2273,7 @@ weechat_ruby_unload (t_weechat_plugin *plugin, t_plugin_script *script) "Unloading Ruby script \"%s\"", script->name); - if (script->shutdown_func[0]) + if (script->shutdown_func && script->shutdown_func[0]) { r = (int *) weechat_ruby_exec (plugin, script, SCRIPT_EXEC_INT, script->shutdown_func, NULL, NULL, NULL); @@ -2675,7 +2675,8 @@ weechat_plugin_init (t_weechat_plugin *plugin) "Ruby error: %s", STR2CSTR(ruby_error_info)); return PLUGIN_RC_KO; } - + + script_init (weechat_ruby_plugin); weechat_script_auto_load (plugin, "ruby", weechat_ruby_load); /* init ok */ diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c index 20ef057ba..dfdb6acd4 100644 --- a/src/plugins/scripts/script.c +++ b/src/plugins/scripts/script.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <ctype.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> @@ -31,6 +32,73 @@ #include "script-callback.h" +#define SCRIPT_OPTION_CHECK_LICENSE "check_license" + +int script_option_check_license = 0; + + +/* + * script_config_read: read config options + */ + +void +script_config_read (struct t_weechat_plugin *weechat_plugin) +{ + char *string; + + weechat_printf (NULL, "script_config_read"); + + string = weechat_config_get_plugin (SCRIPT_OPTION_CHECK_LICENSE); + if (!string) + { + weechat_config_set_plugin (SCRIPT_OPTION_CHECK_LICENSE, "on"); + string = weechat_config_get_plugin (SCRIPT_OPTION_CHECK_LICENSE); + } + if (string && (weechat_config_string_to_boolean (string) > 0)) + script_option_check_license = 1; + else + script_option_check_license = 0; +} + +/* + * script_config_cb: callback called when config option is changed + */ + +int +script_config_cb (void *data, char *type, char *option, char *value) +{ + (void) type; + (void) option; + (void) value; + + script_config_read (data); + + return WEECHAT_RC_OK; +} + +/* + * script_init: initialize script + */ + +void +script_init (struct t_weechat_plugin *weechat_plugin) +{ + char *option; + int length; + + script_config_read (weechat_plugin); + + length = strlen (weechat_plugin->name) + 32; + option= (char *)malloc (length); + if (option) + { + snprintf (option, length - 1, "%s.%s", + weechat_plugin->name, SCRIPT_OPTION_CHECK_LICENSE); + weechat_hook_config ("plugin", option, + &script_config_cb, (void *)weechat_plugin); + } +} + /* * script_pointer_to_string: convert pointer to string for usage * in a script (any language) @@ -211,9 +279,8 @@ struct t_plugin_script * script_add (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script **script_list, char *filename, - char *name, char *version, - char *shutdown_func, char *description, - char *charset) + char *name, char *author, char *version, char *license, + char *shutdown_func, char *description, char *charset) { struct t_plugin_script *new_script; @@ -226,15 +293,29 @@ script_add (struct t_weechat_plugin *weechat_plugin, return NULL; } + if (script_option_check_license + && (weechat_strcmp_ignore_chars (weechat_plugin->license, license, + "0123456789-.,/\\()[]{}", 0) != 0)) + { + weechat_printf (NULL, + _("%s%s: warning, license \"%s\" for script \"%s\" " + "differs from plugin license (\"%s\")"), + weechat_prefix ("error"), weechat_plugin->name, + license, name, weechat_plugin->license); + } + new_script = (struct t_plugin_script *)malloc (sizeof (struct t_plugin_script)); if (new_script) { new_script->filename = strdup (filename); new_script->interpreter = NULL; new_script->name = strdup (name); + new_script->author = strdup (author); new_script->version = strdup (version); - new_script->shutdown_func = strdup (shutdown_func); + new_script->license = strdup (license); new_script->description = strdup (description); + new_script->shutdown_func = (shutdown_func) ? + strdup (shutdown_func) : NULL; new_script->charset = (charset) ? strdup (charset) : NULL; new_script->callbacks = NULL; diff --git a/src/plugins/scripts/script.h b/src/plugins/scripts/script.h index 61771976f..218a0942c 100644 --- a/src/plugins/scripts/script.h +++ b/src/plugins/scripts/script.h @@ -23,17 +23,19 @@ #define WEECHAT_SCRIPT_EXEC_INT 1 #define WEECHAT_SCRIPT_EXEC_STRING 2 -#define WEECHAT_SCRIPT_MSG_NOT_INITIALIZED(__language, __function) \ +#define WEECHAT_SCRIPT_MSG_NOT_INITIALIZED(__function) \ weechat_printf (NULL, \ weechat_gettext("%s%s: unable to call function " \ "\"%s\", script is not " \ "initialized"), \ - weechat_prefix ("error"), __language, __function) -#define WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS(__language, __function) \ + weechat_prefix ("error"), weechat_plugin->name, \ + __function) +#define WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS(__function) \ weechat_printf (NULL, \ weechat_gettext("%s%s: wrong arguments for " \ "function \"%s\""), \ - weechat_prefix ("error"), __language, __function) + weechat_prefix ("error"), weechat_plugin->name, \ + __function) struct t_plugin_script { @@ -41,8 +43,10 @@ struct t_plugin_script char *filename; /* name of script on disk */ void *interpreter; /* interpreter for script */ char *name; /* script name */ - char *description; /* plugin description */ + char *author; /* author name/mail */ char *version; /* plugin version */ + char *license; /* script license */ + char *description; /* plugin description */ char *shutdown_func; /* function when script is unloaded*/ char *charset; /* script charset */ @@ -52,6 +56,7 @@ struct t_plugin_script struct t_plugin_script *next_script; /* link to next script */ }; +extern void script_init (struct t_weechat_plugin *weechat_plugin); extern char *script_pointer_to_string (void *pointer); extern void *script_string_to_pointer (char *pointer_str); extern void script_auto_load (struct t_weechat_plugin *weechat_plugin, @@ -65,8 +70,8 @@ extern char *script_search_full_name (struct t_weechat_plugin *weechat_plugin, extern struct t_plugin_script *script_add (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script **script_list, char *filename, char *name, - char *version, - char *shutdown_func, + char *author, char *version, + char *license, char *shutdown_func, char *description, char *charset); extern void script_remove (struct t_weechat_plugin *weechat_plugin, |