aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-27 19:19:34 +0100
committerMax Kellermann <max@duempel.org>2008-11-27 19:19:34 +0100
commitbd0653f440adf736427d9cc9e3565489cc9a1cde (patch)
tree7714fcf736fb3711050d80baf4a0d696bef26293 /src
parent910c0009542a27bd1e4efe5491a01a97a9d0233e (diff)
downloadmpd-bd0653f440adf736427d9cc9e3565489cc9a1cde.tar.gz
mpd-bd0653f440adf736427d9cc9e3565489cc9a1cde.tar.xz
mpd-bd0653f440adf736427d9cc9e3565489cc9a1cde.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/conf.c10
-rw-r--r--src/conf.h4
2 files changed, 14 insertions, 0 deletions
diff --git a/src/conf.c b/src/conf.c
index 10d0f9d31..885da1f29 100644
--- a/src/conf.c
+++ b/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;
diff --git a/src/conf.h b/src/conf.h
index e5875d9b7..14cc883b9 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -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