From e78825ca7001ef868b32a2f989a7dc62f2a2a9f6 Mon Sep 17 00:00:00 2001 From: Greg Stein Date: Sun, 18 Feb 2001 04:26:13 +0000 Subject: [PATCH] - more ap_conf_vector_t fixup. - break out the cmd_parms to ap_set_config_vectors to clarify/doc what is happening in there and because the function operates independent of cmds. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88227 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_config.h | 42 ++++++++++++++++++++++--------------- modules/http/http_core.c | 23 +++++++++----------- server/config.c | 45 +++++++++++++++++++++++++--------------- 3 files changed, 63 insertions(+), 47 deletions(-) diff --git a/include/http_config.h b/include/http_config.h index 749c7a66aa..9d1d7ada7d 100644 --- a/include/http_config.h +++ b/include/http_config.h @@ -312,7 +312,7 @@ struct cmd_parms_struct { const command_rec *cmd; /** per_dir_config vector passed to handle_command */ - void *context; + struct ap_conf_vector_t *context; /** directive with syntax error */ const ap_directive_t *err_directive; }; @@ -666,10 +666,10 @@ AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive); * @deffunc char *ap_build_cont_config(apr_pool_t *p, apr_pool_t *temp_pool, cmd_parms *parms, ap_directive_t **current, ap_directive_t **curr_parent, char *orig_directive) */ const char * ap_build_cont_config(apr_pool_t *p, apr_pool_t *temp_pool, - cmd_parms *parms, - ap_directive_t **current, - ap_directive_t **curr_parent, - char *orig_directive); + cmd_parms *parms, + ap_directive_t **current, + ap_directive_t **curr_parent, + char *orig_directive); /** * Build a config tree from a config file @@ -689,12 +689,13 @@ AP_DECLARE(const char *) ap_build_config(cmd_parms *parms, * Walk a config tree and setup the server's internal structures * @param conftree The config tree to walk * @param parms The cmd_parms to pass to all functions - * @param config The parms context + * @param section_vector The per-section config vector. * @return Error string on error, NULL otherwise - * @deffunc const char *ap_walk_config(ap_directive_t *conftree, cmd_parms *parms, void *config) + * @deffunc const char *ap_walk_config(ap_directive_t *conftree, cmd_parms *parms, ap_conf_vector_t *section_vector) */ AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree, - cmd_parms *parms, void *config); + cmd_parms *parms, + ap_conf_vector_t *section_vector); /** * ap_check_cmd_context() definitions: @@ -836,7 +837,7 @@ ap_conf_vector_t *ap_create_request_config(apr_pool_t *p); * Setup the config vector for per dir module configs * @param p The pool to allocate the config vector out of * @return The config vector - * @deffunc void *ap_create_per_dir_config(apr_pool_t *p) + * @deffunc ap_conf_vector_t *ap_create_per_dir_config(apr_pool_t *p) */ AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p); @@ -944,14 +945,21 @@ AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name, const com AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod); /** - * Add a per_dir and per_server config vector to a given module - * @param parms The command_parms to use - * @param config The config vector - * @param mod The module to add the vector for. - * @return The new config vector - * @deffunc void *ap_set_config_vectors(cmd_parms *parms, void *config, module *mod) - */ -AP_CORE_DECLARE(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod); + * Ask a module to create per-server and per-section (dir/loc/file) configs + * (if it hasn't happened already). The results are stored in the server's + * config, and the specified per-section config vector. + * @param server The server to operate upon. + * @param section_vector The per-section config vector. + * @param section Which section to create a config for. + * @param mod The module which is defining the config data. + * @param pconf A pool for all configuration allocations. + * @return The (new) per-section config data. + * @deffunc void *ap_set_config_vectors(server_rec *server, ap_conf_vector_t *section_vector, const char *dir, module *mod, apr_pool_t *pconf) + */ +AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server, + ap_conf_vector_t *section_vector, + const char *section, + module *mod, apr_pool_t *pconf); #endif diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 43b11a549b..f9d306ff28 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -1525,7 +1525,7 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg) int old_overrides = cmd->override; char *old_path = cmd->path; core_dir_config *conf; - void *new_dir_conf = ap_create_per_dir_config(cmd->pool); + ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool); regex_t *r = NULL; const command_rec *thiscmd = cmd->cmd; @@ -1569,8 +1569,8 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg) } /* initialize our config and fetch it */ - conf = (core_dir_config *)ap_set_config_vectors(cmd, new_dir_conf, - &core_module); + conf = ap_set_config_vectors(cmd->server, new_dir_conf, cmd->path, + &core_module, cmd->pool); errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_dir_conf); if (errmsg != NULL) @@ -1600,9 +1600,7 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg) core_dir_config *conf; regex_t *r = NULL; const command_rec *thiscmd = cmd->cmd; - - void *new_url_conf = ap_create_per_dir_config(cmd->pool); - + ap_conf_vector_t *new_url_conf = ap_create_per_dir_config(cmd->pool); const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); if (err != NULL) { @@ -1627,8 +1625,8 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg) } /* initialize our config and fetch it */ - conf = (core_dir_config *)ap_set_config_vectors(cmd, new_url_conf, - &core_module); + conf = ap_set_config_vectors(cmd->server, new_url_conf, cmd->path, + &core_module, cmd->pool); errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_url_conf); if (errmsg != NULL) @@ -1661,10 +1659,9 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg) regex_t *r = NULL; const command_rec *thiscmd = cmd->cmd; core_dir_config *c=mconfig; - - void *new_file_conf = ap_create_per_dir_config(cmd->pool); - + ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool); const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_LOCATION); + if (err != NULL) { return err; } @@ -1694,8 +1691,8 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg) } /* initialize our config and fetch it */ - conf = (core_dir_config *)ap_set_config_vectors(cmd, new_file_conf, - &core_module); + conf = ap_set_config_vectors(cmd->server, new_file_conf, cmd->path, + &core_module, cmd->pool); errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf); if (errmsg != NULL) diff --git a/server/config.c b/server/config.c index 64f7530d9d..e8701206d1 100644 --- a/server/config.c +++ b/server/config.c @@ -751,21 +751,26 @@ AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_ return NULL; } -AP_CORE_DECLARE(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod) +AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server, + ap_conf_vector_t *section_vector, + const char *section, + module *mod, apr_pool_t *pconf) { - ap_conf_vector_t *mconfig = ap_get_module_config(config, mod); - ap_conf_vector_t *sconfig = ap_get_module_config(parms->server->module_config, mod); + void *section_config = ap_get_module_config(section_vector, mod); + void *server_config = ap_get_module_config(server->module_config, mod); - if (!mconfig && mod->create_dir_config) { - mconfig = (*mod->create_dir_config) (parms->pool, parms->path); - ap_set_module_config(config, mod, mconfig); + if (!section_config && mod->create_dir_config) { + /* ### need to fix the create_dir_config functions' prototype... */ + section_config = (*mod->create_dir_config) (pconf, (char *)section); + ap_set_module_config(section_vector, mod, section_config); } - if (!sconfig && mod->create_server_config) { - sconfig = (*mod->create_server_config) (parms->pool, parms->server); - ap_set_module_config(parms->server->module_config, mod, sconfig); + if (!server_config && mod->create_server_config) { + server_config = (*mod->create_server_config) (pconf, server); + ap_set_module_config(server->module_config, mod, server_config); } - return mconfig; + + return section_config; } static const char *execute_now(char *cmd_line, const char *args, cmd_parms *parms, @@ -914,7 +919,8 @@ const char *ap_build_cont_config(apr_pool_t *p, apr_pool_t *temp_pool, } static const char *ap_walk_config_sub(const ap_directive_t *current, - cmd_parms *parms, void *config) + cmd_parms *parms, + ap_conf_vector_t *section_vector) { module *mod = top_module; @@ -930,10 +936,14 @@ static const char *ap_walk_config_sub(const ap_directive_t *current, NULL); } else { - void *mconfig = ap_set_config_vectors(parms,config, mod); + void *dir_config = ap_set_config_vectors(parms->server, + section_vector, + parms->path, + mod, + parms->pool); const char *retval; - retval = invoke_cmd(cmd, parms, mconfig, current->args); + retval = invoke_cmd(cmd, parms, dir_config, current->args); if (retval == NULL) { return NULL; } @@ -956,11 +966,12 @@ static const char *ap_walk_config_sub(const ap_directive_t *current, } AP_DECLARE(const char *) ap_walk_config(ap_directive_t *current, - cmd_parms *parms, void *config) + cmd_parms *parms, + ap_conf_vector_t *section_vector) { - void *oldconfig = parms->context; + ap_conf_vector_t *oldconfig = parms->context; - parms->context = config; + parms->context = section_vector; /* scan through all directives, executing each one */ for (; current != NULL; current = current->next) { @@ -969,7 +980,7 @@ AP_DECLARE(const char *) ap_walk_config(ap_directive_t *current, parms->directive = current; /* actually parse the command and execute the correct function */ - errmsg = ap_walk_config_sub(current, parms, config); + errmsg = ap_walk_config_sub(current, parms, section_vector); if (errmsg != NULL) { /* restore the context (just in case) */ parms->context = oldconfig; -- 2.50.1