summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-07-16 10:36:19 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2015-07-20 15:22:59 +0200
commit229f715aaa2d581a0e6db7d989de8c3063b1b20e (patch)
treeec9155076d07ad05e1520485d1f6a6496df38845
parentf0d8111bc5626b2cfa7e00b3c554c6faef39a39b (diff)
downloadNetworkManager-229f715aaa2d581a0e6db7d989de8c3063b1b20e.tar.gz
libnm-core: add _nm_utils_strv_equal()
-rw-r--r--libnm-core/nm-core-internal.h1
-rw-r--r--libnm-core/nm-utils.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
index f05528b3e4..380a2bb4e3 100644
--- a/libnm-core/nm-core-internal.h
+++ b/libnm-core/nm-core-internal.h
@@ -135,6 +135,7 @@ char ** _nm_utils_slist_to_strv (GSList *slist, gboolean deep_copy);
GPtrArray * _nm_utils_strv_to_ptrarray (char **strv);
char ** _nm_utils_ptrarray_to_strv (GPtrArray *ptrarray);
+gboolean _nm_utils_strv_equal (char **strv1, char **strv2);
#define NM_UTILS_UUID_TYPE_LEGACY 0
#define NM_UTILS_UUID_TYPE_VARIANT3 1
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 478e6806db..31382c7085 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -845,6 +845,30 @@ _nm_utils_ptrarray_to_strv (GPtrArray *ptrarray)
}
/**
+ * _nm_utils_strv_equal:
+ * @strv1: a string array
+ * @strv2: a string array
+ *
+ * Compare NULL-terminated string arrays for equality.
+ *
+ * Returns: %TRUE if the arrays are equal, %FALSE otherwise.
+ **/
+gboolean
+_nm_utils_strv_equal (char **strv1, char **strv2)
+{
+ if (strv1 == strv2)
+ return TRUE;
+
+ if (!strv1 || !strv2)
+ return FALSE;
+
+ for ( ; *strv1 && *strv2 && !strcmp (*strv1, *strv2); strv1++, strv2++)
+ ;
+
+ return !*strv1 && !*strv2;
+}
+
+/**
* _nm_utils_strsplit_set:
* @str: string to split
* @delimiters: string of delimiter characters