summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-07-27 23:33:16 +0200
committerThomas Haller <thaller@redhat.com>2014-08-22 15:22:16 +0200
commitff142ce780c8d524b54431db1a523ee36fc1867a (patch)
treef6776ef9685a5fb08963eebb7c2a838c42f77d26
parentd299c425d4495453743e0bc3884dbeb0a7405108 (diff)
downloadNetworkManager-ff142ce780c8d524b54431db1a523ee36fc1867a.tar.gz
libnm-core: add _nm_utils_hash_values_to_slist()
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--libnm-core/nm-core-internal.h3
-rw-r--r--libnm-core/nm-utils.c28
2 files changed, 31 insertions, 0 deletions
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
index fdf2397d6d..1e6dd63892 100644
--- a/libnm-core/nm-core-internal.h
+++ b/libnm-core/nm-core-internal.h
@@ -61,4 +61,7 @@ gboolean _nm_setting_ip4_config_add_address_with_label (NMSettingIP4Config *s
NM_SETTING_SECRET_FLAG_NOT_REQUIRED)
+GSList * _nm_utils_hash_values_to_slist (GHashTable *hash);
+
+
#endif
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 4f91c1e1fa..fd99bfd206 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -536,6 +536,34 @@ done:
return valid;
}
+/**
+ * _nm_utils_hash_values_to_slist:
+ * @hash: a #GHashTable
+ *
+ * Utility function to iterate over a hash table and return
+ * it's values as a #GSList.
+ *
+ * Returns: (element-type gpointer) (transfer container): a newly allocated #GSList
+ * containing the values of the hash table. The caller must free the
+ * returned list with g_slist_free(). The hash values are not owned
+ * by the returned list.
+ **/
+GSList *
+_nm_utils_hash_values_to_slist (GHashTable *hash)
+{
+ GSList *list = NULL;
+ GHashTableIter iter;
+ void *value;
+
+ g_return_val_if_fail (hash, NULL);
+
+ g_hash_table_iter_init (&iter, hash);
+ while (g_hash_table_iter_next (&iter, NULL, &value))
+ list = g_slist_prepend (list, value);
+
+ return list;
+}
+
static gboolean
device_supports_ap_ciphers (guint32 dev_caps,
guint32 ap_flags,