aboutsummaryrefslogtreecommitdiffstats
path: root/src/conf.c
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 /src/conf.c
parent6a958980388727048effaea081b68c8debfaa6df (diff)
downloadmpd-4d1eedbaa2be7e9e59f2332d9bf8886b9b634070.tar.gz
mpd-4d1eedbaa2be7e9e59f2332d9bf8886b9b634070.tar.xz
mpd-4d1eedbaa2be7e9e59f2332d9bf8886b9b634070.zip
conf: added function config_get_unsigned()
Diffstat (limited to 'src/conf.c')
-rw-r--r--src/conf.c17
1 files changed, 17 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);