aboutsummaryrefslogtreecommitdiffstats
path: root/common/strlist.c
diff options
context:
space:
mode:
authorNeal H. Walfield <[email protected]>2015-03-13 14:08:22 +0000
committerNeal H. Walfield <[email protected]>2015-03-23 18:58:25 +0000
commit79907ad256f5b84f36cbebdc92e5a05d9e266557 (patch)
treecbcd88d331b16c85d2e4c589707c55ef12510da3 /common/strlist.c
parentcommon: Add new helper function, strsplit. (diff)
downloadgnupg-79907ad256f5b84f36cbebdc92e5a05d9e266557.tar.gz
gnupg-79907ad256f5b84f36cbebdc92e5a05d9e266557.zip
Add new function strlist_find.
* common/strlist.h (strlist_find): New declaration. * common/strlist.c (strlist_find): New function. -- Signed-off-by: Neal H. Walfield <[email protected]>
Diffstat (limited to 'common/strlist.c')
-rw-r--r--common/strlist.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/common/strlist.c b/common/strlist.c
index d9aed16f2..6816dcf1a 100644
--- a/common/strlist.c
+++ b/common/strlist.c
@@ -1,5 +1,6 @@
/* strlist.c - string helpers
* Copyright (C) 1998, 2000, 2001, 2006 Free Software Foundation, Inc.
+ * Copyright (C) 2015 g10 Code GmbH
*
* This file is part of JNLIB, which is a subsystem of GnuPG.
*
@@ -212,3 +213,16 @@ strlist_pop (strlist_t *list)
return str;
}
+
+/* Return the first element of the string list HAYSTACK whose string
+ matches NEEDLE. If no elements match, return NULL. */
+strlist_t
+strlist_find (strlist_t haystack, const char *needle)
+{
+ for (;
+ haystack;
+ haystack = haystack->next)
+ if (strcmp (haystack->d, needle) == 0)
+ return haystack;
+ return NULL;
+}