mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +01:00
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 <neal@g10code.de>
This commit is contained in:
parent
b18ffcb81a
commit
79907ad256
@ -1,5 +1,6 @@
|
|||||||
/* strlist.c - string helpers
|
/* strlist.c - string helpers
|
||||||
* Copyright (C) 1998, 2000, 2001, 2006 Free Software Foundation, Inc.
|
* 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.
|
* This file is part of JNLIB, which is a subsystem of GnuPG.
|
||||||
*
|
*
|
||||||
@ -212,3 +213,16 @@ strlist_pop (strlist_t *list)
|
|||||||
|
|
||||||
return str;
|
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;
|
||||||
|
}
|
||||||
|
@ -55,6 +55,9 @@ strlist_t strlist_prev (strlist_t head, strlist_t node);
|
|||||||
strlist_t strlist_last (strlist_t node);
|
strlist_t strlist_last (strlist_t node);
|
||||||
char * strlist_pop (strlist_t *list);
|
char * strlist_pop (strlist_t *list);
|
||||||
|
|
||||||
|
strlist_t strlist_find (strlist_t haystack, const char *needle);
|
||||||
|
|
||||||
|
|
||||||
#define FREE_STRLIST(a) do { free_strlist((a)); (a) = NULL ; } while(0)
|
#define FREE_STRLIST(a) do { free_strlist((a)); (a) = NULL ; } while(0)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user