Mercurial > hg > nginx-quic
comparison src/http/ngx_http_script.c @ 3691:55f95e91daed
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 14 Jul 2010 11:13:59 +0000 |
parents | 187783310b65 |
children | 7224d008faaf |
comparison
equal
deleted
inserted
replaced
3690:0f3602accc4b | 3691:55f95e91daed |
---|---|
209 | 209 |
210 return NGX_OK; | 210 return NGX_OK; |
211 } | 211 } |
212 | 212 |
213 | 213 |
214 ngx_int_t | |
215 ngx_http_test_predicates(ngx_http_request_t *r, ngx_array_t *predicates) | |
216 { | |
217 ngx_str_t val; | |
218 ngx_uint_t i; | |
219 ngx_http_complex_value_t *cv; | |
220 | |
221 if (predicates == NULL) { | |
222 return NGX_OK; | |
223 } | |
224 | |
225 cv = predicates->elts; | |
226 | |
227 for (i = 0; i < predicates->nelts; i++) { | |
228 if (ngx_http_complex_value(r, &cv[i], &val) != NGX_OK) { | |
229 return NGX_ERROR; | |
230 } | |
231 | |
232 if (val.len && val.data[0] != '0') { | |
233 return NGX_DECLINED; | |
234 } | |
235 } | |
236 | |
237 return NGX_OK; | |
238 } | |
239 | |
240 | |
241 char * | |
242 ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
243 { | |
244 char *p = conf; | |
245 | |
246 ngx_str_t *value; | |
247 ngx_uint_t i; | |
248 ngx_array_t **a; | |
249 ngx_http_complex_value_t *cv; | |
250 ngx_http_compile_complex_value_t ccv; | |
251 | |
252 a = (ngx_array_t **) (p + cmd->offset); | |
253 | |
254 if (*a == NGX_CONF_UNSET_PTR) { | |
255 *a = ngx_array_create(cf->pool, 1, sizeof(ngx_http_complex_value_t)); | |
256 if (*a == NULL) { | |
257 return NGX_CONF_ERROR; | |
258 } | |
259 } | |
260 | |
261 value = cf->args->elts; | |
262 | |
263 for (i = 1; i < cf->args->nelts; i++) { | |
264 cv = ngx_array_push(*a); | |
265 if (cv == NULL) { | |
266 return NGX_CONF_ERROR; | |
267 } | |
268 | |
269 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
270 | |
271 ccv.cf = cf; | |
272 ccv.value = &value[i]; | |
273 ccv.complex_value = cv; | |
274 | |
275 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
276 return NGX_CONF_ERROR; | |
277 } | |
278 } | |
279 | |
280 return NGX_CONF_OK; | |
281 } | |
282 | |
283 | |
214 ngx_uint_t | 284 ngx_uint_t |
215 ngx_http_script_variables_count(ngx_str_t *value) | 285 ngx_http_script_variables_count(ngx_str_t *value) |
216 { | 286 { |
217 ngx_uint_t i, n; | 287 ngx_uint_t i, n; |
218 | 288 |