diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | doc/de/autogen/user/weechat_options.txt | 4 | ||||
-rw-r--r-- | doc/en/autogen/user/weechat_options.txt | 4 | ||||
-rw-r--r-- | doc/fr/autogen/user/weechat_options.txt | 4 | ||||
-rw-r--r-- | doc/it/autogen/user/weechat_options.txt | 4 | ||||
-rw-r--r-- | po/cs.po | 18 | ||||
-rw-r--r-- | po/de.po | 18 | ||||
-rw-r--r-- | po/es.po | 18 | ||||
-rw-r--r-- | po/fr.po | 19 | ||||
-rw-r--r-- | po/hu.po | 6 | ||||
-rw-r--r-- | po/it.po | 18 | ||||
-rw-r--r-- | po/pl.po | 18 | ||||
-rw-r--r-- | po/pt_BR.po | 15 | ||||
-rw-r--r-- | po/ru.po | 6 | ||||
-rw-r--r-- | po/weechat.pot | 6 | ||||
-rw-r--r-- | src/core/wee-command.c | 15 | ||||
-rw-r--r-- | src/core/wee-config.c | 41 | ||||
-rw-r--r-- | src/core/wee-config.h | 2 | ||||
-rw-r--r-- | src/core/wee-util.c | 105 | ||||
-rw-r--r-- | src/plugins/plugin.c | 157 |
20 files changed, 303 insertions, 179 deletions
@@ -1,12 +1,14 @@ WeeChat ChangeLog ================= Sébastien Helleu <flashcode@flashtux.org> -v0.3.7-dev, 2011-11-12 +v0.3.7-dev, 2011-11-15 Version 0.3.7 (under dev!) -------------------------- +* core: allow list for option weechat.plugin.extension (makes weechat.conf + portable accross Un*x and Windows) (task #11479) * core: fix compilation under OpenBSD 5.0 (lib utf8 not needed any more) (bug #34727) * core: add new option weechat.completion.base_word_until_cursor: allow diff --git a/doc/de/autogen/user/weechat_options.txt b/doc/de/autogen/user/weechat_options.txt index af0c95ae5..e7f19e642 100644 --- a/doc/de/autogen/user/weechat_options.txt +++ b/doc/de/autogen/user/weechat_options.txt @@ -729,9 +729,9 @@ ** Werte: on, off (Standardwert: `off`) * [[option_weechat.plugin.extension]] *weechat.plugin.extension* -** Beschreibung: `Standard Dateinamenserweiterung (Beispiel: ".so" unter Linux oder ".dll" unter Microsoft Windows)` +** Beschreibung: `comma separated list of file name extensions for plugins` ** Typ: Zeichenkette -** Werte: beliebige Zeichenkette (Standardwert: `".so"`) +** Werte: beliebige Zeichenkette (Standardwert: `".so,.dll"`) * [[option_weechat.plugin.path]] *weechat.plugin.path* ** Beschreibung: `Suchpfad für Erweiterungen ("%h"' wird durch das WeeChat-Basisverzeichnis ersetzt, voreingestellt ist "~/.weechat")` diff --git a/doc/en/autogen/user/weechat_options.txt b/doc/en/autogen/user/weechat_options.txt index 5e1fce663..b55c2c3a9 100644 --- a/doc/en/autogen/user/weechat_options.txt +++ b/doc/en/autogen/user/weechat_options.txt @@ -729,9 +729,9 @@ ** values: on, off (default value: `off`) * [[option_weechat.plugin.extension]] *weechat.plugin.extension* -** description: `standard plugins extension in filename (for example ".so" under Linux or ".dll" under Microsoft Windows)` +** description: `comma separated list of file name extensions for plugins` ** type: string -** values: any string (default value: `".so"`) +** values: any string (default value: `".so,.dll"`) * [[option_weechat.plugin.path]] *weechat.plugin.path* ** description: `path for searching plugins ("%h" will be replaced by WeeChat home, "~/.weechat" by default)` diff --git a/doc/fr/autogen/user/weechat_options.txt b/doc/fr/autogen/user/weechat_options.txt index 1d26b33e2..5e102d9f8 100644 --- a/doc/fr/autogen/user/weechat_options.txt +++ b/doc/fr/autogen/user/weechat_options.txt @@ -729,9 +729,9 @@ ** valeurs: on, off (valeur par défaut: `off`) * [[option_weechat.plugin.extension]] *weechat.plugin.extension* -** description: `extension par défaut des extensions (par example ".so" sous Linux ou ".dll" sous Microsoft Windows)` +** description: `liste d'extensions de noms de fichiers pour les extensions (séparées par des virgules)` ** type: chaîne -** valeurs: toute chaîne (valeur par défaut: `".so"`) +** valeurs: toute chaîne (valeur par défaut: `".so,.dll"`) * [[option_weechat.plugin.path]] *weechat.plugin.path* ** description: `chemin de recherche des extensions ("%h" sera remplacé par le répertoire de base WeeChat, par défaut: "~/.weechat")` diff --git a/doc/it/autogen/user/weechat_options.txt b/doc/it/autogen/user/weechat_options.txt index dab468186..2623a776f 100644 --- a/doc/it/autogen/user/weechat_options.txt +++ b/doc/it/autogen/user/weechat_options.txt @@ -729,9 +729,9 @@ ** valori: on, off (valore predefinito: `off`) * [[option_weechat.plugin.extension]] *weechat.plugin.extension* -** descrizione: `estensione standard dei plugin nei nomi file (per esempio ".so" sotto Linux oppure ".dll" sotto Microsoft Windows)` +** descrizione: `comma separated list of file name extensions for plugins` ** tipo: stringa -** valori: qualsiasi stringa (valore predefinito: `".so"`) +** valori: qualsiasi stringa (valore predefinito: `".so,.dll"`) * [[option_weechat.plugin.path]] *weechat.plugin.path* ** descrizione: `percorso per la ricerca dei plugin ("%h" sarà sostituito dalla home di WeeChat, "~/.weechat come predefinita)` @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-12 16:06+0100\n" +"POT-Creation-Date: 2011-11-15 10:42+0100\n" "PO-Revision-Date: 2011-11-03 16:57+0100\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2897,12 +2897,9 @@ msgstr "" "povolit ladící zprávy defaultně ve všech pluginech (volba je defaultně " "vypnuta, což je velice doporučeno)" -msgid "" -"standard plugins extension in filename (for example \".so\" under Linux or " -"\".dll\" under Microsoft Windows)" -msgstr "" -"standardní přípona souboru pluginů (například \".so\" pod Linuxem nebo \".dll" -"\" pod Microsoft Windows)" +#, fuzzy +msgid "comma separated list of file name extensions for plugins" +msgstr "čárkami oddělený seznam slovníků, které použít pro tento buffer" msgid "" "path for searching plugins (\"%h\" will be replaced by WeeChat home, \"~/." @@ -8156,6 +8153,13 @@ msgstr "" msgid "Lists" msgstr "" +#~ msgid "" +#~ "standard plugins extension in filename (for example \".so\" under Linux " +#~ "or \".dll\" under Microsoft Windows)" +#~ msgstr "" +#~ "standardní přípona souboru pluginů (například \".so\" pod Linuxem nebo \"." +#~ "dll\" pod Microsoft Windows)" + #~ msgid "%sWarning: %s, line %d: unknown option \"%s\" (outside a section)" #~ msgstr "%sUpozornění: %s, řádek %d: neznámé nastavení \"%s\" (mimo sekci)" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-12 16:06+0100\n" +"POT-Creation-Date: 2011-11-15 10:42+0100\n" "PO-Revision-Date: 2011-11-08 22:03+0100\n" "Last-Translator: Nils Görs\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3161,12 +3161,11 @@ msgstr "" "aktiviere Debug-Nachrichten für alle Erweiterungen (diese Option ist " "standardmäßig deaktiviert und das ist auch gut so)" -msgid "" -"standard plugins extension in filename (for example \".so\" under Linux or " -"\".dll\" under Microsoft Windows)" +#, fuzzy +msgid "comma separated list of file name extensions for plugins" msgstr "" -"Standard Dateinamenserweiterung (Beispiel: \".so\" unter Linux oder \".dll\" " -"unter Microsoft Windows)" +"Durch Kommata getrennte Liste der Wörterbücher, die in diesem Buffer genutzt " +"werden" msgid "" "path for searching plugins (\"%h\" will be replaced by WeeChat home, \"~/." @@ -8599,6 +8598,13 @@ msgstr "Variablen" msgid "Lists" msgstr "Listen" +#~ msgid "" +#~ "standard plugins extension in filename (for example \".so\" under Linux " +#~ "or \".dll\" under Microsoft Windows)" +#~ msgstr "" +#~ "Standard Dateinamenserweiterung (Beispiel: \".so\" unter Linux oder \".dll" +#~ "\" unter Microsoft Windows)" + #~ msgid "condition(s) for displaying bar (for bars of type \"window\")" #~ msgstr "" #~ "Bedingung(en) für die Darstellung von Infobar(s) (für Infobars des Typs " @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-12 16:06+0100\n" +"POT-Creation-Date: 2011-11-15 10:42+0100\n" "PO-Revision-Date: 2011-11-03 16:57+0100\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3056,12 +3056,9 @@ msgstr "" "habilita mensajes de depuración por defecto en todos los plugins (opción " "desactivada por defecto, ya que es lo recomendado)" -msgid "" -"standard plugins extension in filename (for example \".so\" under Linux or " -"\".dll\" under Microsoft Windows)" -msgstr "" -"extensión estándar de los archivos de plugin (por ejemplo \".so\" en linux o " -"\".dll\" en Microsoft Windows)" +#, fuzzy +msgid "comma separated list of file name extensions for plugins" +msgstr "lista separada por comas de diccionarios para usar en este buffer" msgid "" "path for searching plugins (\"%h\" will be replaced by WeeChat home, \"~/." @@ -8369,6 +8366,13 @@ msgstr "Variables" msgid "Lists" msgstr "Listas" +#~ msgid "" +#~ "standard plugins extension in filename (for example \".so\" under Linux " +#~ "or \".dll\" under Microsoft Windows)" +#~ msgstr "" +#~ "extensión estándar de los archivos de plugin (por ejemplo \".so\" en " +#~ "linux o \".dll\" en Microsoft Windows)" + #~ msgid "%sWarning: %s, line %d: unknown option \"%s\" (outside a section)" #~ msgstr "" #~ "%sAtención: %s, línea %d: opción desconocida \"%s\" (fuera de la sección)" @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-12 16:06+0100\n" -"PO-Revision-Date: 2011-11-12 16:06+0100\n" +"POT-Creation-Date: 2011-11-15 10:42+0100\n" +"PO-Revision-Date: 2011-11-14 19:06+0100\n" "Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: French\n" @@ -3083,12 +3083,10 @@ msgstr "" "active les messages de debug par défaut pour toutes les extensions (option " "désactivée par défaut, ce qui est hautement recommandé)" -msgid "" -"standard plugins extension in filename (for example \".so\" under Linux or " -"\".dll\" under Microsoft Windows)" +msgid "comma separated list of file name extensions for plugins" msgstr "" -"extension par défaut des extensions (par example \".so\" sous Linux ou \".dll" -"\" sous Microsoft Windows)" +"liste d'extensions de noms de fichiers pour les extensions (séparées par des " +"virgules)" msgid "" "path for searching plugins (\"%h\" will be replaced by WeeChat home, \"~/." @@ -8427,6 +8425,13 @@ msgstr "Variables" msgid "Lists" msgstr "Listes" +#~ msgid "" +#~ "standard plugins extension in filename (for example \".so\" under Linux " +#~ "or \".dll\" under Microsoft Windows)" +#~ msgstr "" +#~ "extension par défaut des extensions (par example \".so\" sous Linux ou \"." +#~ "dll\" sous Microsoft Windows)" + #~ msgid "%sWarning: %s, line %d: unknown option \"%s\" (outside a section)" #~ msgstr "" #~ "%sAttention: %s, ligne %d: option \"%s\" inconnue (hors d'une section)" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-12 16:06+0100\n" +"POT-Creation-Date: 2011-11-15 10:42+0100\n" "PO-Revision-Date: 2011-10-22 12:21+0200\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2564,9 +2564,7 @@ msgid "" "which is highly recommended)" msgstr "" -msgid "" -"standard plugins extension in filename (for example \".so\" under Linux or " -"\".dll\" under Microsoft Windows)" +msgid "comma separated list of file name extensions for plugins" msgstr "" #, fuzzy @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-12 16:06+0100\n" +"POT-Creation-Date: 2011-11-15 10:42+0100\n" "PO-Revision-Date: 2011-11-03 16:57+0100\n" "Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3054,12 +3054,9 @@ msgstr "" "abilita come predefinito il debug per tutti i plugin (opzione disabilita di " "default, caldamente raccomandato)" -msgid "" -"standard plugins extension in filename (for example \".so\" under Linux or " -"\".dll\" under Microsoft Windows)" -msgstr "" -"estensione standard dei plugin nei nomi file (per esempio \".so\" sotto " -"Linux oppure \".dll\" sotto Microsoft Windows)" +#, fuzzy +msgid "comma separated list of file name extensions for plugins" +msgstr "elenco separato da virgole di dizionari da usare su questo buffer" msgid "" "path for searching plugins (\"%h\" will be replaced by WeeChat home, \"~/." @@ -8340,6 +8337,13 @@ msgstr "Variabili" msgid "Lists" msgstr "Liste" +#~ msgid "" +#~ "standard plugins extension in filename (for example \".so\" under Linux " +#~ "or \".dll\" under Microsoft Windows)" +#~ msgstr "" +#~ "estensione standard dei plugin nei nomi file (per esempio \".so\" sotto " +#~ "Linux oppure \".dll\" sotto Microsoft Windows)" + #~ msgid "%sWarning: %s, line %d: unknown option \"%s\" (outside a section)" #~ msgstr "" #~ "%sAttenzione: %s, riga %d: opzione \"%s\" sconosciuta (fuori dalla " @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-12 16:06+0100\n" +"POT-Creation-Date: 2011-11-15 10:42+0100\n" "PO-Revision-Date: 2011-11-03 16:57+0100\n" "Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3047,12 +3047,9 @@ msgstr "" "włącz wiadomości debugujące domyślnie we wszystkich wtyczkach (opcja " "domyślnie wyłączona, co jest wysoce zalecane)" -msgid "" -"standard plugins extension in filename (for example \".so\" under Linux or " -"\".dll\" under Microsoft Windows)" -msgstr "" -"domyślne rozszerzenie wtyczek (na przykład \".so\" pod Linuksem lub \".dll\" " -"pod Microsoft Windows)" +#, fuzzy +msgid "comma separated list of file name extensions for plugins" +msgstr "oddzielona przecinkami lista słowników do użycia w tym buforze" msgid "" "path for searching plugins (\"%h\" will be replaced by WeeChat home, \"~/." @@ -8278,6 +8275,13 @@ msgstr "Zmienne" msgid "Lists" msgstr "Listy" +#~ msgid "" +#~ "standard plugins extension in filename (for example \".so\" under Linux " +#~ "or \".dll\" under Microsoft Windows)" +#~ msgstr "" +#~ "domyślne rozszerzenie wtyczek (na przykład \".so\" pod Linuksem lub \".dll" +#~ "\" pod Microsoft Windows)" + #~ msgid "%sWarning: %s, line %d: unknown option \"%s\" (outside a section)" #~ msgstr "%sOstrzeżenie: %s, w linii %d: nieznana opcja \"%s\" (poza sekcją)" diff --git a/po/pt_BR.po b/po/pt_BR.po index 6d4176be8..43598162f 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-12 16:06+0100\n" +"POT-Creation-Date: 2011-11-15 10:42+0100\n" "PO-Revision-Date: 2011-11-03 16:58+0100\n" "Last-Translator: Ivan Sichmann Freitas <ivansichfreitas@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -3011,12 +3011,8 @@ msgstr "" "habilita mensagens de debug por padrão em todos os plugins (opção " "desabilitada por padrão, o que é altamente recomendado)" -msgid "" -"standard plugins extension in filename (for example \".so\" under Linux or " -"\".dll\" under Microsoft Windows)" +msgid "comma separated list of file name extensions for plugins" msgstr "" -"extensão padrão dos plugins no nome de arquivo (por exemplo \".so\" em Linux " -"ou \".dll\" em Microsoft Windows)" msgid "" "path for searching plugins (\"%h\" will be replaced by WeeChat home, \"~/." @@ -7578,6 +7574,13 @@ msgstr "" msgid "Lists" msgstr "" +#~ msgid "" +#~ "standard plugins extension in filename (for example \".so\" under Linux " +#~ "or \".dll\" under Microsoft Windows)" +#~ msgstr "" +#~ "extensão padrão dos plugins no nome de arquivo (por exemplo \".so\" em " +#~ "Linux ou \".dll\" em Microsoft Windows)" + #~ msgid "%sWarning: %s, line %d: unknown option \"%s\" (outside a section)" #~ msgstr "" #~ "%sAviso: %s, linha %d: opção desconhedica \"%s\" (fora de uma seção)" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-12 16:06+0100\n" +"POT-Creation-Date: 2011-11-15 10:42+0100\n" "PO-Revision-Date: 2011-10-22 12:21+0200\n" "Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2578,9 +2578,7 @@ msgid "" "which is highly recommended)" msgstr "" -msgid "" -"standard plugins extension in filename (for example \".so\" under Linux or " -"\".dll\" under Microsoft Windows)" +msgid "comma separated list of file name extensions for plugins" msgstr "" #, fuzzy diff --git a/po/weechat.pot b/po/weechat.pot index cd3792c9e..f4eec8b20 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-12 16:06+0100\n" +"POT-Creation-Date: 2011-11-15 10:42+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -2232,9 +2232,7 @@ msgid "" "which is highly recommended)" msgstr "" -msgid "" -"standard plugins extension in filename (for example \".so\" under Linux or " -"\".dll\" under Microsoft Windows)" +msgid "comma separated list of file name extensions for plugins" msgstr "" msgid "" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index f19b4aa66..6bbd59035 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -3572,7 +3572,7 @@ command_plugin_list (const char *name, int full) COMMAND_CALLBACK(plugin) { int plugin_argc; - char **plugin_argv; + char **plugin_argv, *full_name; /* make C compiler happy */ (void) data; @@ -3614,16 +3614,19 @@ COMMAND_CALLBACK(plugin) { if (argc > 2) { + plugin_argv = NULL; + plugin_argc = 0; if (argc > 3) { plugin_argv = string_split (argv_eol[3], " ", 0, 0, &plugin_argc); - plugin_load (argv[2], plugin_argc, plugin_argv); - if (plugin_argv) - string_free_split (plugin_argv); } - else - plugin_load (argv[2], 0, NULL); + full_name = util_search_full_lib_name (argv[2], "plugins"); + plugin_load (full_name, plugin_argc, plugin_argv); + if (full_name) + free (full_name); + if (plugin_argv) + string_free_split (plugin_argv); } else { diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 00b2307ed..232856e2a 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -242,6 +242,8 @@ int config_day_change_old_day = -1; regex_t *config_highlight_regex = NULL; char **config_highlight_tags = NULL; int config_num_highlight_tags = 0; +char **config_plugin_extensions = NULL; +int config_num_plugin_extensions = 0; /* @@ -534,6 +536,31 @@ config_change_network_gnutls_ca_file (void *data, network_set_gnutls_ca_file (); } +/* + * config_change_plugin_extension: called when plugin extension is changed + */ + +void +config_change_plugin_extension (void *data, struct t_config_option *option) +{ + /* make C compiler happy */ + (void) data; + (void) option; + + if (config_plugin_extensions) + { + string_free_split (config_plugin_extensions); + config_plugin_extensions = NULL; + } + config_num_plugin_extensions = 0; + + if (CONFIG_STRING(config_plugin_extension) + && CONFIG_STRING(config_plugin_extension)[0]) + { + config_plugin_extensions = string_split (CONFIG_STRING(config_plugin_extension), + ",", 0, 0, &config_num_plugin_extensions); + } +} /* * config_day_change_timer_cb: timer callback for displaying @@ -2600,15 +2627,9 @@ config_weechat_init_options () config_plugin_extension = config_file_new_option ( weechat_config_file, ptr_section, "extension", "string", - N_("standard plugins extension in filename (for example " - "\".so\" under Linux or \".dll\" under Microsoft Windows)"), - NULL, 0, 0, -#if defined(WIN32) || defined(__CYGWIN__) - ".dll", -#else - ".so", -#endif - NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + N_("comma separated list of file name extensions for plugins"), + NULL, 0, 0, ".so,.dll", NULL, 0, NULL, NULL, + &config_change_plugin_extension, NULL, NULL, NULL); config_plugin_path = config_file_new_option ( weechat_config_file, ptr_section, "path", "string", @@ -2736,6 +2757,8 @@ config_weechat_init () config_change_highlight_regex (NULL, NULL); if (!config_highlight_tags) config_change_highlight_tags (NULL, NULL); + if (!config_plugin_extensions) + config_change_plugin_extension (NULL, NULL); return rc; } diff --git a/src/core/wee-config.h b/src/core/wee-config.h index e46e94707..644f997b5 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -252,6 +252,8 @@ extern struct t_config_option *config_plugin_save_config_on_unload; extern regex_t *config_highlight_regex; extern char **config_highlight_tags; extern int config_num_highlight_tags; +extern char **config_plugin_extensions; +extern int config_num_plugin_extensions; extern struct t_config_option *config_weechat_debug_get (const char *plugin_name); diff --git a/src/core/wee-util.c b/src/core/wee-util.c index 886a7a821..40a1b50f3 100644 --- a/src/core/wee-util.c +++ b/src/core/wee-util.c @@ -287,50 +287,49 @@ util_exec_on_files (const char *directory, int hidden_files, void *data, } /* - * util_search_full_lib_name: search the full name of a WeeChat library - * file with a part of name + * util_search_full_lib_name: search the full name of a WeeChat library + * file with name and extension * - look in WeeChat user's dir, then WeeChat * global lib dir * - sys_directory is the system directory under * WeeChat lib prefix, for example "plugins" - * - result has to be free() after use + * - result has to be free() after use (if not NULL) + * - NULL is returned if lib is not found */ char * -util_search_full_lib_name (const char *filename, const char *sys_directory) +util_search_full_lib_name_ext (const char *filename, const char *extension, + const char *plugins_dir) { char *name_with_ext, *final_name; int length; struct stat st; - /* filename is already a full path */ - if (strchr (filename, '/') || strchr (filename, '\\')) - return strdup (filename); - - length = strlen (filename) + 16; - if (CONFIG_STRING(config_plugin_extension) - && CONFIG_STRING(config_plugin_extension)[0]) - length += strlen (CONFIG_STRING(config_plugin_extension)); + length = strlen (filename) + strlen (extension) + 1; name_with_ext = malloc (length); if (!name_with_ext) - return strdup (filename); - strcpy (name_with_ext, filename); - if (!strchr (filename, '.') - && CONFIG_STRING(config_plugin_extension) - && CONFIG_STRING(config_plugin_extension)[0]) - strcat (name_with_ext, CONFIG_STRING(config_plugin_extension)); + return NULL; + snprintf (name_with_ext, length, + "%s%s", + filename, + (strchr (filename, '.')) ? "" : extension); /* try WeeChat user's dir */ length = strlen (weechat_home) + strlen (name_with_ext) + - strlen (sys_directory) + 16; + strlen (plugins_dir) + 16; final_name = malloc (length); if (!final_name) { free (name_with_ext); - return strdup (filename); + return NULL; } snprintf (final_name, length, - "%s/%s/%s", weechat_home, sys_directory, name_with_ext); + "%s%s%s%s%s", + weechat_home, + DIR_SEPARATOR, + plugins_dir, + DIR_SEPARATOR, + name_with_ext); if ((stat (final_name, &st) == 0) && (st.st_size > 0)) { free (name_with_ext); @@ -340,15 +339,20 @@ util_search_full_lib_name (const char *filename, const char *sys_directory) /* try WeeChat global lib dir */ length = strlen (WEECHAT_LIBDIR) + strlen (name_with_ext) + - strlen (sys_directory) + 16; + strlen (plugins_dir) + 16; final_name = malloc (length); if (!final_name) { free (name_with_ext); - return strdup (filename); + return NULL; } snprintf (final_name, length, - "%s/%s/%s", WEECHAT_LIBDIR, sys_directory, name_with_ext); + "%s%s%s%s%s", + WEECHAT_LIBDIR, + DIR_SEPARATOR, + plugins_dir, + DIR_SEPARATOR, + name_with_ext); if ((stat (final_name, &st) == 0) && (st.st_size > 0)) { free (name_with_ext); @@ -356,7 +360,58 @@ util_search_full_lib_name (const char *filename, const char *sys_directory) } free (final_name); - return name_with_ext; + free (name_with_ext); + + return NULL; +} + +/* + * util_search_full_lib_name: search the full name of a WeeChat library + * file with a part of name + * - look in WeeChat user's dir, then WeeChat + * global lib dir + * - plugins_dir is the directory under WeeChat lib + * prefix (for system dir) or under WeeChat home, + * for example "plugins" + * - result has to be free() after use (if not NULL) + */ + +char * +util_search_full_lib_name (const char *filename, const char *plugins_dir) +{ + char *filename2, *full_name; + int i; + + /* expand home in filename */ + filename2 = string_expand_home (filename); + if (!filename2) + return NULL; + + /* if full path, return it */ + if (strchr (filename2, '/') || strchr (filename2, '\\')) + return filename2; + + if (config_plugin_extensions) + { + for (i = 0; i < config_num_plugin_extensions; i++) + { + full_name = util_search_full_lib_name_ext (filename2, + config_plugin_extensions[i], + plugins_dir); + if (full_name) + return full_name; + } + } + else + { + full_name = util_search_full_lib_name_ext (filename2, "", plugins_dir); + if (full_name) + return full_name; + } + + free (filename2); + + return strdup (filename); } /* diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index fe8782ee1..d256fe0e4 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -143,6 +143,39 @@ plugin_get_name (struct t_weechat_plugin *plugin) } /* + * plugin_check_extension_allowed: check if extension of filename is allowed + * by option "weechat.plugin.extension" + */ + +int +plugin_check_extension_allowed (const char *filename) +{ + int i, length, length_ext; + + /* extension allowed if no extension is defined */ + if (!config_plugin_extensions) + return 1; + + length = strlen (filename); + for (i = 0; i < config_num_plugin_extensions; i++) + { + length_ext = strlen (config_plugin_extensions[i]); + if (length >= length_ext) + { + if (string_strcasecmp (filename + length - length_ext, + config_plugin_extensions[i]) == 0) + { + /* extension allowed */ + return 1; + } + } + } + + /* extension not allowed */ + return 0; +} + +/* * plugin_check_autoload: check if a plugin can be autoloaded or not * return 1 if plugin can be autoloaded * 0 if plugin can NOT be autoloaded @@ -151,36 +184,58 @@ plugin_get_name (struct t_weechat_plugin *plugin) */ int -plugin_check_autoload (char *plugin_full_name) +plugin_check_autoload (const char *filename) { - int i, plugin_authorized, plugin_blacklisted; - char *ptr_base_name, *base_name, *plugin_name, *pos; + int i, plugin_authorized, plugin_blacklisted, length, length_ext; + char *full_name, *ptr_base_name, *base_name, *plugin_name; /* by default we can auto load all plugins */ if (!plugin_autoload_array) return 1; + full_name = strdup (filename); + if (!full_name) + return 0; + /* get short name of plugin (filename without extension) */ plugin_name = NULL; - ptr_base_name = basename (plugin_full_name); + ptr_base_name = basename (full_name); if (!ptr_base_name) + { + free (full_name); return 1; + } base_name = strdup (ptr_base_name); if (!base_name) + { + free (full_name); return 1; + } + + free (full_name); - if (CONFIG_STRING(config_plugin_extension) - && CONFIG_STRING(config_plugin_extension)[0]) + if (config_plugin_extensions) { - pos = strstr (base_name, - CONFIG_STRING(config_plugin_extension)); - plugin_name = (pos) ? - string_strndup (base_name, pos - base_name) : - strdup (base_name); + length = strlen (base_name); + for (i = 0; i < config_num_plugin_extensions; i++) + { + length_ext = strlen (config_plugin_extensions[i]); + if (length >= length_ext) + { + if (string_strcasecmp (base_name + length - length_ext, + config_plugin_extensions[i]) == 0) + { + plugin_name = string_strndup (base_name, length - length_ext); + break; + } + } + } } else + { plugin_name = strdup (base_name); + } free (base_name); @@ -242,7 +297,6 @@ plugin_find_pos (struct t_weechat_plugin *plugin) struct t_weechat_plugin * plugin_load (const char *filename, int argc, char **argv) { - char *full_name, *full_name2; void *handle; char *name, *api_version, *author, *description, *version; char *license, *charset; @@ -255,39 +309,26 @@ plugin_load (const char *filename, int argc, char **argv) if (!filename) return NULL; - full_name = util_search_full_lib_name (filename, "plugins"); - - if (!full_name) - return NULL; - /* * if plugin must not be autoloaded, then return immediately * Note: the "plugin_autoload_array" variable is set only during auto-load, * ie when WeeChat is starting or when doing /plugin autoload */ - if (plugin_autoload_array && !plugin_check_autoload (full_name)) + if (plugin_autoload_array && !plugin_check_autoload (filename)) return NULL; - full_name2 = string_expand_home (full_name); - if (full_name2) - { - free (full_name); - full_name = full_name2; - } - - handle = dlopen (full_name, RTLD_GLOBAL | RTLD_NOW); + handle = dlopen (filename, RTLD_GLOBAL | RTLD_NOW); if (!handle) { gui_chat_printf (NULL, _("%sError: unable to load plugin \"%s\": %s"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - full_name, dlerror()); + filename, dlerror()); gui_chat_printf (NULL, _("%sIf you're trying to load a script and not a C " "plugin, try command to load scripts (/perl, " "/python, ...)"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); - free (full_name); return NULL; } @@ -300,9 +341,8 @@ plugin_load (const char *filename, int argc, char **argv) "plugin \"%s\", failed to load"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], "weechat_plugin_name", - full_name); + filename); dlclose (handle); - free (full_name); return NULL; } @@ -315,14 +355,13 @@ plugin_load (const char *filename, int argc, char **argv) "plugin \"%s\", failed to load"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], "weechat_plugin_api_version", - full_name); + filename); gui_chat_printf (NULL, _("%sIf plugin \"%s\" is old/obsolete, you can " "delete this file."), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], name); dlclose (handle); - free (full_name); return NULL; } if (strcmp (api_version, WEECHAT_PLUGIN_API_VERSION) != 0) @@ -331,7 +370,7 @@ plugin_load (const char *filename, int argc, char **argv) _("%sError: API mismatch for plugin \"%s\" (current " "API: \"%s\", plugin API: \"%s\"), failed to load"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - full_name, + filename, WEECHAT_PLUGIN_API_VERSION, api_version); gui_chat_printf (NULL, @@ -340,7 +379,6 @@ plugin_load (const char *filename, int argc, char **argv) gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], name); dlclose (handle); - free (full_name); return NULL; } @@ -351,9 +389,8 @@ plugin_load (const char *filename, int argc, char **argv) _("%sError: unable to load plugin \"%s\": a plugin " "with same name already exists"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - full_name); + filename); dlclose (handle); - free (full_name); return NULL; } @@ -366,9 +403,8 @@ plugin_load (const char *filename, int argc, char **argv) "in plugin \"%s\", failed to load"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], "weechat_plugin_description", - full_name); + filename); dlclose (handle); - free (full_name); return NULL; } @@ -381,9 +417,8 @@ plugin_load (const char *filename, int argc, char **argv) "in plugin \"%s\", failed to load"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], "weechat_plugin_author", - full_name); + filename); dlclose (handle); - free (full_name); return NULL; } @@ -396,9 +431,8 @@ plugin_load (const char *filename, int argc, char **argv) "plugin \"%s\", failed to load"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], "weechat_plugin_version", - full_name); + filename); dlclose (handle); - free (full_name); return NULL; } @@ -411,9 +445,8 @@ plugin_load (const char *filename, int argc, char **argv) "plugin \"%s\", failed to load"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], "weechat_plugin_license", - full_name); + filename); dlclose (handle); - free (full_name); return NULL; } @@ -429,9 +462,8 @@ plugin_load (const char *filename, int argc, char **argv) "found in plugin \"%s\", failed to load"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], "weechat_plugin_init", - full_name); + filename); dlclose (handle); - free (full_name); return NULL; } @@ -440,7 +472,7 @@ plugin_load (const char *filename, int argc, char **argv) if (new_plugin) { /* variables */ - new_plugin->filename = strdup (full_name); + new_plugin->filename = strdup (filename); new_plugin->handle = handle; new_plugin->name = strdup (name); new_plugin->description = strdup (description); @@ -779,9 +811,8 @@ plugin_load (const char *filename, int argc, char **argv) _("%sError: unable to initialize plugin " "\"%s\""), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - full_name); + filename); plugin_remove (new_plugin); - free (full_name); return NULL; } } @@ -791,9 +822,8 @@ plugin_load (const char *filename, int argc, char **argv) _("%sError: unable to load plugin \"%s\" " "(not enough memory)"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - full_name); + filename); dlclose (handle); - free (full_name); return NULL; } @@ -804,8 +834,6 @@ plugin_load (const char *filename, int argc, char **argv) name); } - free (full_name); - return new_plugin; } @@ -818,24 +846,10 @@ void plugin_auto_load_file (void *args, const char *filename) { struct t_plugin_args *plugin_args; - char *pos; plugin_args = (struct t_plugin_args *)args; - if (CONFIG_STRING(config_plugin_extension) - && CONFIG_STRING(config_plugin_extension)[0]) - { - pos = strstr (filename, CONFIG_STRING(config_plugin_extension)); - if (pos) - { - if (string_strcasecmp (pos, - CONFIG_STRING(config_plugin_extension)) == 0) - { - plugin_load (filename, plugin_args->argc, plugin_args->argv); - } - } - } - else + if (plugin_check_extension_allowed (filename)) plugin_load (filename, plugin_args->argc, plugin_args->argv); } @@ -849,6 +863,7 @@ plugin_auto_load (int argc, char **argv) { char *dir_name, *plugin_path, *plugin_path2; struct t_plugin_args plugin_args; + int length; plugin_args.argc = argc; plugin_args.argv = argv; @@ -885,11 +900,11 @@ plugin_auto_load (int argc, char **argv) } /* auto-load plugins in WeeChat global lib dir */ - dir_name = malloc (strlen (WEECHAT_LIBDIR) + 16); + length = strlen (WEECHAT_LIBDIR) + 16 + 1; + dir_name = malloc (length); if (dir_name) { - snprintf (dir_name, strlen (WEECHAT_LIBDIR) + 16, - "%s/plugins", WEECHAT_LIBDIR); + snprintf (dir_name, length, "%s/plugins", WEECHAT_LIBDIR); util_exec_on_files (dir_name, 0, &plugin_args, &plugin_auto_load_file); free (dir_name); } |