Mercurial > hg > nginx-quic
diff 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 |
line wrap: on
line diff
--- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -549,33 +549,56 @@ static char *ngx_conf_include(ngx_conf_t ngx_str_t *value, file; value = cf->args->elts; + file = value[1]; - if (value[1].data[0] == '/') { - return ngx_conf_parse(cf, &value[1]); - } - - file.len = cf->cycle->root.len + value[1].len; - if (!(file.data = ngx_palloc(cf->pool, file.len + 1))) { + if (ngx_conf_full_name(cf->cycle, &file) == NGX_ERROR){ return NGX_CONF_ERROR; } - ngx_cpystrn(ngx_cpymem(file.data, cf->cycle->root.data, - cf->cycle->root.len), - value[1].data, value[1].len + 1); - ngx_log_error(NGX_LOG_INFO, cf->log, 0, "include %s", file.data); return ngx_conf_parse(cf, &file); } +ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name) +{ + u_char *p; + ngx_str_t old; + + if (name->data[0] == '/') { + return NGX_OK; + } + + old = *name; + + name->len = cycle->root.len + old.len; + + if (!(name->data = ngx_palloc(cycle->pool, name->len + 1))) { + return NGX_ERROR; + } + + p = ngx_cpymem(name->data, cycle->root.data, cycle->root.len), + ngx_cpystrn(p, old.data, old.len + 1); + + return NGX_OK; +} + + ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name) { + ngx_str_t full; ngx_uint_t i; ngx_list_part_t *part; ngx_open_file_t *file; if (name) { + full = *name; + + if (ngx_conf_full_name(cycle, &full) == NGX_ERROR) { + return NULL; + } + part = &cycle->open_files.part; file = part->elts; @@ -590,11 +613,11 @@ ngx_open_file_t *ngx_conf_open_file(ngx_ i = 0; } - if (name->len != file[i].name.len) { + if (full.len != file[i].name.len) { continue; } - if (ngx_strcmp(name->data, file[i].name.data) == 0) { + if (ngx_strcmp(full.data, file[i].name.data) == 0) { return &file[i]; } } @@ -607,8 +630,12 @@ ngx_open_file_t *ngx_conf_open_file(ngx_ file->fd = NGX_INVALID_FILE; if (name) { - file->name = *name; + file->name = full; + } else { + + /* stderr */ + file->name.len = 0; file->name.data = NULL; }