mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 21:06:38 +02:00
core: send all command line parameters not beginning with a dash to all plugins, add info "auto_load_scripts"
This fixes an issue with IRC URL given on command line when it starts with `ircs://` or `irc6://`: the server is not created at all (only `irc://` works fine).
This commit is contained in:
@@ -1239,6 +1239,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
char str_version[128];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_guile_plugin = plugin;
|
||||
|
||||
/* set interpreter name and version */
|
||||
@@ -1296,7 +1300,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
guile_data.unload_all = &weechat_guile_unload_all;
|
||||
|
||||
guile_quiet = 1;
|
||||
plugin_script_init (weechat_guile_plugin, argc, argv, &guile_data);
|
||||
plugin_script_init (weechat_guile_plugin, &guile_data);
|
||||
guile_quiet = 0;
|
||||
|
||||
plugin_script_display_short_list (weechat_guile_plugin,
|
||||
|
||||
@@ -924,6 +924,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
char str_interpreter[64];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_js_plugin = plugin;
|
||||
|
||||
/* set interpreter name and version */
|
||||
@@ -950,7 +954,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
js_data.unload_all = &weechat_js_unload_all;
|
||||
|
||||
js_quiet = 1;
|
||||
plugin_script_init (plugin, argc, argv, &js_data);
|
||||
plugin_script_init (plugin, &js_data);
|
||||
js_quiet = 0;
|
||||
|
||||
plugin_script_display_short_list (weechat_js_plugin, js_scripts);
|
||||
|
||||
@@ -1237,6 +1237,10 @@ weechat_lua_signal_script_action_cb (const void *pointer, void *data,
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_lua_plugin = plugin;
|
||||
|
||||
/* set interpreter name and version */
|
||||
@@ -1271,7 +1275,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
lua_data.unload_all = &weechat_lua_unload_all;
|
||||
|
||||
lua_quiet = 1;
|
||||
plugin_script_init (weechat_lua_plugin, argc, argv, &lua_data);
|
||||
plugin_script_init (weechat_lua_plugin, &lua_data);
|
||||
lua_quiet = 0;
|
||||
|
||||
plugin_script_display_short_list (weechat_lua_plugin,
|
||||
|
||||
@@ -1253,6 +1253,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
PERL_SYS_INIT3 (&a, (char ***)&perl_args_local, (char ***)&perl_env);
|
||||
#endif /* PERL_SYS_INIT3 */
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_perl_plugin = plugin;
|
||||
|
||||
/* set interpreter name and version */
|
||||
@@ -1304,7 +1308,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
perl_data.unload_all = &weechat_perl_unload_all;
|
||||
|
||||
perl_quiet = 1;
|
||||
plugin_script_init (weechat_perl_plugin, argc, argv, &perl_data);
|
||||
plugin_script_init (weechat_perl_plugin, &perl_data);
|
||||
perl_quiet = 0;
|
||||
|
||||
plugin_script_display_short_list (weechat_perl_plugin,
|
||||
|
||||
@@ -1302,6 +1302,10 @@ php_weechat_log_message (char *message)
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_php_plugin = plugin;
|
||||
|
||||
/* set interpreter name and version */
|
||||
@@ -1341,7 +1345,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
PG(report_zend_debug) = 0; /* Turn off --enable-debug output */
|
||||
|
||||
php_quiet = 1;
|
||||
plugin_script_init (weechat_php_plugin, argc, argv, &php_data);
|
||||
plugin_script_init (weechat_php_plugin, &php_data);
|
||||
php_quiet = 0;
|
||||
|
||||
plugin_script_display_short_list (weechat_php_plugin,
|
||||
|
||||
@@ -448,6 +448,27 @@ plugin_api_info_auto_connect_cb (const void *pointer, void *data,
|
||||
return strdup (value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns WeeChat info "auto_load_scripts".
|
||||
*/
|
||||
|
||||
char *
|
||||
plugin_api_info_auto_load_scripts_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
{
|
||||
char value[32];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) info_name;
|
||||
(void) arguments;
|
||||
|
||||
snprintf (value, sizeof (value), "%d", weechat_auto_load_scripts);
|
||||
return strdup (value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns WeeChat info "charset_terminal".
|
||||
*/
|
||||
@@ -1964,9 +1985,14 @@ plugin_api_info_init ()
|
||||
NULL, &plugin_api_info_weechat_daemon_cb, NULL, NULL);
|
||||
hook_info (NULL, "auto_connect",
|
||||
N_("1 if automatic connection to servers is enabled, "
|
||||
"0 if it has been disabled by the user (option \"-a\" or "
|
||||
"\"--no-connect\")"),
|
||||
"0 if it has been disabled by the user "
|
||||
"(option \"-a\" or \"--no-connect\")"),
|
||||
NULL, &plugin_api_info_auto_connect_cb, NULL, NULL);
|
||||
hook_info (NULL, "auto_load_scripts",
|
||||
N_("1 if scripts are automatically loaded, "
|
||||
"0 if the auto-load has been disabled by the user "
|
||||
"(option \"-s\" or \"--no-script\")"),
|
||||
NULL, &plugin_api_info_auto_load_scripts_cb, NULL, NULL);
|
||||
hook_info (NULL, "charset_terminal",
|
||||
N_("terminal charset"),
|
||||
NULL, &plugin_api_info_charset_terminal_cb, NULL, NULL);
|
||||
|
||||
@@ -158,16 +158,14 @@ plugin_script_create_dirs (struct t_weechat_plugin *weechat_plugin)
|
||||
* - hooks config
|
||||
* - creates directories in WeeChat home
|
||||
* - hooks command, completion, hdata, infolist, signals
|
||||
* - parses arguments
|
||||
* - auto-loads scripts.
|
||||
*/
|
||||
|
||||
void
|
||||
plugin_script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
int argc, char *argv[],
|
||||
struct t_plugin_script_data *plugin_data)
|
||||
{
|
||||
char string[512], *completion;
|
||||
char string[512], *completion, *info_auto_load_scripts;
|
||||
char *action_signals[] = { "install", "remove", "autoload", NULL };
|
||||
int i, auto_load_scripts;
|
||||
|
||||
@@ -273,16 +271,13 @@ plugin_script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
&plugin_script_info_version_cb,
|
||||
weechat_plugin, NULL);
|
||||
|
||||
/* parse arguments */
|
||||
auto_load_scripts = 1;
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if ((strcmp (argv[i], "-s") == 0)
|
||||
|| (strcmp (argv[i], "--no-script") == 0))
|
||||
{
|
||||
auto_load_scripts = 0;
|
||||
}
|
||||
}
|
||||
/* check if auto-load of scripts is enabled */
|
||||
info_auto_load_scripts = weechat_info_get ("auto_load_scripts", NULL);
|
||||
auto_load_scripts = (info_auto_load_scripts
|
||||
&& (strcmp (info_auto_load_scripts, "1") == 0)) ?
|
||||
1 : 0;
|
||||
if (info_auto_load_scripts)
|
||||
free (info_auto_load_scripts);
|
||||
|
||||
/* autoload scripts */
|
||||
if (auto_load_scripts)
|
||||
|
||||
@@ -116,7 +116,6 @@ struct t_plugin_script_data
|
||||
extern void plugin_script_display_interpreter (struct t_weechat_plugin *plugin,
|
||||
int indent);
|
||||
extern void plugin_script_init (struct t_weechat_plugin *weechat_plugin,
|
||||
int argc, char *argv[],
|
||||
struct t_plugin_script_data *plugin_data);
|
||||
extern int plugin_script_valid (struct t_plugin_script *scripts,
|
||||
struct t_plugin_script *script);
|
||||
|
||||
+17
-13
@@ -274,20 +274,18 @@ plugin_check_autoload (const char *filename)
|
||||
*/
|
||||
|
||||
void
|
||||
plugin_get_args (struct t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
plugin_get_args (int argc, char **argv,
|
||||
int *plugin_argc, char ***plugin_argv,
|
||||
int *no_connect)
|
||||
int *no_connect, int *no_script)
|
||||
{
|
||||
int i, temp_argc, length_plugin_name;
|
||||
int i, temp_argc;
|
||||
char **temp_argv;
|
||||
|
||||
temp_argc = 0;
|
||||
temp_argv = NULL;
|
||||
|
||||
*no_connect = 0;
|
||||
|
||||
length_plugin_name = strlen (plugin->name);
|
||||
*no_script = 0;
|
||||
|
||||
if (argc > 0)
|
||||
{
|
||||
@@ -302,10 +300,11 @@ plugin_get_args (struct t_weechat_plugin *plugin,
|
||||
*no_connect = 1;
|
||||
}
|
||||
else if ((strcmp (argv[i], "-s") == 0)
|
||||
|| (strcmp (argv[i], "--no-script") == 0)
|
||||
|| ((strncmp (argv[i], plugin->name,
|
||||
length_plugin_name) == 0)
|
||||
&& (argv[i][length_plugin_name] == ':')))
|
||||
|| (strcmp (argv[i], "--no-script") == 0))
|
||||
{
|
||||
*no_script = 1;
|
||||
}
|
||||
else if (argv[i][0] != '-')
|
||||
{
|
||||
temp_argv[temp_argc++] = argv[i];
|
||||
}
|
||||
@@ -336,7 +335,8 @@ int
|
||||
plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv)
|
||||
{
|
||||
t_weechat_init_func *init_func;
|
||||
int plugin_argc, no_connect, rc, old_auto_connect;
|
||||
int no_connect, rc, old_auto_connect, no_script, old_auto_load_scripts;
|
||||
int plugin_argc;
|
||||
char **plugin_argv;
|
||||
|
||||
if (plugin->initialized)
|
||||
@@ -348,12 +348,15 @@ plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv)
|
||||
return 0;
|
||||
|
||||
/* get arguments for the plugin */
|
||||
plugin_get_args (plugin, argc, argv,
|
||||
&plugin_argc, &plugin_argv, &no_connect);
|
||||
plugin_get_args (argc, argv,
|
||||
&plugin_argc, &plugin_argv, &no_connect, &no_script);
|
||||
|
||||
old_auto_connect = weechat_auto_connect;
|
||||
weechat_auto_connect = (no_connect) ? 0 : 1;
|
||||
|
||||
old_auto_load_scripts = weechat_auto_load_scripts;
|
||||
weechat_auto_load_scripts = (no_script) ? 0 : 1;
|
||||
|
||||
/* init plugin */
|
||||
if (weechat_debug_core >= 1)
|
||||
{
|
||||
@@ -377,6 +380,7 @@ plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv)
|
||||
}
|
||||
|
||||
weechat_auto_connect = old_auto_connect;
|
||||
weechat_auto_load_scripts = old_auto_load_scripts;
|
||||
|
||||
if (plugin_argv)
|
||||
free (plugin_argv);
|
||||
|
||||
@@ -1465,6 +1465,10 @@ weechat_python_signal_script_action_cb (const void *pointer, void *data,
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_python_plugin = plugin;
|
||||
|
||||
/* set interpreter name and version */
|
||||
@@ -1532,7 +1536,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
python_data.unload_all = &weechat_python_unload_all;
|
||||
|
||||
python_quiet = 1;
|
||||
plugin_script_init (weechat_python_plugin, argc, argv, &python_data);
|
||||
plugin_script_init (weechat_python_plugin, &python_data);
|
||||
python_quiet = 0;
|
||||
|
||||
plugin_script_display_short_list (weechat_python_plugin,
|
||||
|
||||
@@ -1340,6 +1340,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"end\n"
|
||||
};
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_ruby_plugin = plugin;
|
||||
|
||||
/* set interpreter name and version */
|
||||
@@ -1413,7 +1417,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
ruby_data.unload_all = &weechat_ruby_unload_all;
|
||||
|
||||
ruby_quiet = 1;
|
||||
plugin_script_init (weechat_ruby_plugin, argc, argv, &ruby_data);
|
||||
plugin_script_init (weechat_ruby_plugin, &ruby_data);
|
||||
ruby_quiet = 0;
|
||||
|
||||
plugin_script_display_short_list (weechat_ruby_plugin,
|
||||
|
||||
@@ -922,6 +922,10 @@ weechat_tcl_signal_script_action_cb (const void *pointer, void *data,
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_tcl_plugin = plugin;
|
||||
|
||||
/* set interpreter name and version */
|
||||
@@ -951,7 +955,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
tcl_data.unload_all = &weechat_tcl_unload_all;
|
||||
|
||||
tcl_quiet = 1;
|
||||
plugin_script_init (weechat_tcl_plugin, argc, argv, &tcl_data);
|
||||
plugin_script_init (weechat_tcl_plugin, &tcl_data);
|
||||
tcl_quiet = 0;
|
||||
|
||||
plugin_script_display_short_list (weechat_tcl_plugin,
|
||||
|
||||
Reference in New Issue
Block a user