NeoMutt  2020-04-24
Teaching an old dog new tricks
Go to the documentation of this file.
24 #ifndef MUTT_LIB_LIST_H
25 #define MUTT_LIB_LIST_H
27 #include <stdbool.h>
28 #include "queue.h"
33 struct ListNode
34 {
35  char *data;
36  STAILQ_ENTRY(ListNode) entries;
37 };
38 STAILQ_HEAD(ListHead, ListNode);
44 typedef void (*list_free_t)(void **ptr);
46 void mutt_list_clear(struct ListHead *h);
47 bool mutt_list_compare(const struct ListHead *ah, const struct ListHead *bh);
48 struct ListNode *mutt_list_find(const struct ListHead *h, const char *data);
49 void mutt_list_free(struct ListHead *h);
50 void mutt_list_free_type(struct ListHead *h, list_free_t fn);
51 struct ListNode *mutt_list_insert_after(struct ListHead *h, struct ListNode *n, char *s);
52 struct ListNode *mutt_list_insert_head(struct ListHead *h, char *s);
53 struct ListNode *mutt_list_insert_tail(struct ListHead *h, char *s);
54 bool mutt_list_match(const char *s, struct ListHead *h);
55 struct ListHead mutt_list_str_split(const char *src, char sep);
57 #endif /* MUTT_LIB_LIST_H */
STAILQ_ENTRY(ListNode) entries
Linked list.
STAILQ_HEAD(ListHead, ListNode)
void mutt_list_clear(struct ListHead *h)
Free a list, but NOT its strings.
Definition: list.c:168
struct ListNode * mutt_list_insert_after(struct ListHead *h, struct ListNode *n, char *s)
Insert a string after a given ListNode.
Definition: list.c:85
struct ListNode * mutt_list_find(const struct ListHead *h, const char *data)
Find a string in a List.
Definition: list.c:103
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
bool mutt_list_compare(const struct ListHead *ah, const struct ListHead *bh)
Compare two string lists.
Definition: list.c:219
bool mutt_list_match(const char *s, struct ListHead *h)
Is the string in the list (see notes)
Definition: list.c:196
struct ListHead mutt_list_str_split(const char *src, char sep)
Split a string into a list using a separator char.
Definition: list.c:246
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
Definition: list.c:46
void mutt_list_free_type(struct ListHead *h, list_free_t fn)
Free a List of type.
Definition: list.c:145
char * data
Definition: list.h:35
int n
Definition: acutest.h:492
A List node for strings.
Definition: list.h:33
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
void(* list_free_t)(void **ptr)
Prototype for a function to free List data.
Definition: list.h:44