File: strfilter.h

package info (click to toggle)
linux 3.2.68-1%2Bdeb7u2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 692,400 kB
  • sloc: ansic: 9,718,050; asm: 244,082; xml: 40,377; makefile: 23,842; perl: 16,079; python: 4,929; sh: 4,425; cpp: 3,596; yacc: 2,979; lex: 1,726; awk: 708; pascal: 231; lisp: 218; sed: 30
file content (48 lines) | stat: -rw-r--r-- 1,305 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef __PERF_STRFILTER_H
#define __PERF_STRFILTER_H
/* General purpose glob matching filter */

#include <linux/list.h>
#include <stdbool.h>

/* A node of string filter */
struct strfilter_node {
	struct strfilter_node *l;	/* Tree left branche (for &,|) */
	struct strfilter_node *r;	/* Tree right branche (for !,&,|) */
	const char *p;		/* Operator or rule */
};

/* String filter */
struct strfilter {
	struct strfilter_node *root;
};

/**
 * strfilter__new - Create a new string filter
 * @rules: Filter rule, which is a combination of glob expressions.
 * @err: Pointer which points an error detected on @rules
 *
 * Parse @rules and return new strfilter. Return NULL if an error detected.
 * In that case, *@err will indicate where it is detected, and *@err is NULL
 * if a memory allocation is failed.
 */
struct strfilter *strfilter__new(const char *rules, const char **err);

/**
 * strfilter__compare - compare given string and a string filter
 * @self: String filter
 * @str: target string
 *
 * Compare @str and @self. Return true if the str match the rule
 */
bool strfilter__compare(struct strfilter *self, const char *str);

/**
 * strfilter__delete - delete a string filter
 * @self: String filter to delete
 *
 * Delete @self.
 */
void strfilter__delete(struct strfilter *self);

#endif