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