Mercurial > hg > nginx-quic
comparison src/core/ngx_conf_file.c @ 440:f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 27 Sep 2004 16:03:21 +0000 |
parents | 5cdc4838d4e8 |
children | da8c5707af39 |
comparison
equal
deleted
inserted
replaced
439:4fe393d82f44 | 440:f390d1775430 |
---|---|
547 static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 547 static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
548 { | 548 { |
549 ngx_str_t *value, file; | 549 ngx_str_t *value, file; |
550 | 550 |
551 value = cf->args->elts; | 551 value = cf->args->elts; |
552 | 552 file = value[1]; |
553 if (value[1].data[0] == '/') { | 553 |
554 return ngx_conf_parse(cf, &value[1]); | 554 if (ngx_conf_full_name(cf->cycle, &file) == NGX_ERROR){ |
555 } | |
556 | |
557 file.len = cf->cycle->root.len + value[1].len; | |
558 if (!(file.data = ngx_palloc(cf->pool, file.len + 1))) { | |
559 return NGX_CONF_ERROR; | 555 return NGX_CONF_ERROR; |
560 } | 556 } |
561 | 557 |
562 ngx_cpystrn(ngx_cpymem(file.data, cf->cycle->root.data, | |
563 cf->cycle->root.len), | |
564 value[1].data, value[1].len + 1); | |
565 | |
566 ngx_log_error(NGX_LOG_INFO, cf->log, 0, "include %s", file.data); | 558 ngx_log_error(NGX_LOG_INFO, cf->log, 0, "include %s", file.data); |
567 | 559 |
568 return ngx_conf_parse(cf, &file); | 560 return ngx_conf_parse(cf, &file); |
569 } | 561 } |
570 | 562 |
571 | 563 |
564 ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name) | |
565 { | |
566 u_char *p; | |
567 ngx_str_t old; | |
568 | |
569 if (name->data[0] == '/') { | |
570 return NGX_OK; | |
571 } | |
572 | |
573 old = *name; | |
574 | |
575 name->len = cycle->root.len + old.len; | |
576 | |
577 if (!(name->data = ngx_palloc(cycle->pool, name->len + 1))) { | |
578 return NGX_ERROR; | |
579 } | |
580 | |
581 p = ngx_cpymem(name->data, cycle->root.data, cycle->root.len), | |
582 ngx_cpystrn(p, old.data, old.len + 1); | |
583 | |
584 return NGX_OK; | |
585 } | |
586 | |
587 | |
572 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name) | 588 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name) |
573 { | 589 { |
590 ngx_str_t full; | |
574 ngx_uint_t i; | 591 ngx_uint_t i; |
575 ngx_list_part_t *part; | 592 ngx_list_part_t *part; |
576 ngx_open_file_t *file; | 593 ngx_open_file_t *file; |
577 | 594 |
578 if (name) { | 595 if (name) { |
596 full = *name; | |
597 | |
598 if (ngx_conf_full_name(cycle, &full) == NGX_ERROR) { | |
599 return NULL; | |
600 } | |
601 | |
579 part = &cycle->open_files.part; | 602 part = &cycle->open_files.part; |
580 file = part->elts; | 603 file = part->elts; |
581 | 604 |
582 for (i = 0; /* void */ ; i++) { | 605 for (i = 0; /* void */ ; i++) { |
583 | 606 |
588 part = part->next; | 611 part = part->next; |
589 file = part->elts; | 612 file = part->elts; |
590 i = 0; | 613 i = 0; |
591 } | 614 } |
592 | 615 |
593 if (name->len != file[i].name.len) { | 616 if (full.len != file[i].name.len) { |
594 continue; | 617 continue; |
595 } | 618 } |
596 | 619 |
597 if (ngx_strcmp(name->data, file[i].name.data) == 0) { | 620 if (ngx_strcmp(full.data, file[i].name.data) == 0) { |
598 return &file[i]; | 621 return &file[i]; |
599 } | 622 } |
600 } | 623 } |
601 } | 624 } |
602 | 625 |
605 } | 628 } |
606 | 629 |
607 file->fd = NGX_INVALID_FILE; | 630 file->fd = NGX_INVALID_FILE; |
608 | 631 |
609 if (name) { | 632 if (name) { |
610 file->name = *name; | 633 file->name = full; |
634 | |
611 } else { | 635 } else { |
636 | |
637 /* stderr */ | |
638 | |
612 file->name.len = 0; | 639 file->name.len = 0; |
613 file->name.data = NULL; | 640 file->name.data = NULL; |
614 } | 641 } |
615 | 642 |
616 return file; | 643 return file; |