strlist.h 763 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef STRLIST_H_
  2. #define STRLIST_H_
  3. #include "rbtree.h"
  4. #include <stdbool.h>
  5. struct str_node {
  6. struct rb_node rb_node;
  7. const char *s;
  8. };
  9. struct strlist {
  10. struct rb_root entries;
  11. bool dupstr;
  12. };
  13. struct strlist *strlist__new(bool dupstr, const char *slist);
  14. void strlist__delete(struct strlist *self);
  15. void strlist__remove(struct strlist *self, struct str_node *sn);
  16. int strlist__load(struct strlist *self, const char *filename);
  17. int strlist__add(struct strlist *self, const char *str);
  18. bool strlist__has_entry(struct strlist *self, const char *entry);
  19. static inline bool strlist__empty(const struct strlist *self)
  20. {
  21. return rb_first(&self->entries) == NULL;
  22. }
  23. int strlist__parse_list(struct strlist *self, const char *s);
  24. #endif /* STRLIST_H_ */