aboutsummaryrefslogtreecommitdiffstats
path: root/src/conf.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-18 19:45:51 +0100
committerMax Kellermann <max@duempel.org>2009-01-18 19:45:51 +0100
commit65f2386b39e88fd1ee5af65336e41ba184d31cf2 (patch)
tree695c14ea66774fda67000c3babeea770cf8d96bf /src/conf.c
parenta531a1e65075d27574bc31d4bac7ab20cb750efd (diff)
downloadmpd-65f2386b39e88fd1ee5af65336e41ba184d31cf2.tar.gz
mpd-65f2386b39e88fd1ee5af65336e41ba184d31cf2.tar.xz
mpd-65f2386b39e88fd1ee5af65336e41ba184d31cf2.zip
conf: added config_get_block_unsigned()
Eliminate some more getBlockParam() invocations.
Diffstat (limited to 'src/conf.c')
-rw-r--r--src/conf.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/conf.c b/src/conf.c
index 73990d45d..116a4ea5f 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
#include <errno.h>
#define MAX_STRING_SIZE MPD_PATH_MAX+80
@@ -457,6 +458,27 @@ config_get_block_string(struct config_param *param, const char *name,
return bp->value;
}
+unsigned
+config_get_block_unsigned(struct config_param *param, const char *name,
+ unsigned default_value)
+{
+ struct block_param *bp = getBlockParam(param, name);
+ long value;
+ char *endptr;
+
+ if (bp == NULL)
+ return default_value;
+
+ value = strtol(bp->value, &endptr, 0);
+ if (*endptr != 0)
+ g_error("Not a valid number in line %i", bp->line);
+
+ if (value < 0)
+ g_error("Not a positive number in line %i", bp->line);
+
+ return (unsigned)value;
+}
+
bool
config_get_block_bool(struct config_param *param, const char *name,
bool default_value)