-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrule.h
More file actions
52 lines (44 loc) · 961 Bytes
/
rule.h
File metadata and controls
52 lines (44 loc) · 961 Bytes
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
49
50
51
52
#ifndef RULE_TREE_H
#define RULE_TREE_H
#include <sys/types.h>
#include <regex.h>
#include "fetch.h"
enum tnode_type {TNUL, OPERAND, OPERATOR, PARETHESE};
enum tnode_name {NNUL, AND, OR, NOT, /*NUL = -1*/};
//enum tnode_ret {FALSE, TRUE};
enum tnode_opet {REGEX, STREQ, EQ, GT, LT, GE, LE, NE, OPET_MAX};
struct tree_node
{
enum tnode_type type;
union {
enum tnode_name oname;
enum log_entry ename;
}name;
enum tnode_opet op;
union {
int inte;
char *str;
regex_t reg;
}operand;
int ret;
int rvisited;
struct tree_node *left;
struct tree_node *right;
struct tree_node *parent;
};
struct stack {
struct tree_node *top;
struct tree_node *base;
int size;
};
struct opet_map{
char *name;
enum tnode_opet opet;
};
extern struct opet_map opet_map[];
int init_stack(void);
int push(struct tree_node *entry);
struct tree_node *pop();
struct tree_node *gen_rule_tree();
int traverse_rule_tree(void *log, struct tree_node *root);
#endif