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