config.c revision ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dc
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder/* Copyright 2000-2004 Apache Software Foundation
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder *
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
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder *
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder * http://www.apache.org/licenses/LICENSE-2.0
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder *
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.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder */
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder/*
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 *
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder * Rob McCool
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder *
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).
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder *
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder * rst
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder *
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder */
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder#include "apr.h"
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder#include "apr_strings.h"
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder#include "apr_portable.h"
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder#include "apr_file_io.h"
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder#include "apr_fnmatch.h"
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder#define APR_WANT_STDIO
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder#define APR_WANT_STRFUNC
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder#include "apr_want.h"
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder#define CORE_PRIVATE
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder
109a53dbf4c9233f869f63ba7a7f3fece49973c3Christian Maeder#include "ap_config.h"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#include "httpd.h"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#include "http_config.h"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#include "http_protocol.h"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#include "http_core.h"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#include "http_log.h" /* for errors in parse_htaccess */
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder#include "http_request.h" /* for default_handler (see invoke_handler) */
3a9d784341454573b50b32fa1b494e7418df3086Christian Maeder#include "http_main.h"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#include "http_vhost.h"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#include "util_cfgtree.h"
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder#include "mpm.h"
fbc7d11880751ef87862b1f4650b16c01c6763f1Klaus Luettich
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE_DATA const char *ap_server_argv0 = NULL;
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE_DATA const char *ap_server_root = NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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;
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE_DATA ap_directive_t *ap_conftree = NULL;
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAPR_HOOK_STRUCT(
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder APR_HOOK_LINK(header_parser)
ea38cad7e4f09060750da5d0b8ebc426628c4d88Christian Maeder APR_HOOK_LINK(pre_config)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder APR_HOOK_LINK(post_config)
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder APR_HOOK_LINK(open_logs)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder APR_HOOK_LINK(child_init)
d81905a5b924415c524d702df26204683c82c12eChristian Maeder APR_HOOK_LINK(handler)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder APR_HOOK_LINK(quick_handler)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder APR_HOOK_LINK(optional_fn_retrieve)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_IMPLEMENT_HOOK_RUN_ALL(int, header_parser,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder (request_rec *r), (r), OK, DECLINED)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_IMPLEMENT_HOOK_RUN_ALL(int, pre_config,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder (apr_pool_t *pconf, apr_pool_t *plog,
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder apr_pool_t *ptemp),
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder (pconf, plog, ptemp), OK, DECLINED)
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder
6352f3c31da3043783a13be6594aacb2147378baRazvan PascanuAP_IMPLEMENT_HOOK_RUN_ALL(int, post_config,
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu (apr_pool_t *pconf, apr_pool_t *plog,
b324cda6178c49ddeead3ce62b832ccf644cbcabRazvan Pascanu apr_pool_t *ptemp, server_rec *s),
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu (pconf, plog, ptemp, s), OK, DECLINED)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder *
8865728716566f42fa73e7e0bc080ba3225df764Christian Maeder * Ben has looked at it and thinks it correct :)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder *
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,
fdac680252d7347858bd67b4c2a2aaa52e623815Christian Maeder int nOrder)
fdac680252d7347858bd67b4c2a2aaa52e623815Christian Maeder{
a9e804dbec424ec36e34bab955cbe90edac5baa6Christian Maeder ap_LINK_post_config_t *pHook;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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);
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich }
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
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
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (apr_hook_debug_enabled)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder apr_hook_debug_show("post_config", aszPre, aszSucc);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_DECLARE(apr_array_header_t *) ap_hook_get_post_config(void) {
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return _hooks.link_post_config;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
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{
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder ap_LINK_post_config_t *pHook;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder int n;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder if(!_hooks.link_post_config)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
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);
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder */
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_IMPLEMENT_HOOK_RUN_ALL(int, open_logs,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder (apr_pool_t *pconf, apr_pool_t *plog,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder apr_pool_t *ptemp, server_rec *s),
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder (pconf, plog, ptemp, s), OK, DECLINED)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_IMPLEMENT_HOOK_VOID(child_init,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder (apr_pool_t *pchild, server_rec *s),
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder (pchild, s))
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_IMPLEMENT_HOOK_RUN_FIRST(int, handler, (request_rec *r),
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder (r), DECLINED)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_IMPLEMENT_HOOK_RUN_FIRST(int, quick_handler, (request_rec *r, int lookup),
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder (r, lookup), DECLINED)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_IMPLEMENT_HOOK_VOID(optional_fn_retrieve, (void), ())
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder/****************************************************************
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 */
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder/* total_modules is the number of modules that have been linked
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder * into the server.
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstatic int total_modules = 0;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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.
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder */
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maederstatic int dynamic_modules = 0;
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian MaederAP_DECLARE_DATA module *ap_top_module = NULL;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_DECLARE_DATA module **ap_loaded_modules=NULL;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maedertypedef int (*handler_func)(request_rec *);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maedertypedef void *(*dir_maker_func)(apr_pool_t *, char *);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maedertypedef void *(*merger_func)(apr_pool_t *, void *, void *);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
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 Maeder */
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maederstatic ap_conf_vector_t *create_empty_config(apr_pool_t *p)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder{
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void *conf_vector = apr_pcalloc(p, sizeof(void *) *
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder (total_modules + DYNAMIC_MODULE_LIMIT));
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return conf_vector;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maederstatic ap_conf_vector_t *create_default_per_dir_config(apr_pool_t *p)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder{
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void **conf_vector = apr_pcalloc(p, sizeof(void *) *
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder (total_modules + DYNAMIC_MODULE_LIMIT));
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder module *modp;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder for (modp = ap_top_module; modp; modp = modp->next) {
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder dir_maker_func df = modp->create_dir_config;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder if (df)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder conf_vector[modp->module_index] = (*df)(p, NULL);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder }
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder return (ap_conf_vector_t *)conf_vector;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder}
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_CORE_DECLARE(ap_conf_vector_t *) ap_merge_per_dir_configs(apr_pool_t *p,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder ap_conf_vector_t *base,
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder ap_conf_vector_t *new_conf)
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder{
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void **conf_vector = apr_palloc(p, sizeof(void *) * total_modules);
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu void **base_vector = (void **)base;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void **new_vector = (void **)new_conf;
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder module *modp;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder for (modp = ap_top_module; modp; modp = modp->next) {
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder int i = modp->module_index;
d81905a5b924415c524d702df26204683c82c12eChristian Maeder
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder if (!new_vector[i]) {
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder conf_vector[i] = base_vector[i];
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder }
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder else {
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder merger_func df = modp->merge_dir_config;
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder if (df && base_vector[i]) {
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder conf_vector[i] = (*df)(p, base_vector[i], new_vector[i]);
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder }
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder else
5b5f3190cc8d51a7942dda33a1ec45345cca5028Thiemo Wiedemeyer conf_vector[i] = new_vector[i];
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder }
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder }
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return (ap_conf_vector_t *)conf_vector;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder}
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstatic ap_conf_vector_t *create_server_config(apr_pool_t *p, server_rec *s)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder{
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void **conf_vector = apr_pcalloc(p, sizeof(void *) *
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder (total_modules + DYNAMIC_MODULE_LIMIT));
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder module *modp;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder for (modp = ap_top_module; modp; modp = modp->next) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (modp->create_server_config)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder conf_vector[modp->module_index] = (*modp->create_server_config)(p, s);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return (ap_conf_vector_t *)conf_vector;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstatic void merge_server_configs(apr_pool_t *p, ap_conf_vector_t *base,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder ap_conf_vector_t *virt)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder{
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 */
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void **base_vector = (void **)base;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder void **virt_vector = (void **)virt;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder module *modp;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder for (modp = ap_top_module; modp; modp = modp->next) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder merger_func df = modp->merge_server_config;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder int i = modp->module_index;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder if (!virt_vector[i])
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder virt_vector[i] = base_vector[i];
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder else if (df)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder virt_vector[i] = (*df)(p, base_vector[i], virt_vector[i]);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder }
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_CORE_DECLARE(ap_conf_vector_t *) ap_create_request_config(apr_pool_t *p)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder{
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return create_empty_config(p);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder}
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
beff4152e9f0fe90885458d1a1733b183a2a8816Christian MaederAP_CORE_DECLARE(ap_conf_vector_t *) ap_create_conn_config(apr_pool_t *p)
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder{
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder return create_empty_config(p);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder}
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder{
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return create_empty_config(p);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maederstatic int ap_invoke_filter_init(ap_filter_t *filters)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder{
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder while (filters) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (filters->frec->filter_init_func) {
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder int result = filters->frec->filter_init_func(filters);
3c4e64e0b4361a24275ee8f308fa965ab1e52f2eHeng Jiang if (result != OK) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return result;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
818b228955ef40dd5a253bd942dd6ab8779ed713Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder filters = filters->next;
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich }
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich return OK;
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder{
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich const char *handler;
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich const char *p;
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich int result;
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich const char *old_handler = r->handler;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder /*
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 */
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder ap_run_insert_filter(r);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
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 */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder result = ap_invoke_filter_init(r->input_filters);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder if (result != OK) {
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return result;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder }
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder result = ap_invoke_filter_init(r->output_filters);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder if (result != OK) {
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return result;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder }
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder if (!r->handler) {
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,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder p - handler + 1);
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder char *p2 = new_handler + (p - handler);
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder handler = new_handler;
a9e804dbec424ec36e34bab955cbe90edac5baa6Christian Maeder
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder /* MIME type arguments */
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder while (p2 > handler && p2[-1] == ' ')
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder --p2; /* strip trailing spaces */
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder *p2='\0';
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder }
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich r->handler = handler;
b76d27eba526ecac2a20400fa505ec5c642ae7d2Dominik Luecke }
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder result = ap_run_handler(r);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder r->handler = old_handler;
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder
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 }
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return result == DECLINED ? HTTP_INTERNAL_SERVER_ERROR : result;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder}
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method)
27b988cb88bfa05fe6f35a853d76ef04f61293efChristian Maeder{
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder int methnum;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder methnum = ap_method_number_of(method);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder /*
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * A method number either hardcoded into apache or
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * added by a module and registered.
8865728716566f42fa73e7e0bc080ba3225df764Christian Maeder */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (methnum != M_INVALID) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return (cmd->limited & (AP_METHOD_BIT << methnum)) ? 1 : 0;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder }
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return 0; /* not found */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder{
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (m->register_hooks) {
8865728716566f42fa73e7e0bc080ba3225df764Christian Maeder if (getenv("SHOW_HOOKS")) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder printf("Registering hooks for %s\n", m->name);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder apr_hook_debug_enabled = 1;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder apr_hook_debug_current = m->name;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder m->register_hooks(p);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder }
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
8865728716566f42fa73e7e0bc080ba3225df764Christian Maeder/* One-time setup for precompiled modules --- NOT to be done on restart */
4f1815aad02f2d2a7a34864bbafd563961b72886Christian Maeder
91ba5d95b2472cb075646b6120a559dc6581a867Christian MaederAP_DECLARE(void) ap_add_module(module *m, apr_pool_t *p)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder{
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...
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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).",
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder ap_server_argv0, m->name, m->version,
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder MODULE_MAGIC_NUMBER_MAJOR);
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder "Please contact the vendor for the correct version.");
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder exit(1);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder if (m->next == NULL) {
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder m->next = ap_top_module;
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder ap_top_module = m;
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder }
d81905a5b924415c524d702df26204683c82c12eChristian Maeder
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder if (m->module_index == -1) {
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder m->module_index = total_modules++;
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu dynamic_modules++;
91ba5d95b2472cb075646b6120a559dc6581a867Christian Maeder
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"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder " the dynamic", ap_server_argv0, m->name);
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.");
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder exit(1);
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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.
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder */
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder if (ap_strrchr_c(m->name, '/'))
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder m->name = 1 + ap_strrchr_c(m->name, '/');
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder
ab2f38d9cd1249f6bc9cc5b838dc2fcd76189c0fChristian Maeder if (ap_strrchr_c(m->name, '\\'))
974b0baababf2878820de073b8fad8db68bef08aDominik Luecke m->name = 1 + ap_strrchr_c(m->name, '\\');
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder#ifdef _OSD_POSIX
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder /* __FILE__ =
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder * "*POSIX(/home/martin/apache/src/modules/standard/mod_info.c)"
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder */
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder
27b988cb88bfa05fe6f35a853d76ef04f61293efChristian Maeder /* We cannot fix the string in-place, because it's const */
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder if (m->name[strlen(m->name)-1] == ')') {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder char *tmp = strdup(m->name); /* FIXME: memory leak, albeit a small one */
2353f65833a3da763392f771223250cd50b8d873Christian Maeder tmp[strlen(tmp)-1] = '\0';
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder m->name = tmp;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#endif /*_OSD_POSIX*/
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder /* FIXME: is this the right place to call this?
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * It doesn't appear to be
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder */
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder ap_register_hooks(m, p);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder/*
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.
e5636f167d8113960d320407cbbd7cd3580241d4Christian Maeder */
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan PascanuAP_DECLARE(void) ap_remove_module(module *m)
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu{
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu module *modp;
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu modp = ap_top_module;
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu if (modp == m) {
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu /* We are the top module, special case */
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu ap_top_module = modp->next;
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu m->next = NULL;
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu }
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu else {
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu /* Not the top module, find use. When found modp will
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu * point to the module _before_ us in the list
66a774f13272fde036481edd2298081ab3d04678Razvan Pascanu */
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu
fefee7e1dee1ee5f0768a03a4abae88d1ca2c3fdRazvan Pascanu while (modp && modp->next != m) {
66a774f13272fde036481edd2298081ab3d04678Razvan Pascanu modp = modp->next;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
9dd71ac51c9a6e72bcb126224f9c64131698b636Christian Maeder if (!modp) {
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",
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder m->name);
0ea2cddb8715a770e646895e16b7b8085f49167cChristian Maeder return;
0ea2cddb8715a770e646895e16b7b8085f49167cChristian Maeder }
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder /* Eliminate us from the module list */
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder modp->next = modp->next->next;
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder }
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder
0ea2cddb8715a770e646895e16b7b8085f49167cChristian Maeder m->module_index = -1; /* simulate being unloaded, should
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder * be unnecessary */
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder dynamic_modules--;
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder total_modules--;
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder}
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian MaederAP_DECLARE(void) ap_add_loaded_module(module *mod, apr_pool_t *p)
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder{
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder module **m;
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder /*
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder * Add module pointer to top of chained module list
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder */
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder ap_add_module(mod, p);
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder /*
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder * And module pointer to list of loaded modules
2353f65833a3da763392f771223250cd50b8d873Christian Maeder *
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 */
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder for (m = ap_loaded_modules; *m != NULL; m++)
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder ;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder *m++ = mod;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder *m = NULL;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_DECLARE(void) ap_remove_loaded_module(module *mod)
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder{
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder module **m;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder module **m2;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder int done;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder /*
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder * Remove module pointer from chained module list
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder */
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder ap_remove_module(mod);
93bc87ee96c68506945dbad8c704badaa42ecf14Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder /*
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder * Remove module pointer from list of loaded modules
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder *
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 */
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder for (m = m2 = ap_loaded_modules, done = 0; *m2 != NULL; m2++) {
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder if (*m2 == mod && done == 0)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder done = 1;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder else
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder *m++ = *m2;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder *m = NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder}
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian MaederAP_DECLARE(void) ap_setup_prelinked_modules(process_rec *process)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder{
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder module **m;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder module **m2;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder apr_hook_global_pool=process->pconf;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder /*
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * Initialise total_modules variable and module indices
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder total_modules = 0;
2353f65833a3da763392f771223250cd50b8d873Christian Maeder for (m = ap_preloaded_modules; *m != NULL; m++)
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder (*m)->module_index = total_modules++;
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder /*
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder * Initialise list of loaded modules
528539f3d544c24afe14e979fe51f03e50aa6e9cChristian Maeder */
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder ap_loaded_modules = (module **)apr_palloc(process->pool,
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder sizeof(module *) * (total_modules + DYNAMIC_MODULE_LIMIT + 1));
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (ap_loaded_modules == NULL) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder "Ouch! Out of memory in ap_setup_prelinked_modules()!");
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder }
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder for (m = ap_preloaded_modules, m2 = ap_loaded_modules; *m != NULL; )
59a10395caff224b2ec541f94dac5082a506c00fChristian Maeder *m2++ = *m++;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder *m2 = NULL;
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder /*
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder * Initialize chain of linked (=activate) modules
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder for (m = ap_prelinked_modules; *m != NULL; m++)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder ap_add_module(*m, process->pconf);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder apr_hook_sort_all();
2353f65833a3da763392f771223250cd50b8d873Christian Maeder}
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE(const char *) ap_find_module_name(module *m)
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder{
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder return m->name;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder}
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederAP_DECLARE(module *) ap_find_linked_module(const char *name)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder{
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder module *modp;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder for (modp = ap_top_module; modp; modp = modp->next) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (strcmp(modp->name, name) == 0)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return modp;
964ee9fff06b8c821e1d00207f6f185301371be8Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder return NULL;
964ee9fff06b8c821e1d00207f6f185301371be8Christian Maeder}
964ee9fff06b8c821e1d00207f6f185301371be8Christian Maeder
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)
964ee9fff06b8c821e1d00207f6f185301371be8Christian Maeder{
964ee9fff06b8c821e1d00207f6f185301371be8Christian Maeder module *modp;
964ee9fff06b8c821e1d00207f6f185301371be8Christian Maeder int i = 0;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder for (modp = ap_loaded_modules[i]; modp; modp = ap_loaded_modules[++i]) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (strcmp(modp->name, name) == 0) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder /* Only add modules that are not already enabled. */
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder if (modp->next == NULL) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder ap_add_module(modp, p);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return 1;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return 0;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder}
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/*****************************************************************
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder *
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * Resource, access, and .htaccess config files now parsed by a common
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * command loop.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder *
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * Let's begin with the basics; parsing the line and
59a10395caff224b2ec541f94dac5082a506c00fChristian Maeder * invoking the function...
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder */
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maederstatic const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder void *mconfig, const char *args)
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder{
2353f65833a3da763392f771223250cd50b8d873Christian Maeder char *w, *w2, *w3;
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder const char *errmsg = NULL;
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder if ((parms->override & cmd->req_override) == 0)
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder return apr_pstrcat(parms->pool, cmd->name, " not allowed here", NULL);
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder parms->info = cmd->cmd_data;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder parms->cmd = cmd;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder switch (cmd->args_how) {
4b1833c7d3af466e6bcba24f16304e0a78e8da87Christian Maeder case RAW_ARGS:
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder#ifdef RESOLVE_ENV_PER_TOKEN
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder args = ap_resolve_env(parms->pool,args);
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder#endif
2353f65833a3da763392f771223250cd50b8d873Christian Maeder return cmd->AP_RAW_ARGS(parms, mconfig, args);
4b1833c7d3af466e6bcba24f16304e0a78e8da87Christian Maeder
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder case NO_ARGS:
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (*args != 0)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return apr_pstrcat(parms->pool, cmd->name, " takes no arguments",
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder NULL);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder return cmd->AP_NO_ARGS(parms, mconfig);
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder case TAKE1:
2353f65833a3da763392f771223250cd50b8d873Christian Maeder w = ap_getword_conf(parms->pool, &args);
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder if (*w == '\0' || *args != 0)
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder return apr_pstrcat(parms->pool, cmd->name, " takes one argument",
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder return cmd->AP_TAKE1(parms, mconfig, w);
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder case TAKE2:
dbc98cd8a9a829e020cfa0a9f3aff89de75caaa9Christian Maeder w = ap_getword_conf(parms->pool, &args);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder w2 = ap_getword_conf(parms->pool, &args);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
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);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder return cmd->AP_TAKE2(parms, mconfig, w, w2);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder case TAKE12:
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder w = ap_getword_conf(parms->pool, &args);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder w2 = ap_getword_conf(parms->pool, &args);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder if (*w == '\0' || *args != 0)
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder return apr_pstrcat(parms->pool, cmd->name, " takes 1-2 arguments",
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return cmd->AP_TAKE2(parms, mconfig, w, *w2 ? w2 : NULL);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder case TAKE3:
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w = ap_getword_conf(parms->pool, &args);
0a64bfd28dff15bc93e1f7a86e0a8052e879636dChristian Maeder w2 = ap_getword_conf(parms->pool, &args);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder w3 = ap_getword_conf(parms->pool, &args);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
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
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder case TAKE23:
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w = ap_getword_conf(parms->pool, &args);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w2 = ap_getword_conf(parms->pool, &args);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (*w == '\0' || *w2 == '\0' || *args != 0)
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder return apr_pstrcat(parms->pool, cmd->name,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder " takes two or three arguments",
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder case TAKE123:
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w = ap_getword_conf(parms->pool, &args);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (*w == '\0' || *args != 0)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return apr_pstrcat(parms->pool, cmd->name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder " takes one, two or three arguments",
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder case TAKE13:
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder w = ap_getword_conf(parms->pool, &args);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder if (*w == '\0' || (w2 && *w2 && !w3) || *args != 0)
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder return apr_pstrcat(parms->pool, cmd->name,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder " takes one or three arguments",
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return cmd->AP_TAKE3(parms, mconfig, w, w2, w3);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder case ITERATE:
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder while (*(w = ap_getword_conf(parms->pool, &args)) != '\0') {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder errmsg = cmd->AP_TAKE1(parms, mconfig, w);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (errmsg && strcmp(errmsg, DECLINE_CMD) != 0)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return errmsg;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder }
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return errmsg;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder case ITERATE2:
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder w = ap_getword_conf(parms->pool, &args);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (*w == '\0' || *args == 0)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return apr_pstrcat(parms->pool, cmd->name,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder " requires at least two arguments",
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder while (*(w2 = ap_getword_conf(parms->pool, &args)) != '\0') {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder errmsg = cmd->AP_TAKE2(parms, mconfig, w, w2);
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (errmsg && strcmp(errmsg, DECLINE_CMD) != 0)
a1c6679d00e15a949730ab640159e0adc5b0e3e7Christian Maeder return errmsg;
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder }
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder return errmsg;
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder case FLAG:
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder w = ap_getword_conf(parms->pool, &args);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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",
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder NULL);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder return cmd->AP_FLAG(parms, mconfig, strcasecmp(w, "off") != 0);
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder default:
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return apr_pstrcat(parms->pool, cmd->name,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder " is improperly configured internally (server bug)",
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder NULL);
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder }
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder}
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian MaederAP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name,
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder const command_rec *cmds)
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder{
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder while (cmds->name) {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (!strcasecmp(name, cmds->name))
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder return cmds;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder ++cmds;
a3a7d8b3cdf05c8040c62dbcf9a15dc5042cd721Christian Maeder }
return NULL;
}
AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(
const char *cmd_name, module **mod)
{
const command_rec *cmdp;
module *modp;
for (modp = *mod; modp; modp = modp->next) {
if (modp->cmds && (cmdp = ap_find_command(cmd_name, modp->cmds))) {
*mod = modp;
return cmdp;
}
}
return NULL;
}
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)
{
void *section_config = ap_get_module_config(section_vector, mod);
void *server_config = ap_get_module_config(server->module_config, mod);
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 (!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 section_config;
}
static const char *execute_now(char *cmd_line, const char *args,
cmd_parms *parms,
apr_pool_t *p, apr_pool_t *ptemp,
ap_directive_t **sub_tree,
ap_directive_t *parent);
static const char *ap_build_config_sub(apr_pool_t *p, apr_pool_t *temp_pool,
const char *l, cmd_parms *parms,
ap_directive_t **current,
ap_directive_t **curr_parent,
ap_directive_t **conftree)
{
const char *retval = NULL;
const char *args;
char *cmd_name;
ap_directive_t *newdir;
module *mod = ap_top_module;
const command_rec *cmd;
if (*l == '#' || *l == '\0')
return NULL;
#if RESOLVE_ENV_PER_TOKEN
args = l;
#else
args = ap_resolve_env(temp_pool, l);
#endif
cmd_name = ap_getword_conf(p, &args);
if (*cmd_name == '\0') {
/* Note: this branch should not occur. An empty line should have
* triggered the exit further above.
*/
return NULL;
}
if (cmd_name[1] != '/') {
char *lastc = cmd_name + strlen(cmd_name) - 1;
if (*lastc == '>') {
*lastc = '\0' ;
}
if (cmd_name[0] == '<' && *args == '\0') {
args = ">";
}
}
newdir = apr_pcalloc(p, sizeof(ap_directive_t));
newdir->filename = parms->config_file->name;
newdir->line_num = parms->config_file->line_number;
newdir->directive = cmd_name;
newdir->args = apr_pstrdup(p, args);
if ((cmd = ap_find_command_in_modules(cmd_name, &mod)) != NULL) {
if (cmd->req_override & EXEC_ON_READ) {
ap_directive_t *sub_tree = NULL;
parms->err_directive = newdir;
retval = execute_now(cmd_name, args, parms, p, temp_pool,
&sub_tree, *curr_parent);
if (*current) {
(*current)->next = sub_tree;
}
else {
*current = sub_tree;
if (*curr_parent) {
(*curr_parent)->first_child = (*current);
}
if (*current) {
(*current)->parent = (*curr_parent);
}
}
if (*current) {
if (!*conftree) {
/* Before walking *current to the end of the list,
* set the head to *current.
*/
*conftree = *current;
}
while ((*current)->next != NULL) {
(*current) = (*current)->next;
(*current)->parent = (*curr_parent);
}
}
return retval;
}
}
if (cmd_name[0] == '<') {
if (cmd_name[1] != '/') {
(*current) = ap_add_node(curr_parent, *current, newdir, 1);
}
else if (*curr_parent == NULL) {
parms->err_directive = newdir;
return apr_pstrcat(p, cmd_name,
" without matching <", cmd_name + 2,
" section", NULL);
}
else {
char *bracket = cmd_name + strlen(cmd_name) - 1;
if (*bracket != '>') {
parms->err_directive = newdir;
return apr_pstrcat(p, cmd_name,
"> directive missing closing '>'", NULL);
}
*bracket = '\0';
if (strcasecmp(cmd_name + 2,
(*curr_parent)->directive + 1) != 0) {
parms->err_directive = newdir;
return apr_pstrcat(p, "Expected </",
(*curr_parent)->directive + 1, "> but saw ",
cmd_name, ">", NULL);
}
*bracket = '>';
/* done with this section; move up a level */
*current = *curr_parent;
*curr_parent = (*current)->parent;
}
}
else {
*current = ap_add_node(curr_parent, *current, newdir, 0);
}
return retval;
}
AP_DECLARE(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)
{
char l[MAX_STRING_LEN];
char *bracket;
const char *retval;
ap_directive_t *sub_tree = NULL;
bracket = apr_pstrcat(p, orig_directive + 1, ">", NULL);
while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
if (!memcmp(l, "</", 2)
&& (strcasecmp(l + 2, bracket) == 0)
&& (*curr_parent == NULL)) {
break;
}
retval = ap_build_config_sub(p, temp_pool, l, parms, current,
curr_parent, &sub_tree);
if (retval != NULL)
return retval;
if (sub_tree == NULL && curr_parent != NULL) {
sub_tree = *curr_parent;
}
if (sub_tree == NULL && current != NULL) {
sub_tree = *current;
}
}
*current = sub_tree;
return NULL;
}
static const char *ap_walk_config_sub(const ap_directive_t *current,
cmd_parms *parms,
ap_conf_vector_t *section_vector)
{
module *mod = ap_top_module;
while (1) {
const command_rec *cmd;
if (!(cmd = ap_find_command_in_modules(current->directive, &mod))) {
parms->err_directive = current;
return apr_pstrcat(parms->pool, "Invalid command '",
current->directive,
"', perhaps mis-spelled or defined by a module "
"not included in the server configuration",
NULL);
}
else {
void *dir_config = ap_set_config_vectors(parms->server,
section_vector,
parms->path,
mod,
parms->pool);
const char *retval;
/* Once was enough? */
if (cmd->req_override & EXEC_ON_READ) {
return NULL;
}
retval = invoke_cmd(cmd, parms, dir_config, current->args);
if (retval == NULL) {
return NULL;
}
if (strcmp(retval, DECLINE_CMD) != 0) {
/* If the directive in error has already been set, don't
* replace it. Otherwise, an error inside a container
* will be reported as occuring on the first line of the
* container.
*/
if (!parms->err_directive) {
parms->err_directive = current;
}
return retval;
}
mod = mod->next; /* Next time around, skip this one */
}
}
/* NOTREACHED */
}
AP_DECLARE(const char *) ap_walk_config(ap_directive_t *current,
cmd_parms *parms,
ap_conf_vector_t *section_vector)
{
ap_conf_vector_t *oldconfig = parms->context;
parms->context = section_vector;
/* scan through all directives, executing each one */
for (; current != NULL; current = current->next) {
const char *errmsg;
parms->directive = current;
/* actually parse the command and execute the correct function */
errmsg = ap_walk_config_sub(current, parms, section_vector);
if (errmsg != NULL) {
/* restore the context (just in case) */
parms->context = oldconfig;
return errmsg;
}
}
parms->context = oldconfig;
return NULL;
}
AP_DECLARE(const char *) ap_build_config(cmd_parms *parms,
apr_pool_t *p, apr_pool_t *temp_pool,
ap_directive_t **conftree)
{
ap_directive_t *current = *conftree;
ap_directive_t *curr_parent = NULL;
char l[MAX_STRING_LEN];
const char *errmsg;
if (current != NULL) {
while (current->next) {
current = current->next;
}
}
while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
errmsg = ap_build_config_sub(p, temp_pool, l, parms,
&current, &curr_parent, conftree);
if (errmsg != NULL)
return errmsg;
if (*conftree == NULL && curr_parent != NULL) {
*conftree = curr_parent;
}
if (*conftree == NULL && current != NULL) {
*conftree = current;
}
}
if (curr_parent != NULL) {
errmsg = "";
while (curr_parent != NULL) {
errmsg = apr_psprintf(p, "%s%s%s:%u: %s> was not closed.",
errmsg,
*errmsg == '\0' ? "" : APR_EOL_STR,
curr_parent->filename,
curr_parent->line_num,
curr_parent->directive);
parms->err_directive = curr_parent;
curr_parent = curr_parent->parent;
}
return errmsg;
}
return NULL;
}
/*
* Generic command functions...
*/
AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
void *struct_ptr,
const char *arg)
{
int offset = (int)(long)cmd->info;
*(const char **)((char *)struct_ptr + offset) = arg;
return NULL;
}
AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd,
void *struct_ptr,
const char *arg)
{
char *endptr;
char *error_str = NULL;
int offset = (int)(long)cmd->info;
*(int *)((char*)struct_ptr + offset) = strtol(arg, &endptr, 10);
if ((*arg == '\0') || (*endptr != '\0')) {
error_str = apr_psprintf(cmd->pool,
"Invalid value for directive %s, expected integer",
cmd->directive->directive);
}
return error_str;
}
AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
void *struct_ptr,
const char *arg_)
{
char *arg = apr_pstrdup(cmd->pool,arg_);
int offset = (int)(long)cmd->info;
ap_str_tolower(arg);
*(char **)((char *)struct_ptr + offset) = arg;
return NULL;
}
AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
void *struct_ptr_v, int arg)
{
int offset = (int)(long)cmd->info;
char *struct_ptr = (char *)struct_ptr_v;
*(int *)(struct_ptr + offset) = arg ? 1 : 0;
return NULL;
}
AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, void *struct_ptr,
const char *arg)
{
/* Prepend server_root to relative arg.
* This allows most args to be independent of server_root,
* so the server can be moved or mirrored with less pain.
*/
const char *path;
int offset = (int)(long)cmd->info;
path = ap_server_root_relative(cmd->pool, arg);
if (!path) {
return apr_pstrcat(cmd->pool, "Invalid file path ",
arg, NULL);
}
*(const char **) ((char*)struct_ptr + offset) = path;
return NULL;
}
AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd,
void *struct_ptr,
const char *arg)
{
return cmd->cmd->errmsg;
}
/*****************************************************************
*
* Reading whole config files...
*/
static cmd_parms default_parms =
{NULL, 0, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *file)
{
char *newpath = NULL;
apr_status_t rv;
rv = apr_filepath_merge(&newpath, ap_server_root, file,
APR_FILEPATH_TRUENAME, p);
if (newpath && (rv == APR_SUCCESS || APR_STATUS_IS_EPATHWILD(rv)
|| APR_STATUS_IS_ENOENT(rv)
|| APR_STATUS_IS_ENOTDIR(rv))) {
return newpath;
}
else {
return NULL;
}
}
AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive)
{
char l[MAX_STRING_LEN];
const char *args;
char *cmd_name;
while(!(ap_cfg_getline(l, MAX_STRING_LEN, cmd->config_file))) {
#if RESOLVE_ENV_PER_TOKEN
args = l;
#else
args = ap_resolve_env(cmd->temp_pool, l);
#endif
cmd_name = ap_getword_conf(cmd->pool, &args);
if (cmd_name[0] == '<') {
if (cmd_name[1] == '/') {
cmd_name[strlen(cmd_name) - 1] = '\0';
if (strcasecmp(cmd_name + 2, directive + 1) != 0) {
return apr_pstrcat(cmd->pool, "Expected </",
directive + 1, "> but saw ",
cmd_name, ">", NULL);
}
return NULL; /* found end of container */
}
else {
const char *msg;
if ((msg = ap_soak_end_container(cmd, cmd_name)) != NULL) {
return msg;
}
}
}
}
return apr_pstrcat(cmd->pool, "Expected </",
directive + 1, "> before end of configuration",
NULL);
}
static const char *execute_now(char *cmd_line, const char *args,
cmd_parms *parms,
apr_pool_t *p, apr_pool_t *ptemp,
ap_directive_t **sub_tree,
ap_directive_t *parent)
{
module *mod = ap_top_module;
const command_rec *cmd;
if (!(cmd = ap_find_command_in_modules(cmd_line, &mod))) {
return apr_pstrcat(parms->pool, "Invalid command '",
cmd_line,
"', perhaps mis-spelled or defined by a module "
"not included in the server configuration",
NULL);
}
else {
return invoke_cmd(cmd, parms, sub_tree, args);
}
}
/* This structure and the following functions are needed for the
* table-based config file reading. They are passed to the
* cfg_open_custom() routine.
*/
/* Structure to be passed to cfg_open_custom(): it contains an
* index which is incremented from 0 to nelts on each call to
* cfg_getline() (which in turn calls arr_elts_getstr())
* and an apr_array_header_t pointer for the string array.
*/
typedef struct {
apr_array_header_t *array;
int curr_idx;
} arr_elts_param_t;
/* arr_elts_getstr() returns the next line from the string array. */
static void *arr_elts_getstr(void *buf, size_t bufsiz, void *param)
{
arr_elts_param_t *arr_param = (arr_elts_param_t *)param;
/* End of array reached? */
if (++arr_param->curr_idx > arr_param->array->nelts)
return NULL;
/* return the line */
apr_cpystrn(buf,
((char **)arr_param->array->elts)[arr_param->curr_idx - 1],
bufsiz);
return buf;
}
/* arr_elts_close(): dummy close routine (makes sure no more lines can be read) */
static int arr_elts_close(void *param)
{
arr_elts_param_t *arr_param = (arr_elts_param_t *)param;
arr_param->curr_idx = arr_param->array->nelts;
return 0;
}
static void process_command_config(server_rec *s, apr_array_header_t *arr,
ap_directive_t **conftree, apr_pool_t *p,
apr_pool_t *ptemp)
{
const char *errmsg;
cmd_parms parms;
arr_elts_param_t arr_parms;
arr_parms.curr_idx = 0;
arr_parms.array = arr;
parms = default_parms;
parms.pool = p;
parms.temp_pool = ptemp;
parms.server = s;
parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
parms.config_file = ap_pcfg_open_custom(p, "-c/-C directives",
&arr_parms, NULL,
arr_elts_getstr, arr_elts_close);
errmsg = ap_build_config(&parms, p, ptemp, conftree);
if (errmsg) {
ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
"Syntax error in -C/-c directive:" APR_EOL_STR "%s",
errmsg);
exit(1);
}
ap_cfg_closefile(parms.config_file);
}
typedef struct {
char *fname;
} fnames;
static int fname_alphasort(const void *fn1, const void *fn2)
{
const fnames *f1 = fn1;
const fnames *f2 = fn2;
return strcmp(f1->fname,f2->fname);
}
static void process_resource_config_nofnmatch(server_rec *s, const char *fname,
ap_directive_t **conftree,
apr_pool_t *p,
apr_pool_t *ptemp)
{
cmd_parms parms;
ap_configfile_t *cfp;
const char *errmsg;
if (ap_is_rdirectory(p, fname)) {
apr_dir_t *dirp;
apr_finfo_t dirent;
int current;
apr_array_header_t *candidates = NULL;
fnames *fnew;
apr_status_t rv;
char errmsg[120], *path = apr_pstrdup(p, fname);
/*
* first course of business is to grok all the directory
* entries here and store 'em away. Recall we need full pathnames
* for this.
*/
rv = apr_dir_open(&dirp, path, p);
if (rv != APR_SUCCESS) {
fprintf(stderr, "%s: could not open config directory %s: %s\n",
ap_server_argv0, path,
apr_strerror(rv, errmsg, sizeof errmsg));
exit(1);
}
candidates = apr_array_make(p, 1, sizeof(fnames));
while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp) == APR_SUCCESS) {
/* strip out '.' and '..' */
if (strcmp(dirent.name, ".")
&& strcmp(dirent.name, "..")) {
fnew = (fnames *) apr_array_push(candidates);
fnew->fname = ap_make_full_path(p, path, dirent.name);
}
}
apr_dir_close(dirp);
if (candidates->nelts != 0) {
qsort((void *) candidates->elts, candidates->nelts,
sizeof(fnames), fname_alphasort);
/*
* Now recurse these... we handle errors and subdirectories
* via the recursion, which is nice
*/
for (current = 0; current < candidates->nelts; ++current) {
fnew = &((fnames *) candidates->elts)[current];
process_resource_config_nofnmatch(s, fnew->fname, conftree, p,
ptemp);
}
}
return;
}
/* GCC's initialization extensions are soooo nice here... */
parms = default_parms;
parms.pool = p;
parms.temp_pool = ptemp;
parms.server = s;
parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
if (ap_pcfg_openfile(&cfp, p, fname) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
"%s: could not open document config file %s",
ap_server_argv0, fname);
exit(1);
}
parms.config_file = cfp;
errmsg = ap_build_config(&parms, p, ptemp, conftree);
if (errmsg != NULL) {
ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
"Syntax error on line %d of %s:",
parms.err_directive->line_num,
parms.err_directive->filename);
ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
"%s", errmsg);
exit(1);
}
ap_cfg_closefile(cfp);
return;
}
AP_DECLARE(void) ap_process_resource_config(server_rec *s, const char *fname,
ap_directive_t **conftree,
apr_pool_t *p,
apr_pool_t *ptemp)
{
/* XXX: lstat() won't work on the wildcard pattern...
*/
/* don't require conf/httpd.conf if we have a -C or -c switch */
if ((ap_server_pre_read_config->nelts
|| ap_server_post_read_config->nelts)
&& !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
apr_finfo_t finfo;
if (apr_stat(&finfo, fname, APR_FINFO_LINK | APR_FINFO_TYPE, p) != APR_SUCCESS)
return;
}
if (!apr_fnmatch_test(fname)) {
process_resource_config_nofnmatch(s, fname, conftree, p, ptemp);
}
else {
apr_dir_t *dirp;
apr_finfo_t dirent;
int current;
apr_array_header_t *candidates = NULL;
fnames *fnew;
apr_status_t rv;
char errmsg[120], *path = apr_pstrdup(p, fname), *pattern = NULL;
pattern = ap_strrchr(path, '/');
AP_DEBUG_ASSERT(pattern != NULL); /* path must be absolute. */
*pattern++ = '\0';
if (apr_fnmatch_test(path)) {
fprintf(stderr, "%s: wildcard patterns not allowed in Include "
"%s\n", ap_server_argv0, fname);
exit(1);
}
if (!ap_is_rdirectory(p, path)){
fprintf(stderr, "%s: Include directory '%s' not found",
ap_server_argv0, path);
exit(1);
}
if (!apr_fnmatch_test(pattern)) {
fprintf(stderr, "%s: must include a wildcard pattern "
"for Include %s\n", ap_server_argv0, fname);
exit(1);
}
/*
* first course of business is to grok all the directory
* entries here and store 'em away. Recall we need full pathnames
* for this.
*/
rv = apr_dir_open(&dirp, path, p);
if (rv != APR_SUCCESS) {
fprintf(stderr, "%s: could not open config directory %s: %s\n",
ap_server_argv0, path,
apr_strerror(rv, errmsg, sizeof errmsg));
exit(1);
}
candidates = apr_array_make(p, 1, sizeof(fnames));
while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp) == APR_SUCCESS) {
/* strip out '.' and '..' */
if (strcmp(dirent.name, ".")
&& strcmp(dirent.name, "..")
&& (apr_fnmatch(pattern, dirent.name,
APR_FNM_PERIOD) == APR_SUCCESS)) {
fnew = (fnames *) apr_array_push(candidates);
fnew->fname = ap_make_full_path(p, path, dirent.name);
}
}
apr_dir_close(dirp);
if (candidates->nelts != 0) {
qsort((void *) candidates->elts, candidates->nelts,
sizeof(fnames), fname_alphasort);
/*
* Now recurse these... we handle errors and subdirectories
* via the recursion, which is nice
*/
for (current = 0; current < candidates->nelts; ++current) {
fnew = &((fnames *) candidates->elts)[current];
process_resource_config_nofnmatch(s, fnew->fname, conftree, p,
ptemp);
}
}
}
return;
}
AP_DECLARE(int) ap_process_config_tree(server_rec *s,
ap_directive_t *conftree,
apr_pool_t *p,
apr_pool_t *ptemp)
{
const char *errmsg;
cmd_parms parms;
parms = default_parms;
parms.pool = p;
parms.temp_pool = ptemp;
parms.server = s;
parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
parms.limited = -1;
errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
if (errmsg) {
ap_log_perror(APLOG_MARK, APLOG_STARTUP, 0, p,
"Syntax error on line %d of %s:",
parms.err_directive->line_num,
parms.err_directive->filename);
ap_log_perror(APLOG_MARK, APLOG_STARTUP, 0, p,
"%s", errmsg);
return HTTP_INTERNAL_SERVER_ERROR;
}
return OK;
}
AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result,
request_rec *r, int override,
const char *d, const char *access_name)
{
ap_configfile_t *f = NULL;
cmd_parms parms;
char *filename = NULL;
const struct htaccess_result *cache;
struct htaccess_result *new;
ap_conf_vector_t *dc = NULL;
apr_status_t status;
/* firstly, search cache */
for (cache = r->htaccess; cache != NULL; cache = cache->next) {
if (cache->override == override && strcmp(cache->dir, d) == 0) {
*result = cache->htaccess;
return OK;
}
}
parms = default_parms;
parms.override = override;
parms.pool = r->pool;
parms.temp_pool = r->pool;
parms.server = r->server;
parms.path = apr_pstrdup(r->pool, d);
/* loop through the access names and find the first one */
while (access_name[0]) {
/* AFAICT; there is no use of the actual 'filename' against
* any canonicalization, so we will simply take the given
* name, ignoring case sensitivity and aliases
*/
filename = ap_make_full_path(r->pool, d,
ap_getword_conf(r->pool, &access_name));
status = ap_pcfg_openfile(&f, r->pool, filename);
if (status == APR_SUCCESS) {
const char *errmsg;
ap_directive_t *temptree = NULL;
dc = ap_create_per_dir_config(r->pool);
parms.config_file = f;
errmsg = ap_build_config(&parms, r->pool, r->pool, &temptree);
if (errmsg == NULL)
errmsg = ap_walk_config(temptree, &parms, dc);
ap_cfg_closefile(f);
if (errmsg) {
ap_log_rerror(APLOG_MARK, APLOG_ALERT, 0, r,
"%s: %s", filename, errmsg);
return HTTP_INTERNAL_SERVER_ERROR;
}
*result = dc;
break;
}
else {
if (!APR_STATUS_IS_ENOENT(status)
&& !APR_STATUS_IS_ENOTDIR(status)) {
ap_log_rerror(APLOG_MARK, APLOG_CRIT, status, r,
"%s pcfg_openfile: unable to check htaccess file, "
"ensure it is readable",
filename);
apr_table_setn(r->notes, "error-notes",
"Server unable to read htaccess file, denying "
"access to be safe");
return HTTP_FORBIDDEN;
}
}
}
/* cache it */
new = apr_palloc(r->pool, sizeof(struct htaccess_result));
new->dir = parms.path;
new->override = override;
new->htaccess = dc;
/* add to head of list */
new->next = r->htaccess;
r->htaccess = new;
return OK;
}
AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p,
const char *hostname,
server_rec *main_server,
server_rec **ps)
{
server_rec *s = (server_rec *) apr_pcalloc(p, sizeof(server_rec));
/* TODO: this crap belongs in http_core */
s->process = main_server->process;
s->server_admin = NULL;
s->server_hostname = NULL;
s->error_fname = NULL;
s->timeout = 0;
s->keep_alive_timeout = 0;
s->keep_alive = -1;
s->keep_alive_max = -1;
s->error_log = main_server->error_log;
s->loglevel = main_server->loglevel;
/* useful default, otherwise we get a port of 0 on redirects */
s->port = main_server->port;
s->next = NULL;
s->is_virtual = 1;
s->names = apr_array_make(p, 4, sizeof(char **));
s->wild_names = apr_array_make(p, 4, sizeof(char **));
s->module_config = create_empty_config(p);
s->lookup_defaults = ap_create_per_dir_config(p);
s->limit_req_line = main_server->limit_req_line;
s->limit_req_fieldsize = main_server->limit_req_fieldsize;
s->limit_req_fields = main_server->limit_req_fields;
*ps = s;
return ap_parse_vhost_addrs(p, hostname, s);
}
AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server)
{
server_rec *virt;
for (virt = main_server->next; virt; virt = virt->next) {
merge_server_configs(p, main_server->module_config,
virt->module_config);
virt->lookup_defaults =
ap_merge_per_dir_configs(p, main_server->lookup_defaults,
virt->lookup_defaults);
if (virt->server_admin == NULL)
virt->server_admin = main_server->server_admin;
if (virt->timeout == 0)
virt->timeout = main_server->timeout;
if (virt->keep_alive_timeout == 0)
virt->keep_alive_timeout = main_server->keep_alive_timeout;
if (virt->keep_alive == -1)
virt->keep_alive = main_server->keep_alive;
if (virt->keep_alive_max == -1)
virt->keep_alive_max = main_server->keep_alive_max;
/* XXX: this is really something that should be dealt with by a
* post-config api phase
*/
ap_core_reorder_directories(p, virt);
}
ap_core_reorder_directories(p, main_server);
}
/*****************************************************************
*
* Getting *everything* configured...
*/
static void init_config_globals(apr_pool_t *p)
{
/* Global virtual host hash bucket pointers. Init to null. */
ap_init_vhost_config(p);
}
static server_rec *init_server_config(process_rec *process, apr_pool_t *p)
{
apr_status_t rv;
server_rec *s = (server_rec *) apr_pcalloc(p, sizeof(server_rec));
apr_file_open_stderr(&s->error_log, p);
s->process = process;
s->port = 0;
s->server_admin = DEFAULT_ADMIN;
s->server_hostname = NULL;
s->error_fname = DEFAULT_ERRORLOG;
s->loglevel = DEFAULT_LOGLEVEL;
s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE;
s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE;
s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS;
s->timeout = apr_time_from_sec(DEFAULT_TIMEOUT);
s->keep_alive_timeout = apr_time_from_sec(DEFAULT_KEEPALIVE_TIMEOUT);
s->keep_alive_max = DEFAULT_KEEPALIVE;
s->keep_alive = 1;
s->next = NULL;
s->addrs = apr_pcalloc(p, sizeof(server_addr_rec));
/* NOT virtual host; don't match any real network interface */
rv = apr_sockaddr_info_get(&s->addrs->host_addr,
NULL, APR_INET, 0, 0, p);
ap_assert(rv == APR_SUCCESS); /* otherwise: bug or no storage */
s->addrs->host_port = 0; /* matches any port */
s->addrs->virthost = ""; /* must be non-NULL */
s->names = s->wild_names = NULL;
s->module_config = create_server_config(p, s);
s->lookup_defaults = create_default_per_dir_config(p);
return s;
}
AP_DECLARE(server_rec*) ap_read_config(process_rec *process, apr_pool_t *ptemp,
const char *filename,
ap_directive_t **conftree)
{
const char *confname;
apr_pool_t *p = process->pconf;
server_rec *s = init_server_config(process, p);
init_config_globals(p);
/* All server-wide config files now have the SAME syntax... */
process_command_config(s, ap_server_pre_read_config, conftree,
p, ptemp);
/* process_command_config may change the ServerRoot so
* compute this config file name afterwards.
*/
confname = ap_server_root_relative(p, filename);
if (!confname) {
ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT,
APR_EBADPATH, NULL, "Invalid config file path %s",
filename);
exit(1);
}
ap_process_resource_config(s, confname, conftree, p, ptemp);
process_command_config(s, ap_server_post_read_config, conftree,
p, ptemp);
return s;
}
AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s,
module *m)
{
if (m->create_server_config)
ap_set_module_config(s->module_config, m,
(*m->create_server_config)(p, s));
if (m->create_dir_config)
ap_set_module_config(s->lookup_defaults, m,
(*m->create_dir_config)(p, NULL));
}
AP_DECLARE(void) ap_run_rewrite_args(process_rec *process)
{
module *m;
for (m = ap_top_module; m; m = m->next) {
if (m->rewrite_args) {
(*m->rewrite_args)(process);
}
}
}
/********************************************************************
* Configuration directives are restricted in terms of where they may
* appear in the main configuration files and/or .htaccess files according
* to the bitmask req_override in the command_rec structure.
* If any of the overrides set in req_override are also allowed in the
* context in which the command is read, then the command is allowed.
* The context is determined as follows:
*
* inside *.conf --> override = (RSRC_CONF|OR_ALL)&~(OR_AUTHCFG|OR_LIMIT);
* within <Directory> or <Location> --> override = OR_ALL|ACCESS_CONF;
* within .htaccess --> override = AllowOverride for current directory;
*
* the result is, well, a rather confusing set of possibilities for when
* a particular directive is allowed to be used. This procedure prints
* in English where the given (pc) directive can be used.
*/
static void show_overrides(const command_rec *pc, module *pm)
{
int n = 0;
printf("\tAllowed in *.conf ");
if ((pc->req_override & (OR_OPTIONS | OR_FILEINFO | OR_INDEXES))
|| ((pc->req_override & RSRC_CONF)
&& ((pc->req_override & (ACCESS_CONF | OR_AUTHCFG | OR_LIMIT))))) {
printf("anywhere");
}
else if (pc->req_override & RSRC_CONF) {
printf("only outside <Directory>, <Files> or <Location>");
}
else {
printf("only inside <Directory>, <Files> or <Location>");
}
/* Warn if the directive is allowed inside <Directory> or .htaccess
* but module doesn't support per-dir configuration
*/
if ((pc->req_override & (OR_ALL | ACCESS_CONF)) && !pm->create_dir_config)
printf(" [no per-dir config]");
if (pc->req_override & OR_ALL) {
printf(" and in .htaccess\n\twhen AllowOverride");
if ((pc->req_override & OR_ALL) == OR_ALL) {
printf(" isn't None");
}
else {
printf(" includes ");
if (pc->req_override & OR_AUTHCFG) {
if (n++)
printf(" or ");
printf("AuthConfig");
}
if (pc->req_override & OR_LIMIT) {
if (n++)
printf(" or ");
printf("Limit");
}
if (pc->req_override & OR_OPTIONS) {
if (n++)
printf(" or ");
printf("Options");
}
if (pc->req_override & OR_FILEINFO) {
if (n++)
printf(" or ");
printf("FileInfo");
}
if (pc->req_override & OR_INDEXES) {
if (n++)
printf(" or ");
printf("Indexes");
}
}
}
printf("\n");
}
/* Show the preloaded configuration directives, the help string explaining
* the directive arguments, in what module they are handled, and in
* what parts of the configuration they are allowed. Used for httpd -L.
*/
AP_DECLARE(void) ap_show_directives(void)
{
const command_rec *pc;
int n;
for (n = 0; ap_loaded_modules[n]; ++n) {
for (pc = ap_loaded_modules[n]->cmds; pc && pc->name; ++pc) {
printf("%s (%s)\n", pc->name, ap_loaded_modules[n]->name);
if (pc->errmsg)
printf("\t%s\n", pc->errmsg);
show_overrides(pc, ap_loaded_modules[n]);
}
}
}
/* Show the preloaded module names. Used for httpd -l. */
AP_DECLARE(void) ap_show_modules(void)
{
int n;
printf("Compiled in modules:\n");
for (n = 0; ap_loaded_modules[n]; ++n)
printf(" %s\n", ap_loaded_modules[n]->name);
}
AP_DECLARE(const char *) ap_show_mpm(void)
{
return MPM_NAME;
}