blob: 2fdcfee87586ab47d69f49cc5ceaf2d71aceadc6 [file] [log] [blame]
Arnaldo Carvalho de Melo25903402009-06-30 19:01:20 -03001#ifndef STRLIST_H_
2#define STRLIST_H_
3
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -03004#include <linux/rbtree.h>
Arnaldo Carvalho de Melo25903402009-06-30 19:01:20 -03005#include <stdbool.h>
6
7struct str_node {
8 struct rb_node rb_node;
9 const char *s;
10};
11
12struct strlist {
13 struct rb_root entries;
14 bool dupstr;
15};
16
17struct strlist *strlist__new(bool dupstr, const char *slist);
18void strlist__delete(struct strlist *self);
19
20void strlist__remove(struct strlist *self, struct str_node *sn);
21int strlist__load(struct strlist *self, const char *filename);
22int strlist__add(struct strlist *self, const char *str);
23
24bool strlist__has_entry(struct strlist *self, const char *entry);
25
26static inline bool strlist__empty(const struct strlist *self)
27{
28 return rb_first(&self->entries) == NULL;
29}
30
31int strlist__parse_list(struct strlist *self, const char *s);
32#endif /* STRLIST_H_ */