summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-08-28 19:03:58 +0200
committerThomas Haller <thaller@redhat.com>2014-11-07 15:19:06 +0100
commit627ad6f8056137244c6671eb18670ee227acb788 (patch)
treed82b474e3848e0c8ab96c50459aa05a54fb8db78
parent808ad85ff4f0a4905f8e81be04d04a784402bc24 (diff)
downloadNetworkManager-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.c14
-rw-r--r--src/settings/plugins/keyfile/writer.c6
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) {