config.c revision ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dc
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder/* Copyright 2000-2004 Apache Software Foundation
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski * Licensed under the Apache License, Version 2.0 (the "License");
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder * you may not use this file except in compliance with the License.
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian Maeder * You may obtain a copy of the License at
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder * http://www.apache.org/licenses/LICENSE-2.0
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * Unless required by applicable law or agreed to in writing, software
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * distributed under the License is distributed on an "AS IS" BASIS,
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * See the License for the specific language governing permissions and
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * limitations under the License.
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder * http_config.c: once was auxillary functions for reading httpd's config
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder * file and converting filenames into a namespace
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder * Wall-to-wall rewrite for Apache... commands which are part of the
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder * server core can now be found next door in "http_core.c". Now contains
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder * general command loop, and functions which do bookkeeping for the new
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder * Apache config stuff (modules and configuration vectors).
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#include "http_log.h" /* for errors in parse_htaccess */
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder#include "http_request.h" /* for default_handler (see invoke_handler) */
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE_DATA const char *ap_server_argv0 = NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE_DATA const char *ap_server_root = NULL;
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian MaederAP_DECLARE_DATA apr_array_header_t *ap_server_pre_read_config = NULL;
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian MaederAP_DECLARE_DATA apr_array_header_t *ap_server_post_read_config = NULL;
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian MaederAP_DECLARE_DATA apr_array_header_t *ap_server_config_defines = NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE_DATA ap_directive_t *ap_conftree = NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_IMPLEMENT_HOOK_RUN_ALL(int, header_parser,
8865728716566f42fa73e7e0bc080ba3225df764Christian Maeder/* During the course of debugging I expanded this macro out, so
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * rather than remove all the useful information there is in the
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * following lines, I'm going to leave it here in case anyone
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * else finds it useful.
8865728716566f42fa73e7e0bc080ba3225df764Christian Maeder * Ben has looked at it and thinks it correct :)
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE(int) ap_hook_post_config(ap_HOOK_post_config_t *pf,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char * const *aszPre,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder const char * const *aszSucc,
a9e804dbec424ec36e34bab955cbe90edac5baa6Christian Maeder ap_LINK_post_config_t *pHook;
b76d27eba526ecac2a20400fa505ec5c642ae7d2Dominik Luecke if (!_hooks.link_post_config) {
b76d27eba526ecac2a20400fa505ec5c642ae7d2Dominik Luecke _hooks.link_post_config = apr_array_make(apr_hook_global_pool, 1,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich sizeof(ap_LINK_post_config_t));
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich apr_hook_sort_register("post_config", &_hooks.link_post_config);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder pHook = apr_array_push(_hooks.link_post_config);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder pHook->pFunc = pf;
2353f65833a3da763392f771223250cd50b8d873Christian Maeder pHook->aszPredecessors = aszPre;
2353f65833a3da763392f771223250cd50b8d873Christian Maeder pHook->aszSuccessors = aszSucc;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder pHook->nOrder = nOrder;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder pHook->szName = apr_hook_debug_current;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (apr_hook_debug_enabled)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder apr_hook_debug_show("post_config", aszPre, aszSucc);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_DECLARE(apr_array_header_t *) ap_hook_get_post_config(void) {
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return _hooks.link_post_config;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_DECLARE(int) ap_run_post_config(apr_pool_t *pconf,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder apr_pool_t *plog,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder apr_pool_t *ptemp,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder server_rec *s)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder ap_LINK_post_config_t *pHook;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder if(!_hooks.link_post_config)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder pHook = (ap_LINK_post_config_t *)_hooks.link_post_config->elts;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder for (n = 0; n < _hooks.link_post_config->nelts; ++n)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder pHook[n].pFunc (pconf, plog, ptemp, s);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_IMPLEMENT_HOOK_RUN_FIRST(int, handler, (request_rec *r),
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_IMPLEMENT_HOOK_RUN_FIRST(int, quick_handler, (request_rec *r, int lookup),
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_IMPLEMENT_HOOK_VOID(optional_fn_retrieve, (void), ())
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder/****************************************************************
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * We begin with the functions which deal with the linked list
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * of modules which control just about all of the server operation.
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder/* total_modules is the number of modules that have been linked
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder * into the server.
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder/* dynamic_modules is the number of modules that have been added
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * after the pre-loaded ones have been set up. It shouldn't be larger
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder * than DYNAMIC_MODULE_LIMIT.
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian MaederAP_DECLARE_DATA module *ap_top_module = NULL;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_DECLARE_DATA module **ap_loaded_modules=NULL;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maedertypedef void *(*dir_maker_func)(apr_pool_t *, char *);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maedertypedef void *(*merger_func)(apr_pool_t *, void *, void *);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder/* Dealing with config vectors. These are associated with per-directory,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * per-server, and per-request configuration, and have a void* pointer for
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * each modules. The nature of the structure pointed to is private to the
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * module in question... the core doesn't (and can't) know. However, there
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * are defined interfaces which allow it to create instances of its private
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * per-directory and per-server structures, and to merge the per-directory
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * structures of a directory and its subdirectory (producing a new one in
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * which the defaults applying to the base directory have been properly
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * overridden).
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maederstatic ap_conf_vector_t *create_empty_config(apr_pool_t *p)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void *conf_vector = apr_pcalloc(p, sizeof(void *) *
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maederstatic ap_conf_vector_t *create_default_per_dir_config(apr_pool_t *p)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void **conf_vector = apr_pcalloc(p, sizeof(void *) *
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder for (modp = ap_top_module; modp; modp = modp->next) {
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder dir_maker_func df = modp->create_dir_config;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder conf_vector[modp->module_index] = (*df)(p, NULL);
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_CORE_DECLARE(ap_conf_vector_t *) ap_merge_per_dir_configs(apr_pool_t *p,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void **conf_vector = apr_palloc(p, sizeof(void *) * total_modules);
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder for (modp = ap_top_module; modp; modp = modp->next) {
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder conf_vector[i] = (*df)(p, base_vector[i], new_vector[i]);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstatic ap_conf_vector_t *create_server_config(apr_pool_t *p, server_rec *s)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void **conf_vector = apr_pcalloc(p, sizeof(void *) *
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder for (modp = ap_top_module; modp; modp = modp->next) {
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder conf_vector[modp->module_index] = (*modp->create_server_config)(p, s);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstatic void merge_server_configs(apr_pool_t *p, ap_conf_vector_t *base,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder /* Can reuse the 'virt' vector for the spine of it, since we don't
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * have to deal with the moral equivalent of .htaccess files here...
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder for (modp = ap_top_module; modp; modp = modp->next) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder merger_func df = modp->merge_server_config;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder virt_vector[i] = (*df)(p, base_vector[i], virt_vector[i]);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_CORE_DECLARE(ap_conf_vector_t *) ap_create_request_config(apr_pool_t *p)
beff4152e9f0fe90885458d1a1733b183a2a8816Christian MaederAP_CORE_DECLARE(ap_conf_vector_t *) ap_create_conn_config(apr_pool_t *p)
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maederstatic int ap_invoke_filter_init(ap_filter_t *filters)
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder int result = filters->frec->filter_init_func(filters);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r)
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich const char *p;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * The new insert_filter stage makes the most sense here. We only use
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * it when we are going to run the request, so we must insert filters
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * if any are available. Since the goal of this phase is to allow all
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * modules to insert a filter if they want to, this filter returns
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * void. I just can't see any way that this filter can reasonably
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * fail, either your modules inserts something or it doesn't. rbb
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder /* Before continuing, allow each filter that is in the two chains to
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * run their init function to let them do any magic before we could
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * start generating data.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder result = ap_invoke_filter_init(r->input_filters);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder result = ap_invoke_filter_init(r->output_filters);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder handler = r->content_type ? r->content_type : ap_default_type(r);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder if ((p=ap_strchr_c(handler, ';')) != NULL) {
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder char *new_handler = (char *)apr_pmemdup(r->pool, handler,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder /* MIME type arguments */
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder if (result == DECLINED && r->handler && r->filename) {
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder "handler \"%s\" not found for: %s", r->handler, r->filename);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return result == DECLINED ? HTTP_INTERNAL_SERVER_ERROR : result;
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * A method number either hardcoded into apache or
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * added by a module and registered.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return (cmd->limited & (AP_METHOD_BIT << methnum)) ? 1 : 0;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return 0; /* not found */
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder printf("Registering hooks for %s\n", m->name);
8865728716566f42fa73e7e0bc080ba3225df764Christian Maeder/* One-time setup for precompiled modules --- NOT to be done on restart */
91ba5d95b2472cb075646b6120a559dc6581a867Christian MaederAP_DECLARE(void) ap_add_module(module *m, apr_pool_t *p)
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder /* This could be called from a LoadModule httpd.conf command,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * after the file has been linked and the module structure within it
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * teased out...
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder if (m->version != MODULE_MAGIC_NUMBER_MAJOR) {
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder "%s: module \"%s\" is not compatible with this "
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder "version of Apache (found %d, need %d).",
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder "Please contact the vendor for the correct version.");
16bd58b831e09422f0f2f1c9da2a66f0487239f0Christian Maeder if (dynamic_modules > DYNAMIC_MODULE_LIMIT) {
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder "%s: module \"%s\" could not be loaded, because"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
818b228955ef40dd5a253bd942dd6ab8779ed713Christian Maeder "module limit was reached. Please increase "
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder "DYNAMIC_MODULE_LIMIT and recompile.");
4a2f7efdf67dfcda0946f1b6373f41976ddea7a4Christian Maeder /* Some C compilers put a complete path into __FILE__, but we want
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder * only the filename (e.g. mod_includes.c). So check for path
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder * components (Unix and DOS), and remove them.
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder /* __FILE__ =
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder * "*POSIX(/home/martin/apache/src/modules/standard/mod_info.c)"
27b988cb88bfa05fe6f35a853d76ef04f61293efChristian Maeder /* We cannot fix the string in-place, because it's const */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder char *tmp = strdup(m->name); /* FIXME: memory leak, albeit a small one */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#endif /*_OSD_POSIX*/
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder /* FIXME: is this the right place to call this?
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * It doesn't appear to be
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * remove_module undoes what add_module did. There are some caveats:
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder * when the module is removed, its slot is lost so all the current
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu * per-dir and per-server configurations are invalid. So we should
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu * only ever call this function when you are invalidating almost
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu * all our current data. I.e. when doing a restart.
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu /* We are the top module, special case */
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu /* Not the top module, find use. When found modp will
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu * point to the module _before_ us in the list
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder /* Uh-oh, this module doesn't exist */
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder "Cannot remove module %s: not found in module list",
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder /* Eliminate us from the module list */
0ea2cddb8715a770e646895e16b7b8085f49167cChristian Maeder m->module_index = -1; /* simulate being unloaded, should
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder * be unnecessary */
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian MaederAP_DECLARE(void) ap_add_loaded_module(module *mod, apr_pool_t *p)
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder * Add module pointer to top of chained module list
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder * And module pointer to list of loaded modules
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * Notes: 1. ap_add_module() would already complain if no more space
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder * exists for adding a dynamically loaded module
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder * 2. ap_add_module() accepts double inclusion, so we have
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder * to accept this, too.
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder for (m = ap_loaded_modules; *m != NULL; m++)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_DECLARE(void) ap_remove_loaded_module(module *mod)
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder * Remove module pointer from chained module list
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder * Remove module pointer from list of loaded modules
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder * Note: 1. We cannot determine if the module was successfully
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder * removed by ap_remove_module().
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder * 2. We have not to complain explicity when the module
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder * is not found because ap_remove_module() did it
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder * for us already.
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder for (m = m2 = ap_loaded_modules, done = 0; *m2 != NULL; m2++) {
2353f65833a3da763392f771223250cd50b8d873Christian MaederAP_DECLARE(void) ap_setup_prelinked_modules(process_rec *process)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * Initialise total_modules variable and module indices
2353f65833a3da763392f771223250cd50b8d873Christian Maeder for (m = ap_preloaded_modules; *m != NULL; m++)
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder * Initialise list of loaded modules
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder ap_loaded_modules = (module **)apr_palloc(process->pool,
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder sizeof(module *) * (total_modules + DYNAMIC_MODULE_LIMIT + 1));
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder "Ouch! Out of memory in ap_setup_prelinked_modules()!");
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder for (m = ap_preloaded_modules, m2 = ap_loaded_modules; *m != NULL; )
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder * Initialize chain of linked (=activate) modules
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder for (m = ap_prelinked_modules; *m != NULL; m++)
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE(const char *) ap_find_module_name(module *m)
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE(module *) ap_find_linked_module(const char *name)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder for (modp = ap_top_module; modp; modp = modp->next) {
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu/* Add a named module. Returns 1 if module found, 0 otherwise. */
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan PascanuAP_DECLARE(int) ap_add_named_module(const char *name, apr_pool_t *p)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder for (modp = ap_loaded_modules[i]; modp; modp = ap_loaded_modules[++i]) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder /* Only add modules that are not already enabled. */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/*****************************************************************
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * Resource, access, and .htaccess config files now parsed by a common
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * command loop.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * Let's begin with the basics; parsing the line and
59a10395caff224b2ec541f94dac5082a506c00fChristian Maeder * invoking the function...
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maederstatic const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder if ((parms->override & cmd->req_override) == 0)
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder return apr_pstrcat(parms->pool, cmd->name, " not allowed here", NULL);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder return cmd->AP_RAW_ARGS(parms, mconfig, args);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return apr_pstrcat(parms->pool, cmd->name, " takes no arguments",
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder return apr_pstrcat(parms->pool, cmd->name, " takes one argument",
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder if (*w == '\0' || *w2 == '\0' || *args != 0)
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder return apr_pstrcat(parms->pool, cmd->name, " takes two arguments",
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder return cmd->AP_TAKE2(parms, mconfig, w, w2);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder return apr_pstrcat(parms->pool, cmd->name, " takes 1-2 arguments",
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return cmd->AP_TAKE2(parms, mconfig, w, *w2 ? w2 : NULL);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder if (*w == '\0' || *w2 == '\0' || *w3 == '\0' || *args != 0)
2353f65833a3da763392f771223250cd50b8d873Christian Maeder return apr_pstrcat(parms->pool, cmd->name, " takes three arguments",
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (*w == '\0' || *w2 == '\0' || *args != 0)
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder " takes two or three arguments",
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder " takes one, two or three arguments",
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder if (*w == '\0' || (w2 && *w2 && !w3) || *args != 0)
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder " takes one or three arguments",
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder while (*(w = ap_getword_conf(parms->pool, &args)) != '\0') {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (errmsg && strcmp(errmsg, DECLINE_CMD) != 0)
2353f65833a3da763392f771223250cd50b8d873Christian Maeder " requires at least two arguments",
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder while (*(w2 = ap_getword_conf(parms->pool, &args)) != '\0') {
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder errmsg = cmd->AP_TAKE2(parms, mconfig, w, w2);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (errmsg && strcmp(errmsg, DECLINE_CMD) != 0)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (*w == '\0' || (strcasecmp(w, "on") && strcasecmp(w, "off")))
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return apr_pstrcat(parms->pool, cmd->name, " must be On or Off",
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return cmd->AP_FLAG(parms, mconfig, strcasecmp(w, "off") != 0);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder " is improperly configured internally (server bug)",
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name,
return NULL;
return cmdp;
return NULL;
const char *section,
return section_config;
const char *args;
char *cmd_name;
return NULL;
args = l;
return NULL;
if (*current) {
if (*curr_parent) {
if (*current) {
if (*current) {
if (!*conftree) {
return retval;
return retval;
char *orig_directive)
char l[MAX_STRING_LEN];
char *bracket;
const char *retval;
return retval;
return NULL;
NULL);
mod,
const char *retval;
return NULL;
return NULL;
return retval;
const char *errmsg;
return errmsg;
return NULL;
char l[MAX_STRING_LEN];
const char *errmsg;
return errmsg;
return errmsg;
return NULL;
void *struct_ptr,
const char *arg)
return NULL;
void *struct_ptr,
const char *arg)
char *endptr;
return error_str;
void *struct_ptr,
const char *arg_)
return NULL;
return NULL;
const char *arg)
const char *path;
if (!path) {
return NULL;
void *struct_ptr,
const char *arg)
return newpath;
return NULL;
char l[MAX_STRING_LEN];
const char *args;
char *cmd_name;
args = l;
const char *msg;
return msg;
NULL);
NULL);
int curr_idx;
return NULL;
bufsiz);
return buf;
const char *errmsg;
if (errmsg) {
errmsg);
char *fname;
} fnames;
apr_pool_t *p,
const char *errmsg;
int current;
ptemp);
apr_pool_t *p,
/* don't require conf/httpd.conf if we have a -C or -c switch */
int current;
ptemp);
apr_pool_t *p,
const char *errmsg;
if (errmsg) {
return HTTP_INTERNAL_SERVER_ERROR;
return OK;
const char *d, const char *access_name)
return OK;
while (access_name[0]) {
const char *errmsg;
ap_cfg_closefile(f);
if (errmsg) {
return HTTP_INTERNAL_SERVER_ERROR;
filename);
return HTTP_FORBIDDEN;
return OK;
const char *hostname,
s->timeout = 0;
s->keep_alive_timeout = 0;
*ps = s;
s->port = 0;
const char *filename,
const char *confname;
p, ptemp);
if (!confname) {
filename);
p, ptemp);
module *m)
if (m->create_server_config)
(*m->create_server_config)(p, s));
if (m->create_dir_config)
module *m;
if (m->rewrite_args) {
for (n = 0; ap_loaded_modules[n]; ++n) {
for (n = 0; ap_loaded_modules[n]; ++n)
return MPM_NAME;