Mercurial > hg > nginx-vendor-0-8
comparison src/core/ngx_conf_file.c @ 384:12defd37f578 NGINX_0_7_4
nginx 0.7.4
*) Feature: variables support in the "access_log" directive.
*) Feature: the "open_log_file_cache" directive.
*) Feature: the -g switch.
*) Feature: the "Expect" request header line support.
*) Bugfix: large SSI inclusions might be truncated.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 30 Jun 2008 00:00:00 +0400 |
parents | 984bb0b1399b |
children | a094317ba307 |
comparison
equal
deleted
inserted
replaced
383:6ee3ada01457 | 384:12defd37f578 |
---|---|
56 NGX_CONF_TAKE7 | 56 NGX_CONF_TAKE7 |
57 }; | 57 }; |
58 | 58 |
59 | 59 |
60 char * | 60 char * |
61 ngx_conf_param(ngx_conf_t *cf) | |
62 { | |
63 ngx_str_t *param; | |
64 ngx_buf_t b; | |
65 ngx_conf_file_t conf_file; | |
66 | |
67 param = &cf->cycle->conf_param; | |
68 | |
69 if (param->len == 0) { | |
70 return NGX_CONF_OK; | |
71 } | |
72 | |
73 ngx_memzero(&conf_file, sizeof(ngx_conf_file_t)); | |
74 | |
75 ngx_memzero(&b, sizeof(ngx_buf_t)); | |
76 | |
77 b.start = param->data; | |
78 b.pos = param->data; | |
79 b.last = param->data + param->len; | |
80 b.end = b.last; | |
81 b.temporary = 1; | |
82 | |
83 conf_file.file.fd = NGX_INVALID_FILE; | |
84 conf_file.file.name.data = (u_char *) "command line"; | |
85 conf_file.line = 1; | |
86 | |
87 cf->conf_file = &conf_file; | |
88 cf->conf_file->buffer = &b; | |
89 | |
90 return ngx_conf_parse(cf, NULL); | |
91 } | |
92 | |
93 | |
94 char * | |
61 ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename) | 95 ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename) |
62 { | 96 { |
63 char *rv; | 97 char *rv; |
64 ngx_fd_t fd; | 98 ngx_fd_t fd; |
65 ngx_int_t rc; | 99 ngx_int_t rc; |
66 ngx_buf_t *b; | 100 ngx_buf_t *b; |
67 ngx_uint_t block; | |
68 ngx_conf_file_t *prev; | 101 ngx_conf_file_t *prev; |
102 enum { | |
103 parse_file = 0, | |
104 parse_block, | |
105 parse_param | |
106 } type; | |
69 | 107 |
70 #if (NGX_SUPPRESS_WARN) | 108 #if (NGX_SUPPRESS_WARN) |
71 fd = NGX_INVALID_FILE; | 109 fd = NGX_INVALID_FILE; |
72 prev = NULL; | 110 prev = NULL; |
73 #endif | 111 #endif |
118 cf->conf_file->file.name.data = filename->data; | 156 cf->conf_file->file.name.data = filename->data; |
119 cf->conf_file->file.offset = 0; | 157 cf->conf_file->file.offset = 0; |
120 cf->conf_file->file.log = cf->log; | 158 cf->conf_file->file.log = cf->log; |
121 cf->conf_file->line = 1; | 159 cf->conf_file->line = 1; |
122 | 160 |
123 block = 0; | 161 type = parse_file; |
162 | |
163 } else if (cf->conf_file->file.fd != NGX_INVALID_FILE) { | |
164 | |
165 type = parse_block; | |
124 | 166 |
125 } else { | 167 } else { |
126 block = 1; | 168 type = parse_param; |
127 } | 169 } |
128 | 170 |
129 | 171 |
130 for ( ;; ) { | 172 for ( ;; ) { |
131 rc = ngx_conf_read_token(cf); | 173 rc = ngx_conf_read_token(cf); |
143 if (rc == NGX_ERROR) { | 185 if (rc == NGX_ERROR) { |
144 goto done; | 186 goto done; |
145 } | 187 } |
146 | 188 |
147 if (rc == NGX_CONF_BLOCK_DONE) { | 189 if (rc == NGX_CONF_BLOCK_DONE) { |
148 if (!block) { | 190 |
191 if (type != parse_block) { | |
149 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "unexpected \"}\""); | 192 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "unexpected \"}\""); |
150 goto failed; | 193 goto failed; |
151 } | 194 } |
152 | 195 |
153 block = 0; | |
154 } | |
155 | |
156 if (rc == NGX_CONF_FILE_DONE && block) { | |
157 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
158 "unexpected end of file, expecting \"}\""); | |
159 goto failed; | |
160 } | |
161 | |
162 if (rc != NGX_OK && rc != NGX_CONF_BLOCK_START) { | |
163 goto done; | 196 goto done; |
164 } | 197 } |
198 | |
199 if (rc == NGX_CONF_FILE_DONE) { | |
200 | |
201 if (type == parse_block) { | |
202 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
203 "unexpected end of file, expecting \"}\""); | |
204 goto failed; | |
205 } | |
206 | |
207 goto done; | |
208 } | |
209 | |
210 if (rc == NGX_CONF_BLOCK_START) { | |
211 | |
212 if (type == parse_param) { | |
213 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
214 "block directives are not supported " | |
215 "in -g option"); | |
216 goto failed; | |
217 } | |
218 } | |
219 | |
220 /* rc == NGX_OK || rc == NGX_CONF_BLOCK_START */ | |
165 | 221 |
166 if (cf->handler) { | 222 if (cf->handler) { |
167 | 223 |
168 /* | 224 /* |
169 * the custom handler, i.e., that is used in the http's | 225 * the custom handler, i.e., that is used in the http's |
396 start = b->pos; | 452 start = b->pos; |
397 | 453 |
398 for ( ;; ) { | 454 for ( ;; ) { |
399 | 455 |
400 if (b->pos >= b->last) { | 456 if (b->pos >= b->last) { |
457 | |
401 if (cf->conf_file->file.offset | 458 if (cf->conf_file->file.offset |
402 >= ngx_file_size(&cf->conf_file->file.info)) | 459 >= ngx_file_size(&cf->conf_file->file.info)) |
403 { | 460 { |
404 if (cf->args->nelts > 0) { | 461 if (cf->args->nelts > 0) { |
462 | |
463 if (cf->conf_file->file.fd == NGX_INVALID_FILE) { | |
464 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
465 "unexpected end of parameter, " | |
466 "expecting \";\""); | |
467 return NGX_ERROR; | |
468 } | |
469 | |
405 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 470 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
406 "unexpected end of file, " | 471 "unexpected end of file, " |
407 "expecting \";\" or \"}\""); | 472 "expecting \";\" or \"}\""); |
408 return NGX_ERROR; | 473 return NGX_ERROR; |
409 } | 474 } |