]> git.ipfire.org Git - people/ms/systemd.git/commitdiff
introduce strv_contains()
authorLennart Poettering <lennart@poettering.net>
Wed, 27 Jan 2010 21:38:21 +0000 (22:38 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 27 Jan 2010 21:38:21 +0000 (22:38 +0100)
strv.c
strv.h

diff --git a/strv.c b/strv.c
index faa878c006748c0e0fc21f4c7ea004636224c73f..7e0810bffe48ddb8b71e82b36d8498d7ec8fbf14 100644 (file)
--- a/strv.c
+++ b/strv.c
@@ -145,3 +145,13 @@ fail:
         return NULL;
 
 }
+
+bool strv_contains(char **l, const char *s) {
+        char **i;
+
+        STRV_FOREACH(i, l)
+                if (streq(*i, s))
+                        return true;
+
+        return false;
+}
diff --git a/strv.h b/strv.h
index 9504cccad4a330ecefd435f7234ebc9624f3ca09..cc21eb19303010cac2c79a9bafeef17cbece5928 100644 (file)
--- a/strv.h
+++ b/strv.h
@@ -12,10 +12,12 @@ unsigned strv_length(char **l);
 
 char **strv_merge(char **a, char **b);
 
+bool strv_contains(char **l, const char *s);
+
 char **strv_new(const char *x, ...) __sentinel;
 
 #define STRV_FOREACH(s, l)                      \
-        for ((s) = (l); (l) && *(s); (s)++)
+        for ((s) = (l); (s) && *(s); (s)++)
 
 #define STRV_FOREACH_BACKWARDS(s, l)            \
         for (; (l) && ((s) >= (l)); (s)--)