diff --git a/ChangeLog.adoc b/ChangeLog.adoc index f32816365..3cb6a8c18 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -36,6 +36,7 @@ New features:: * api: add info "plugin_loaded" * api: add support of specifier `%!` for timestamp in function util_strftimeval * api: add support of base64url in encode/decode functions + * fset: add option `-import` in command `/fset` * irc: add option `-all` in command `/allchan`, do not execute command on parted channels by default (issue #2085) * irc: add server option "autojoin_delay" (delay before autojoin), use option "command_delay" before execution of the command (issue #862) * relay: add "api" protocol (HTTP REST API), add option relay.look.display_clients, change option type relay.look.auto_open_buffer to string, rename option relay.weechat.commands to relay.network.commands, add option relay.network.time_window (issue #2066) diff --git a/po/cs.po b/po/cs.po index cab22c2aa..c70432d34 100644 --- a/po/cs.po +++ b/po/cs.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2024-03-06 20:32+0100\n" "Last-Translator: Ondřej Súkup \n" "Language-Team: weechat-dev \n" @@ -7403,7 +7403,7 @@ msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" msgid "raw[-bar]: add the help bar" @@ -7472,6 +7472,11 @@ msgid "" "has format: \"/set name value\" or \"/unset name\")" msgstr "" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/de.po b/po/de.po index 933860289..56319bffd 100644 --- a/po/de.po +++ b/po/de.po @@ -26,7 +26,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2024-03-25 11:43+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -8497,11 +8497,17 @@ msgid "fast set WeeChat and plugins options" msgstr "Optionen von WeeChat und Erweiterungen schnell anpassen" #. TRANSLATORS: only text between angle brackets (eg: "") must be translated +#, fuzzy +#| msgid "" +#| "-bar || -refresh || -up|-down [] || -left|-right [] || -" +#| "go |end || -toggle || -add [] || -reset || -unset || -set || " +#| "-setnew || -append || -mark || -format || -export [-help|-nohelp] " +#| " || " msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" @@ -8599,6 +8605,11 @@ msgstr "" "eine Datei (jede Zeile hat das Format: \"/set Name Wert\" oder \"/unset " "Name\")" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/es.po b/po/es.po index 968de3e23..b1585f40e 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2024-03-06 20:32+0100\n" "Last-Translator: Santiago Forero \n" "Language-Team: weechat-dev \n" @@ -7584,7 +7584,7 @@ msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" msgid "raw[-bar]: add the help bar" @@ -7653,6 +7653,11 @@ msgid "" "has format: \"/set name value\" or \"/unset name\")" msgstr "" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/fr.po b/po/fr.po index 4f9419a3b..858551cb5 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" -"PO-Revision-Date: 2024-03-25 12:06+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" +"PO-Revision-Date: 2024-03-25 21:00+0100\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -8336,12 +8336,12 @@ msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" "-bar || -refresh || -up|-down [] || -left|-right [] || -" "go |end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgid "raw[-bar]: add the help bar" msgstr "raw[-bar] : ajouter la barre d'aide" @@ -8432,6 +8432,13 @@ msgstr "" "raw[-export] : exporter les options et valeurs affichées dans un fichier " "(chaque ligne a le format : \"/set nom valeur\" ou \"/unset nom\")" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" +"raw[-import] : importer les options depuis un fichier (toutes les lignes qui " +"contiennent des commandes sont exécutées)" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/hu.po b/po/hu.po index 0ed0dfa04..ed10a786f 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2023-11-29 09:59+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -7068,7 +7068,7 @@ msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" msgid "raw[-bar]: add the help bar" @@ -7137,6 +7137,11 @@ msgid "" "has format: \"/set name value\" or \"/unset name\")" msgstr "" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/it.po b/po/it.po index 0df63c505..04805bc5a 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2024-03-06 20:32+0100\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -7576,7 +7576,7 @@ msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" msgid "raw[-bar]: add the help bar" @@ -7645,6 +7645,11 @@ msgid "" "has format: \"/set name value\" or \"/unset name\")" msgstr "" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/ja.po b/po/ja.po index d39d49e31..c9ab48a0d 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2024-03-06 20:32+0100\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese ") must be translated +#, fuzzy +#| msgid "" +#| "-bar || -refresh || -up|-down [] || -left|-right [] || -" +#| "go |end || -toggle || -add [] || -reset || -unset || -set || " +#| "-setnew || -append || -mark || -format || -export [-help|-nohelp] " +#| " || " msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" @@ -7906,6 +7912,11 @@ msgid "" "has format: \"/set name value\" or \"/unset name\")" msgstr "" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/pl.po b/po/pl.po index 754bc30c0..014dc555d 100644 --- a/po/pl.po +++ b/po/pl.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2024-03-06 20:32+0100\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -8081,11 +8081,17 @@ msgid "fast set WeeChat and plugins options" msgstr "szybkie ustawianie opcji WeeChat i wtyczek" #. TRANSLATORS: only text between angle brackets (eg: "") must be translated +#, fuzzy +#| msgid "" +#| "-bar || -refresh || -up|-down [] || -left|-right [] || -" +#| "go |end || -toggle || -add [] || -reset || -unset || -set || " +#| "-setnew || -append || -mark || -format || -export [-help|-nohelp] " +#| " || " msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" @@ -8173,6 +8179,11 @@ msgstr "" "raw[-export]: wyeksportuj opcje i wartości wyświetlane w pliku (każda linia " "ma format: „/set nazwa wartość” lub „/unset nazwa”)" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/pt.po b/po/pt.po index fac17b038..24f6b4068 100644 --- a/po/pt.po +++ b/po/pt.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2024-03-06 20:32+0100\n" "Last-Translator: Vasco Almeida \n" "Language-Team: Portuguese <>\n" @@ -7816,7 +7816,7 @@ msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" msgid "raw[-bar]: add the help bar" @@ -7885,6 +7885,11 @@ msgid "" "has format: \"/set name value\" or \"/unset name\")" msgstr "" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/pt_BR.po b/po/pt_BR.po index 0a26f8180..f7c5b15f7 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2024-02-17 10:07+0100\n" "Last-Translator: Érico Nogueira \n" "Language-Team: weechat-dev \n" @@ -7478,7 +7478,7 @@ msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" msgid "raw[-bar]: add the help bar" @@ -7547,6 +7547,11 @@ msgid "" "has format: \"/set name value\" or \"/unset name\")" msgstr "" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/ru.po b/po/ru.po index 8eebfc581..fbab6d8ab 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2023-11-29 09:59+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -7109,7 +7109,7 @@ msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" msgid "raw[-bar]: add the help bar" @@ -7178,6 +7178,11 @@ msgid "" "has format: \"/set name value\" or \"/unset name\")" msgstr "" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/sr.po b/po/sr.po index 69eb11cb1..848795bde 100644 --- a/po/sr.po +++ b/po/sr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2024-03-06 20:32+0100\n" "Last-Translator: Ivan Pešić \n" "Language-Team: weechat-dev \n" @@ -8107,11 +8107,17 @@ msgid "fast set WeeChat and plugins options" msgstr "брзо постављање опција за програм WeeChat и додатке" #. TRANSLATORS: only text between angle brackets (eg: "") must be translated +#, fuzzy +#| msgid "" +#| "-bar || -refresh || -up|-down [] || -left|-right [] || -" +#| "go |end || -toggle || -add [] || -reset || -unset || -set || " +#| "-setnew || -append || -mark || -format || -export [-help|-nohelp] " +#| " || " msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" "-bar || -refresh || -up|-down [<број>] || -left|-right [<проценат>] || -go " "<линија>|end || -toggle || -add [<вредн>] || -reset || -unset || -set || -" @@ -8199,6 +8205,11 @@ msgstr "" "raw[-export]: извоз опција и вредности које су приказане у фајлу (свака " "линија има формат: „/set име вредност” или „/unset име”)" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/tr.po b/po/tr.po index 942aa594a..cce8d2589 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2024-03-06 20:33+0100\n" "Last-Translator: Emir SARI \n" "Language-Team: weechat-dev \n" @@ -7911,11 +7911,17 @@ msgid "fast set WeeChat and plugins options" msgstr "WeeChat ve eklenti seçeneklerini hızlıca ayarla" #. TRANSLATORS: only text between angle brackets (eg: "") must be translated +#, fuzzy +#| msgid "" +#| "-bar || -refresh || -up|-down [] || -left|-right [] || -" +#| "go |end || -toggle || -add [] || -reset || -unset || -set || " +#| "-setnew || -append || -mark || -format || -export [-help|-nohelp] " +#| " || " msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" @@ -7992,6 +7998,11 @@ msgid "" "has format: \"/set name value\" or \"/unset name\")" msgstr "" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/po/weechat.pot b/po/weechat.pot index 70ccdb000..62c201b9b 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2024-03-25 12:05+0100\n" +"POT-Creation-Date: 2024-03-25 20:59+0100\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -6612,7 +6612,7 @@ msgid "" "-bar || -refresh || -up|-down [] || -left|-right [] || -go " "|end || -toggle || -add [] || -reset || -unset || -set || -" "setnew || -append || -mark || -format || -export [-help|-nohelp] " -"|| " +"|| -import || " msgstr "" msgid "raw[-bar]: add the help bar" @@ -6681,6 +6681,11 @@ msgid "" "has format: \"/set name value\" or \"/unset name\")" msgstr "" +msgid "" +"raw[-import]: import the options from a file (all lines containing commands " +"are are executed)" +msgstr "" + msgid "" "raw[-help]: force writing of help on options in exported file (see /help " "fset.look.export_help_default)" diff --git a/src/plugins/fset/fset-command.c b/src/plugins/fset/fset-command.c index a3135107c..946c4c17f 100644 --- a/src/plugins/fset/fset-command.c +++ b/src/plugins/fset/fset-command.c @@ -423,6 +423,15 @@ fset_command_fset (const void *pointer, void *data, return WEECHAT_RC_OK; } + if (weechat_strcmp (argv[1], "-import") == 0) + { + if (argc < 3) + WEECHAT_COMMAND_ERROR; + if (!fset_option_import (argv_eol[2])) + WEECHAT_COMMAND_ERROR; + return WEECHAT_RC_OK; + } + WEECHAT_COMMAND_ERROR; } else @@ -639,6 +648,7 @@ fset_command_init () " || -mark" " || -format" " || -export [-help|-nohelp] " + " || -import " " || "), WEECHAT_CMD_ARGS_DESC( N_("raw[-bar]: add the help bar"), @@ -666,6 +676,8 @@ fset_command_init () N_("raw[-format]: switch to the next available format"), N_("raw[-export]: export the options and values displayed in a file " "(each line has format: \"/set name value\" or \"/unset name\")"), + N_("raw[-import]: import the options from a file " + "(all lines containing commands are are executed)"), N_("raw[-help]: force writing of help on options in exported file " "(see /help fset.look.export_help_default)"), N_("raw[-nohelp]: do not write help on options in exported file " @@ -784,6 +796,7 @@ fset_command_init () " || -mark" " || -format" " || -export -help|-nohelp|%(filename) %(filename)" + " || -import %(filename)" " || *|c:|f:|s:|d|d:|d=|d==|=|==|%(fset_options)", &fset_command_fset, NULL, NULL); weechat_hook_command_run ("/set", &fset_command_run_set_cb, NULL, NULL); diff --git a/src/plugins/fset/fset-option.c b/src/plugins/fset/fset-option.c index 2ef8c219d..a783d2f0e 100644 --- a/src/plugins/fset/fset-option.c +++ b/src/plugins/fset/fset-option.c @@ -1470,6 +1470,63 @@ fset_option_export (const char *filename, int with_help) return 1; } +/* + * Imports options from a file: all lines starting with "/" are executed. + * + * Returns: + * 1: export OK + * 0: error + */ + +int +fset_option_import (const char *filename) +{ + char *filename2, line[4096], *ptr_line; + FILE *file; + int length; + + filename2 = weechat_string_expand_home (filename); + if (!filename2) + return 0; + + file = fopen (filename2, "r"); + if (!file) + { + free (filename2); + return 0; + } + + while (!feof (file)) + { + ptr_line = fgets (line, sizeof (line) - 1, file); + if (!ptr_line) + continue; + /* ignore comments */ + if (ptr_line[0] == '#') + continue; + /* execute command (if it's a valid command) */ + if (!weechat_string_input_for_buffer (ptr_line)) + { + /* remove trailing '\r' and '\n' */ + length = strlen (line) - 1; + while ((length >= 0) + && ((line[length] == '\n') + || (line[length] == '\r'))) + { + line[length] = '\0'; + length--; + } + weechat_command (NULL, ptr_line); + } + } + + fclose (file); + + free (filename2); + + return 1; +} + /* * Refreshes the fset buffer after the change of an option. */ diff --git a/src/plugins/fset/fset-option.h b/src/plugins/fset/fset-option.h index 82be59c73..b8266274d 100644 --- a/src/plugins/fset/fset-option.h +++ b/src/plugins/fset/fset-option.h @@ -121,6 +121,7 @@ extern void fset_option_mark_options_matching_filter (const char *filter, int mark); extern void fset_option_unmark_all (); extern int fset_option_export (const char *filename, int with_help); +extern int fset_option_import (const char *filename); extern int fset_option_config_cb (const void *pointer, void *data, const char *option,