![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 #ifndef __PERF_STRFILTER_H 0003 #define __PERF_STRFILTER_H 0004 /* General purpose glob matching filter */ 0005 0006 #include <linux/list.h> 0007 #include <stdbool.h> 0008 0009 /* A node of string filter */ 0010 struct strfilter_node { 0011 struct strfilter_node *l; /* Tree left branch (for &,|) */ 0012 struct strfilter_node *r; /* Tree right branch (for !,&,|) */ 0013 const char *p; /* Operator or rule */ 0014 }; 0015 0016 /* String filter */ 0017 struct strfilter { 0018 struct strfilter_node *root; 0019 }; 0020 0021 /** 0022 * strfilter__new - Create a new string filter 0023 * @rules: Filter rule, which is a combination of glob expressions. 0024 * @err: Pointer which points an error detected on @rules 0025 * 0026 * Parse @rules and return new strfilter. Return NULL if an error detected. 0027 * In that case, *@err will indicate where it is detected, and *@err is NULL 0028 * if a memory allocation is failed. 0029 */ 0030 struct strfilter *strfilter__new(const char *rules, const char **err); 0031 0032 /** 0033 * strfilter__or - Append an additional rule by logical-or 0034 * @filter: Original string filter 0035 * @rules: Filter rule to be appended at left of the root of 0036 * @filter by using logical-or. 0037 * @err: Pointer which points an error detected on @rules 0038 * 0039 * Parse @rules and join it to the @filter by using logical-or. 0040 * Return 0 if success, or return the error code. 0041 */ 0042 int strfilter__or(struct strfilter *filter, 0043 const char *rules, const char **err); 0044 0045 /** 0046 * strfilter__add - Append an additional rule by logical-and 0047 * @filter: Original string filter 0048 * @rules: Filter rule to be appended at left of the root of 0049 * @filter by using logical-and. 0050 * @err: Pointer which points an error detected on @rules 0051 * 0052 * Parse @rules and join it to the @filter by using logical-and. 0053 * Return 0 if success, or return the error code. 0054 */ 0055 int strfilter__and(struct strfilter *filter, 0056 const char *rules, const char **err); 0057 0058 /** 0059 * strfilter__compare - compare given string and a string filter 0060 * @filter: String filter 0061 * @str: target string 0062 * 0063 * Compare @str and @filter. Return true if the str match the rule 0064 */ 0065 bool strfilter__compare(struct strfilter *filter, const char *str); 0066 0067 /** 0068 * strfilter__delete - delete a string filter 0069 * @filter: String filter to delete 0070 * 0071 * Delete @filter. 0072 */ 0073 void strfilter__delete(struct strfilter *filter); 0074 0075 /** 0076 * strfilter__string - Reconstruct a rule string from filter 0077 * @filter: String filter to reconstruct 0078 * 0079 * Reconstruct a rule string from @filter. This will be good for 0080 * debug messages. Note that returning string must be freed afterward. 0081 */ 0082 char *strfilter__string(struct strfilter *filter); 0083 0084 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |