conf: added config_get_bool()
In contrast to, getBoolConfigParam(), config_get_bool() properly returns a "bool" value. In case of "unset", it returns the default value provided by the caller.
This commit is contained in:
parent
910c000954
commit
bd0653f440
10
src/conf.c
10
src/conf.c
@ -418,6 +418,16 @@ int getBoolConfigParam(const char *name, int force)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool config_get_bool(const char *name, bool default_value)
|
||||
{
|
||||
int value = getBoolConfigParam(name, true);
|
||||
|
||||
if (value == CONF_BOOL_UNSET)
|
||||
return default_value;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int getBoolBlockParam(ConfigParam *param, const char *name, int force)
|
||||
{
|
||||
int ret;
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef MPD_CONF_H
|
||||
#define MPD_CONF_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define CONF_MUSIC_DIR "music_directory"
|
||||
#define CONF_PLAYLIST_DIR "playlist_directory"
|
||||
#define CONF_DB_FILE "db_file"
|
||||
@ -97,6 +99,8 @@ ConfigParam *parseConfigFilePath(const char *name, int force);
|
||||
|
||||
int getBoolConfigParam(const char *name, int force);
|
||||
|
||||
bool config_get_bool(const char *name, bool default_value);
|
||||
|
||||
int getBoolBlockParam(ConfigParam *param, const char *name, int force);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user