strfilter.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef __PERF_STRFILTER_H
  2. #define __PERF_STRFILTER_H
  3. /* General purpose glob matching filter */
  4. #include <linux/list.h>
  5. #include <stdbool.h>
  6. /* A node of string filter */
  7. struct strfilter_node {
  8. struct strfilter_node *l; /* Tree left branche (for &,|) */
  9. struct strfilter_node *r; /* Tree right branche (for !,&,|) */
  10. const char *p; /* Operator or rule */
  11. };
  12. /* String filter */
  13. struct strfilter {
  14. struct strfilter_node *root;
  15. };
  16. /**
  17. * strfilter__new - Create a new string filter
  18. * @rules: Filter rule, which is a combination of glob expressions.
  19. * @err: Pointer which points an error detected on @rules
  20. *
  21. * Parse @rules and return new strfilter. Return NULL if an error detected.
  22. * In that case, *@err will indicate where it is detected, and *@err is NULL
  23. * if a memory allocation is failed.
  24. */
  25. struct strfilter *strfilter__new(const char *rules, const char **err);
  26. /**
  27. * strfilter__compare - compare given string and a string filter
  28. * @self: String filter
  29. * @str: target string
  30. *
  31. * Compare @str and @self. Return true if the str match the rule
  32. */
  33. bool strfilter__compare(struct strfilter *self, const char *str);
  34. /**
  35. * strfilter__delete - delete a string filter
  36. * @self: String filter to delete
  37. *
  38. * Delete @self.
  39. */
  40. void strfilter__delete(struct strfilter *self);
  41. #endif