diff options
Diffstat (limited to 'src/conf.c')
-rw-r--r-- | src/conf.c | 22 |
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) |