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 #include <ucx/string.h>
30
31 #include "../public/nsapi.h"
32
33 #include "object.h"
34
35 #include "pool.h"
36 #include "../daemon/func.h"
37
38
39
40 httpd_object* object_new(
pool_handle_t *pool,
char *name) {
41
42 httpd_object *obj = pool_malloc(pool,
sizeof(httpd_object));
43 obj->pool = pool;
44 obj->name = name;
45 obj->path =
NULL;
46
47
48 obj->dt = pool_calloc(pool,
NUM_NSAPI_TYPES -
1,
sizeof(
struct dtable));
49 obj->nd =
NUM_NSAPI_TYPES -
1;
50
51 return obj;
52 }
53
54 void object_free(httpd_object *obj) {
55
56
57 }
58
59
60 void object_add_directive(httpd_object *obj, directive *dir,
int dt) {
61 dtable *l = object_get_dtable(obj, dt);
62
63
64
65
66
67 directive **drs = pool_malloc(obj->pool, (l->ndir+
1)*
sizeof(
void*));
68 for(
int i=
0;i<l->ndir;i++) {
69 drs[i] = l->dirs[i];
70 }
71 if(l->dirs !=
NULL) {
72 pool_free(obj->pool, l->dirs);
73 }
74 l->dirs = drs;
75
76
77 l->dirs[l->ndir] = dir;
78 l->ndir++;
79 }
80
81
82
83 httpd_objset* objset_create(
pool_handle_t *pool) {
84 httpd_objset *os = pool_malloc(pool,
sizeof(httpd_objset));
85
86 os->obj = pool_calloc(pool,
2,
sizeof(
void*));
87 os->pos =
0;
88
89 return os;
90 }
91
92 void objset_add_object(
pool_handle_t *p, httpd_objset *os, httpd_object *obj) {
93 if(os->pos !=
0 && os->pos %
2 ==
0) {
94 os->obj = pool_realloc(p, os->obj, (os->pos +
2) *
sizeof(
void*));
95 }
96 os->obj[os->pos] = obj;
97 os->pos++;
98 }
99
100 void httpobjconf_add_object(HTTPObjectConfig *conf, httpd_object *obj) {
101 conf->nobj++;
102 conf->objects = realloc(conf->objects, conf->nobj *
sizeof(
void*));
103 conf->objects[conf->nobj -
1] = obj;
104 }
105
106
107 void nsapi_context_next_stage(NSAPIContext *context) {
108 context->dtable_index =
0;
109 context->objset_index = -
1;
110 context->last_req_code =
REQ_NOACTION;
111 }
112
113
114 Condition* condition_from_str(
pool_handle_t *pool,
char *expr,
size_t len) {
115 Condition *cond = pool_malloc(pool,
sizeof(Condition));
116 cond->expression =
NULL;
117 cond->parent =
NULL;
118 cond->index =
0;
119
120 printf(
"Expression: {");
121 fwrite(expr, len,
1, stdout);
122 printf(
"}\n");
123
124 cond->expression = expression_from_str(pool, expr, len);
125
126 return cond;
127 }
128
129 Expression* expression_from_str(
pool_handle_t *pool,
char *expr,
size_t len) {
130 return NULL;
131 }
132
133 int condition_evaluate(Condition *condition, Session *sn, Request *rq) {
134 return 1;
135 }
136