comparison src/http/modules/ngx_http_rewrite_handler.c @ 325:7c3323909107

nginx-0.0.3-2004-04-23-20:50:51 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 23 Apr 2004 16:50:51 +0000
parents 87e73f067470
children 8733703a37f3
comparison
equal deleted inserted replaced
324:0ab66f4b6c4d 325:7c3323909107
30 } ngx_http_rewrite_rule_t; 30 } ngx_http_rewrite_rule_t;
31 31
32 32
33 typedef struct { 33 typedef struct {
34 ngx_array_t rules; 34 ngx_array_t rules;
35 unsigned log:1; 35 ngx_flag_t log;
36 } ngx_http_rewrite_srv_conf_t; 36 } ngx_http_rewrite_srv_conf_t;
37 37
38 38
39 static void *ngx_http_rewrite_create_loc_conf(ngx_conf_t *cf); 39 static void *ngx_http_rewrite_create_srv_conf(ngx_conf_t *cf);
40 static char *ngx_http_rewrite_merge_srv_conf(ngx_conf_t *cf,
41 void *parent, void *child);
40 static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd, 42 static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
41 void *conf); 43 void *conf);
42 static ngx_int_t ngx_http_rewrite_init(ngx_cycle_t *cycle); 44 static ngx_int_t ngx_http_rewrite_init(ngx_cycle_t *cycle);
43 45
44 46
49 ngx_http_rewrite_rule, 51 ngx_http_rewrite_rule,
50 NGX_HTTP_SRV_CONF_OFFSET, 52 NGX_HTTP_SRV_CONF_OFFSET,
51 0, 53 0,
52 NULL }, 54 NULL },
53 55
56 { ngx_string("rewrite_log"),
57 NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
58 ngx_conf_set_flag_slot,
59 NGX_HTTP_SRV_CONF_OFFSET,
60 offsetof(ngx_http_rewrite_srv_conf_t, log),
61 NULL },
62
54 ngx_null_command 63 ngx_null_command
55 }; 64 };
56 65
57 66
58 ngx_http_module_t ngx_http_rewrite_module_ctx = { 67 ngx_http_module_t ngx_http_rewrite_module_ctx = {
59 NULL, /* pre conf */ 68 NULL, /* pre conf */
60 69
61 NULL, /* create main configuration */ 70 NULL, /* create main configuration */
62 NULL, /* init main configuration */ 71 NULL, /* init main configuration */
63 72
64 ngx_http_rewrite_create_loc_conf, /* create server configuration */ 73 ngx_http_rewrite_create_srv_conf, /* create server configuration */
65 NULL, /* merge server configuration */ 74 ngx_http_rewrite_merge_srv_conf, /* merge server configuration */
66 75
67 NULL, /* create location configration */ 76 NULL, /* create location configration */
68 NULL, /* merge location configration */ 77 NULL, /* merge location configration */
69 }; 78 };
70 79
185 194
186 return NGX_DECLINED; 195 return NGX_DECLINED;
187 } 196 }
188 197
189 198
190 static void *ngx_http_rewrite_create_loc_conf(ngx_conf_t *cf) 199 static void *ngx_http_rewrite_create_srv_conf(ngx_conf_t *cf)
191 { 200 {
192 ngx_http_rewrite_srv_conf_t *conf; 201 ngx_http_rewrite_srv_conf_t *conf;
193 202
194 if (!(conf = ngx_palloc(cf->pool, sizeof(ngx_http_rewrite_srv_conf_t)))) { 203 if (!(conf = ngx_palloc(cf->pool, sizeof(ngx_http_rewrite_srv_conf_t)))) {
195 return NGX_CONF_ERROR; 204 return NGX_CONF_ERROR;
196 } 205 }
197 206
198 ngx_init_array(conf->rules, cf->pool, 5, sizeof(ngx_http_rewrite_rule_t), 207 ngx_init_array(conf->rules, cf->pool, 5, sizeof(ngx_http_rewrite_rule_t),
199 NGX_CONF_ERROR); 208 NGX_CONF_ERROR);
200 209
201 conf->log = 1; 210 conf->log = NGX_CONF_UNSET;
202 211
203 return conf; 212 return conf;
213 }
214
215
216 static char *ngx_http_rewrite_merge_srv_conf(ngx_conf_t *cf,
217 void *parent, void *child)
218 {
219 ngx_http_rewrite_srv_conf_t *prev = parent;
220 ngx_http_rewrite_srv_conf_t *conf = child;
221
222 ngx_conf_merge_value(conf->log, prev->log, 0);
223
224 return NGX_CONF_OK;
204 } 225 }
205 226
206 227
207 static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd, 228 static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
208 void *conf) 229 void *conf)