pgbackrest.git / summary / log / commit / refs

commit    c07aa2ae1940f2c6cf0f7a2e701b20e2d0c32ff9
Author:   David Steele <david@pgmasters.net>
Date:     Sat Mar 03 03:42:02 2018 +0000

    Improve code documentation in config module.


doc/xml/release.xml | 4 +++ src/config/config.h | 69 +++++++++++++++++++++++++------------- test/src/module/config/parseTest.c | 1 - 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 7fa48547b..655590d3e 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -36,6 +36,10 @@ <release-item> <p>Enable <id>-Wswitch-enum</id> and <id>-Wconversion</id> and silence new warnings.</p> </release-item> + + <release-item> + <p>Improve code documentation in <code>config</code> module.</p> + </release-item> </release-development-list> </release-core-list> diff --git a/src/config/config.h b/src/config/config.h index 80589a410..6c2799e6f 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -1,5 +1,8 @@ /*********************************************************************************************************************************** Command and Option Configuration + +This module serves as a database for the configuration options. The configuration rules reside in config/define.c and +config/parse.c sets the command and options and determines which options are valid for a command. ***********************************************************************************************************************************/ #ifndef CONFIG_H #define CONFIG_H @@ -10,7 +13,41 @@ Command and Option Configuration #include "config/config.auto.h" /*********************************************************************************************************************************** -Option source enum - defines where an option value came from +Command Functions + +Access the current command and command parameters. +***********************************************************************************************************************************/ +ConfigCommand cfgCommand(); +const char *cfgCommandName(ConfigCommand commandId); + +const StringList *cfgCommandParam(); + +/*********************************************************************************************************************************** +Option Functions + +Access option values, indexes, and determine if an option is valid for the current command. +***********************************************************************************************************************************/ +const Variant *cfgOption(ConfigOption optionId); +bool cfgOptionBool(ConfigOption optionId); +double cfgOptionDbl(ConfigOption optionId); +int cfgOptionInt(ConfigOption optionId); +int64 cfgOptionInt64(ConfigOption optionId); +const KeyValue *cfgOptionKv(ConfigOption optionId); +const VariantList *cfgOptionLst(ConfigOption optionId); +const String *cfgOptionStr(ConfigOption optionId); + +unsigned int cfgOptionIndex(ConfigOption optionId); +unsigned int cfgOptionIndexTotal(ConfigOption optionDefId); + +const char *cfgOptionName(ConfigOption optionId); + +bool cfgOptionValid(ConfigOption optionId); + +/*********************************************************************************************************************************** +Option Source Enum + +Defines where an option was sourced from. The source is only needed when determining what parameters should be passed to a remote +process. ***********************************************************************************************************************************/ typedef enum { @@ -20,48 +57,34 @@ typedef enum } ConfigSource; /*********************************************************************************************************************************** -Functions +Load Functions + +Used primarily by modules that need to manipulate the configuration. These modules include, but are not limited to, config/parse.c, +config/load.c, perl/config.c, and perl/exec.c. ***********************************************************************************************************************************/ void cfgInit(); -ConfigCommand cfgCommand(); -bool cfgCommandHelp(); -int cfgCommandId(const char *commandName); -const char *cfgCommandName(ConfigCommand commandId); ConfigDefineCommand cfgCommandDefIdFromId(ConfigCommand commandId); -const StringList *cfgCommandParam(); - +bool cfgCommandHelp(); void cfgCommandHelpSet(bool helpParam); +int cfgCommandId(const char *commandName); void cfgCommandParamSet(const StringList *param); void cfgCommandSet(ConfigCommand commandParam); const String *cfgExe(); void cfgExeSet(const String *exeParam); -const Variant *cfgOption(ConfigOption optionId); -bool cfgOptionBool(ConfigOption optionId); const Variant *cfgOptionDefault(ConfigOption optionId); void cfgOptionDefaultSet(ConfigOption optionId, const Variant *defaultValue); ConfigDefineOption cfgOptionDefIdFromId(ConfigOption optionId); -double cfgOptionDbl(ConfigOption optionId); int cfgOptionId(const char *optionName); ConfigOption cfgOptionIdFromDefId(ConfigDefineOption optionDefId, unsigned int index); -unsigned int cfgOptionIndex(ConfigOption optionId); -unsigned int cfgOptionIndexTotal(ConfigOption optionDefId); -int cfgOptionInt(ConfigOption optionId); -int64 cfgOptionInt64(ConfigOption optionId); -const KeyValue *cfgOptionKv(ConfigOption optionId); -const VariantList *cfgOptionLst(ConfigOption optionId); -const char *cfgOptionName(ConfigOption optionId); bool cfgOptionNegate(ConfigOption optionId); +void cfgOptionNegateSet(ConfigOption optionId, bool negate); bool cfgOptionReset(ConfigOption optionId); void cfgOptionResetSet(ConfigOption optionId, bool reset); -ConfigSource cfgOptionSource(ConfigOption optionId); -const String *cfgOptionStr(ConfigOption optionId); -bool cfgOptionValid(ConfigOption optionId); - -void cfgOptionNegateSet(ConfigOption optionId, bool negate); void cfgOptionSet(ConfigOption optionId, ConfigSource source, const Variant *value); +ConfigSource cfgOptionSource(ConfigOption optionId); void cfgOptionValidSet(ConfigOption optionId, bool valid); #endif diff --git a/test/src/module/config/parseTest.c b/test/src/module/config/parseTest.c index c1fbf34f5..e31ccfa63 100644 --- a/test/src/module/config/parseTest.c +++ b/test/src/module/config/parseTest.c @@ -398,7 +398,6 @@ testRun() ))); TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_BACKUP " command"); - logInit(logLevelInfo, logLevelOff, false); testLogErrResult( strPtr( strNewFmt( [parent: 406acf9cba16]