diff options
author | Thomas Haller <thaller@redhat.com> | 2018-08-13 21:21:14 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-08-22 10:49:30 +0200 |
commit | c06a55958b96d549726411efd5583ea05df62a86 (patch) | |
tree | 6a2a66f73763aa5689ee6c5ef31f9b953d428bee | |
parent | cd79a22d186e2bd465a84bd9340a8971f4542090 (diff) | |
download | NetworkManager-c06a55958b96d549726411efd5583ea05df62a86.tar.gz |
shared: add nm_utils_gbytes_to_variant_ay() util
-rw-r--r-- | shared/nm-utils/nm-shared-utils.c | 17 | ||||
-rw-r--r-- | shared/nm-utils/nm-shared-utils.h | 4 |
2 files changed, 21 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-shared-utils.c b/shared/nm-utils/nm-shared-utils.c index 96b5f2acab..43981e3177 100644 --- a/shared/nm-utils/nm-shared-utils.c +++ b/shared/nm-utils/nm-shared-utils.c @@ -117,6 +117,23 @@ nm_utils_strbuf_append (char **buf, gsize *len, const char *format, ...) /*****************************************************************************/ +GVariant * +nm_utils_gbytes_to_variant_ay (GBytes *bytes) +{ + const guint8 *p; + gsize l; + + if (!bytes) { + /* for convenience, accept NULL to return an empty variant */ + return g_variant_new_array (G_VARIANT_TYPE_BYTE, NULL, 0); + } + + p = g_bytes_get_data (bytes, &l); + return g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, p, l, 1); +} + +/*****************************************************************************/ + /** * nm_strquote: * @buf: the output buffer of where to write the quoted @str argument. diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h index 265d2ded36..0670c6c2f6 100644 --- a/shared/nm-utils/nm-shared-utils.h +++ b/shared/nm-utils/nm-shared-utils.h @@ -202,6 +202,10 @@ nm_utils_is_separator (const char c) /*****************************************************************************/ +GVariant *nm_utils_gbytes_to_variant_ay (GBytes *bytes); + +/*****************************************************************************/ + const char *nm_utils_dbus_path_get_last_component (const char *dbus_path); int nm_utils_dbus_path_cmp (const char *dbus_path_a, const char *dbus_path_b); |