| 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] = '/'; |