Mercurial > hg > nginx-quic
comparison src/http/ngx_http_variables.c @ 3872:83cd1910329c
allow regex as "map" parameter
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 16 Mar 2011 15:32:31 +0000 |
parents | 6802ba529ec4 |
children | fa4612bfb9fa |
comparison
equal
deleted
inserted
replaced
3871:8ccd6ed1d4bb | 3872:83cd1910329c |
---|---|
1658 | 1658 |
1659 return NGX_OK; | 1659 return NGX_OK; |
1660 } | 1660 } |
1661 | 1661 |
1662 | 1662 |
1663 void * | |
1664 ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map, ngx_uint_t key, | |
1665 u_char *text, size_t len, ngx_str_t *match) | |
1666 { | |
1667 void *p; | |
1668 | |
1669 p = ngx_hash_find_combined(&map->hash, key, text, len); | |
1670 if (p) { | |
1671 return p; | |
1672 } | |
1673 | |
1674 #if (NGX_PCRE) | |
1675 | |
1676 if (len && map->nregex) { | |
1677 ngx_int_t n; | |
1678 ngx_uint_t i; | |
1679 ngx_http_map_regex_t *reg; | |
1680 | |
1681 reg = map->regex; | |
1682 | |
1683 for (i = 0; i < map->nregex; i++) { | |
1684 | |
1685 n = ngx_http_regex_exec(r, reg[i].regex, match); | |
1686 | |
1687 if (n == NGX_OK) { | |
1688 return reg[i].value; | |
1689 } | |
1690 | |
1691 if (n == NGX_DECLINED) { | |
1692 continue; | |
1693 } | |
1694 | |
1695 /* NGX_ERROR */ | |
1696 | |
1697 return NULL; | |
1698 } | |
1699 } | |
1700 | |
1701 #endif | |
1702 | |
1703 return NULL; | |
1704 } | |
1705 | |
1706 | |
1663 #if (NGX_PCRE) | 1707 #if (NGX_PCRE) |
1664 | 1708 |
1665 static ngx_int_t | 1709 static ngx_int_t |
1666 ngx_http_variable_not_found(ngx_http_request_t *r, ngx_http_variable_value_t *v, | 1710 ngx_http_variable_not_found(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
1667 uintptr_t data) | 1711 uintptr_t data) |