summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/strv.c17
-rw-r--r--src/shared/strv.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c
index 6448f3170f..0df978d23b 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -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;
diff --git a/src/shared/strv.h b/src/shared/strv.h
index ee55c148aa..9c9633c515 100644
--- a/src/shared/strv.h
+++ b/src/shared/strv.h
@@ -28,6 +28,7 @@
char *strv_find(char **l, const char *name) _pure_;
char *strv_find_prefix(char **l, const char *name) _pure_;
+char *strv_find_startswith(char **l, const char *name) _pure_;
void strv_free(char **l);
DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free);