summaryrefslogtreecommitdiff
path: root/pith/rulestype.h
blob: 8e7ddd9e58a4b3bff1acd4720c21c0ee9c60c5fd (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef PITH_RULESTYPE_INCLUDED
#define PITH_RULESTYPE_INCLUDED

typedef struct rule {
	char *result;	/* The result of the rule */
	int number;	/* The number of the rule that succeded, -1 if not */
} RULE_RESULT;

typedef struct {
        char    *value;
        int     type;
} RULE_ACTION;


#define TOKEN_VALUE	struct tokenvalue_s
#define CONDITION_S	struct condition_s
#define RULEACTION_S	struct ruleaction_s
#define RULE_S		struct rule_s
#define RULELIST	struct rulelist_s
#define PRULELIST_S	struct parsedrulelist_s

#define FREEREGEX	1

TOKEN_VALUE {
	char	*testxt;
	void	*voidtxt;
	int	codefcn;
	TOKEN_VALUE *next;
};

typedef enum {Equal, Subset, Includes, NotEqual, NotSubset, NotIncludes, EndTypes} TestType;

typedef enum {And, Or, ParOpen, ParClose, Condition} CondType;

typedef struct condvalue_s {
    char	*tname;		/* tname ttype {value} */
    TestType	ttype;		/* type of rule */
    TOKEN_VALUE	*value;		/* value to check against */
} CONDVALUE_S;

CONDITION_S {
    void     *cndrule;		/* text in condition */
    CondType  cndtype;		/* type of object    */
    CONDITION_S	*next;		/* next condition to test */
};

#define COND(C)  ((CONDVALUE_S *)((C)->cndrule))

RULEACTION_S {
   char *token;		/* token := function{value} or token = null  */
   char *function;	/* token := function{value} or simply function{value}*/
   TOKEN_VALUE  *value; /* token := function{value} or simply function{value}*/
   int   context;	/* context in which this rule can be used */
   char* (*exec)();
   unsigned int is_trim:1;
   unsigned int is_rextrim:1;
   unsigned int is_replace:1;
};

RULE_S {
  CONDITION_S  *condition;
  RULEACTION_S *action;
};

RULELIST {
   RULE_S *prule;
   RULELIST *next;
};

PRULELIST_S {
   int varnum;		/* number associated to the variable */
   RULELIST *rlist;
   PRULELIST_S *next;
};

#define USE_RAW_SP      0x001
#define PROCESS_SP      0x010

typedef struct sparep {
   int flag;
   char *value;
} SPAREP_S;


#endif	/* PITH_RULESTYPE_INCLUDED */