Commit 4d1eedba authored by Max Kellermann's avatar Max Kellermann

conf: added function config_get_unsigned()

parent 6a958980
...@@ -504,6 +504,23 @@ config_get_path(const char *name) ...@@ -504,6 +504,23 @@ config_get_path(const char *name)
} }
unsigned 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) config_get_positive(const char *name, unsigned default_value)
{ {
const struct config_param *param = config_get_param(name); const struct config_param *param = config_get_param(name);
......
...@@ -164,6 +164,10 @@ config_get_path(const char *name); ...@@ -164,6 +164,10 @@ config_get_path(const char *name);
G_GNUC_PURE G_GNUC_PURE
unsigned unsigned
config_get_unsigned(const char *name, unsigned default_value);
G_GNUC_PURE
unsigned
config_get_positive(const char *name, unsigned default_value); config_get_positive(const char *name, unsigned default_value);
G_GNUC_PURE G_GNUC_PURE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment