diff options
author | Igor Sysoev <igor@sysoev.ru> | 2002-12-17 21:08:15 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2002-12-17 21:08:15 +0000 |
commit | 4fa792320aff7522635f2c7045d664a7353c3c86 (patch) | |
tree | 6464468032fcd6393973e391b4308b561218b774 /src | |
parent | 5518aba253096193df31b0f64e7461d1ac224dfd (diff) | |
download | nginx-4fa792320aff7522635f2c7045d664a7353c3c86.tar.gz nginx-4fa792320aff7522635f2c7045d664a7353c3c86.zip |
nginx-0.0.1-2002-12-18-00:08:15 import
Diffstat (limited to 'src')
-rw-r--r-- | src/http/ngx_http_config.c | 122 | ||||
-rw-r--r-- | src/http/ngx_http_core.c | 53 |
2 files changed, 175 insertions, 0 deletions
diff --git a/src/http/ngx_http_config.c b/src/http/ngx_http_config.c index f298bd113..2fb641079 100644 --- a/src/http/ngx_http_config.c +++ b/src/http/ngx_http_config.c @@ -1,4 +1,5 @@ +#include <ngx_config.h> #include <ngx_core.h> #include <ngx_config_command.h> #include <ngx_http.h> @@ -15,6 +16,127 @@ int (*ngx_http_top_header_filter) (ngx_http_request_t *r); void **ngx_srv_conf; void **ngx_loc_conf; +#if 0 +void *ngx_http_block(ngx_conf_t *cf) +{ + ngx_http_conf_ctx_t *ctx; + + ngx_test_null(ctx, + ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), + NGX_ERROR); + + /* null server config */ + ngx_test_null(ctx->srv_conf, + ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module), + NGX_ERROR); + + /* null location config */ + ngx_test_null(ctx->loc_conf, + ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module), + NGX_ERROR); + + 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); + + if (modules[i]->create_loc_conf) + ngx_test_null(ctx->loc_conf[i], + modules[i]->create_loc_conf(cf->pool), + NGX_ERROR); + } + + cf->ctx = ctx; + return ngx_conf_parse(cf); +} + +void *ngx_server_block(ngx_conf_t *cf) +{ + ngx_http_conf_ctx_t *ctx, *prev; + ngx_http_core_loc_conf_t *loc_conf; + + ngx_test_null(ctx, + ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), + NGX_ERROR); + + /* server config */ + ngx_test_null(ctx->srv_conf, + ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module), + NGX_ERROR); + + /* server location config */ + ngx_test_null(ctx->loc_conf, + ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module), + NGX_ERROR); + + + 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); + + if (modules[i]->create_loc_conf) + ngx_test_null(ctx->loc_conf[i], + modules[i]->create_loc_conf(cf->pool), + NGX_ERROR); + } + + prev = cf->ctx; + cf->ctx = ctx; + rc = ngx_conf_parse(cf); + cf->ctx = prev; + + if (loc == NULL) + return NULL; + + for (i = 0; modules[i]; i++) { + 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; + + 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; + } + + return (void *) 1; +} + +void *ngx_location_block(ngx_conf_t *cf) +{ + + ngx_test_null(ctx, + ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), + NGX_ERROR); + + ctx->srv_conf = cf->ctx->srv_conf; + + ngx_test_null(ctx->loc_conf, + ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module), + NGX_ERROR); + + for (i = 0; modules[i]; i++) { + if (modules[i]->create_loc_conf) + ngx_test_null(ctx->loc_conf[i], + modules[i]->create_loc_conf(cf->pool), + NGX_ERROR); + + if (ngx_http_core_module.index == i) + ctx->loc_conf[i].location = cf->args[0]; + } + + push + + return ngx_conf_parse(cf); +} + +#endif int ngx_http_config_modules(ngx_pool_t *pool, ngx_http_module_t **modules) { diff --git a/src/http/ngx_http_core.c b/src/http/ngx_http_core.c index e4f97eef7..cb7bdc9d9 100644 --- a/src/http/ngx_http_core.c +++ b/src/http/ngx_http_core.c @@ -278,6 +278,59 @@ 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; |