diff options
author | Thomas Haller <thaller@redhat.com> | 2016-12-21 19:43:44 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-01-04 14:54:04 +0100 |
commit | e343d9a8307e512032b58d84f27f966c0b6cab1d (patch) | |
tree | 77cc2fa19f2bd987ed776782241b3ccab48d0861 | |
parent | c46468565fdac61356633246a9f880bb63f49f39 (diff) | |
download | NetworkManager-e343d9a8307e512032b58d84f27f966c0b6cab1d.tar.gz |
keyfile: add nm_keyfile_plugin_kf_set_integer_list_uint8() helper
-rw-r--r-- | libnm-core/nm-keyfile-utils.c | 24 | ||||
-rw-r--r-- | libnm-core/nm-keyfile-utils.h | 6 |
2 files changed, 30 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 \ diff --git a/libnm-core/nm-keyfile-utils.h b/libnm-core/nm-keyfile-utils.h index e7d803ce1e..89fd3041a0 100644 --- a/libnm-core/nm-keyfile-utils.h +++ b/libnm-core/nm-keyfile-utils.h @@ -47,6 +47,12 @@ void nm_keyfile_plugin_kf_set_##stype##_list (GKeyFile *kf, \ DEFINE_KF_LIST_WRAPPER_PROTO(integer, gint*, gint) DEFINE_KF_LIST_WRAPPER_PROTO(string, gchar**, const gchar* const) +void nm_keyfile_plugin_kf_set_integer_list_uint8 (GKeyFile *kf, + const char *group, + const char *key, + const guint8 *list, + gsize length); + /* Single-value helpers */ #define DEFINE_KF_WRAPPER_PROTO(stype, get_ctype, set_ctype) \ get_ctype nm_keyfile_plugin_kf_get_##stype (GKeyFile *kf, \ |