From 41789d70d16a3921c68132187f08a1b8fa058cf1 Mon Sep 17 00:00:00 2001 From: David Steele Date: Tue, 20 Oct 2020 11:24:26 -0400 Subject: [PATCH] Remove cfgOptionId() and replace it with cfgParseOption(). cfgOptionId() did not recognize deprecated options which made the help command throw errors when they were specified on the command line. cfgParseOption() will correctly identify deprecated options. cfgParseOption() can also be used in cfgParse() to reduce code duplication when parsing info out of the option value returned by optionFind(). Finally, code the option key index separately in parse.auto.c. For now they are simply added back together but future code will need them separated. --- .../lib/pgBackRestBuild/Config/BuildParse.pm | 2 +- src/command/help/help.c | 25 +- src/config/config.c | 19 - src/config/config.h | 3 - src/config/parse.auto.c | 774 +++++++++--------- src/config/parse.c | 168 ++-- src/config/parse.h | 12 + src/config/protocol.c | 8 +- test/src/module/command/helpTest.c | 11 +- test/src/module/config/configTest.c | 3 - test/src/module/config/parseTest.c | 100 +-- 11 files changed, 578 insertions(+), 547 deletions(-) diff --git a/build/lib/pgBackRestBuild/Config/BuildParse.pm b/build/lib/pgBackRestBuild/Config/BuildParse.pm index dd8c7b989..17222171d 100644 --- a/build/lib/pgBackRestBuild/Config/BuildParse.pm +++ b/build/lib/pgBackRestBuild/Config/BuildParse.pm @@ -143,7 +143,7 @@ sub buildConfigParse } my $strOptionVal = - ($iOptionIdx > 1 ? "(" : '') . $strOptionEnum . ($iOptionIdx > 1 ? " + " . ($iOptionIdx - 1) . ')' : ''); + ($rhOption->{&CFGDEF_GROUP} ? "(" . ($iOptionIdx - 1) . " << PARSE_KEY_IDX_SHIFT) | " : '') . $strOptionEnum; # Add option $strBuildSource .= diff --git a/src/command/help/help.c b/src/command/help/help.c index cda5ca16e..1f82c9c89 100644 --- a/src/command/help/help.c +++ b/src/command/help/help.c @@ -12,6 +12,7 @@ Help Command #include "common/memContext.h" #include "config/config.h" #include "config/define.h" +#include "config/parse.h" #include "version.h" /*********************************************************************************************************************************** @@ -303,19 +304,21 @@ helpRender(void) THROW(ParamInvalidError, "only one option allowed for option help"); // Ensure the option is valid - const char *optionName = strZ(strLstGet(cfgCommandParam(), 0)); - ConfigOption optionId = cfgOptionId(optionName); + const String *optionName = strLstGet(cfgCommandParam(), 0); + CfgParseOptionResult option = cfgParseOption(optionName); - if (cfgOptionId(optionName) == -1) + if (!option.found) { - if (cfgDefOptionId(optionName) != -1) - optionId = cfgOptionIdFromDefId(cfgDefOptionId(optionName), 0); + int optionId = cfgDefOptionId(strZ(optionName)); + + if (optionId == -1) + THROW_FMT(OptionInvalidError, "option '%s' is not valid for command '%s'", strZ(optionName), commandName); else - THROW_FMT(OptionInvalidError, "option '%s' is not valid for command '%s'", optionName, commandName); + option.id = cfgOptionIdFromDefId((unsigned int)optionId, 0); } // Output option summary and description - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId); + ConfigDefineOption optionDefId = cfgOptionDefIdFromId(option.id); strCatFmt( result, @@ -324,16 +327,16 @@ helpRender(void) "%s\n" "\n" "%s\n", - optionName, + cfgDefOptionName(optionDefId), strZ(helpRenderText(STR(cfgDefOptionHelpSummary(commandId, optionDefId)), 0, true, CONSOLE_WIDTH)), strZ(helpRenderText(STR(cfgDefOptionHelpDescription(commandId, optionDefId)), 0, true, CONSOLE_WIDTH))); // Ouput current and default values if they exist - const String *defaultValue = helpRenderValue(cfgOptionDefault(optionId)); + const String *defaultValue = helpRenderValue(cfgOptionDefault(option.id)); const String *value = NULL; - if (cfgOptionSource(optionId) != cfgSourceDefault) - value = helpRenderValue(cfgOption(optionId)); + if (cfgOptionSource(option.id) != cfgSourceDefault) + value = helpRenderValue(cfgOption(option.id)); if (value != NULL || defaultValue != NULL) { diff --git a/src/config/config.c b/src/config/config.c index 349b551d0..6ff8c5c76 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -713,25 +713,6 @@ cfgOptionIndex(ConfigOption optionId) FUNCTION_TEST_RETURN(configOptionData[optionId].index); } -/**********************************************************************************************************************************/ -int -cfgOptionId(const char *optionName) -{ - FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(STRINGZ, optionName); - FUNCTION_TEST_END(); - - ASSERT(optionName != NULL); - - int result = -1; - - for (ConfigOption optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++) - if (strcmp(optionName, configOptionData[optionId].name) == 0) - result = optionId; - - FUNCTION_TEST_RETURN(result); -} - /**********************************************************************************************************************************/ ConfigOption cfgOptionIdFromDefId(ConfigDefineOption optionDefId, unsigned int index) diff --git a/src/config/config.h b/src/config/config.h index b2f46d25f..0662cb070 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -193,9 +193,6 @@ ConfigDefineOption cfgOptionDefIdFromId(ConfigOption optionId); // Parse a host option and extract the host and port (if it exists) String *cfgOptionHostPort(ConfigOption optionId, unsigned int *port); -// Get option id by name -int cfgOptionId(const char *optionName); - // Get the id for this option define ConfigOption cfgOptionIdFromDefId(ConfigDefineOption optionDefId, unsigned int index); diff --git a/src/config/parse.auto.c b/src/config/parse.auto.c index 634a7e881..bbc35e9e1 100644 --- a/src/config/parse.auto.c +++ b/src/config/parse.auto.c @@ -535,119 +535,119 @@ static const struct option optionList[] = { .name = "pg1-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgHost, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "reset-pg1-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgHost, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "db-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgHost, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "db1-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgHost, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "pg2-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHost + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "reset-pg2-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHost + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "db2-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHost + 1), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "pg3-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHost + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "reset-pg3-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHost + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "db3-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHost + 2), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "pg4-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHost + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "reset-pg4-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHost + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "db4-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHost + 3), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "pg5-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHost + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "reset-pg5-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHost + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "db5-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHost + 4), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "pg6-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHost + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "reset-pg6-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHost + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "db6-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHost + 5), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "pg7-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHost + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "reset-pg7-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHost + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "db7-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHost + 6), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "pg8-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHost + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "reset-pg8-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHost + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, { .name = "db8-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHost + 7), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHost, }, // pg-host-cmd option and deprecations @@ -655,119 +655,119 @@ static const struct option optionList[] = { .name = "pg1-host-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgHostCmd, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "reset-pg1-host-cmd", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgHostCmd, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "db-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgHostCmd, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "db1-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgHostCmd, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "pg2-host-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostCmd + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "reset-pg2-host-cmd", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostCmd + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "db2-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostCmd + 1), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "pg3-host-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostCmd + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "reset-pg3-host-cmd", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostCmd + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "db3-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostCmd + 2), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "pg4-host-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostCmd + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "reset-pg4-host-cmd", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostCmd + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "db4-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostCmd + 3), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "pg5-host-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostCmd + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "reset-pg5-host-cmd", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostCmd + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "db5-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostCmd + 4), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "pg6-host-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostCmd + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "reset-pg6-host-cmd", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostCmd + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "db6-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostCmd + 5), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "pg7-host-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostCmd + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "reset-pg7-host-cmd", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostCmd + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "db7-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostCmd + 6), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "pg8-host-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostCmd + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "reset-pg8-host-cmd", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostCmd + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, { .name = "db8-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostCmd + 7), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostCmd, }, // pg-host-config option and deprecations @@ -775,119 +775,119 @@ static const struct option optionList[] = { .name = "pg1-host-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgHostConfig, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "reset-pg1-host-config", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgHostConfig, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "db-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgHostConfig, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "db1-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgHostConfig, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "pg2-host-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfig + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "reset-pg2-host-config", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfig + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "db2-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostConfig + 1), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "pg3-host-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfig + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "reset-pg3-host-config", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfig + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "db3-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostConfig + 2), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "pg4-host-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfig + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "reset-pg4-host-config", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfig + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "db4-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostConfig + 3), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "pg5-host-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfig + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "reset-pg5-host-config", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfig + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "db5-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostConfig + 4), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "pg6-host-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfig + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "reset-pg6-host-config", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfig + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "db6-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostConfig + 5), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "pg7-host-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfig + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "reset-pg7-host-config", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfig + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "db7-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostConfig + 6), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "pg8-host-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfig + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "reset-pg8-host-config", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfig + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, { .name = "db8-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostConfig + 7), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfig, }, // pg-host-config-include-path option @@ -895,74 +895,74 @@ static const struct option optionList[] = { .name = "pg1-host-config-include-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgHostConfigIncludePath, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "reset-pg1-host-config-include-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgHostConfigIncludePath, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "pg2-host-config-include-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigIncludePath + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "reset-pg2-host-config-include-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigIncludePath + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "pg3-host-config-include-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigIncludePath + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "reset-pg3-host-config-include-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigIncludePath + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "pg4-host-config-include-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigIncludePath + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "reset-pg4-host-config-include-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigIncludePath + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "pg5-host-config-include-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigIncludePath + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "reset-pg5-host-config-include-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigIncludePath + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "pg6-host-config-include-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigIncludePath + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "reset-pg6-host-config-include-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigIncludePath + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "pg7-host-config-include-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigIncludePath + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "reset-pg7-host-config-include-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigIncludePath + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "pg8-host-config-include-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigIncludePath + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, { .name = "reset-pg8-host-config-include-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigIncludePath + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigIncludePath, }, // pg-host-config-path option @@ -970,74 +970,74 @@ static const struct option optionList[] = { .name = "pg1-host-config-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgHostConfigPath, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "reset-pg1-host-config-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgHostConfigPath, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "pg2-host-config-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigPath + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "reset-pg2-host-config-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigPath + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "pg3-host-config-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigPath + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "reset-pg3-host-config-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigPath + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "pg4-host-config-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigPath + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "reset-pg4-host-config-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigPath + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "pg5-host-config-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigPath + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "reset-pg5-host-config-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigPath + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "pg6-host-config-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigPath + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "reset-pg6-host-config-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigPath + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "pg7-host-config-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigPath + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "reset-pg7-host-config-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigPath + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "pg8-host-config-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostConfigPath + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, { .name = "reset-pg8-host-config-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostConfigPath + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostConfigPath, }, // pg-host-port option and deprecations @@ -1045,119 +1045,119 @@ static const struct option optionList[] = { .name = "pg1-host-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgHostPort, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "reset-pg1-host-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgHostPort, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "db-ssh-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgHostPort, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "db1-ssh-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgHostPort, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "pg2-host-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostPort + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "reset-pg2-host-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostPort + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "db2-ssh-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostPort + 1), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "pg3-host-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostPort + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "reset-pg3-host-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostPort + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "db3-ssh-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostPort + 2), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "pg4-host-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostPort + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "reset-pg4-host-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostPort + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "db4-ssh-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostPort + 3), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "pg5-host-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostPort + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "reset-pg5-host-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostPort + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "db5-ssh-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostPort + 4), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "pg6-host-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostPort + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "reset-pg6-host-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostPort + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "db6-ssh-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostPort + 5), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "pg7-host-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostPort + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "reset-pg7-host-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostPort + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "db7-ssh-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostPort + 6), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "pg8-host-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostPort + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "reset-pg8-host-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostPort + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, { .name = "db8-ssh-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostPort + 7), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostPort, }, // pg-host-user option and deprecations @@ -1165,218 +1165,218 @@ static const struct option optionList[] = { .name = "pg1-host-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgHostUser, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "reset-pg1-host-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgHostUser, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "db-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgHostUser, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "db1-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgHostUser, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "pg2-host-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostUser + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "reset-pg2-host-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostUser + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "db2-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostUser + 1), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "pg3-host-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostUser + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "reset-pg3-host-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostUser + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "db3-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostUser + 2), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "pg4-host-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostUser + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "reset-pg4-host-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostUser + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "db4-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostUser + 3), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "pg5-host-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostUser + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "reset-pg5-host-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostUser + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "db5-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostUser + 4), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "pg6-host-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostUser + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "reset-pg6-host-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostUser + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "db6-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostUser + 5), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "pg7-host-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostUser + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "reset-pg7-host-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostUser + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "db7-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostUser + 6), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "pg8-host-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgHostUser + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "reset-pg8-host-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgHostUser + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, { .name = "db8-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgHostUser + 7), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgHostUser, }, // pg-local option // ----------------------------------------------------------------------------------------------------------------------------- { .name = "pg1-local", - .val = PARSE_OPTION_FLAG | cfgOptPgLocal, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "no-pg1-local", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | cfgOptPgLocal, + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "reset-pg1-local", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgLocal, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "pg2-local", - .val = PARSE_OPTION_FLAG | (cfgOptPgLocal + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "no-pg2-local", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (cfgOptPgLocal + 1), + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "reset-pg2-local", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgLocal + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "pg3-local", - .val = PARSE_OPTION_FLAG | (cfgOptPgLocal + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "no-pg3-local", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (cfgOptPgLocal + 2), + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "reset-pg3-local", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgLocal + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "pg4-local", - .val = PARSE_OPTION_FLAG | (cfgOptPgLocal + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "no-pg4-local", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (cfgOptPgLocal + 3), + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "reset-pg4-local", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgLocal + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "pg5-local", - .val = PARSE_OPTION_FLAG | (cfgOptPgLocal + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "no-pg5-local", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (cfgOptPgLocal + 4), + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "reset-pg5-local", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgLocal + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "pg6-local", - .val = PARSE_OPTION_FLAG | (cfgOptPgLocal + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "no-pg6-local", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (cfgOptPgLocal + 5), + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "reset-pg6-local", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgLocal + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "pg7-local", - .val = PARSE_OPTION_FLAG | (cfgOptPgLocal + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "no-pg7-local", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (cfgOptPgLocal + 6), + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "reset-pg7-local", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgLocal + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "pg8-local", - .val = PARSE_OPTION_FLAG | (cfgOptPgLocal + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "no-pg8-local", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (cfgOptPgLocal + 7), + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, { .name = "reset-pg8-local", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgLocal + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgLocal, }, // pg-path option and deprecations @@ -1384,119 +1384,119 @@ static const struct option optionList[] = { .name = "pg1-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgPath, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "reset-pg1-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgPath, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "db-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgPath, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "db1-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgPath, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "pg2-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPath + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "reset-pg2-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPath + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "db2-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPath + 1), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "pg3-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPath + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "reset-pg3-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPath + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "db3-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPath + 2), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "pg4-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPath + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "reset-pg4-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPath + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "db4-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPath + 3), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "pg5-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPath + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "reset-pg5-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPath + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "db5-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPath + 4), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "pg6-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPath + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "reset-pg6-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPath + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "db6-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPath + 5), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "pg7-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPath + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "reset-pg7-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPath + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "db7-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPath + 6), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "pg8-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPath + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "reset-pg8-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPath + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, { .name = "db8-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPath + 7), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPath, }, // pg-port option and deprecations @@ -1504,119 +1504,119 @@ static const struct option optionList[] = { .name = "pg1-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgPort, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "reset-pg1-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgPort, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "db-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgPort, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "db1-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgPort, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "pg2-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPort + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "reset-pg2-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPort + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "db2-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPort + 1), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "pg3-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPort + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "reset-pg3-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPort + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "db3-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPort + 2), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "pg4-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPort + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "reset-pg4-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPort + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "db4-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPort + 3), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "pg5-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPort + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "reset-pg5-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPort + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "db5-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPort + 4), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "pg6-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPort + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "reset-pg6-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPort + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "db6-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPort + 5), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "pg7-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPort + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "reset-pg7-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPort + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "db7-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPort + 6), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "pg8-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgPort + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "reset-pg8-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgPort + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, { .name = "db8-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgPort + 7), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgPort, }, // pg-socket-path option and deprecations @@ -1624,119 +1624,119 @@ static const struct option optionList[] = { .name = "pg1-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgSocketPath, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "reset-pg1-socket-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgSocketPath, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "db-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgSocketPath, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "db1-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptPgSocketPath, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "pg2-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgSocketPath + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "reset-pg2-socket-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgSocketPath + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "db2-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgSocketPath + 1), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "pg3-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgSocketPath + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "reset-pg3-socket-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgSocketPath + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "db3-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgSocketPath + 2), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "pg4-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgSocketPath + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "reset-pg4-socket-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgSocketPath + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "db4-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgSocketPath + 3), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "pg5-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgSocketPath + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "reset-pg5-socket-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgSocketPath + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "db5-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgSocketPath + 4), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "pg6-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgSocketPath + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "reset-pg6-socket-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgSocketPath + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "db6-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgSocketPath + 5), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "pg7-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgSocketPath + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "reset-pg7-socket-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgSocketPath + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "db7-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgSocketPath + 6), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "pg8-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgSocketPath + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "reset-pg8-socket-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgSocketPath + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, { .name = "db8-socket-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (cfgOptPgSocketPath + 7), + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgSocketPath, }, // pg-user option @@ -1744,74 +1744,74 @@ static const struct option optionList[] = { .name = "pg1-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptPgUser, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "reset-pg1-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPgUser, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "pg2-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgUser + 1), + .val = PARSE_OPTION_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "reset-pg2-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgUser + 1), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (1 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "pg3-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgUser + 2), + .val = PARSE_OPTION_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "reset-pg3-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgUser + 2), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (2 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "pg4-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgUser + 3), + .val = PARSE_OPTION_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "reset-pg4-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgUser + 3), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (3 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "pg5-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgUser + 4), + .val = PARSE_OPTION_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "reset-pg5-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgUser + 4), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (4 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "pg6-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgUser + 5), + .val = PARSE_OPTION_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "reset-pg6-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgUser + 5), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (5 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "pg7-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgUser + 6), + .val = PARSE_OPTION_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "reset-pg7-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgUser + 6), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (6 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "pg8-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | (cfgOptPgUser + 7), + .val = PARSE_OPTION_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, { .name = "reset-pg8-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (cfgOptPgUser + 7), + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (7 << PARSE_KEY_IDX_SHIFT) | cfgOptPgUser, }, // process option @@ -1885,11 +1885,11 @@ static const struct option optionList[] = { .name = "repo1-azure-account", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoAzureAccount, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureAccount, }, { .name = "reset-repo1-azure-account", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoAzureAccount, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureAccount, }, // repo-azure-ca-file option @@ -1897,11 +1897,11 @@ static const struct option optionList[] = { .name = "repo1-azure-ca-file", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoAzureCaFile, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureCaFile, }, { .name = "reset-repo1-azure-ca-file", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoAzureCaFile, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureCaFile, }, // repo-azure-ca-path option @@ -1909,11 +1909,11 @@ static const struct option optionList[] = { .name = "repo1-azure-ca-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoAzureCaPath, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureCaPath, }, { .name = "reset-repo1-azure-ca-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoAzureCaPath, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureCaPath, }, // repo-azure-container option @@ -1921,11 +1921,11 @@ static const struct option optionList[] = { .name = "repo1-azure-container", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoAzureContainer, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureContainer, }, { .name = "reset-repo1-azure-container", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoAzureContainer, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureContainer, }, // repo-azure-endpoint option @@ -1933,11 +1933,11 @@ static const struct option optionList[] = { .name = "repo1-azure-endpoint", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoAzureEndpoint, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureEndpoint, }, { .name = "reset-repo1-azure-endpoint", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoAzureEndpoint, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureEndpoint, }, // repo-azure-host option @@ -1945,11 +1945,11 @@ static const struct option optionList[] = { .name = "repo1-azure-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoAzureHost, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureHost, }, { .name = "reset-repo1-azure-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoAzureHost, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureHost, }, // repo-azure-key option @@ -1957,11 +1957,11 @@ static const struct option optionList[] = { .name = "repo1-azure-key", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoAzureKey, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureKey, }, { .name = "reset-repo1-azure-key", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoAzureKey, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureKey, }, // repo-azure-key-type option @@ -1969,11 +1969,11 @@ static const struct option optionList[] = { .name = "repo1-azure-key-type", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoAzureKeyType, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureKeyType, }, { .name = "reset-repo1-azure-key-type", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoAzureKeyType, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureKeyType, }, // repo-azure-port option @@ -1981,26 +1981,26 @@ static const struct option optionList[] = { .name = "repo1-azure-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoAzurePort, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzurePort, }, { .name = "reset-repo1-azure-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoAzurePort, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzurePort, }, // repo-azure-verify-tls option // ----------------------------------------------------------------------------------------------------------------------------- { .name = "repo1-azure-verify-tls", - .val = PARSE_OPTION_FLAG | cfgOptRepoAzureVerifyTls, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureVerifyTls, }, { .name = "no-repo1-azure-verify-tls", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoAzureVerifyTls, + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureVerifyTls, }, { .name = "reset-repo1-azure-verify-tls", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoAzureVerifyTls, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoAzureVerifyTls, }, // repo-cipher-pass option and deprecations @@ -2008,16 +2008,16 @@ static const struct option optionList[] = { .name = "repo1-cipher-pass", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoCipherPass, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoCipherPass, }, { .name = "reset-repo1-cipher-pass", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoCipherPass, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoCipherPass, }, { .name = "repo-cipher-pass", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoCipherPass, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoCipherPass, }, // repo-cipher-type option and deprecations @@ -2025,39 +2025,39 @@ static const struct option optionList[] = { .name = "repo1-cipher-type", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoCipherType, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoCipherType, }, { .name = "reset-repo1-cipher-type", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoCipherType, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoCipherType, }, { .name = "repo-cipher-type", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoCipherType, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoCipherType, }, // repo-hardlink option and deprecations // ----------------------------------------------------------------------------------------------------------------------------- { .name = "repo1-hardlink", - .val = PARSE_OPTION_FLAG | cfgOptRepoHardlink, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHardlink, }, { .name = "no-repo1-hardlink", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoHardlink, + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHardlink, }, { .name = "reset-repo1-hardlink", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoHardlink, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHardlink, }, { .name = "hardlink", - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoHardlink, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHardlink, }, { .name = "no-hardlink", - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoHardlink, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHardlink, }, // repo-host option and deprecations @@ -2065,16 +2065,16 @@ static const struct option optionList[] = { .name = "repo1-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoHost, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHost, }, { .name = "reset-repo1-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoHost, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHost, }, { .name = "backup-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoHost, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHost, }, // repo-host-cmd option and deprecations @@ -2082,16 +2082,16 @@ static const struct option optionList[] = { .name = "repo1-host-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoHostCmd, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostCmd, }, { .name = "reset-repo1-host-cmd", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoHostCmd, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostCmd, }, { .name = "backup-cmd", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoHostCmd, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostCmd, }, // repo-host-config option and deprecations @@ -2099,16 +2099,16 @@ static const struct option optionList[] = { .name = "repo1-host-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoHostConfig, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostConfig, }, { .name = "reset-repo1-host-config", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoHostConfig, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostConfig, }, { .name = "backup-config", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoHostConfig, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostConfig, }, // repo-host-config-include-path option @@ -2116,11 +2116,11 @@ static const struct option optionList[] = { .name = "repo1-host-config-include-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoHostConfigIncludePath, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostConfigIncludePath, }, { .name = "reset-repo1-host-config-include-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoHostConfigIncludePath, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostConfigIncludePath, }, // repo-host-config-path option @@ -2128,11 +2128,11 @@ static const struct option optionList[] = { .name = "repo1-host-config-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoHostConfigPath, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostConfigPath, }, { .name = "reset-repo1-host-config-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoHostConfigPath, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostConfigPath, }, // repo-host-port option and deprecations @@ -2140,16 +2140,16 @@ static const struct option optionList[] = { .name = "repo1-host-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoHostPort, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostPort, }, { .name = "reset-repo1-host-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoHostPort, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostPort, }, { .name = "backup-ssh-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoHostPort, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostPort, }, // repo-host-user option and deprecations @@ -2157,31 +2157,31 @@ static const struct option optionList[] = { .name = "repo1-host-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoHostUser, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostUser, }, { .name = "reset-repo1-host-user", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoHostUser, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostUser, }, { .name = "backup-user", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoHostUser, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoHostUser, }, // repo-local option // ----------------------------------------------------------------------------------------------------------------------------- { .name = "repo1-local", - .val = PARSE_OPTION_FLAG | cfgOptRepoLocal, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoLocal, }, { .name = "no-repo1-local", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoLocal, + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoLocal, }, { .name = "reset-repo1-local", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoLocal, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoLocal, }, // repo-path option and deprecations @@ -2189,16 +2189,16 @@ static const struct option optionList[] = { .name = "repo1-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoPath, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoPath, }, { .name = "reset-repo1-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoPath, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoPath, }, { .name = "repo-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoPath, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoPath, }, // repo-retention-archive option and deprecations @@ -2206,16 +2206,16 @@ static const struct option optionList[] = { .name = "repo1-retention-archive", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoRetentionArchive, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionArchive, }, { .name = "reset-repo1-retention-archive", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoRetentionArchive, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionArchive, }, { .name = "retention-archive", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoRetentionArchive, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionArchive, }, // repo-retention-archive-type option and deprecations @@ -2223,16 +2223,16 @@ static const struct option optionList[] = { .name = "repo1-retention-archive-type", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoRetentionArchiveType, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionArchiveType, }, { .name = "reset-repo1-retention-archive-type", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoRetentionArchiveType, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionArchiveType, }, { .name = "retention-archive-type", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoRetentionArchiveType, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionArchiveType, }, // repo-retention-diff option and deprecations @@ -2240,16 +2240,16 @@ static const struct option optionList[] = { .name = "repo1-retention-diff", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoRetentionDiff, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionDiff, }, { .name = "reset-repo1-retention-diff", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoRetentionDiff, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionDiff, }, { .name = "retention-diff", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoRetentionDiff, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionDiff, }, // repo-retention-full option and deprecations @@ -2257,16 +2257,16 @@ static const struct option optionList[] = { .name = "repo1-retention-full", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoRetentionFull, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionFull, }, { .name = "reset-repo1-retention-full", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoRetentionFull, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionFull, }, { .name = "retention-full", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoRetentionFull, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionFull, }, // repo-retention-full-type option @@ -2274,11 +2274,11 @@ static const struct option optionList[] = { .name = "repo1-retention-full-type", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoRetentionFullType, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionFullType, }, { .name = "reset-repo1-retention-full-type", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoRetentionFullType, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoRetentionFullType, }, // repo-s3-bucket option and deprecations @@ -2286,16 +2286,16 @@ static const struct option optionList[] = { .name = "repo1-s3-bucket", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3Bucket, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Bucket, }, { .name = "reset-repo1-s3-bucket", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3Bucket, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Bucket, }, { .name = "repo-s3-bucket", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoS3Bucket, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Bucket, }, // repo-s3-ca-file option and deprecations @@ -2303,16 +2303,16 @@ static const struct option optionList[] = { .name = "repo1-s3-ca-file", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3CaFile, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3CaFile, }, { .name = "reset-repo1-s3-ca-file", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3CaFile, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3CaFile, }, { .name = "repo-s3-ca-file", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoS3CaFile, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3CaFile, }, // repo-s3-ca-path option and deprecations @@ -2320,16 +2320,16 @@ static const struct option optionList[] = { .name = "repo1-s3-ca-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3CaPath, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3CaPath, }, { .name = "reset-repo1-s3-ca-path", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3CaPath, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3CaPath, }, { .name = "repo-s3-ca-path", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoS3CaPath, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3CaPath, }, // repo-s3-endpoint option and deprecations @@ -2337,16 +2337,16 @@ static const struct option optionList[] = { .name = "repo1-s3-endpoint", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3Endpoint, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Endpoint, }, { .name = "reset-repo1-s3-endpoint", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3Endpoint, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Endpoint, }, { .name = "repo-s3-endpoint", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoS3Endpoint, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Endpoint, }, // repo-s3-host option and deprecations @@ -2354,16 +2354,16 @@ static const struct option optionList[] = { .name = "repo1-s3-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3Host, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Host, }, { .name = "reset-repo1-s3-host", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3Host, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Host, }, { .name = "repo-s3-host", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoS3Host, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Host, }, // repo-s3-key option and deprecations @@ -2371,16 +2371,16 @@ static const struct option optionList[] = { .name = "repo1-s3-key", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3Key, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Key, }, { .name = "reset-repo1-s3-key", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3Key, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Key, }, { .name = "repo-s3-key", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoS3Key, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Key, }, // repo-s3-key-secret option and deprecations @@ -2388,16 +2388,16 @@ static const struct option optionList[] = { .name = "repo1-s3-key-secret", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3KeySecret, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3KeySecret, }, { .name = "reset-repo1-s3-key-secret", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3KeySecret, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3KeySecret, }, { .name = "repo-s3-key-secret", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoS3KeySecret, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3KeySecret, }, // repo-s3-key-type option @@ -2405,11 +2405,11 @@ static const struct option optionList[] = { .name = "repo1-s3-key-type", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3KeyType, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3KeyType, }, { .name = "reset-repo1-s3-key-type", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3KeyType, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3KeyType, }, // repo-s3-port option @@ -2417,11 +2417,11 @@ static const struct option optionList[] = { .name = "repo1-s3-port", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3Port, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Port, }, { .name = "reset-repo1-s3-port", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3Port, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Port, }, // repo-s3-region option and deprecations @@ -2429,16 +2429,16 @@ static const struct option optionList[] = { .name = "repo1-s3-region", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3Region, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Region, }, { .name = "reset-repo1-s3-region", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3Region, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Region, }, { .name = "repo-s3-region", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoS3Region, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Region, }, // repo-s3-role option @@ -2446,11 +2446,11 @@ static const struct option optionList[] = { .name = "repo1-s3-role", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3Role, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Role, }, { .name = "reset-repo1-s3-role", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3Role, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Role, }, // repo-s3-token option @@ -2458,11 +2458,11 @@ static const struct option optionList[] = { .name = "repo1-s3-token", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3Token, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Token, }, { .name = "reset-repo1-s3-token", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3Token, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3Token, }, // repo-s3-uri-style option @@ -2470,42 +2470,42 @@ static const struct option optionList[] = { .name = "repo1-s3-uri-style", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoS3UriStyle, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3UriStyle, }, { .name = "reset-repo1-s3-uri-style", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3UriStyle, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3UriStyle, }, // repo-s3-verify-tls option and deprecations // ----------------------------------------------------------------------------------------------------------------------------- { .name = "repo1-s3-verify-tls", - .val = PARSE_OPTION_FLAG | cfgOptRepoS3VerifyTls, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3VerifyTls, }, { .name = "no-repo1-s3-verify-tls", - .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoS3VerifyTls, + .val = PARSE_OPTION_FLAG | PARSE_NEGATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3VerifyTls, }, { .name = "reset-repo1-s3-verify-tls", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoS3VerifyTls, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3VerifyTls, }, { .name = "repo-s3-verify-ssl", - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoS3VerifyTls, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3VerifyTls, }, { .name = "no-repo-s3-verify-ssl", - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoS3VerifyTls, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3VerifyTls, }, { .name = "repo1-s3-verify-ssl", - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoS3VerifyTls, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3VerifyTls, }, { .name = "no-repo1-s3-verify-ssl", - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoS3VerifyTls, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoS3VerifyTls, }, // repo-type option and deprecations @@ -2513,16 +2513,16 @@ static const struct option optionList[] = { .name = "repo1-type", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | cfgOptRepoType, + .val = PARSE_OPTION_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoType, }, { .name = "reset-repo1-type", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepoType, + .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoType, }, { .name = "repo-type", .has_arg = required_argument, - .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | cfgOptRepoType, + .val = PARSE_OPTION_FLAG | PARSE_DEPRECATE_FLAG | (0 << PARSE_KEY_IDX_SHIFT) | cfgOptRepoType, }, // resume option diff --git a/src/config/parse.c b/src/config/parse.c index 2b7023c8e..cd03ebf0b 100644 --- a/src/config/parse.c +++ b/src/config/parse.c @@ -61,8 +61,12 @@ Parse option flags // Indicate that option name has been deprecated and will be removed in a future release #define PARSE_DEPRECATE_FLAG (1 << 27) -// Mask to exclude all flags and get at the actual option id (only 12 bits allowed for option id, the rest reserved for flags) -#define PARSE_OPTION_MASK 0xFFF +// Mask for option id (must be 0-255) +#define PARSE_OPTION_MASK 0xFF + +// Shift and mask for option key index (must be 0-255) +#define PARSE_KEY_IDX_SHIFT 8 +#define PARSE_KEY_IDX_MASK 0xFF /*********************************************************************************************************************************** Include automatically generated data structure for getopt_long() @@ -84,23 +88,46 @@ typedef struct ParseOption #define FUNCTION_LOG_PARSE_OPTION_FORMAT(value, buffer, bufferSize) \ typeToLog("ParseOption", buffer, bufferSize) -/*********************************************************************************************************************************** -Find an option by name in the option list -***********************************************************************************************************************************/ -static unsigned int -optionFind(const String *option) +/**********************************************************************************************************************************/ +// Helper to parse the option info into a structure +__attribute__((always_inline)) static inline CfgParseOptionResult +cfgParseOptionInfo(int info) { - unsigned int optionIdx = 0; - - while (optionList[optionIdx].name != NULL) + return (CfgParseOptionResult) { - if (strcmp(strZ(option), optionList[optionIdx].name) == 0) + .found = true, + .id = (info & PARSE_OPTION_MASK) + ((info >> PARSE_KEY_IDX_SHIFT) & PARSE_KEY_IDX_MASK), + .negate = info & PARSE_NEGATE_FLAG, + .reset = info & PARSE_RESET_FLAG, + .deprecated = info & PARSE_DEPRECATE_FLAG, + }; +} + +CfgParseOptionResult +cfgParseOption(const String *optionName) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(STRING, optionName); + FUNCTION_TEST_END(); + + ASSERT(optionName != NULL); + + // Search for the option + unsigned int findIdx = 0; + + while (optionList[findIdx].name != NULL) + { + if (strEqZ(optionName, optionList[findIdx].name)) break; - optionIdx++; + findIdx++; } - return optionIdx; + // If the option was found + if (optionList[findIdx].name != NULL) + FUNCTION_TEST_RETURN(cfgParseOptionInfo(optionList[findIdx].val)); + + FUNCTION_TEST_RETURN((CfgParseOptionResult){0}); } /*********************************************************************************************************************************** @@ -432,7 +459,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) // Phase 1: parse command line parameters // ------------------------------------------------------------------------------------------------------------------------- - int option; // Code returned by getopt_long + int optionValue; // Value returned by getopt_long int optionListIdx; // Index of option is list (if an option was returned) bool argFound = false; // Track args found to decide on error or help at the end StringList *commandParamList = NULL; // List of command parameters @@ -449,9 +476,9 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) // Only the first non-option parameter should be treated as a command so track if the command has been set bool commandSet = false; - while ((option = getopt_long((int)argListSize, (char **)argList, "-:", optionList, &optionListIdx)) != -1) + while ((optionValue = getopt_long((int)argListSize, (char **)argList, "-:", optionList, &optionListIdx)) != -1) { - switch (option) + switch (optionValue) { // Parse arguments that are not options, i.e. commands and parameters passed to commands case 1: @@ -517,71 +544,72 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) default: { // Get option id and flags from the option code - ConfigOption optionId = option & PARSE_OPTION_MASK; - bool negate = option & PARSE_NEGATE_FLAG; - bool reset = option & PARSE_RESET_FLAG; + CfgParseOptionResult option = cfgParseOptionInfo(optionValue); // Make sure the option id is valid - ASSERT(optionId < CFG_OPTION_TOTAL); + ASSERT(option.id < CFG_OPTION_TOTAL); // Error if this option is secure and cannot be passed on the command line - if (cfgDefOptionSecure(cfgOptionDefIdFromId(optionId))) + if (cfgDefOptionSecure(cfgOptionDefIdFromId(option.id))) { THROW_FMT( OptionInvalidError, "option '%s' is not allowed on the command-line\n" "HINT: this option could expose secrets in the process list.\n" "HINT: specify the option in a configuration file or an environment variable instead.", - cfgOptionName(optionId)); + cfgOptionName(option.id)); } // If the the option has not been found yet then set it - if (!parseOptionList[optionId].found) + if (!parseOptionList[option.id].found) { - parseOptionList[optionId].found = true; - parseOptionList[optionId].negate = negate; - parseOptionList[optionId].reset = reset; - parseOptionList[optionId].source = cfgSourceParam; + parseOptionList[option.id].found = true; + parseOptionList[option.id].negate = option.negate; + parseOptionList[option.id].reset = option.reset; + parseOptionList[option.id].source = cfgSourceParam; // Only set the argument if the option requires one if (optionList[optionListIdx].has_arg == required_argument) { - parseOptionList[optionId].valueList = strLstNew(); - strLstAdd(parseOptionList[optionId].valueList, STR(optarg)); + parseOptionList[option.id].valueList = strLstNew(); + strLstAdd(parseOptionList[option.id].valueList, STR(optarg)); } } else { // Make sure option is not negated more than once. It probably wouldn't hurt anything to accept this case // but there's no point in allowing the user to be sloppy. - if (parseOptionList[optionId].negate && negate) - THROW_FMT(OptionInvalidError, "option '%s' is negated multiple times", cfgOptionName(optionId)); + if (parseOptionList[option.id].negate && option.negate) + THROW_FMT(OptionInvalidError, "option '%s' is negated multiple times", cfgOptionName(option.id)); // Make sure option is not reset more than once. Same justification as negate. - if (parseOptionList[optionId].reset && reset) - THROW_FMT(OptionInvalidError, "option '%s' is reset multiple times", cfgOptionName(optionId)); + if (parseOptionList[option.id].reset && option.reset) + THROW_FMT(OptionInvalidError, "option '%s' is reset multiple times", cfgOptionName(option.id)); // Don't allow an option to be both negated and reset - if ((parseOptionList[optionId].reset && negate) || (parseOptionList[optionId].negate && reset)) - THROW_FMT(OptionInvalidError, "option '%s' cannot be negated and reset", cfgOptionName(optionId)); + if ((parseOptionList[option.id].reset && option.negate) || + (parseOptionList[option.id].negate && option.reset)) + { + THROW_FMT(OptionInvalidError, "option '%s' cannot be negated and reset", cfgOptionName(option.id)); + } // Don't allow an option to be both set and negated - if (parseOptionList[optionId].negate != negate) - THROW_FMT(OptionInvalidError, "option '%s' cannot be set and negated", cfgOptionName(optionId)); + if (parseOptionList[option.id].negate != option.negate) + THROW_FMT(OptionInvalidError, "option '%s' cannot be set and negated", cfgOptionName(option.id)); // Don't allow an option to be both set and reset - if (parseOptionList[optionId].reset != reset) - THROW_FMT(OptionInvalidError, "option '%s' cannot be set and reset", cfgOptionName(optionId)); + if (parseOptionList[option.id].reset != option.reset) + THROW_FMT(OptionInvalidError, "option '%s' cannot be set and reset", cfgOptionName(option.id)); // Add the argument if (optionList[optionListIdx].has_arg == required_argument && - cfgDefOptionMulti(cfgOptionDefIdFromId(optionId))) + cfgDefOptionMulti(cfgOptionDefIdFromId(option.id))) { - strLstAdd(parseOptionList[optionId].valueList, strNew(optarg)); + strLstAdd(parseOptionList[option.id].valueList, strNew(optarg)); } // Error if the option does not accept multiple arguments else - THROW_FMT(OptionInvalidError, "option '%s' cannot be set multiple times", cfgOptionName(optionId)); + THROW_FMT(OptionInvalidError, "option '%s' cannot be set multiple times", cfgOptionName(option.id)); } break; @@ -647,29 +675,28 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) const String *value = STR(equalPtr + 1); // Find the option - unsigned int optionIdx = optionFind(key); + CfgParseOptionResult option = cfgParseOption(key); // Warn if the option not found - if (optionList[optionIdx].name == NULL) + if (!option.found) { LOG_WARN_FMT("environment contains invalid option '%s'", strZ(key)); continue; } // Warn if negate option found in env - else if (optionList[optionIdx].val & PARSE_NEGATE_FLAG) + else if (option.negate) { LOG_WARN_FMT("environment contains invalid negate option '%s'", strZ(key)); continue; } // Warn if reset option found in env - else if (optionList[optionIdx].val & PARSE_RESET_FLAG) + else if (option.reset) { LOG_WARN_FMT("environment contains invalid reset option '%s'", strZ(key)); continue; } - ConfigOption optionId = optionList[optionIdx].val & PARSE_OPTION_MASK; - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId); + ConfigDefineOption optionDefId = cfgOptionDefIdFromId(option.id); // Continue if the option is not valid for this command if (!cfgDefOptionValid(commandId, optionDefId)) @@ -679,30 +706,30 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) THROW_FMT(OptionInvalidValueError, "environment variable '%s' must have a value", strZ(key)); // Continue if the option has already been specified on the command line - if (parseOptionList[optionId].found) + if (parseOptionList[option.id].found) continue; - parseOptionList[optionId].found = true; - parseOptionList[optionId].source = cfgSourceConfig; + parseOptionList[option.id].found = true; + parseOptionList[option.id].source = cfgSourceConfig; // Convert boolean to string if (cfgDefOptionType(optionDefId) == cfgDefOptTypeBoolean) { if (strEqZ(value, "n")) - parseOptionList[optionId].negate = true; + parseOptionList[option.id].negate = true; else if (!strEqZ(value, "y")) THROW_FMT(OptionInvalidValueError, "environment boolean option '%s' must be 'y' or 'n'", strZ(key)); } // Else split list/hash into separate values else if (cfgDefOptionMulti(optionDefId)) { - parseOptionList[optionId].valueList = strLstNewSplitZ(value, ":"); + parseOptionList[option.id].valueList = strLstNewSplitZ(value, ":"); } // Else add the string value else { - parseOptionList[optionId].valueList = strLstNew(); - strLstAdd(parseOptionList[optionId].valueList, value); + parseOptionList[option.id].valueList = strLstNew(); + strLstAdd(parseOptionList[option.id].valueList, value); } } } @@ -750,31 +777,30 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) String *key = strLstGet(keyList, keyIdx); // Find the optionName in the main list - unsigned int optionIdx = optionFind(key); + CfgParseOptionResult option = cfgParseOption(key); // Warn if the option not found - if (optionList[optionIdx].name == NULL) + if (!option.found) { LOG_WARN_FMT("configuration file contains invalid option '%s'", strZ(key)); continue; } // Warn if negate option found in config - else if (optionList[optionIdx].val & PARSE_NEGATE_FLAG) + else if (option.negate) { LOG_WARN_FMT("configuration file contains negate option '%s'", strZ(key)); continue; } // Warn if reset option found in config - else if (optionList[optionIdx].val & PARSE_RESET_FLAG) + else if (option.reset) { LOG_WARN_FMT("configuration file contains reset option '%s'", strZ(key)); continue; } - ConfigOption optionId = optionList[optionIdx].val & PARSE_OPTION_MASK; - ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId); + ConfigDefineOption optionDefId = cfgOptionDefIdFromId(option.id); - /// Warn if this option should be command-line only + // Warn if this option should be command-line only if (cfgDefOptionSection(optionDefId) == cfgDefSectionCommandLine) { LOG_WARN_FMT("configuration file contains command-line only option '%s'", strZ(key)); @@ -782,7 +808,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) } // Make sure this option does not appear in the same section with an alternate name - const Variant *optionFoundKey = VARINT(optionId); + const Variant *optionFoundKey = VARINT(option.id); const Variant *optionFoundName = kvGet(optionFound, optionFoundKey); if (optionFoundName != NULL) @@ -820,20 +846,20 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) } // Continue if this option has already been found in another section or command-line/environment - if (parseOptionList[optionId].found) + if (parseOptionList[option.id].found) continue; - parseOptionList[optionId].found = true; - parseOptionList[optionId].source = cfgSourceConfig; + parseOptionList[option.id].found = true; + parseOptionList[option.id].source = cfgSourceConfig; // Process list if (iniSectionKeyIsList(config, section, key)) { // Error if the option cannot be specified multiple times if (!cfgDefOptionMulti(optionDefId)) - THROW_FMT(OptionInvalidError, "option '%s' cannot be set multiple times", cfgOptionName(optionId)); + THROW_FMT(OptionInvalidError, "option '%s' cannot be set multiple times", cfgOptionName(option.id)); - parseOptionList[optionId].valueList = iniGetList(config, section, key); + parseOptionList[option.id].valueList = iniGetList(config, section, key); } else { @@ -850,15 +876,15 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) if (cfgDefOptionType(optionDefId) == cfgDefOptTypeBoolean) { if (strEqZ(value, "n")) - parseOptionList[optionId].negate = true; + parseOptionList[option.id].negate = true; else if (!strEqZ(value, "y")) THROW_FMT(OptionInvalidValueError, "boolean option '%s' must be 'y' or 'n'", strZ(key)); } // Else add the string value else { - parseOptionList[optionId].valueList = strLstNew(); - strLstAdd(parseOptionList[optionId].valueList, value); + parseOptionList[option.id].valueList = strLstNew(); + strLstAdd(parseOptionList[option.id].valueList, value); } } } diff --git a/src/config/parse.h b/src/config/parse.h index c0def5e0b..6e6fc3b67 100644 --- a/src/config/parse.h +++ b/src/config/parse.h @@ -12,4 +12,16 @@ Functions // Parse the command-line arguments and config file to produce final config data void configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel); +// Parse option name and return option info +typedef struct CfgParseOptionResult +{ + bool found; // Was the option found? + ConfigOption id; // Option ID + bool negate; // Was the option negated? + bool reset; // Was the option reset? + bool deprecated; // Is the option deprecated? +} CfgParseOptionResult; + +CfgParseOptionResult cfgParseOption(const String *optionName); + #endif diff --git a/src/config/protocol.c b/src/config/protocol.c index 80e9dc746..3ae25966d 100644 --- a/src/config/protocol.c +++ b/src/config/protocol.c @@ -8,6 +8,7 @@ Configuration Protocol Handler #include "common/log.h" #include "common/memContext.h" #include "config/config.h" +#include "config/parse.h" #include "config/protocol.h" /*********************************************************************************************************************************** @@ -37,7 +38,12 @@ configProtocol(const String *command, const VariantList *paramList, ProtocolServ VariantList *optionList = varLstNew(); for (unsigned int optionIdx = 0; optionIdx < varLstSize(paramList); optionIdx++) - varLstAdd(optionList, varDup(cfgOption(cfgOptionId(strZ(varStr(varLstGet(paramList, optionIdx))))))); + { + CfgParseOptionResult option = cfgParseOption(varStr(varLstGet(paramList, optionIdx))); + CHECK(option.found); + + varLstAdd(optionList, varDup(cfgOption(option.id))); + } protocolServerResponse(server, varNewVarLst(optionList)); } diff --git a/test/src/module/command/helpTest.c b/test/src/module/command/helpTest.c index c34b3a0a8..c5882facd 100644 --- a/test/src/module/command/helpTest.c +++ b/test/src/module/command/helpTest.c @@ -309,7 +309,7 @@ testRun(void) // ------------------------------------------------------------------------------------------------------------------------- optionHelp = strZ(strNewFmt( - "%s - 'archive-push' command - 'repo1-s3-host' option help\n" + "%s - 'archive-push' command - 'repo-s3-host' option help\n" "\n" "S3 repository host.\n" "\n" @@ -379,6 +379,15 @@ testRun(void) harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for backup command, repo-hardlink option"); TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text"); + argList = strLstNew(); + strLstAddZ(argList, "/path/to/pgbackrest"); + strLstAddZ(argList, "help"); + strLstAddZ(argList, "backup"); + strLstAddZ(argList, "hardlink"); + TEST_RESULT_VOID( + harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for backup command, deprecated hardlink option"); + TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text"); + // Check admonition // ------------------------------------------------------------------------------------------------------------------------- optionHelp = strZ(strNewFmt( diff --git a/test/src/module/config/configTest.c b/test/src/module/config/configTest.c index de8faef70..91d6ac4e3 100644 --- a/test/src/module/config/configTest.c +++ b/test/src/module/config/configTest.c @@ -24,9 +24,6 @@ testRun(void) TEST_RESULT_INT(cfgOptionDefIdFromId(cfgOptPgHost + 6), cfgDefOptPgHost, "option id to def id"); - TEST_RESULT_INT(cfgOptionId("target"), cfgOptTarget, "option id from name"); - TEST_RESULT_INT(cfgOptionId(BOGUS_STR), -1, "option id from invalid option name"); - TEST_ERROR( cfgOptionIdFromDefId(999999, 6), AssertError, "assertion 'optionId != CFG_OPTION_TOTAL' failed"); diff --git a/test/src/module/config/parseTest.c b/test/src/module/config/parseTest.c index f92e869c5..0bfc39129 100644 --- a/test/src/module/config/parseTest.c +++ b/test/src/module/config/parseTest.c @@ -18,13 +18,15 @@ Test Configuration Parse Option find test -- this is done a lot in the deprecated tests ***********************************************************************************************************************************/ static void -testOptionFind(const char *option, unsigned int value) +testOptionFind(const char *optionName, unsigned int optionId, unsigned int optionKeyIdx, bool negate, bool reset, bool deprecated) { - // If not testing for a missing option, then add the option offset that is already added to each option in the list - if (value != 0) - value |= PARSE_OPTION_FLAG; + CfgParseOptionResult option = cfgParseOption(STR(optionName)); - TEST_RESULT_INT(optionList[optionFind(strNew(option))].val, value, "check %s", option); + TEST_RESULT_BOOL(option.found, true, "check %s found", optionName); + TEST_RESULT_UINT(option.id, optionId + optionKeyIdx, "check %s id %u", optionName, optionId + optionKeyIdx); + TEST_RESULT_BOOL(option.negate, negate, "check %s negate %d", optionName, negate); + TEST_RESULT_BOOL(option.reset, reset, "check %s reset %d", optionName, reset); + TEST_RESULT_BOOL(option.deprecated, deprecated, "check %s deprecated %d", optionName, deprecated); } /*********************************************************************************************************************************** @@ -1433,61 +1435,59 @@ testRun(void) { // Repository options // ------------------------------------------------------------------------------------------------------------------------- - testOptionFind("hardlink", PARSE_DEPRECATE_FLAG | cfgOptRepoHardlink); - testOptionFind("no-hardlink", PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoHardlink); + testOptionFind("hardlink", cfgOptRepoHardlink, 0, false, false, true); + testOptionFind("no-hardlink", cfgOptRepoHardlink, 0, true, false, true); - testOptionFind("archive-queue-max", PARSE_DEPRECATE_FLAG | cfgOptArchivePushQueueMax); - testOptionFind("reset-archive-queue-max", PARSE_DEPRECATE_FLAG | PARSE_RESET_FLAG | cfgOptArchivePushQueueMax); + testOptionFind("archive-queue-max", cfgOptArchivePushQueueMax, 0, false, false, true); + testOptionFind("reset-archive-queue-max", cfgOptArchivePushQueueMax, 0, false, true, true); - testOptionFind("backup-cmd", PARSE_DEPRECATE_FLAG | cfgOptRepoHostCmd); - testOptionFind("backup-config", PARSE_DEPRECATE_FLAG | cfgOptRepoHostConfig); - testOptionFind("backup-host", PARSE_DEPRECATE_FLAG | cfgOptRepoHost); - testOptionFind("backup-ssh-port", PARSE_DEPRECATE_FLAG | cfgOptRepoHostPort); - testOptionFind("backup-user", PARSE_DEPRECATE_FLAG | cfgOptRepoHostUser); + testOptionFind("backup-cmd", cfgOptRepoHostCmd, 0, false, false, true); + testOptionFind("backup-config", cfgOptRepoHostConfig, 0, false, false, true); + testOptionFind("backup-host", cfgOptRepoHost, 0, false, false, true); + testOptionFind("backup-ssh-port", cfgOptRepoHostPort, 0, false, false, true); + testOptionFind("backup-user", cfgOptRepoHostUser, 0, false, false, true); - testOptionFind("repo-cipher-pass", PARSE_DEPRECATE_FLAG | cfgOptRepoCipherPass); - testOptionFind("repo-cipher-type", PARSE_DEPRECATE_FLAG | cfgOptRepoCipherType); - testOptionFind("repo-path", PARSE_DEPRECATE_FLAG | cfgOptRepoPath); - testOptionFind("repo-type", PARSE_DEPRECATE_FLAG | cfgOptRepoType); + testOptionFind("repo-cipher-pass", cfgOptRepoCipherPass, 0, false, false, true); + testOptionFind("repo-cipher-type", cfgOptRepoCipherType, 0, false, false, true); + testOptionFind("repo-path", cfgOptRepoPath, 0, false, false, true); + testOptionFind("repo-type", cfgOptRepoType, 0, false, false, true); - testOptionFind("repo-s3-bucket", PARSE_DEPRECATE_FLAG | cfgOptRepoS3Bucket); - testOptionFind("repo-s3-ca-file", PARSE_DEPRECATE_FLAG | cfgOptRepoS3CaFile); - testOptionFind("repo-s3-ca-path", PARSE_DEPRECATE_FLAG | cfgOptRepoS3CaPath); - testOptionFind("repo-s3-endpoint", PARSE_DEPRECATE_FLAG | cfgOptRepoS3Endpoint); - testOptionFind("repo-s3-host", PARSE_DEPRECATE_FLAG | cfgOptRepoS3Host); - testOptionFind("repo-s3-key", PARSE_DEPRECATE_FLAG | cfgOptRepoS3Key); - testOptionFind("repo-s3-key-secret", PARSE_DEPRECATE_FLAG | cfgOptRepoS3KeySecret); - testOptionFind("repo-s3-region", PARSE_DEPRECATE_FLAG | cfgOptRepoS3Region); - testOptionFind("repo-s3-verify-ssl", PARSE_DEPRECATE_FLAG | cfgOptRepoS3VerifyTls); - testOptionFind("repo1-s3-verify-ssl", PARSE_DEPRECATE_FLAG | cfgOptRepoS3VerifyTls); - testOptionFind("no-repo-s3-verify-ssl", PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoS3VerifyTls); + testOptionFind("repo-s3-bucket", cfgOptRepoS3Bucket, 0, false, false, true); + testOptionFind("repo-s3-ca-file", cfgOptRepoS3CaFile, 0, false, false, true); + testOptionFind("repo-s3-ca-path", cfgOptRepoS3CaPath, 0, false, false, true); + testOptionFind("repo-s3-endpoint", cfgOptRepoS3Endpoint, 0, false, false, true); + testOptionFind("repo-s3-host", cfgOptRepoS3Host, 0, false, false, true); + testOptionFind("repo-s3-key", cfgOptRepoS3Key, 0, false, false, true); + testOptionFind("repo-s3-key-secret", cfgOptRepoS3KeySecret, 0, false, false, true); + testOptionFind("repo-s3-region", cfgOptRepoS3Region, 0, false, false, true); + testOptionFind("repo-s3-verify-ssl", cfgOptRepoS3VerifyTls, 0, false, false, true); + testOptionFind("repo1-s3-verify-ssl", cfgOptRepoS3VerifyTls, 0, false, false, true); + testOptionFind("no-repo-s3-verify-ssl", cfgOptRepoS3VerifyTls, 0, true, false, true); // PostreSQL options // ------------------------------------------------------------------------------------------------------------------------- - testOptionFind("db-cmd", PARSE_DEPRECATE_FLAG | cfgOptPgHostCmd); - testOptionFind("db-config", PARSE_DEPRECATE_FLAG | cfgOptPgHostConfig); - testOptionFind("db-host", PARSE_DEPRECATE_FLAG | cfgOptPgHost); - testOptionFind("db-path", PARSE_DEPRECATE_FLAG | cfgOptPgPath); - testOptionFind("db-port", PARSE_DEPRECATE_FLAG | cfgOptPgPort); - testOptionFind("db-socket-path", PARSE_DEPRECATE_FLAG | cfgOptPgSocketPath); - testOptionFind("db-ssh-port", PARSE_DEPRECATE_FLAG | cfgOptPgHostPort); - testOptionFind("db-user", PARSE_DEPRECATE_FLAG | cfgOptPgHostUser); + testOptionFind("db-cmd", cfgOptPgHostCmd, 0, false, false, true); + testOptionFind("db-config", cfgOptPgHostConfig, 0, false, false, true); + testOptionFind("db-host", cfgOptPgHost, 0, false, false, true); + testOptionFind("db-path", cfgOptPgPath, 0, false, false, true); + testOptionFind("db-port", cfgOptPgPort, 0, false, false, true); + testOptionFind("db-socket-path", cfgOptPgSocketPath, 0, false, false, true); + testOptionFind("db-ssh-port", cfgOptPgHostPort, 0, false, false, true); + testOptionFind("db-user", cfgOptPgHostUser, 0, false, false, true); - testOptionFind("no-db-user", 0); + TEST_RESULT_BOOL(cfgParseOption(STR("no-db-user")).found, false, "no-db-user not found"); - for (unsigned int optionIdx = 0; optionIdx < cfgDefOptionIndexTotal(cfgDefOptPgPath); optionIdx++) + // Only check 1-8 since 8 was the max index when these option names were deprecated + for (unsigned int optionIdx = 0; optionIdx < 8; optionIdx++) { - testOptionFind(strZ(strNewFmt("db%u-cmd", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHostCmd + optionIdx)); - testOptionFind( - strZ(strNewFmt("db%u-config", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHostConfig + optionIdx)); - testOptionFind(strZ(strNewFmt("db%u-host", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHost + optionIdx)); - testOptionFind(strZ(strNewFmt("db%u-path", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgPath + optionIdx)); - testOptionFind(strZ(strNewFmt("db%u-port", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgPort + optionIdx)); - testOptionFind( - strZ(strNewFmt("db%u-socket-path", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgSocketPath + optionIdx)); - testOptionFind( - strZ(strNewFmt("db%u-ssh-port", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHostPort + optionIdx)); - testOptionFind(strZ(strNewFmt("db%u-user", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHostUser + optionIdx)); + testOptionFind(strZ(strNewFmt("db%u-cmd", optionIdx + 1)), cfgOptPgHostCmd, optionIdx, false, false, true); + testOptionFind(strZ(strNewFmt("db%u-config", optionIdx + 1)), cfgOptPgHostConfig, optionIdx, false, false, true); + testOptionFind(strZ(strNewFmt("db%u-host", optionIdx + 1)), cfgOptPgHost, optionIdx, false, false, true); + testOptionFind(strZ(strNewFmt("db%u-path", optionIdx + 1)), cfgOptPgPath, optionIdx, false, false, true); + testOptionFind(strZ(strNewFmt("db%u-port", optionIdx + 1)), cfgOptPgPort, optionIdx, false, false, true); + testOptionFind(strZ(strNewFmt("db%u-socket-path", optionIdx + 1)), cfgOptPgSocketPath, optionIdx, false, false, true); + testOptionFind(strZ(strNewFmt("db%u-ssh-port", optionIdx + 1)), cfgOptPgHostPort, optionIdx, false, false, true); + testOptionFind(strZ(strNewFmt("db%u-user", optionIdx + 1)), cfgOptPgHostUser, optionIdx, false, false, true); } }