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 #ifndef OBJECT_H
30 #define OBJECT_H
31
32 #include "../public/nsapi.h"
33 #include "pool.h"
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39
40 enum RequestStage {
41 NSAPIAuthTrans =
0,
42 NSAPINameTrans,
43 NSAPIPathCheck,
44 NSAPIObjectType,
45 NSAPIService,
46 NSAPIError,
47 NSAPIAddLog,
48 REQ_FINISH,
49 NUM_NSAPI_TYPES
50 };
51 typedef enum RequestStage RequestStage;
52
53 typedef struct Condition Condition;
54 typedef int8_t ConditionResult;
55 typedef struct Expression Expression;
56 typedef enum OperandType OperandType;
57 typedef enum Operator Operator;
58 typedef enum VarType VarType;
59
60 typedef struct NSAPIContext NSAPIContext;
61 typedef struct HTTPObjectConfig HTTPObjectConfig;
62
63 struct directive {
64 FuncStruct *func;
65 pblock *param;
66 Condition *cond;
67 };
68
69 struct dtable {
70 directive **dirs;
71 int ndir;
72 };
73
74 struct httpd_object {
75 pool_handle_t *pool;
76 char *name;
77 char *path;
78 dtable *dt;
79 int nd;
80 };
81
82 struct httpd_objset {
83 httpd_object **obj;
84 int pos;
85 };
86
87 struct Condition {
88 Condition *parent;
89 Expression *expression;
90 int index;
91 };
92
93 struct Expression {
94
95 int n;
96 };
97
98
99 struct NSAPIContext{
100 HTTPObjectConfig *conf;
101
102 ConditionResult **results;
103 int nres;
104 int nmaxres;
105
106
107 int last_req_code;
108
109 int objset_index;
110 int dtable_index;
111 };
112
113 struct HTTPObjectConfig {
114 httpd_object **objects;
115 int nobj;
116 pool_handle_t *pool;
117 uint32_t ref;
118 };
119
120
121
122
123 httpd_object* object_new(
pool_handle_t *pool,
char *name);
124
125
126
127
128 void object_free(httpd_object *obj);
129
130
131
132
133 void object_add_directive(httpd_object *obj, directive *dir,
int dt);
134
135
136
137
138 #define object_get_dtable(obj,type) &obj->dt[type];
139
140
141
142
143
144
145 httpd_objset* objset_create(
pool_handle_t *pool);
146
147
148
149
150 void objset_add_object(
pool_handle_t *p, httpd_objset *os, httpd_object *obj);
151
152
153
154
155
156
157
158
159
160
161 void httpobjconf_add_object(HTTPObjectConfig *conf, httpd_object *obj);
162
163
164
165
166
167
168 void nsapi_context_next_stage(NSAPIContext *context);
169
170 Condition* condition_from_str(
pool_handle_t *pool,
char *expr,
size_t len);
171 Expression* expression_from_str(
pool_handle_t *pool,
char *expr,
size_t len);
172
173 int condition_evaluate(Condition *condition, Session *sn, Request *rq);
174
175
176 #ifdef __cplusplus
177 }
178 #endif
179
180 #endif
181
182