libsodium: Needed for Dnscrypto-proxy Release 1.3.0
[tomato.git] / release / src / router / hotplug2 / rules.h
blob0cff3fb2eb1ad0a22b19ce904c139edb4013ba35
1 /*****************************************************************************\
2 * _ _ _ _ ___ *
3 * | || | ___ | |_ _ __ | | _ _ __ _ |_ ) *
4 * | __ |/ _ \| _|| '_ \| || || |/ _` | / / *
5 * |_||_|\___/ \__|| .__/|_| \_,_|\__, |/___| *
6 * |_| |___/ *
7 \*****************************************************************************/
9 #ifndef RULES_H
10 #define RULES_H 1
12 #define COND_MATCH_CMP 0 /* == */
13 #define COND_MATCH_RE 1 /* ~~ */
14 #define COND_NMATCH_CMP 2 /* != */
15 #define COND_NMATCH_RE 3 /* !~ */
16 #define COND_MATCH_IS 4 /* is */
18 #define ACT_RUN_SHELL 0 /* system app <...>, run app <...> */
19 #define ACT_RUN_NOSHELL 1 /* exec app <...> */
20 #define ACT_STOP_PROCESSING 2 /* break */
21 #define ACT_STOP_IF_FAILED 3 /* break_if_failed */
22 #define ACT_MAKE_DEVICE 4 /* makedev <...> */
23 #define ACT_CHMOD 5 /* chmod <...> */
24 #define ACT_CHGRP 6 /* chgrp <...> */
25 #define ACT_CHOWN 7 /* chown <...> */
26 #define ACT_SYMLINK 8 /* symlink <...> */
27 #define ACT_NEXT_EVENT 9 /* next */
28 #define ACT_NEXT_IF_FAILED 10 /* next_if_failed */
29 #define ACT_SETENV 11 /* setenv <...> */
30 #define ACT_REMOVE 12 /* remove <...> */
31 #define ACT_DEBUG 13 /* debug */
32 #define ACT_FLAG_NOTHROTTLE 14 /* sets 'nothrottle' flag */
34 #define EVAL_MATCH 1
35 #define EVAL_NOT_MATCH 0
36 #define EVAL_NOT_AVAILABLE -1
38 #define QUOTES_NONE 0
39 #define QUOTES_SINGLE 1
40 #define QUOTES_DOUBLE 2
42 #define STATUS_KEY 0 /* just about anything */
43 #define STATUS_CONDTYPE 1 /* viz COND_* */
44 #define STATUS_VALUE 2 /* just about anything */
45 #define STATUS_INITIATOR 3 /* ',' for next cond, '{' for block*/
46 #define STATUS_ACTION 4 /* viz ACT_* and '}' for end of block */
48 #define FLAG_UNSET 0
49 #define FLAG_ALL 0xffffffff
50 #define FLAG_NOTHROTTLE 1 /* We want this rule to ignore max_children limit */
52 struct key_rec_t {
53 char *key;
54 int param;
55 int type;
58 struct condition_t {
59 int type;
60 char *key;
61 char *value;
64 struct action_t {
65 int type;
66 char **parameter;
69 struct rule_t {
70 struct condition_t *conditions;
71 int conditions_c;
73 struct action_t *actions;
74 int actions_c;
76 unsigned int flags;
79 struct rules_t {
80 struct rule_t *rules;
81 int rules_c;
84 int rule_condition_eval(struct hotplug2_event_t *, struct condition_t *);
85 int rule_execute(struct hotplug2_event_t *, struct rule_t *);
86 void rule_flags(struct rule_t *);
87 void rules_free(struct rules_t *);
88 struct rules_t *rules_from_config(char *, struct rules_t *);
90 #endif /* ifndef RULES_H*/