# HG changeset patch # User Igor Sysoev # Date 1040159295 0 # Node ID c2d9ef3ebb6dce65f59b4ab919704a33b78b11bd # Parent 6a0b3d6e9c137d24a12ad239377a4a9ff52aacee nginx-0.0.1-2002-12-18-00:08:15 import diff --git a/src/http/ngx_http_config.c b/src/http/ngx_http_config.c --- a/src/http/ngx_http_config.c +++ b/src/http/ngx_http_config.c @@ -1,4 +1,5 @@ +#include #include #include #include @@ -15,6 +16,127 @@ int (*ngx_http_top_header_filter) (ngx_h 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 --- 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_ } +#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;