diff options
author | Thomas Haller <thaller@redhat.com> | 2014-08-28 19:03:58 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-11-07 15:19:06 +0100 |
commit | 627ad6f8056137244c6671eb18670ee227acb788 (patch) | |
tree | d82b474e3848e0c8ab96c50459aa05a54fb8db78 | |
parent | 808ad85ff4f0a4905f8e81be04d04a784402bc24 (diff) | |
download | NetworkManager-627ad6f8056137244c6671eb18670ee227acb788.tar.gz |
keyfile: add support for G_INT64 properties
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | src/settings/plugins/keyfile/reader.c | 14 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/writer.c | 6 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c index 9d65539149..19149e0723 100644 --- a/src/settings/plugins/keyfile/reader.c +++ b/src/settings/plugins/keyfile/reader.c @@ -36,6 +36,7 @@ #include "common.h" #include "utils.h" #include "nm-core-internal.h" +#include "NetworkManagerUtils.h" /* Some setting properties also contain setting names, such as * NMSettingConnection's 'type' property (which specifies the base type of the @@ -1021,6 +1022,7 @@ read_one_setting_value (NMSetting *setting, { ReadInfo *info = user_data; const char *setting_name; + int errsv; GType type; GError *err = NULL; gboolean check_for_key = TRUE; @@ -1121,6 +1123,18 @@ read_one_setting_value (NMSetting *setting, uint_val = g_ascii_strtoull (tmp_str, NULL, 10); g_free (tmp_str); g_object_set (setting, key, uint_val, NULL); + } else if (type == G_TYPE_INT64) { + char *tmp_str; + gint64 int_val; + + tmp_str = nm_keyfile_plugin_kf_get_value (info->keyfile, setting_name, key, NULL); + int_val = nm_utils_ascii_str_to_int64 (tmp_str, 10, G_MININT64, G_MAXINT64, 0); + errsv = errno; + if (errsv) + nm_log_warn (LOGD_SETTINGS, "Invalid int64 value (%s)", tmp_str); + else + g_object_set (setting, key, int_val, NULL); + g_free (tmp_str); } else if (type == G_TYPE_BYTES) { gint *tmp; GByteArray *array; diff --git a/src/settings/plugins/keyfile/writer.c b/src/settings/plugins/keyfile/writer.c index 77c996095b..02f2d7ff77 100644 --- a/src/settings/plugins/keyfile/writer.c +++ b/src/settings/plugins/keyfile/writer.c @@ -722,6 +722,12 @@ write_setting_value (NMSetting *setting, numstr = g_strdup_printf ("%" G_GUINT64_FORMAT, g_value_get_uint64 (value)); nm_keyfile_plugin_kf_set_value (info->keyfile, setting_name, key, numstr); g_free (numstr); + } else if (type == G_TYPE_INT64) { + char *numstr; + + numstr = g_strdup_printf ("%" G_GINT64_FORMAT, g_value_get_int64 (value)); + nm_keyfile_plugin_kf_set_value (info->keyfile, setting_name, key, numstr); + g_free (numstr); } else if (type == G_TYPE_BOOLEAN) { nm_keyfile_plugin_kf_set_boolean (info->keyfile, setting_name, key, g_value_get_boolean (value)); } else if (type == G_TYPE_CHAR) { |