chiark / gitweb /
timedate: remove daylight saving time handling and tzfile parser
[elogind.git] / src / shared / strv.c
index f86dddaf811223b0df1caa8f71c6f0c316440f7b..8c6ba6a6336c1e252218c1c8b6109b81e77e37a1 100644 (file)
@@ -19,7 +19,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <assert.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
@@ -81,9 +80,10 @@ void strv_clear(char **l) {
         *l = NULL;
 }
 
-void strv_free(char **l) {
+char **strv_free(char **l) {
         strv_clear(l);
         free(l);
+        return NULL;
 }
 
 char **strv_copy(char * const *l) {
@@ -524,6 +524,16 @@ char **strv_uniq(char **l) {
         return l;
 }
 
+bool strv_is_uniq(char **l) {
+        char **i;
+
+        STRV_FOREACH(i, l)
+                if (strv_find(i+1, *i))
+                        return false;
+
+        return true;
+}
+
 char **strv_remove(char **l, const char *s) {
         char **f, **t;
 
@@ -664,3 +674,31 @@ int strv_extendf(char ***l, const char *format, ...) {
 
         return strv_consume(l, x);
 }
+
+char **strv_reverse(char **l) {
+        unsigned n, i;
+
+        n = strv_length(l);
+        if (n <= 1)
+                return l;
+
+        for (i = 0; i < n / 2; i++) {
+                char *t;
+
+                t = l[i];
+                l[i] = l[n-1-i];
+                l[n-1-i] = t;
+        }
+
+        return l;
+}
+
+bool strv_fnmatch(char* const* patterns, const char *s, int flags) {
+        char* const* p;
+
+        STRV_FOREACH(p, patterns)
+                if (fnmatch(*p, s, 0) == 0)
+                        return true;
+
+        return false;
+}