Mercurial > hg > nginx
comparison src/core/ngx_conf_file.c @ 119:cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 20 Jul 2003 21:15:59 +0000 |
parents | 5bf52498665c |
children | 656d468f4ead |
comparison
equal
deleted
inserted
replaced
118:5bf52498665c | 119:cd54bcbaf3b5 |
---|---|
1 | 1 |
2 #include <ngx_config.h> | 2 #include <ngx_config.h> |
3 #include <ngx_core.h> | 3 #include <ngx_core.h> |
4 | 4 |
5 | 5 |
6 char ngx_conf_errstr[MAX_CONF_ERRSTR]; | 6 |
7 | 7 #define MAX_CONF_ERRSTR 256 |
8 | 8 |
9 static int argument_number[] = { | 9 static int argument_number[] = { |
10 NGX_CONF_NOARGS, | 10 NGX_CONF_NOARGS, |
11 NGX_CONF_TAKE1, | 11 NGX_CONF_TAKE1, |
12 NGX_CONF_TAKE2 | 12 NGX_CONF_TAKE2 |
210 } else if (rv == NGX_CONF_ERROR) { | 210 } else if (rv == NGX_CONF_ERROR) { |
211 rc = NGX_ERROR; | 211 rc = NGX_ERROR; |
212 break; | 212 break; |
213 | 213 |
214 } else { | 214 } else { |
215 if (rv == ngx_conf_errstr) { | 215 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
216 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 216 "\"%s\" directive %s in %s:%d", |
217 "%s in %s:%d", | 217 name->data, rv, |
218 rv, | 218 cf->conf_file->file.name.data, |
219 cf->conf_file->file.name.data, | 219 cf->conf_file->line); |
220 cf->conf_file->line); | |
221 } else { | |
222 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | |
223 "\"%s\" directive %s in %s:%d", | |
224 name->data, rv, | |
225 cf->conf_file->file.name.data, | |
226 cf->conf_file->line); | |
227 } | |
228 | 220 |
229 rc = NGX_ERROR; | 221 rc = NGX_ERROR; |
230 break; | 222 break; |
231 } | 223 } |
232 } | 224 } |
473 } | 465 } |
474 } | 466 } |
475 } | 467 } |
476 | 468 |
477 | 469 |
470 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name) | |
471 { | |
472 int i; | |
473 ngx_open_file_t *file; | |
474 | |
475 if (name) { | |
476 file = cycle->open_files.elts; | |
477 for (i = 0; i < cycle->open_files.nelts; i++) { | |
478 if (name->len != file[i].name.len) { | |
479 continue; | |
480 } | |
481 | |
482 if (ngx_strcmp(name->data, file[i].name.data) == 0) { | |
483 return &file[i]; | |
484 } | |
485 } | |
486 } | |
487 | |
488 ngx_test_null(file, ngx_push_array(&cycle->open_files), NULL); | |
489 file->fd = NGX_INVALID_FILE; | |
490 if (name) { | |
491 file->name = *name; | |
492 } | |
493 | |
494 return file; | |
495 } | |
496 | |
497 | |
478 void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err, | 498 void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err, |
479 char *fmt, ...) | 499 char *fmt, ...) |
480 { | 500 { |
481 int len; | 501 int len; |
482 char errstr[MAX_CONF_ERRSTR]; | 502 char errstr[MAX_CONF_ERRSTR]; |
524 | 544 |
525 } else if (ngx_strcasecmp(value[1].data, "off") == 0) { | 545 } else if (ngx_strcasecmp(value[1].data, "off") == 0) { |
526 flag = 0; | 546 flag = 0; |
527 | 547 |
528 } else { | 548 } else { |
529 ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, | 549 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
530 "invalid value \"%s\", it must be \"on\" or \"off\"", | 550 "invalid value \"%s\" in \"%s\" directive, " |
531 value[1].data); | 551 "it must be \"on\" or \"off\"", |
532 return ngx_conf_errstr; | 552 value[1].data, cmd->name.data); |
553 return NGX_CONF_ERROR; | |
533 } | 554 } |
534 | 555 |
535 *(int *) (p + cmd->offset) = flag; | 556 *(int *) (p + cmd->offset) = flag; |
536 | 557 |
537 return NGX_CONF_OK; | 558 return NGX_CONF_OK; |