src/server/daemon/location.c

changeset 642
7b71e2973acc
parent 641
159172937c86
child 644
e96e92e3508f
equal deleted inserted replaced
641:159172937c86 642:7b71e2973acc
94 const CxAllocator *a = cfg->a; 94 const CxAllocator *a = cfg->a;
95 95
96 WSLocationMatch match = WS_LOCATION_MATCH_EXACT; 96 WSLocationMatch match = WS_LOCATION_MATCH_EXACT;
97 cxmutstr match_str; 97 cxmutstr match_str;
98 98
99 int regex_flags = REG_EXTENDED | REG_NOSUB; 99 int regex_flags = REG_EXTENDED;
100 int argc = serverconfig_directive_count_args(obj); 100 int argc = serverconfig_directive_count_args(obj);
101 if(argc == 2) { 101 if(argc == 2) {
102 // arg0: match type 102 // arg0: match type
103 cxmutstr type_str = obj->args->value; 103 cxmutstr type_str = obj->args->value;
104 if(!cx_strcmp(type_str, "=")) { 104 if(!cx_strcmp(type_str, "=")) {
174 // TODO: ... 174 // TODO: ...
175 175
176 return 0; 176 return 0;
177 } 177 }
178 178
179 int location_match(WSLocation *loc, cxstring uri) { 179 int location_match(WSLocation *loc, cxstring uri, regmatch_t *match) {
180 if(loc->match == WS_LOCATION_MATCH_EXACT) { 180 if(loc->match == WS_LOCATION_MATCH_EXACT) {
181 return !cx_strcmp(loc->match_string, uri); 181 return !cx_strcmp(loc->match_string, uri);
182 } else if(loc->match == WS_LOCATION_MATCH_PREFIX) { 182 } else if(loc->match == WS_LOCATION_MATCH_PREFIX) {
183 return cx_strprefix(uri, loc->match_string); 183 return cx_strprefix(uri, loc->match_string);
184 } else { 184 } else {
185 return regexec(&loc->regex, uri.ptr, 0, NULL, 0) == 0; 185 return regexec(&loc->regex, uri.ptr, 0, match, WS_LOCATION_NMATCH) == 0;
186 } 186 }
187 return 0; 187 return 0;
188 } 188 }
189 189
190 WSLocationConfig* location_match_and_get_config(pool_handle_t *pool, cxstring uri, WSLocation *loc) { 190 WSLocationConfig* location_match_and_get_config(pool_handle_t *pool, cxstring uri, WSLocation *loc) {
193 return NULL; 193 return NULL;
194 } 194 }
195 ZERO(config, sizeof(WSLocationConfig)); 195 ZERO(config, sizeof(WSLocationConfig));
196 196
197 while(loc) { 197 while(loc) {
198 if(location_match(loc, uri)) { 198 if(location_match(loc, uri, config->match)) {
199 if(location_apply_config(config, loc)) { 199 if(location_apply_config(config, loc)) {
200 return NULL; 200 return NULL;
201 } 201 }
202 } 202 }
203 loc = loc->next; 203 loc = loc->next;

mercurial