14 #define is_operator(c) ((c) == '|' || (c) == '&' || (c) == '!') 15 #define is_separator(c) (is_operator(c) || (c) == '(' || (c) == ')') 36 static const char *
get_token(
const char *s,
const char **e)
55 if (*(p - 1) ==
'\\' || (*p ==
'!' && *(p - 1) ==
'[')) {
89 memset(&root, 0,
sizeof(root));
90 last_op = cur = &
root;
93 while (*s !=
'\0' && *s !=
')') {
96 if (!cur->
r || !last_op->
r)
105 if (!cur->
r || !root.
r)
127 if (!cur->
r || *s !=
')')
137 cur->
r->
p = strndup(s, e - s);
162 const char *ep = NULL;
167 if (!filter || !filter->
root || *ep !=
'\0') {
178 const char *rules,
const char **
err)
181 const char *ep = NULL;
183 if (!filter || !rules)
187 if (!right || *ep !=
'\0') {
203 return ep ? -EINVAL : -ENOMEM;
220 if (!node || !node->
p)
251 int pt = node->
r ? 2 : 0;
267 if (!node || !node->
p)
279 *(buf + len++) = *node->
p;
289 len = strlen(node->
p);
291 strcpy(buf, node->
p);
struct strfilter * strfilter__new(const char *rules, const char **err)
static const char * OP_and
static int strfilter_node__sprint_pt(struct strfilter_node *node, char *buf)
struct strfilter_node * root
bool strglobmatch(const char *str, const char *pat)
static int strfilter__append(struct strfilter *filter, bool _or, const char *rules, const char **err)
int strfilter__or(struct strfilter *filter, const char *rules, const char **err)
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
void strfilter__delete(struct strfilter *filter)
static const char * OP_not
static int str(yyscan_t scanner, int token)
struct strfilter_node * r
struct strfilter_node * l
static struct strfilter_node * strfilter_node__alloc(const char *op, struct strfilter_node *l, struct strfilter_node *r)
char * strfilter__string(struct strfilter *filter)
bool strfilter__compare(struct strfilter *filter, const char *str)
static struct strfilter_node * strfilter_node__new(const char *s, const char **ep)
struct strfilter * filter
int strfilter__and(struct strfilter *filter, const char *rules, const char **err)
static bool strfilter_node__compare(struct strfilter_node *node, const char *str)
static void strfilter_node__delete(struct strfilter_node *node)
static const char * get_token(const char *s, const char **e)
static int strfilter_node__sprint(struct strfilter_node *node, char *buf)
static const char * OP_or
void static void * zalloc(size_t size)