aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-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