src/server/daemon/request.c

changeset 702
ee80191310ca
parent 415
d938228c382e
equal deleted inserted replaced
701:936e5487418a 702:ee80191310ca
130 int request_set_path(cxstring root, cxstring path, pblock *vars) { 130 int request_set_path(cxstring root, cxstring path, pblock *vars) {
131 // TODO: maybe replace this code with request_set_path from req.cpp 131 // TODO: maybe replace this code with request_set_path from req.cpp
132 132
133 // concat path 133 // concat path
134 size_t length = root.length + path.length; 134 size_t length = root.length + path.length;
135 char *translated_path = alloca(length + 1); 135 char *translated_path = malloc(length + 1);
136 memcpy(translated_path, root.ptr, root.length); 136 memcpy(translated_path, root.ptr, root.length);
137 if(root.ptr[root.length-1] == '/') { 137 if(root.ptr[root.length-1] == '/') {
138 memcpy(translated_path + root.length, path.ptr, path.length); 138 memcpy(translated_path + root.length, path.ptr, path.length);
139 } else { 139 } else {
140 translated_path[root.length] = '/'; 140 translated_path[root.length] = '/';
149 length, 149 length,
150 vars); 150 vars);
151 151
152 pblock_kvinsert(pb_key_ntrans_base, root.ptr, root.length, vars); 152 pblock_kvinsert(pb_key_ntrans_base, root.ptr, root.length, vars);
153 153
154 free(translated_path);
154 return REQ_PROCEED; 155 return REQ_PROCEED;
155 } 156 }
156 157
157 void request_free(Request *rq) { 158 void request_free(Request *rq) {
158 // TODO: implement 159 // TODO: implement

mercurial