add drive letter for Win32 root path
This commit is contained in:
parent
4c5403bbf7
commit
641c68fb6c
1 changed files with 71 additions and 24 deletions
|
@ -12,6 +12,7 @@
|
||||||
static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
|
static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
|
||||||
static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
|
static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
|
||||||
static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||||
|
static ngx_int_t ngx_conf_test_full_name(ngx_str_t *name);
|
||||||
static void ngx_conf_flush_files(ngx_cycle_t *cycle);
|
static void ngx_conf_flush_files(ngx_cycle_t *cycle);
|
||||||
|
|
||||||
|
|
||||||
|
@ -802,29 +803,15 @@ ngx_int_t
|
||||||
ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
|
ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
u_char *p, *prefix;
|
u_char *p, *n, *prefix;
|
||||||
ngx_str_t old;
|
ngx_int_t rc;
|
||||||
|
|
||||||
#if (NGX_WIN32)
|
rc = ngx_conf_test_full_name(name);
|
||||||
|
|
||||||
if (name->len > 2
|
if (rc == NGX_OK) {
|
||||||
&& name->data[1] == ':'
|
return rc;
|
||||||
&& ((name->data[0] >= 'a' && name->data[0] <= 'z')
|
|
||||||
|| (name->data[0] >= 'A' && name->data[0] <= 'Z')))
|
|
||||||
{
|
|
||||||
return NGX_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
if (name->data[0] == '/') {
|
|
||||||
return NGX_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
old = *name;
|
|
||||||
|
|
||||||
if (conf_prefix) {
|
if (conf_prefix) {
|
||||||
len = cycle->conf_prefix.len;
|
len = cycle->conf_prefix.len;
|
||||||
prefix = cycle->conf_prefix.data;
|
prefix = cycle->conf_prefix.data;
|
||||||
|
@ -834,19 +821,79 @@ ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
|
||||||
prefix = cycle->prefix.data;
|
prefix = cycle->prefix.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
name->len = len + old.len;
|
#if (NGX_WIN32)
|
||||||
name->data = ngx_pnalloc(cycle->pool, name->len + 1);
|
|
||||||
if (name->data == NULL) {
|
if (rc == 2) {
|
||||||
|
len = rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
n = ngx_pnalloc(cycle->pool, len + name->len + 1);
|
||||||
|
if (n == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ngx_cpymem(name->data, prefix, len);
|
p = ngx_cpymem(n, prefix, len);
|
||||||
ngx_cpystrn(p, old.data, old.len + 1);
|
ngx_cpystrn(p, name->data, name->len + 1);
|
||||||
|
|
||||||
|
name->len += len;
|
||||||
|
name->data = n;
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_int_t
|
||||||
|
ngx_conf_test_full_name(ngx_str_t *name)
|
||||||
|
{
|
||||||
|
#if (NGX_WIN32)
|
||||||
|
u_char c0, c1;
|
||||||
|
|
||||||
|
c0 = name->data[0];
|
||||||
|
|
||||||
|
if (name->len < 2) {
|
||||||
|
if (c0 == '/') {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NGX_DECLINED;
|
||||||
|
}
|
||||||
|
|
||||||
|
c1 = name->data[1];
|
||||||
|
|
||||||
|
if (c1 == ':') {
|
||||||
|
c0 |= 0x20;
|
||||||
|
|
||||||
|
if ((c0 >= 'a' && c0 <= 'z')) {
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NGX_DECLINED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c1 == '/') {
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c0 == '/') {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NGX_DECLINED;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
if (name->data[0] == '/') {
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NGX_DECLINED;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_open_file_t *
|
ngx_open_file_t *
|
||||||
ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
|
ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue