Mercurial > hg > nginx
comparison src/core/ngx_conf_file.c @ 114:ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 07 Jul 2003 06:11:50 +0000 |
parents | 7ebc8b7fb816 |
children | f6e3c5d019b6 |
comparison
equal
deleted
inserted
replaced
113:d7f606e25b99 | 114:ac69ab96328d |
---|---|
23 ngx_str_t *name; | 23 ngx_str_t *name; |
24 ngx_fd_t fd; | 24 ngx_fd_t fd; |
25 ngx_conf_file_t *prev; | 25 ngx_conf_file_t *prev; |
26 ngx_command_t *cmd; | 26 ngx_command_t *cmd; |
27 | 27 |
28 #if (NGX_SUPPRESS_WARN) | |
29 fd = NGX_INVALID_FILE; | |
30 prev = NULL; | |
31 #endif | |
32 | |
28 if (filename) { | 33 if (filename) { |
29 | 34 |
30 /* open configuration file */ | 35 /* open configuration file */ |
31 | 36 |
32 fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN); | 37 fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN); |
51 NGX_CONF_ERROR); | 56 NGX_CONF_ERROR); |
52 | 57 |
53 cf->conf_file->file.fd = fd; | 58 cf->conf_file->file.fd = fd; |
54 cf->conf_file->file.name.len = filename->len; | 59 cf->conf_file->file.name.len = filename->len; |
55 cf->conf_file->file.name.data = filename->data; | 60 cf->conf_file->file.name.data = filename->data; |
61 cf->conf_file->file.offset = 0; | |
56 cf->conf_file->file.log = cf->log;; | 62 cf->conf_file->file.log = cf->log;; |
57 cf->conf_file->line = 1; | 63 cf->conf_file->line = 1; |
58 } | 64 } |
59 | 65 |
60 for ( ;; ) { | 66 for ( ;; ) { |
66 #if 0 | 72 #if 0 |
67 ngx_log_debug(cf->log, "token %d" _ rc); | 73 ngx_log_debug(cf->log, "token %d" _ rc); |
68 #endif | 74 #endif |
69 | 75 |
70 if (rc == NGX_ERROR) { | 76 if (rc == NGX_ERROR) { |
71 return NGX_CONF_ERROR; | 77 break; |
72 } | 78 } |
73 | 79 |
74 if (rc != NGX_OK) { | 80 if (rc != NGX_OK) { |
75 return NGX_CONF_OK; | 81 break; |
76 } | 82 } |
77 | 83 |
78 if (cf->handler) { | 84 if (cf->handler) { |
79 | 85 |
80 /* custom handler, i.e. used in http "types { ... }" directive */ | 86 /* custom handler, i.e. used in http "types { ... }" directive */ |
82 rv = (*cf->handler)(cf, NULL, cf->handler_conf); | 88 rv = (*cf->handler)(cf, NULL, cf->handler_conf); |
83 if (rv == NGX_CONF_OK) { | 89 if (rv == NGX_CONF_OK) { |
84 continue; | 90 continue; |
85 | 91 |
86 } else if (rv == NGX_CONF_ERROR) { | 92 } else if (rv == NGX_CONF_ERROR) { |
87 return NGX_CONF_ERROR; | 93 rc = NGX_ERROR; |
94 break; | |
88 | 95 |
89 } else { | 96 } else { |
90 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 97 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
91 "%s in %s:%d", | 98 "%s in %s:%d", |
92 rv, | 99 rv, |
93 cf->conf_file->file.name.data, | 100 cf->conf_file->file.name.data, |
94 cf->conf_file->line); | 101 cf->conf_file->line); |
95 return NGX_CONF_ERROR; | 102 rc = NGX_ERROR; |
103 break; | |
96 } | 104 } |
97 } | 105 } |
98 | 106 |
99 name = (ngx_str_t *) cf->args->elts; | 107 name = (ngx_str_t *) cf->args->elts; |
100 found = 0; | 108 found = 0; |
101 | 109 |
102 for (m = 0; !found && ngx_modules[m]; m++) { | 110 for (m = 0; rc != NGX_ERROR && !found && ngx_modules[m]; m++) { |
103 | 111 |
104 /* look up the directive in the appropriate modules */ | 112 /* look up the directive in the appropriate modules */ |
105 | 113 |
106 if (ngx_modules[m]->type != NGX_CONF_MODULE | 114 if (ngx_modules[m]->type != NGX_CONF_MODULE |
107 && ngx_modules[m]->type != cf->module_type) | 115 && ngx_modules[m]->type != cf->module_type) |
129 "directive \"%s\" in %s:%d " | 137 "directive \"%s\" in %s:%d " |
130 "is not allowed here", | 138 "is not allowed here", |
131 name->data, | 139 name->data, |
132 cf->conf_file->file.name.data, | 140 cf->conf_file->file.name.data, |
133 cf->conf_file->line); | 141 cf->conf_file->line); |
134 return NGX_CONF_ERROR; | 142 rc = NGX_ERROR; |
143 break; | |
135 } | 144 } |
136 | 145 |
137 /* is the directive's argument count right ? */ | 146 /* is the directive's argument count right ? */ |
138 | 147 |
139 if (cmd->type & argument_number[cf->args->nelts - 1]) { | 148 if (cmd->type & argument_number[cf->args->nelts - 1]) { |
167 "invalid number arguments in " | 176 "invalid number arguments in " |
168 "directive \"%s\" in %s:%d", | 177 "directive \"%s\" in %s:%d", |
169 name->data, | 178 name->data, |
170 cf->conf_file->file.name.data, | 179 cf->conf_file->file.name.data, |
171 cf->conf_file->line); | 180 cf->conf_file->line); |
172 return NGX_CONF_ERROR; | 181 rc = NGX_ERROR; |
182 break; | |
173 } | 183 } |
174 | 184 |
175 /* set up the directive's configuration context */ | 185 /* set up the directive's configuration context */ |
176 | 186 |
177 conf = NULL; | 187 conf = NULL; |
196 if (rv == NGX_CONF_OK) { | 206 if (rv == NGX_CONF_OK) { |
197 found = 1; | 207 found = 1; |
198 break; | 208 break; |
199 | 209 |
200 } else if (rv == NGX_CONF_ERROR) { | 210 } else if (rv == NGX_CONF_ERROR) { |
201 return NGX_CONF_ERROR; | 211 rc = NGX_ERROR; |
212 break; | |
202 | 213 |
203 } else { | 214 } else { |
204 if (rv == ngx_conf_errstr) { | 215 if (rv == ngx_conf_errstr) { |
205 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 216 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
206 "%s in %s:%d", | 217 "%s in %s:%d", |
213 name->data, rv, | 224 name->data, rv, |
214 cf->conf_file->file.name.data, | 225 cf->conf_file->file.name.data, |
215 cf->conf_file->line); | 226 cf->conf_file->line); |
216 } | 227 } |
217 | 228 |
218 return NGX_CONF_ERROR; | 229 rc = NGX_ERROR; |
230 break; | |
219 } | 231 } |
220 } | 232 } |
221 | 233 |
222 cmd++; | 234 cmd++; |
223 } | 235 } |
228 "unknown directive \"%s\" in %s:%d", | 240 "unknown directive \"%s\" in %s:%d", |
229 name->data, | 241 name->data, |
230 cf->conf_file->file.name.data, | 242 cf->conf_file->file.name.data, |
231 cf->conf_file->line); | 243 cf->conf_file->line); |
232 | 244 |
233 return NGX_CONF_ERROR; | 245 rc = NGX_ERROR; |
246 break; | |
234 } | 247 } |
235 } | 248 } |
236 | 249 |
237 if (filename) { | 250 if (filename) { |
238 cf->conf_file = prev; | 251 cf->conf_file = prev; |
241 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno, | 254 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno, |
242 ngx_close_file_n " %s failed", | 255 ngx_close_file_n " %s failed", |
243 cf->conf_file->file.name.data); | 256 cf->conf_file->file.name.data); |
244 return NGX_CONF_ERROR; | 257 return NGX_CONF_ERROR; |
245 } | 258 } |
259 } | |
260 | |
261 if (rc == NGX_ERROR) { | |
262 return NGX_CONF_ERROR; | |
246 } | 263 } |
247 | 264 |
248 return NGX_CONF_OK; | 265 return NGX_CONF_OK; |
249 } | 266 } |
250 | 267 |