aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/ngx_http_config.c')
-rw-r--r--src/http/ngx_http_config.c212
1 files changed, 105 insertions, 107 deletions
diff --git a/src/http/ngx_http_config.c b/src/http/ngx_http_config.c
index f33fc625d..b003c021a 100644
--- a/src/http/ngx_http_config.c
+++ b/src/http/ngx_http_config.c
@@ -3,58 +3,106 @@
#include <ngx_core.h>
#include <ngx_config_file.h>
#include <ngx_http.h>
+#include <ngx_http_core.h>
+#include <ngx_http_config.h>
#include <ngx_http_write_filter.h>
#include <ngx_http_output_filter.h>
#include <ngx_http_index_handler.h>
-int ngx_max_module;
-
-int (*ngx_http_top_header_filter) (ngx_http_request_t *r);
-
-/* STUB: gobal srv and loc conf */
+/* STUB */
void **ngx_srv_conf;
void **ngx_loc_conf;
+/**/
-#if 0
-int ngx_http_block(ngx_conf_t *cf)
+
+static int ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy);
+
+
+void *null_loc_conf;
+
+
+static ngx_command_t ngx_http_commands[] = {
+
+ {ngx_string("http"),
+ NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+ ngx_http_block,
+ 0,
+ 0},
+
+ {ngx_string(""), 0, NULL, 0, 0}
+};
+
+
+static ngx_http_module_t ngx_http_module_ctx = {
+ NGX_HTTP_MODULE,
+
+ NULL, /* create server config */
+ NULL, /* create location config */
+
+ NULL, /* translate handler */
+
+ NULL, /* output header filter */
+ NULL, /* next output header filter */
+ NULL, /* output body filter */
+ NULL /* next output body filter */
+};
+
+
+ngx_module_t ngx_http_module = {
+ &ngx_http_module_ctx, /* module context */
+ ngx_http_commands, /* module directives */
+ 0, /* module type */
+ NULL /* init module */
+};
+
+
+static int ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy)
{
+ int i, j;
+ ngx_http_module_t *module;
ngx_http_conf_ctx_t *ctx;
- ngx_test_null(ctx,
- ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
- NGX_ERROR);
+ for (i = 0; ngx_modules[i]; i++) {
+ if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) {
+ continue;
+ }
-#if 0
- /* null server config */
- ngx_test_null(ctx->srv_conf,
- ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module),
- NGX_ERROR);
-#endif
+ module = (ngx_http_module_t *) ngx_modules[i]->ctx;
+ module->index = i;
+ }
- /* null location config */
- ngx_test_null(ctx->loc_conf,
- ngx_pcalloc(cf->pool, sizeof(void *) * ngx_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);
- for (i = 0; modules[i]; i++) {
-#if 0
- if (modules[i]->create_srv_conf)
- ngx_test_null(ctx->srv_conf[i],
- modules[i]->create_srv_conf(cf->pool),
- NGX_ERROR);
-#endif
+ ctx->srv_conf = NULL;
+ ctx->loc_conf = null_loc_conf;
- if (modules[i]->create_loc_conf)
- ngx_test_null(ctx->loc_conf[i],
- modules[i]->create_loc_conf(cf->pool),
+ for (i = 0, j = 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,
+ module->create_loc_conf(cf->pool),
NGX_ERROR);
+ j++;
+ }
}
cf->ctx = ctx;
- return ngx_conf_parse(cf);
+ cf->type = NGX_HTTP_MODULE_TYPE;
+ return ngx_conf_parse(cf, NULL);
}
+
+#if 0
int ngx_server_block(ngx_conf_t *cf)
{
ngx_http_conf_ctx_t *ctx, *prev;
@@ -155,21 +203,29 @@ int ngx_location_block(ngx_conf_t *cf)
#endif
-int ngx_http_config_modules(ngx_pool_t *pool, ngx_http_module_t **modules)
+
+int ngx_http_config_modules(ngx_pool_t *pool, ngx_module_t **modules)
{
int i;
+ ngx_http_module_t *module;
for (i = 0; modules[i]; i++) {
- modules[i]->index = i;
+ if (modules[i]->type != NGX_HTTP_MODULE_TYPE) {
+ continue;
+ }
+
+ module = (ngx_http_module_t *) modules[i]->ctx;
+ module->index = i;
}
- ngx_max_module = i;
+ ngx_http_max_module = i;
+#if 0
ngx_test_null(ngx_srv_conf,
- ngx_pcalloc(pool, sizeof(void *) * ngx_max_module),
+ ngx_pcalloc(pool, sizeof(void *) * ngx_http_max_module),
NGX_ERROR);
ngx_test_null(ngx_loc_conf,
- ngx_pcalloc(pool, sizeof(void *) * ngx_max_module),
+ ngx_pcalloc(pool, sizeof(void *) * ngx_http_max_module),
NGX_ERROR);
for (i = 0; modules[i]; i++) {
@@ -179,94 +235,36 @@ int ngx_http_config_modules(ngx_pool_t *pool, ngx_http_module_t **modules)
if (modules[i]->create_loc_conf)
ngx_loc_conf[i] = modules[i]->create_loc_conf(pool);
}
+#endif
}
-int ngx_http_init_modules(ngx_pool_t *pool, ngx_http_module_t **modules)
-{
- int i;
- for (i = 0; modules[i]; i++) {
- if (modules[i]->init_module)
- modules[i]->init_module(pool);
- }
-}
-
-int ngx_http_init_filters(ngx_pool_t *pool, ngx_http_module_t **modules)
+void ngx_http_init_filters(ngx_pool_t *pool, ngx_module_t **modules)
{
- int i;
+ int i;
+ ngx_http_module_t *module;
int (*ohf)(ngx_http_request_t *r);
int (*obf)(ngx_http_request_t *r, ngx_chain_t *ch);
ohf = NULL;
-
- for (i = 0; modules[i]; i++) {
- if (modules[i]->output_header_filter) {
- modules[i]->next_output_header_filter = ohf;
- ohf = modules[i]->output_header_filter;
- }
- }
-
- ngx_http_top_header_filter = ohf;
-
obf = NULL;
for (i = 0; modules[i]; i++) {
- if (modules[i]->output_body_filter) {
- modules[i]->next_output_body_filter = obf;
- obf = modules[i]->output_body_filter;
+ if (modules[i]->type != NGX_HTTP_MODULE_TYPE) {
+ continue;
}
- }
-}
-
-/* STUB */
-ngx_http_output_filter_set_stub(ngx_pool_t *pool, ngx_http_module_t **modules)
-{
- int i;
- ngx_command_t *cmd;
-
- for (i = 0; modules[i]; i++) {
- if (modules[i] == &ngx_http_output_filter_module) {
- for (cmd = modules[i]->commands; cmd->name; cmd++) {
- if (strcmp(cmd->name, "output_buffer") == 0) {
- cmd->set(ngx_loc_conf[i], cmd->offset, "32768");
- }
- }
+ module = (ngx_http_module_t *) modules[i]->ctx;
+ if (module->output_header_filter) {
+ module->next_output_header_filter = ohf;
+ ohf = module->output_header_filter;
}
- }
-}
-
-ngx_http_write_filter_set_stub(ngx_pool_t *pool, ngx_http_module_t **modules)
-{
- int i;
- ngx_command_t *cmd;
- for (i = 0; modules[i]; i++) {
- if (modules[i] == &ngx_http_write_filter_module) {
- for (cmd = modules[i]->commands; cmd->name; cmd++) {
- if (strcmp(cmd->name, "write_buffer") == 0) {
- cmd->set(ngx_loc_conf[i], cmd->offset, "1500");
- }
- }
+ if (module->output_body_filter) {
+ module->next_output_body_filter = obf;
+ obf = module->output_body_filter;
}
}
-}
-
-ngx_http_index_set_stub(ngx_pool_t *pool, ngx_http_module_t **modules)
-{
- int i;
- ngx_str_t index;
- ngx_command_t *cmd;
- for (i = 0; modules[i]; i++) {
- if (modules[i] == &ngx_http_index_module) {
- for (cmd = modules[i]->commands; cmd->name; cmd++) {
- if (strcmp(cmd->name, "index") == 0) {
- index.len = sizeof("index.html") - 1;
- index.data = "index.html";
- cmd->set(pool, ngx_loc_conf[i], &index);
- }
- }
- }
- }
+ ngx_http_top_header_filter = ohf;
}