chiark / gitweb /
service,strv: introduce strv_find_startswith() and make use of it
[elogind.git] / src / shared / strv.c
index 6448f3170fc837ac6ef7035fb8506bc9c430ab52..0df978d23b911f53be7e7c597e01c8b26c28a2a6 100644 (file)
@@ -52,6 +52,23 @@ char *strv_find_prefix(char **l, const char *name) {
         return NULL;
 }
 
+char *strv_find_startswith(char **l, const char *name) {
+        char **i, *e;
+
+        assert(name);
+
+        /* Like strv_find_prefix, but actually returns only the
+         * suffix, not the whole item */
+
+        STRV_FOREACH(i, l) {
+                e = startswith(*i, name);
+                if (e)
+                        return e;
+        }
+
+        return NULL;
+}
+
 void strv_free(char **l) {
         char **k;