ARM: dts: kirkwood: gpio-leds fixes for linkstation ls-wvl/vl
[linux/fpc-iii.git] / tools / perf / util / strfilter.h
blobcff5eda88728b20e9ebae22d7476ed14f367869c
1 #ifndef __PERF_STRFILTER_H
2 #define __PERF_STRFILTER_H
3 /* General purpose glob matching filter */
5 #include <linux/list.h>
6 #include <stdbool.h>
8 /* A node of string filter */
9 struct strfilter_node {
10 struct strfilter_node *l; /* Tree left branche (for &,|) */
11 struct strfilter_node *r; /* Tree right branche (for !,&,|) */
12 const char *p; /* Operator or rule */
15 /* String filter */
16 struct strfilter {
17 struct strfilter_node *root;
20 /**
21 * strfilter__new - Create a new string filter
22 * @rules: Filter rule, which is a combination of glob expressions.
23 * @err: Pointer which points an error detected on @rules
25 * Parse @rules and return new strfilter. Return NULL if an error detected.
26 * In that case, *@err will indicate where it is detected, and *@err is NULL
27 * if a memory allocation is failed.
29 struct strfilter *strfilter__new(const char *rules, const char **err);
31 /**
32 * strfilter__or - Append an additional rule by logical-or
33 * @filter: Original string filter
34 * @rules: Filter rule to be appended at left of the root of
35 * @filter by using logical-or.
36 * @err: Pointer which points an error detected on @rules
38 * Parse @rules and join it to the @filter by using logical-or.
39 * Return 0 if success, or return the error code.
41 int strfilter__or(struct strfilter *filter,
42 const char *rules, const char **err);
44 /**
45 * strfilter__add - Append an additional rule by logical-and
46 * @filter: Original string filter
47 * @rules: Filter rule to be appended at left of the root of
48 * @filter by using logical-and.
49 * @err: Pointer which points an error detected on @rules
51 * Parse @rules and join it to the @filter by using logical-and.
52 * Return 0 if success, or return the error code.
54 int strfilter__and(struct strfilter *filter,
55 const char *rules, const char **err);
57 /**
58 * strfilter__compare - compare given string and a string filter
59 * @filter: String filter
60 * @str: target string
62 * Compare @str and @filter. Return true if the str match the rule
64 bool strfilter__compare(struct strfilter *filter, const char *str);
66 /**
67 * strfilter__delete - delete a string filter
68 * @filter: String filter to delete
70 * Delete @filter.
72 void strfilter__delete(struct strfilter *filter);
74 /**
75 * strfilter__string - Reconstruct a rule string from filter
76 * @filter: String filter to reconstruct
78 * Reconstruct a rule string from @filter. This will be good for
79 * debug messages. Note that returning string must be freed afterward.
81 char *strfilter__string(struct strfilter *filter);
83 #endif