aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2002-12-27 07:27:47 +0000
committerIgor Sysoev <igor@sysoev.ru>2002-12-27 07:27:47 +0000
commit6b5c0f70d7cdcc8ac9e63989efcf6911aaf9ab05 (patch)
treeeafd8558e79c67ea1045e9a0bed78f6ba2f92fa8 /src
parent207ed5a589055899a5841d1a9f3074fc4ff407c5 (diff)
downloadnginx-6b5c0f70d7cdcc8ac9e63989efcf6911aaf9ab05.tar.gz
nginx-6b5c0f70d7cdcc8ac9e63989efcf6911aaf9ab05.zip
nginx-0.0.1-2002-12-27-10:27:47 import
Diffstat (limited to 'src')
-rw-r--r--src/core/ngx_config_file.h2
-rw-r--r--src/core/ngx_hunk.c1
-rw-r--r--src/core/ngx_modules.c2
-rw-r--r--src/http/modules/ngx_http_index_handler.c2
-rw-r--r--src/http/ngx_http.h2
-rw-r--r--src/http/ngx_http_config.c163
-rw-r--r--src/http/ngx_http_config.h5
-rw-r--r--src/http/ngx_http_core.c84
-rw-r--r--src/http/ngx_http_header_filter.c2
-rw-r--r--src/http/ngx_http_output_filter.c2
-rw-r--r--src/http/ngx_http_write_filter.c2
-rw-r--r--src/os/win32/ngx_files.c2
-rw-r--r--src/os/win32/ngx_sendv.c2
-rw-r--r--src/os/win32/ngx_stat.c2
14 files changed, 132 insertions, 141 deletions
diff --git a/src/core/ngx_config_file.h b/src/core/ngx_config_file.h
index 768dc666b..97a4d2a33 100644
--- a/src/core/ngx_config_file.h
+++ b/src/core/ngx_config_file.h
@@ -26,6 +26,8 @@
#define NGX_CONF_FILE_DONE 2
+#define NGX_CONF_ERROR (char *) -1
+
typedef struct ngx_conf_s ngx_conf_t;
diff --git a/src/core/ngx_hunk.c b/src/core/ngx_hunk.c
index 1f05dc839..e1e960fd3 100644
--- a/src/core/ngx_hunk.c
+++ b/src/core/ngx_hunk.c
@@ -1,4 +1,5 @@
+#include <ngx_config.h>
#include <ngx_hunk.h>
diff --git a/src/core/ngx_modules.c b/src/core/ngx_modules.c
index 4d43349f3..ad9372baa 100644
--- a/src/core/ngx_modules.c
+++ b/src/core/ngx_modules.c
@@ -1,4 +1,6 @@
+#include <ngx_config.h>
+
#include <ngx_config_file.h>
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index 65a896c99..faddd743a 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -33,7 +33,9 @@ ngx_http_module_t ngx_http_index_module_ctx = {
NGX_HTTP_MODULE,
NULL, /* create server config */
+ NULL, /* init server config */
ngx_http_index_create_conf, /* create location config */
+ ngx_http_index_merge_conf, /* merge location config */
NULL, /* translate handler */
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index 8e94ab9a9..b6bcfe7cc 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -191,7 +191,9 @@ typedef struct {
int index;
void *(*create_srv_conf)(ngx_pool_t *p);
+ void *(*init_srv_conf)(ngx_pool_t *p, void *conf);
void *(*create_loc_conf)(ngx_pool_t *p);
+ void *(*merge_loc_conf)(ngx_pool_t *p, void *prev, void *conf);
int (*translate_handler)(ngx_http_request_t *r);
diff --git a/src/http/ngx_http_config.c b/src/http/ngx_http_config.c
index b003c021a..eb09d5759 100644
--- a/src/http/ngx_http_config.c
+++ b/src/http/ngx_http_config.c
@@ -16,10 +16,11 @@ void **ngx_loc_conf;
/**/
-static int ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy);
+static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy);
+static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy);
-void *null_loc_conf;
+void **null_loc_conf;
static ngx_command_t ngx_http_commands[] = {
@@ -34,11 +35,32 @@ static ngx_command_t ngx_http_commands[] = {
};
-static ngx_http_module_t ngx_http_module_ctx = {
+ngx_module_t ngx_http_module = {
+ NULL, /* module context */
+ ngx_http_commands, /* module directives */
+ 0, /* module type */
+ NULL /* init module */
+};
+
+static ngx_command_t ngx_http_core_commands[] = {
+
+ {ngx_string("server"),
+ NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+ ngx_server_block,
+ NGX_HTTP_MODULE_TYPE,
+ 0},
+
+ {ngx_string(""), 0, NULL, 0, 0}
+};
+
+
+static ngx_http_module_t ngx_http_core_module_ctx = {
NGX_HTTP_MODULE,
NULL, /* create server config */
+ NULL, /* init server config */
NULL, /* create location config */
+ NULL, /* merge location config */
NULL, /* translate handler */
@@ -49,17 +71,17 @@ static ngx_http_module_t ngx_http_module_ctx = {
};
-ngx_module_t ngx_http_module = {
- &ngx_http_module_ctx, /* module context */
- ngx_http_commands, /* module directives */
- 0, /* module type */
+ngx_module_t ngx_http_core_module = {
+ &ngx_http_core_module_ctx, /* module context */
+ ngx_http_core_commands, /* module directives */
+ NGX_HTTP_MODULE_TYPE, /* module type */
NULL /* init module */
};
-static int ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
+static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
{
- int i, j;
+ int i;
ngx_http_module_t *module;
ngx_http_conf_ctx_t *ctx;
@@ -69,30 +91,28 @@ static int ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
}
module = (ngx_http_module_t *) ngx_modules[i]->ctx;
- module->index = i;
+ module->index = ngx_http_max_module++;
}
- ngx_http_max_module = i;
-
ngx_test_null(null_loc_conf,
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
- NGX_ERROR);
+ NGX_CONF_ERROR);
ctx->srv_conf = NULL;
ctx->loc_conf = null_loc_conf;
+ ctx->locations = NULL;
- for (i = 0, j = 0; ngx_modules[i]; i++) {
+ for (i = 0; ngx_modules[i]; i++) {
if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) {
continue;
}
module = (ngx_http_module_t *) ngx_modules[i]->ctx;
- module->index = i;
+
if (module->create_loc_conf) {
- ngx_test_null(null_loc_conf,
+ ngx_test_null(null_loc_conf[module->index],
module->create_loc_conf(cf->pool),
- NGX_ERROR);
- j++;
+ NGX_CONF_ERROR);
}
}
@@ -102,77 +122,96 @@ static int ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
}
-#if 0
-int ngx_server_block(ngx_conf_t *cf)
+static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
{
- ngx_http_conf_ctx_t *ctx, *prev;
+ int i, j;
+ char *rv;
+ void ***loc_conf; /* YES! 3 stars */
+ ngx_http_module_t *module;
+ ngx_http_conf_ctx_t *ctx, *prev;
ngx_test_null(ctx,
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
- NGX_ERROR);
+ NGX_CONF_ERROR);
/* server config */
ngx_test_null(ctx->srv_conf,
- ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module),
- NGX_ERROR);
+ ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
+ NGX_CONF_ERROR);
/* server location config */
ngx_test_null(ctx->loc_conf,
- ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module),
- NGX_ERROR);
+ ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module),
+ NGX_CONF_ERROR);
+ for (i = 0; ngx_modules[i]; i++) {
+ if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) {
+ continue;
+ }
- for (i = 0; modules[i]; i++) {
- if (modules[i]->create_srv_conf)
- ngx_test_null(ctx->srv_conf[i],
- modules[i]->create_srv_conf(cf->pool),
- NGX_ERROR);
+ module = (ngx_http_module_t *) ngx_modules[i]->ctx;
- if (modules[i]->create_loc_conf)
- ngx_test_null(ctx->loc_conf[i],
- modules[i]->create_loc_conf(cf->pool),
- NGX_ERROR);
+ if (module->create_srv_conf) {
+ ngx_test_null(ctx->srv_conf[module->index],
+ module->create_srv_conf(cf->pool),
+ NGX_CONF_ERROR);
+ }
+
+ if (module->create_loc_conf) {
+ ngx_test_null(ctx->loc_conf[module->index],
+ module->create_loc_conf(cf->pool),
+ NGX_CONF_ERROR);
+ }
}
prev = cf->ctx;
cf->ctx = ctx;
- rc = ngx_conf_parse(cf);
+ rv = ngx_conf_parse(cf, NULL);
cf->ctx = prev;
- if (loc == NGX_ERROR)
- return NGX_ERROR;
+ if (rv != NULL)
+ return rv;
- for (i = 0; modules[i]; i++) {
-#if 0
- if (modules[i]->merge_srv_conf)
- if (modules[i]->merge_srv_conf(cf->pool,
- prev->srv_conf, ctx->srv_conf)
- == NGX_ERROR)
- return NGX_ERROR;
-#endif
+ for (i = 0; ngx_modules[i]; i++) {
+ if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) {
+ continue;
+ }
- if (modules[i]->init_srv_conf)
- if (modules[i]->init_srv_conf(cf->pool, ctx->srv_conf) == NGX_ERROR)
- return NGX_ERROR;
-
- if (modules[i]->merge_loc_conf)
- if (modules[i]->merge_loc_conf(cf->pool,
- prev->loc_conf, ctx->loc_conf)
- == NGX_ERROR)
- return NGX_ERROR;
-
- for (array) {
- if (modules[i]->merge_loc_conf(cf->pool,
- ctx->loc_conf, loc->loc_conf)
- == NGX_ERROR)
- return NGX_ERROR;
+ module = (ngx_http_module_t *) ngx_modules[i]->ctx;
+
+ if (module->init_srv_conf) {
+ if (module->init_srv_conf(cf->pool,
+ ctx->srv_conf[module->index])
+ == NGX_CONF_ERROR) {
+ return NGX_CONF_ERROR;
+ }
+ }
+
+ if (module->merge_loc_conf) {
+ if (module->merge_loc_conf(cf->pool,
+ prev->loc_conf[module->index],
+ ctx->loc_conf[module->index])
+ == NGX_CONF_ERROR) {
+ return NGX_CONF_ERROR;
+ }
+
+ loc_conf = (void ***)ctx->locations->elts;
+ for (j = 0; j < ctx->locations->nelts; j++) {
+ if (module->merge_loc_conf(cf->pool,
+ ctx->loc_conf[module->index],
+ loc_conf[j][module->index])
+ == NGX_CONF_ERROR) {
+ return NGX_CONF_ERROR;
+ }
}
}
}
- return NGX_OK;
+ return NULL;
}
+
+#if 0
int ngx_location_block(ngx_conf_t *cf)
{
ngx_http_conf_ctx_t *ctx, *prev;
diff --git a/src/http/ngx_http_config.h b/src/http/ngx_http_config.h
index f0321f642..4bea178eb 100644
--- a/src/http/ngx_http_config.h
+++ b/src/http/ngx_http_config.h
@@ -7,8 +7,9 @@
typedef struct {
- void **srv_conf;
- void **loc_conf;
+ void **srv_conf;
+ void **loc_conf;
+ ngx_array_t *locations;
} ngx_http_conf_ctx_t;
diff --git a/src/http/ngx_http_core.c b/src/http/ngx_http_core.c
index 0890ca579..848dd8e0e 100644
--- a/src/http/ngx_http_core.c
+++ b/src/http/ngx_http_core.c
@@ -21,7 +21,7 @@ int (*ngx_http_top_header_filter) (ngx_http_request_t *r);
int ngx_http_max_module;
-
+#if 0
static ngx_command_t ngx_http_core_commands[] = {
{ngx_string("send_timeout"),
@@ -32,13 +32,15 @@ static ngx_command_t ngx_http_core_commands[] = {
{ngx_string(""), 0, NULL, 0, 0}
};
-
+#endif
ngx_http_module_t ngx_http_core_module_ctx = {
NGX_HTTP_MODULE,
ngx_http_core_create_srv_conf, /* create server config */
+ NULL, /* init server config */
ngx_http_core_create_loc_conf, /* create location config */
+ NULL, /* merge location config */
ngx_http_core_translate_handler, /* translate handler */
@@ -48,14 +50,14 @@ ngx_http_module_t ngx_http_core_module_ctx = {
NULL, /* next output body filter */
};
-
+#if 0
ngx_module_t ngx_http_core_module = {
&ngx_http_core_module_ctx, /* module context */
ngx_http_core_commands, /* module directives */
NGX_HTTP_MODULE_TYPE, /* module type */
NULL /* init module */
};
-
+#endif
int ngx_http_handler(ngx_http_request_t *r)
{
@@ -265,14 +267,10 @@ int ngx_http_close_request(ngx_http_request_t *r)
r->connection->log, "file already closed");
if (r->file.fd != NGX_INVALID_FILE) {
-/* STUB WIN32 */
-#if (WIN32)
- if (ngx_close_file(r->file.fd) == 0)
-#else
- if (ngx_close_file(r->file.fd) == -1)
-#endif
+ if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
ngx_close_file_n " failed");
+ }
}
/*
@@ -307,59 +305,6 @@ int ngx_http_internal_redirect(ngx_http_request_t *r, ngx_str_t uri)
}
-#if 0
-
-
- {"http", ngx_http_enter_container, 0,
- NGX_GLOBAL_CONF, NGX_CONF_CONTAINER},
-
- {"server", ngx_http_enter_server_container, 0,
- NGX_HTTP_CONF, NGX_CONF_CONTAINER],
-
- {"location", ngx_http_enter_location_container, 0,
- NGX_HTTP_SRV_CONF, NGX_CONF_CONTAINER|NGX_CONF_TAKE1}
-
-
-int ngx_http_enter_container()
-{
- create_srv_conf(null_srv_conf)
- create_loc_conf(null_loc_conf)
-}
-
-int ngx_http_exit_container()
-{
- nothing ?
-}
-
-
-int ngx_http_enter_server_container()
-{
- create_srv_conf()
- create_loc_conf(NULL)
-}
-
-int ngx_http_exit_server_container()
-{
- merge_srv_conf(srv_conf, null_srv_conf)
- merge_loc_conf(loc_conf, null_loc_conf)
-
- iterate check_loc_conf_is_set and merge_loc_conf()
-}
-
-int ngx_http_enter_location_container()
-{
- create_loc_conf(loc)
-
- push to array
-}
-
-int ngx_http_exit_location_container()
-{
-}
-
-#endif
-
-
static void *ngx_http_core_create_srv_conf(ngx_pool_t *pool)
{
ngx_http_core_srv_conf_t *conf;
@@ -386,16 +331,3 @@ static void *ngx_http_core_create_loc_conf(ngx_pool_t *pool)
return conf;
}
-
-#if 0
-static void *ngx_http_core_create_conf(ngx_pool_t *pool)
-{
-
- ngx_test_null(conf, ngx_palloc(pool, sizeof(ngx_http_core_conf_t)), NULL);
-
- ngx_test_null(conf->srv, ngx_http_core_create_srv_conf_t(pool), NULL);
- ngx_test_null(conf->loc, ngx_http_core_create_loc_conf_t(pool), NULL);
- conf->parent =
- conf->next = NULL;
-}
-#endif
diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c
index acc5df5f5..aab4e528b 100644
--- a/src/http/ngx_http_header_filter.c
+++ b/src/http/ngx_http_header_filter.c
@@ -18,7 +18,9 @@ ngx_http_module_t ngx_http_header_filter_module_ctx = {
NGX_HTTP_MODULE,
NULL, /* create server config */
+ NULL, /* init server config */
NULL, /* create location config */
+ NULL, /* merge location config */
NULL, /* translate handler */
diff --git a/src/http/ngx_http_output_filter.c b/src/http/ngx_http_output_filter.c
index 8b8b0e658..f19584580 100644
--- a/src/http/ngx_http_output_filter.c
+++ b/src/http/ngx_http_output_filter.c
@@ -30,7 +30,9 @@ static ngx_http_module_t ngx_http_output_filter_module_ctx = {
NGX_HTTP_MODULE,
NULL, /* create server config */
+ NULL, /* init server config */
ngx_http_output_filter_create_conf, /* create location config */
+ NULL, /* merge location config */
NULL, /* translate handler */
diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c
index 7c60d8fe5..c4321c7c7 100644
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter.c
@@ -27,7 +27,9 @@ ngx_http_module_t ngx_http_write_filter_module_ctx = {
NGX_HTTP_MODULE,
NULL, /* create server config */
+ NULL, /* init server config */
ngx_http_write_filter_create_conf, /* create location config */
+ NULL, /* merge location config */
NULL, /* translate handler */
diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c
index 47bf56dc5..60e132b2a 100644
--- a/src/os/win32/ngx_files.c
+++ b/src/os/win32/ngx_files.c
@@ -1,4 +1,6 @@
+#include <ngx_config.h>
+
#include <ngx_core.h>
#include <ngx_types.h>
#include <ngx_file.h>
diff --git a/src/os/win32/ngx_sendv.c b/src/os/win32/ngx_sendv.c
index 452df9f15..b04362990 100644
--- a/src/os/win32/ngx_sendv.c
+++ b/src/os/win32/ngx_sendv.c
@@ -1,4 +1,6 @@
+#include <ngx_config.h>
+
#include <ngx_core.h>
#include <ngx_types.h>
#include <ngx_errno.h>
diff --git a/src/os/win32/ngx_stat.c b/src/os/win32/ngx_stat.c
index 5c844b14f..81559bc31 100644
--- a/src/os/win32/ngx_stat.c
+++ b/src/os/win32/ngx_stat.c
@@ -1,5 +1,5 @@
-#include <windows.h>
+#include <ngx_config.h>
#include <ngx_stat.h>