aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-04-13 21:19:07 +0200
committerMax Kellermann <max@duempel.org>2010-04-13 21:19:07 +0200
commit4d1eedbaa2be7e9e59f2332d9bf8886b9b634070 (patch)
tree4ae5dfad1be10baefe0534732667952ebf5d5260
parent6a958980388727048effaea081b68c8debfaa6df (diff)
downloadmpd-4d1eedbaa2be7e9e59f2332d9bf8886b9b634070.tar.gz
mpd-4d1eedbaa2be7e9e59f2332d9bf8886b9b634070.tar.xz
mpd-4d1eedbaa2be7e9e59f2332d9bf8886b9b634070.zip
conf: added function config_get_unsigned()
-rw-r--r--src/conf.c17
-rw-r--r--src/conf.h4
2 files changed, 21 insertions, 0 deletions
diff --git a/src/conf.c b/src/conf.c
index cf78bb29c..bb59373af 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -504,6 +504,23 @@ config_get_path(const char *name)
}
unsigned
+config_get_unsigned(const char *name, unsigned default_value)
+{
+ const struct config_param *param = config_get_param(name);
+ long value;
+ char *endptr;
+
+ if (param == NULL)
+ return default_value;
+
+ value = strtol(param->value, &endptr, 0);
+ if (*endptr != 0 || value < 0)
+ g_error("Not a valid non-negative number in line %i", param->line);
+
+ return (unsigned)value;
+}
+
+unsigned
config_get_positive(const char *name, unsigned default_value)
{
const struct config_param *param = config_get_param(name);
diff --git a/src/conf.h b/src/conf.h
index 7ffa6e44a..16360feee 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -164,6 +164,10 @@ config_get_path(const char *name);
G_GNUC_PURE
unsigned
+config_get_unsigned(const char *name, unsigned default_value);
+
+G_GNUC_PURE
+unsigned
config_get_positive(const char *name, unsigned default_value);
G_GNUC_PURE