conf: added function config_get_unsigned()
This commit is contained in:
parent
6a95898038
commit
4d1eedbaa2
17
src/conf.c
17
src/conf.c
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue