summaryrefslogtreecommitdiff
path: root/libnm-core/nm-keyfile-utils.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-12-21 19:43:44 +0100
committerThomas Haller <thaller@redhat.com>2017-01-05 12:00:54 +0100
commite965718ddd7069a13da7b7224a1563dcd24a17f6 (patch)
tree64721c6ed9779e01d89fefc7aa6ca63f44111529 /libnm-core/nm-keyfile-utils.c
parent5e7b14af03fef98566367c211c0e7f75ad9a9525 (diff)
downloadNetworkManager-e965718ddd7069a13da7b7224a1563dcd24a17f6.tar.gz
keyfile: add nm_keyfile_plugin_kf_set_integer_list_uint8() helper
Diffstat (limited to 'libnm-core/nm-keyfile-utils.c')
-rw-r--r--libnm-core/nm-keyfile-utils.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libnm-core/nm-keyfile-utils.c b/libnm-core/nm-keyfile-utils.c
index 79b6ea112d..13cf616161 100644
--- a/libnm-core/nm-keyfile-utils.c
+++ b/libnm-core/nm-keyfile-utils.c
@@ -112,6 +112,30 @@ nm_keyfile_plugin_kf_set_##stype##_list (GKeyFile *kf, \
DEFINE_KF_LIST_WRAPPER(integer, gint*, gint);
DEFINE_KF_LIST_WRAPPER(string, gchar **, const gchar* const);
+void
+nm_keyfile_plugin_kf_set_integer_list_uint8 (GKeyFile *kf,
+ const char *group,
+ const char *key,
+ const guint8 *data,
+ gsize length)
+{
+ gsize i;
+ gsize l = length * 4 + 2;
+ gs_free char *value = g_malloc (l);
+ char *s = value;
+
+ g_return_if_fail (kf);
+ g_return_if_fail (!length || data);
+ g_return_if_fail (group && group[0]);
+ g_return_if_fail (key && key[0]);
+
+ value[0] = '\0';
+ for (i = 0; i < length; i++)
+ nm_utils_strbuf_append (&s, &l, "%d;", (int) data[i]);
+ nm_assert (l > 0);
+ nm_keyfile_plugin_kf_set_value (kf, group, key, value);
+}
+
/* Single value helpers */
#define DEFINE_KF_WRAPPER(stype, get_ctype, set_ctype) \
get_ctype \