summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2018-08-17 19:44:41 +0200
committerSébastien Helleu <flashcode@flashtux.org>2018-08-17 19:44:41 +0200
commit466dbbe75b0fe32b9e647adebc7de06ea1b835fe (patch)
tree47040e77a3764a4f2063d938e1f7ffa12150ad3e /src
parent822270cccaec9f76b6fb952aca0e31005a6d7217 (diff)
downloadweechat-466dbbe75b0fe32b9e647adebc7de06ea1b835fe.zip
core: add option "-P" (or "--plugins") to customize the plugins to load at startup
If given, the option replaces the option weechat.plugin.autoload.
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c8
-rw-r--r--src/core/weechat.c31
-rw-r--r--src/plugins/plugin.c29
-rw-r--r--src/plugins/plugin.h8
4 files changed, 51 insertions, 25 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 7bacb73d5..93ec84a56 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -4534,10 +4534,10 @@ COMMAND_CALLBACK(plugin)
{
plugin_argv = string_split (argv_eol[2], " ", 0, 0,
&plugin_argc);
- plugin_auto_load (plugin_argc, plugin_argv, 1, 1, 1);
+ plugin_auto_load (NULL, 1, 1, 1, plugin_argc, plugin_argv);
}
else
- plugin_auto_load (0, NULL, 1, 1, 1);
+ plugin_auto_load (NULL, 1, 1, 1, 0, NULL);
return WEECHAT_RC_OK;
}
@@ -4571,7 +4571,7 @@ COMMAND_CALLBACK(plugin)
if (strcmp (argv[2], "*") == 0)
{
plugin_unload_all ();
- plugin_auto_load (plugin_argc, plugin_argv, 1, 1, 1);
+ plugin_auto_load (NULL, 1, 1, 1, plugin_argc, plugin_argv);
}
else
{
@@ -4586,7 +4586,7 @@ COMMAND_CALLBACK(plugin)
else
{
plugin_unload_all ();
- plugin_auto_load (0, NULL, 1, 1, 1);
+ plugin_auto_load (NULL, 1, 1, 1, 0, NULL);
}
return WEECHAT_RC_OK;
}
diff --git a/src/core/weechat.c b/src/core/weechat.c
index f74598ad5..76a9b1849 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -95,7 +95,7 @@ char *weechat_home = NULL; /* home dir. (default: ~/.weechat) */
int weechat_locale_ok = 0; /* is locale OK? */
char *weechat_local_charset = NULL; /* example: ISO-8859-1, UTF-8 */
int weechat_server_cmd_line = 0; /* at least 1 server on cmd line */
-int weechat_auto_load_plugins = 1; /* auto load plugins */
+char *weechat_force_plugin_autoload = NULL; /* force load of plugins */
int weechat_plugin_no_dlclose = 0; /* remove calls to dlclose for libs */
/* (useful with valgrind) */
int weechat_no_gnutls = 0; /* remove init/deinit of gnutls */
@@ -152,6 +152,8 @@ weechat_display_usage ()
" -h, --help display this help\n"
" -l, --license display WeeChat license\n"
" -p, --no-plugin don't load any plugin at startup\n"
+ " -P, --plugins <plugins> load only these plugins at startup\n"
+ " (see /help weechat.plugin.autoload)\n"
" -r, --run-command <cmd> run command(s) after startup\n"
" (many commands can be separated by "
"semicolons)\n"
@@ -193,7 +195,7 @@ weechat_parse_args (int argc, char *argv[])
weechat_upgrading = 0;
weechat_home = NULL;
weechat_server_cmd_line = 0;
- weechat_auto_load_plugins = 1;
+ weechat_force_plugin_autoload = NULL;
weechat_plugin_no_dlclose = 0;
for (i = 1; i < argc; i++)
@@ -269,7 +271,26 @@ weechat_parse_args (int argc, char *argv[])
else if ((strcmp (argv[i], "-p") == 0)
|| (strcmp (argv[i], "--no-plugin") == 0))
{
- weechat_auto_load_plugins = 0;
+ if (weechat_force_plugin_autoload)
+ free (weechat_force_plugin_autoload);
+ weechat_force_plugin_autoload = strdup ("!*");
+ }
+ else if ((strcmp (argv[i], "-P") == 0)
+ || (strcmp (argv[i], "--plugins") == 0))
+ {
+ if (i + 1 < argc)
+ {
+ if (weechat_force_plugin_autoload)
+ free (weechat_force_plugin_autoload);
+ weechat_force_plugin_autoload = strdup (argv[++i]);
+ }
+ else
+ {
+ string_fprintf (stderr,
+ _("Error: missing argument for \"%s\" option\n"),
+ argv[i]);
+ weechat_shutdown (EXIT_FAILURE, 0);
+ }
}
else if ((strcmp (argv[i], "-r") == 0)
|| (strcmp (argv[i], "--run-command") == 0))
@@ -616,6 +637,8 @@ weechat_shutdown (int return_code, int crash)
free (weechat_home);
if (weechat_local_charset)
free (weechat_local_charset);
+ if (weechat_force_plugin_autoload)
+ free (weechat_force_plugin_autoload);
if (crash)
abort ();
@@ -697,7 +720,7 @@ weechat_init (int argc, char *argv[], void (*gui_init_cb)())
weechat_term_check (); /* warning about wrong $TERM */
weechat_locale_check (); /* warning about wrong locale */
command_startup (0); /* command executed before plugins */
- plugin_init (weechat_auto_load_plugins, /* init plugin interface(s) */
+ plugin_init (weechat_force_plugin_autoload, /* init plugin interface(s) */
argc, argv);
command_startup (1); /* commands executed after plugins */
if (!weechat_upgrading)
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index e99c5a189..eb96db103 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -998,12 +998,14 @@ plugin_arraylist_cmp_cb (void *data,
*/
void
-plugin_auto_load (int argc, char **argv,
+plugin_auto_load (char *force_plugin_autoload,
int load_from_plugin_path,
int load_from_extra_lib_dir,
- int load_from_lib_dir)
+ int load_from_lib_dir,
+ int argc, char **argv)
{
char *dir_name, *plugin_path, *plugin_path2, *extra_libdir;
+ const char *ptr_plugin_autoload;
struct t_weechat_plugin *ptr_plugin;
struct t_plugin_args plugin_args;
struct t_arraylist *arraylist;
@@ -1015,10 +1017,12 @@ plugin_auto_load (int argc, char **argv,
plugin_autoload_array = NULL;
plugin_autoload_count = 0;
- if (CONFIG_STRING(config_plugin_autoload)
- && CONFIG_STRING(config_plugin_autoload)[0])
+ ptr_plugin_autoload = (force_plugin_autoload) ?
+ force_plugin_autoload : CONFIG_STRING(config_plugin_autoload);
+
+ if (ptr_plugin_autoload && ptr_plugin_autoload[0])
{
- plugin_autoload_array = string_split (CONFIG_STRING(config_plugin_autoload),
+ plugin_autoload_array = string_split (ptr_plugin_autoload,
",", 0, 0,
&plugin_autoload_count);
}
@@ -1351,20 +1355,17 @@ plugin_display_short_list ()
*/
void
-plugin_init (int auto_load, int argc, char *argv[])
+plugin_init (char *force_plugin_autoload, int argc, char *argv[])
{
/* read plugins options on disk */
plugin_config_init ();
plugin_config_read ();
- /* auto-load plugins if asked */
- if (auto_load)
- {
- plugin_quiet = 1;
- plugin_auto_load (argc, argv, 1, 1, 1);
- plugin_display_short_list ();
- plugin_quiet = 0;
- }
+ /* auto-load plugins */
+ plugin_quiet = 1;
+ plugin_auto_load (force_plugin_autoload, 1, 1, 1, argc, argv);
+ plugin_display_short_list ();
+ plugin_quiet = 0;
}
/*
diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h
index fa62cb4bb..103b4b547 100644
--- a/src/plugins/plugin.h
+++ b/src/plugins/plugin.h
@@ -39,15 +39,17 @@ extern const char *plugin_get_name (struct t_weechat_plugin *plugin);
extern struct t_weechat_plugin *plugin_load (const char *filename,
int init_plugin,
int argc, char **argv);
-extern void plugin_auto_load (int argc, char **argv,
+extern void plugin_auto_load (char *force_plugin_autoload,
int load_from_plugin_path,
int load_from_extra_lib_dir,
- int load_from_lib_dir);
+ int load_from_lib_dir,
+ int argc,
+ char **argv);
extern void plugin_unload (struct t_weechat_plugin *plugin);
extern void plugin_unload_name (const char *name);
extern void plugin_unload_all ();
extern void plugin_reload_name (const char *name, int argc, char **argv);
-extern void plugin_init (int auto_load, int argc, char *argv[]);
+extern void plugin_init (char *force_plugin_autoload, int argc, char *argv[]);
extern void plugin_end ();
extern struct t_hdata *plugin_hdata_plugin_cb (const void *pointer,
void *data,