diff --git a/daemon/x52d_command.c b/daemon/x52d_command.c index ad5172c..d372cb2 100644 --- a/daemon/x52d_command.c +++ b/daemon/x52d_command.c @@ -273,6 +273,7 @@ static void cmd_config(char *buffer, int *buflen, int argc, char **argv) ERR_fmt("Error %d setting '%s.%s'='%s': %s", rc, argv[2], argv[3], argv[4], strerror(rc)); } else { + x52d_config_apply_immediate(argv[2], argv[3]); OK("config", "set", argv[2], argv[3], argv[4]); } } else { @@ -295,16 +296,6 @@ static void cmd_config(char *buffer, int *buflen, int argc, char **argv) return; } - MATCH(1, "apply") { - if (argc == 2) { - x52d_config_apply(); - OK("config", "apply"); - } else { - ERR_fmt("Unexpected arguments for 'config apply' command; got %d, expected 2", argc); - } - return; - } - ERR_fmt("Unknown subcommand '%s' for 'config' command", argv[1]); } diff --git a/daemon/x52d_config.c b/daemon/x52d_config.c index e3ec487..a5bcff7 100644 --- a/daemon/x52d_config.c +++ b/daemon/x52d_config.c @@ -89,6 +89,20 @@ void x52d_cfg_set_Profiles_Directory(char* param) { (void)param; } void x52d_cfg_set_Profiles_ClutchEnabled(bool param) { (void)param; } void x52d_cfg_set_Profiles_ClutchLatched(bool param) { (void)param; } +void x52d_config_apply_immediate(const char *section, const char *key) +{ +#define CFG(c_sec, c_key, name, parser, def) \ + if (!strcasecmp(section, #c_sec) && !strcasecmp(key, #c_key)) { \ + PINELOG_TRACE("Invoking " #c_sec "." #c_key " callback"); \ + x52d_cfg_set_ ## c_sec ## _ ## c_key(x52d_config . name); \ + } else + +#include "x52d_config.def" + // Dummy to capture the trailing else + // Wrap it in braces in case tracing has been disabled + { PINELOG_TRACE("Ignoring apply_immediate(%s.%s)", section, key); } +} + void x52d_config_apply(void) { #define CFG(section, key, name, parser, def) \ diff --git a/daemon/x52d_config.h b/daemon/x52d_config.h index 1f60ab6..bd41c77 100644 --- a/daemon/x52d_config.h +++ b/daemon/x52d_config.h @@ -89,6 +89,7 @@ int x52d_config_apply_overrides(struct x52d_config *cfg); void x52d_config_clear_overrides(void); void x52d_config_load(const char *cfg_file); +void x52d_config_apply_immediate(const char *section, const char *key); void x52d_config_apply(void); int x52d_config_save_file(struct x52d_config *cfg, const char *cfg_file); diff --git a/po/libx52.pot b/po/libx52.pot index 78759c7..55d4604 100644 --- a/po/libx52.pot +++ b/po/libx52.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: libx52 0.2.3\n" "Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n" -"POT-Creation-Date: 2022-02-03 11:11-0800\n" +"POT-Creation-Date: 2022-02-11 13:23-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -678,12 +678,12 @@ msgstr "" msgid "Timed out when polling for command" msgstr "" -#: daemon/x52d_command.c:499 +#: daemon/x52d_command.c:490 #, c-format msgid "Error reading from client %d: %s" msgstr "" -#: daemon/x52d_command.c:510 +#: daemon/x52d_command.c:501 #, c-format msgid "Short write to client %d; expected %d bytes, wrote %d bytes" msgstr "" diff --git a/po/xx_PL.po b/po/xx_PL.po index 374d70f..03da2e6 100644 --- a/po/xx_PL.po +++ b/po/xx_PL.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: libx52 0.2.3\n" "Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n" -"POT-Creation-Date: 2022-02-03 11:11-0800\n" +"POT-Creation-Date: 2022-02-11 13:23-0800\n" "PO-Revision-Date: 2021-11-04 15:35-0700\n" "Last-Translator: Nirenjan Krishnan \n" "Language-Team: Dummy Language for testing i18n\n" @@ -729,12 +729,12 @@ msgstr "Erroray enwhay ollingpay orfay ommandcay: %s" msgid "Timed out when polling for command" msgstr "Imedtay outay enwhay ollingpay orfay ommandcay" -#: daemon/x52d_command.c:499 +#: daemon/x52d_command.c:490 #, c-format msgid "Error reading from client %d: %s" msgstr "Erroray eadingray omfray ientclay %d: %s" -#: daemon/x52d_command.c:510 +#: daemon/x52d_command.c:501 #, c-format msgid "Short write to client %d; expected %d bytes, wrote %d bytes" msgstr ""