From: Rocco Rutte Date: Wed, 13 May 2009 12:19:26 +0000 (+0200) Subject: Add mutt_find_list() to lookup data in lists X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3f3f8b3d84a4f953d7540304edc0705f0df36d5;p=neomutt Add mutt_find_list() to lookup data in lists --- diff --git a/mutt.h b/mutt.h index 5ee1f1ba6..06cdab8b3 100644 --- a/mutt.h +++ b/mutt.h @@ -552,6 +552,7 @@ int mutt_matches_ignore (const char *, LIST *); /* add an element to a list */ LIST *mutt_add_list (LIST *, const char *); LIST *mutt_add_list_n (LIST*, const void *, size_t); +LIST *mutt_find_list (LIST *, const char *); void mutt_init (int, LIST *); diff --git a/muttlib.c b/muttlib.c index a031941cc..590bef7a8 100644 --- a/muttlib.c +++ b/muttlib.c @@ -252,6 +252,21 @@ LIST *mutt_add_list_n (LIST *head, const void *data, size_t len) return head; } +LIST *mutt_find_list (LIST *l, const char *data) +{ + LIST *p = l; + + while (p) + { + if (data == p->data) + return p; + if (data && p->data && mutt_strcmp (p->data, data) == 0) + return p; + p = p->next; + } + return NULL; +} + void mutt_free_list (LIST **list) { LIST *p;