comparison src/core/ngx_conf_file.c @ 727:532d15ddbe68

glob support in include
author Igor Sysoev <igor@sysoev.ru>
date Mon, 02 Oct 2006 08:46:45 +0000
parents 6d5c1535bb9d
children 666302d1234c
comparison
equal deleted inserted replaced
726:7b71936d5299 727:532d15ddbe68
648 648
649 649
650 static char * 650 static char *
651 ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 651 ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
652 { 652 {
653 ngx_str_t *value, file; 653 char *rv;
654 ngx_int_t n;
655 ngx_str_t *value, file;
656 ngx_glob_t gl;
654 657
655 value = cf->args->elts; 658 value = cf->args->elts;
656 file = value[1]; 659 file = value[1];
657 660
661 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data);
662
658 if (ngx_conf_full_name(cf->cycle, &file) == NGX_ERROR) { 663 if (ngx_conf_full_name(cf->cycle, &file) == NGX_ERROR) {
659 return NGX_CONF_ERROR; 664 return NGX_CONF_ERROR;
660 } 665 }
661 666
662 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data); 667 ngx_memzero(&gl, sizeof(ngx_glob_t));
663 668
664 return ngx_conf_parse(cf, &file); 669 gl.pattern = file.data;
670 gl.log = cf->log;
671
672 if (ngx_open_glob(&gl) != NGX_OK) {
673 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
674 ngx_open_glob_n " \"%s\" failed", file.data);
675 return NGX_CONF_ERROR;
676 }
677
678 rv = NGX_CONF_OK;
679
680 for ( ;; ) {
681 n = ngx_read_glob(&gl, &file);
682
683 if (n != NGX_OK) {
684 break;
685 }
686
687 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data);
688
689 rv = ngx_conf_parse(cf, &file);
690
691 if (rv != NGX_CONF_OK) {
692 break;
693 }
694 }
695
696 ngx_close_glob(&gl);
697
698 return rv;
665 } 699 }
666 700
667 701
668 ngx_int_t 702 ngx_int_t
669 ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name) 703 ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name)