From e0dfa472d1d32268d08a91cc37606bd0ec803a11 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 18 Sep 2008 15:12:43 +0000 Subject: Add new functions, rc_stringlist_find and rc_stringlist_split. --- src/librc/librc-stringlist.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/librc/librc-stringlist.c') diff --git a/src/librc/librc-stringlist.c b/src/librc/librc-stringlist.c index 4dc07030..35889fb7 100644 --- a/src/librc/librc-stringlist.c +++ b/src/librc/librc-stringlist.c @@ -80,6 +80,31 @@ bool rc_stringlist_delete(RC_STRINGLIST *list, const char *value) } librc_hidden_def(rc_stringlist_delete) +RC_STRING *rc_stringlist_find(RC_STRINGLIST *list, const char *value) +{ + RC_STRING *s; + + TAILQ_FOREACH(s, list, entries) + if (strcmp(s->value, value) == 0) + return s; + return NULL; +} +librc_hidden_def(rc_stringlist_find) + +RC_STRINGLIST *rc_stringlist_split(const char *value, const char *sep) +{ + RC_STRINGLIST *list = rc_stringlist_new(); + char *d = xstrdup(value); + char *p = d, *token; + + while ((token = strsep(&p, sep))) + rc_stringlist_add(list, token); + free(d); + + return list; +} +librc_hidden_def(rc_stringlist_split) + void rc_stringlist_sort(RC_STRINGLIST **list) { RC_STRINGLIST *l = *list; -- cgit v1.2.3