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:
Max Kellermann 2008-11-27 19:19:34 +01:00
parent 910c000954
commit bd0653f440
2 changed files with 14 additions and 0 deletions

View File

@ -418,6 +418,16 @@ int getBoolConfigParam(const char *name, int force)
return ret; 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 getBoolBlockParam(ConfigParam *param, const char *name, int force)
{ {
int ret; int ret;

View File

@ -19,6 +19,8 @@
#ifndef MPD_CONF_H #ifndef MPD_CONF_H
#define MPD_CONF_H #define MPD_CONF_H
#include <stdbool.h>
#define CONF_MUSIC_DIR "music_directory" #define CONF_MUSIC_DIR "music_directory"
#define CONF_PLAYLIST_DIR "playlist_directory" #define CONF_PLAYLIST_DIR "playlist_directory"
#define CONF_DB_FILE "db_file" #define CONF_DB_FILE "db_file"
@ -97,6 +99,8 @@ ConfigParam *parseConfigFilePath(const char *name, int force);
int getBoolConfigParam(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); int getBoolBlockParam(ConfigParam *param, const char *name, int force);
#endif #endif