nginx-0.0.3-2004-05-18-19:29:08 import
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index fc4c950..bb05b72 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -3,7 +3,34 @@
#include <ngx_core.h>
-/* Ten fixed arguments */
+static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+
+
+static ngx_command_t ngx_conf_commands[] = {
+
+ { ngx_string("include"),
+ NGX_ANY_CONF|NGX_CONF_TAKE1,
+ ngx_conf_include,
+ 0,
+ 0,
+ NULL },
+
+ ngx_null_command
+};
+
+
+ngx_module_t ngx_conf_module = {
+ NGX_MODULE,
+ NULL, /* module context */
+ ngx_conf_commands, /* module directives */
+ NGX_CONF_MODULE, /* module type */
+ NULL, /* init module */
+ NULL /* init child */
+};
+
+
+
+/* The ten fixed arguments */
static int argument_number[] = {
NGX_CONF_NOARGS,
@@ -513,6 +540,27 @@
}
+static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ ngx_str_t *value, file;
+
+ value = cf->args->elts;
+
+ file.len = cf->cycle->root.len + value[1].len;
+ if (!(file.data = ngx_palloc(cf->pool, file.len + 1))) {
+ 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_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
{
ngx_uint_t i;
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 01080cc..ff01e88 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -37,7 +37,9 @@
#define NGX_CONF_2MORE 0x00001000
#define NGX_DIRECT_CONF 0x00010000
+
#define NGX_MAIN_CONF 0x01000000
+#define NGX_ANY_CONF 0x0F000000
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 24e30f7..989973a 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -24,6 +24,7 @@
ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
{
void *rv;
+ u_char *root;
ngx_uint_t i, n, failed;
ngx_log_t *log;
ngx_conf_t conf;
@@ -33,6 +34,7 @@
ngx_open_file_t *file;
ngx_listening_t *ls, *nls;
ngx_core_module_t *module;
+ char cwd[NGX_MAX_PATH + 1];
log = old_cycle->log;
@@ -51,6 +53,42 @@
cycle->conf_file = old_cycle->conf_file;
+ for (i = cycle->conf_file.len; i > 0; i--) {
+ if (cycle->conf_file.data[i] == '/') {
+ break;
+ }
+ }
+
+ if (i == 0 && cycle->conf_file.data[i] != '/') {
+ if (ngx_getcwd(cwd, NGX_MAX_PATH) == 0) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ ngx_getcwd_n " failed");
+ ngx_destroy_pool(pool);
+ return NULL;
+ }
+
+ for ( /* void */; i < NGX_MAX_PATH && cwd[i]; i++) /* void */;
+ cwd[i] = '/';
+ cwd[i + 1] = '\0';
+
+ root = (u_char *) cwd;
+
+ } else {
+ root = cycle->conf_file.data;
+ }
+
+ cycle->root.len = ++i;
+ cycle->root.data = ngx_palloc(pool, ++i);
+ if (cycle->root.data == NULL) {
+ ngx_destroy_pool(pool);
+ return NULL;
+ }
+
+ ngx_cpystrn(cycle->root.data, root, i);
+
+ ngx_log_error(NGX_LOG_INFO, log, 0, "root: %s", cycle->root.data);
+
+
n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;
if (!(cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)))) {
ngx_destroy_pool(pool);
diff --git a/src/core/ngx_cycle.h b/src/core/ngx_cycle.h
index 6588a7a..e1b5368 100644
--- a/src/core/ngx_cycle.h
+++ b/src/core/ngx_cycle.h
@@ -25,6 +25,7 @@
ngx_cycle_t *old_cycle;
ngx_str_t conf_file;
+ ngx_str_t root;
};