conf: added function config_get_unsigned()

This commit is contained in:
Max Kellermann 2010-04-13 21:19:07 +02:00
parent 6a95898038
commit 4d1eedbaa2
2 changed files with 21 additions and 0 deletions

View File

@ -503,6 +503,23 @@ config_get_path(const char *name)
return param->value = path;
}
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)
{

View File

@ -162,6 +162,10 @@ G_GNUC_PURE
const char *
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);