Mercurial > hg > nginx
comparison src/http/modules/ngx_http_rewrite_handler.c @ 290:87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 16 Mar 2004 07:10:12 +0000 |
parents | 05592fd7a436 |
children | 7c3323909107 |
comparison
equal
deleted
inserted
replaced
289:0750faf8d7e3 | 290:87e73f067470 |
---|---|
80 | 80 |
81 | 81 |
82 static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r) | 82 static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r) |
83 { | 83 { |
84 int *matches; | 84 int *matches; |
85 char *p; | 85 u_char *p; |
86 size_t len; | 86 size_t len; |
87 uintptr_t data; | 87 uintptr_t data; |
88 ngx_int_t rc, i, n, m; | 88 ngx_int_t rc; |
89 ngx_uint_t i, m, n; | |
89 ngx_str_t uri; | 90 ngx_str_t uri; |
90 ngx_http_rewrite_op_t *op; | 91 ngx_http_rewrite_op_t *op; |
91 ngx_http_rewrite_rule_t *rule; | 92 ngx_http_rewrite_rule_t *rule; |
92 ngx_http_rewrite_srv_conf_t *scf; | 93 ngx_http_rewrite_srv_conf_t *scf; |
93 | 94 |
132 "\"%s\" matches", rule[i].re_name.data); | 133 "\"%s\" matches", rule[i].re_name.data); |
133 } | 134 } |
134 | 135 |
135 uri.len = rule[i].size; | 136 uri.len = rule[i].size; |
136 | 137 |
137 for (n = 1; n < rc; n++) { | 138 for (n = 1; n < (ngx_uint_t) rc; n++) { |
138 uri.len += matches[2 * n + 1] - matches[2 * n]; | 139 uri.len += matches[2 * n + 1] - matches[2 * n]; |
139 } | 140 } |
140 | 141 |
141 if (!(uri.data = ngx_palloc(r->pool, uri.len + 1))) { | 142 if (!(uri.data = ngx_palloc(r->pool, uri.len + 1))) { |
142 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 143 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
148 for (n = 0; n < rule[i].ops.nelts; n++) { | 149 for (n = 0; n < rule[i].ops.nelts; n++) { |
149 if (op[n].op == NGX_HTTP_REWRITE_COPY_SHORT) { | 150 if (op[n].op == NGX_HTTP_REWRITE_COPY_SHORT) { |
150 len = op[n].len; | 151 len = op[n].len; |
151 data = op[n].data; | 152 data = op[n].data; |
152 while (len--) { | 153 while (len--) { |
153 *p++ = data & 0xff; | 154 *p++ = (char) (data & 0xff); |
154 data >>= 8; | 155 data >>= 8; |
155 } | 156 } |
156 | 157 |
157 } else if (op[n].op == NGX_HTTP_REWRITE_COPY_LONG) { | 158 } else if (op[n].op == NGX_HTTP_REWRITE_COPY_LONG) { |
158 p = ngx_cpymem(p, (void *) op[n].data, op[n].len); | 159 p = ngx_cpymem(p, (void *) op[n].data, op[n].len); |
206 static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd, | 207 static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd, |
207 void *conf) | 208 void *conf) |
208 { | 209 { |
209 ngx_http_rewrite_srv_conf_t *scf = conf; | 210 ngx_http_rewrite_srv_conf_t *scf = conf; |
210 | 211 |
211 char *data, *p; | 212 u_char *data, *p; |
212 size_t len; | 213 size_t len; |
213 ngx_str_t *value, err; | 214 ngx_str_t *value, err; |
214 ngx_uint_t i; | 215 ngx_uint_t i; |
215 ngx_http_rewrite_op_t *op; | 216 ngx_http_rewrite_op_t *op; |
216 ngx_http_rewrite_rule_t *rule; | 217 ngx_http_rewrite_rule_t *rule; |
217 char errstr[NGX_MAX_CONF_ERRSTR]; | 218 u_char errstr[NGX_MAX_CONF_ERRSTR]; |
218 | 219 |
219 if (!(rule = ngx_push_array(&scf->rules))) { | 220 if (!(rule = ngx_push_array(&scf->rules))) { |
220 return NGX_CONF_ERROR; | 221 return NGX_CONF_ERROR; |
221 } | 222 } |
222 | 223 |