Commit 262159be authored by Thomas Haller's avatar Thomas Haller
Browse files

config: add nm_config_data_get_value_int64() util

parent ec9bff29
...@@ -211,7 +211,7 @@ nm_config_data_get_value_boolean (const NMConfigData *self, const char *group, c ...@@ -211,7 +211,7 @@ nm_config_data_get_value_boolean (const NMConfigData *self, const char *group, c
g_return_val_if_fail (key && *key, default_value); g_return_val_if_fail (key && *key, default_value);
/* when parsing the boolean, base it on the raw value from g_key_file_get_value(). */ /* when parsing the boolean, base it on the raw value from g_key_file_get_value(). */
str = g_key_file_get_value (NM_CONFIG_DATA_GET_PRIVATE (self)->keyfile, group, key, NULL); str = nm_config_keyfile_get_value (NM_CONFIG_DATA_GET_PRIVATE (self)->keyfile, group, key, NM_CONFIG_GET_VALUE_RAW);
if (str) { if (str) {
value = nm_config_parse_boolean (str, default_value); value = nm_config_parse_boolean (str, default_value);
g_free (str); g_free (str);
...@@ -219,6 +219,28 @@ nm_config_data_get_value_boolean (const NMConfigData *self, const char *group, c ...@@ -219,6 +219,28 @@ nm_config_data_get_value_boolean (const NMConfigData *self, const char *group, c
return value; return value;
} }
gint64
nm_config_data_get_value_int64 (const NMConfigData *self, const char *group, const char *key, guint base, gint64 min, gint64 max, gint64 fallback)
{
int errsv;
gint64 val;
char *str;
g_return_val_if_fail (NM_IS_CONFIG_DATA (self), fallback);
g_return_val_if_fail (group && *group, fallback);
g_return_val_if_fail (key && *key, fallback);
str = nm_config_keyfile_get_value (NM_CONFIG_DATA_GET_PRIVATE (self)->keyfile, group, key, NM_CONFIG_GET_VALUE_NONE);
val = _nm_utils_ascii_str_to_int64 (str, base, min, max, fallback);
if (str) {
/* preserve errno from the parsing. */
errsv = errno;
g_free (str);
errno = errsv;
}
return val;
}
char ** char **
nm_config_data_get_plugins (const NMConfigData *self, gboolean allow_default) nm_config_data_get_plugins (const NMConfigData *self, gboolean allow_default)
{ {
......
...@@ -158,6 +158,7 @@ gboolean nm_config_data_has_value (const NMConfigData *self, const char *group, ...@@ -158,6 +158,7 @@ gboolean nm_config_data_has_value (const NMConfigData *self, const char *group,
char *nm_config_data_get_value (const NMConfigData *config_data, const char *group, const char *key, NMConfigGetValueFlags flags); char *nm_config_data_get_value (const NMConfigData *config_data, const char *group, const char *key, NMConfigGetValueFlags flags);
const char *nm_config_data_get_value_cached (const NMConfigData *config_data, const char *group, const char *key, NMConfigGetValueFlags flags); const char *nm_config_data_get_value_cached (const NMConfigData *config_data, const char *group, const char *key, NMConfigGetValueFlags flags);
gint nm_config_data_get_value_boolean (const NMConfigData *self, const char *group, const char *key, gint default_value); gint nm_config_data_get_value_boolean (const NMConfigData *self, const char *group, const char *key, gint default_value);
gint64 nm_config_data_get_value_int64 (const NMConfigData *self, const char *group, const char *key, guint base, gint64 min, gint64 max, gint64 fallback);
char **nm_config_data_get_plugins (const NMConfigData *config_data, gboolean allow_default); char **nm_config_data_get_plugins (const NMConfigData *config_data, gboolean allow_default);
gboolean nm_config_data_get_connectivity_enabled (const NMConfigData *config_data); gboolean nm_config_data_get_connectivity_enabled (const NMConfigData *config_data);
......
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