config.c revision d936d7dcfc1a35dec2a026d23053f8230301cdff
842ae4bd224140319ae7feec1872b93dfd491143fielding/* ====================================================================
842ae4bd224140319ae7feec1872b93dfd491143fielding * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
842ae4bd224140319ae7feec1872b93dfd491143fielding * Redistribution and use in source and binary forms, with or without
842ae4bd224140319ae7feec1872b93dfd491143fielding * modification, are permitted provided that the following conditions
04891cf70e0bfc38bfb027541dc821f04c754ff7nd * 1. Redistributions of source code must retain the above copyright
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * notice, this list of conditions and the following disclaimer.
04891cf70e0bfc38bfb027541dc821f04c754ff7nd * 2. Redistributions in binary form must reproduce the above copyright
04891cf70e0bfc38bfb027541dc821f04c754ff7nd * notice, this list of conditions and the following disclaimer in
04891cf70e0bfc38bfb027541dc821f04c754ff7nd * the documentation and/or other materials provided with the
04891cf70e0bfc38bfb027541dc821f04c754ff7nd * distribution.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * 3. All advertising materials mentioning features or use of this
3568de757bac0b47256647504c186d17ca272f85rbb * software must display the following acknowledgment:
3568de757bac0b47256647504c186d17ca272f85rbb * "This product includes software developed by the Apache Group
3568de757bac0b47256647504c186d17ca272f85rbb * for use in the Apache HTTP server project (http://www.apache.org/)."
3568de757bac0b47256647504c186d17ca272f85rbb * 4. The names "Apache Server" and "Apache Group" must not be used to
3568de757bac0b47256647504c186d17ca272f85rbb * endorse or promote products derived from this software without
3568de757bac0b47256647504c186d17ca272f85rbb * prior written permission. For written permission, please contact
3568de757bac0b47256647504c186d17ca272f85rbb * apache@apache.org.
3568de757bac0b47256647504c186d17ca272f85rbb * 5. Products derived from this software may not be called "Apache"
3568de757bac0b47256647504c186d17ca272f85rbb * nor may "Apache" appear in their names without prior written
3568de757bac0b47256647504c186d17ca272f85rbb * permission of the Apache Group.
3568de757bac0b47256647504c186d17ca272f85rbb * 6. Redistributions of any form whatsoever must retain the following
3568de757bac0b47256647504c186d17ca272f85rbb * acknowledgment:
3568de757bac0b47256647504c186d17ca272f85rbb * "This product includes software developed by the Apache Group
3568de757bac0b47256647504c186d17ca272f85rbb * for use in the Apache HTTP server project (http://www.apache.org/)."
3568de757bac0b47256647504c186d17ca272f85rbb * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
3568de757bac0b47256647504c186d17ca272f85rbb * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3568de757bac0b47256647504c186d17ca272f85rbb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3568de757bac0b47256647504c186d17ca272f85rbb * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
3568de757bac0b47256647504c186d17ca272f85rbb * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3568de757bac0b47256647504c186d17ca272f85rbb * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
3568de757bac0b47256647504c186d17ca272f85rbb * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3568de757bac0b47256647504c186d17ca272f85rbb * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3568de757bac0b47256647504c186d17ca272f85rbb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3568de757bac0b47256647504c186d17ca272f85rbb * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3568de757bac0b47256647504c186d17ca272f85rbb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
3568de757bac0b47256647504c186d17ca272f85rbb * OF THE POSSIBILITY OF SUCH DAMAGE.
3568de757bac0b47256647504c186d17ca272f85rbb * ====================================================================
3568de757bac0b47256647504c186d17ca272f85rbb * This software consists of voluntary contributions made by many
3568de757bac0b47256647504c186d17ca272f85rbb * individuals on behalf of the Apache Group and was originally based
3568de757bac0b47256647504c186d17ca272f85rbb * on public domain software written at the National Center for
3568de757bac0b47256647504c186d17ca272f85rbb * Supercomputing Applications, University of Illinois, Urbana-Champaign.
3568de757bac0b47256647504c186d17ca272f85rbb * For more information on the Apache Group and the Apache HTTP server
3568de757bac0b47256647504c186d17ca272f85rbb * project, please see <http://www.apache.org/>.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * http_config.c: once was auxillary functions for reading httpd's config
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * file and converting filenames into a namespace
cd8f8c995d415473f3bfb0b329b2450f2a722c3atrawick * Rob McCool
3568de757bac0b47256647504c186d17ca272f85rbb * Wall-to-wall rewrite for Apache... commands which are part of the
3568de757bac0b47256647504c186d17ca272f85rbb * server core can now be found next door in "http_core.c". Now contains
3568de757bac0b47256647504c186d17ca272f85rbb * general command loop, and functions which do bookkeeping for the new
98fb535f829e2a95aabd82420931f476661fa8e3jorton * Apache config stuff (modules and configuration vectors).
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz#include "http_log.h" /* for errors in parse_htaccess */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding#include "http_request.h" /* for default_handler (see invoke_handler) */
f0e395a55abfcad3d2bd7c63470003b08a93d567ndIMPLEMENT_HOOK_RUN_ALL(int,header_parser,(request_rec *r),(r),OK,DECLINED)
f0e395a55abfcad3d2bd7c63470003b08a93d567ndIMPLEMENT_HOOK_VOID(pre_config,(ap_context_t *pconf,ap_context_t *plog,ap_context_t *ptemp),
98fb535f829e2a95aabd82420931f476661fa8e3jorton (ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s),
7cd5419264796cfeaf8215383cf0f89130a81fectrawick (ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s),
7cd5419264796cfeaf8215383cf0f89130a81fectrawickIMPLEMENT_HOOK_VOID(child_init,(ap_context_t *pchild, server_rec *s),(pchild,s))
3568de757bac0b47256647504c186d17ca272f85rbb/****************************************************************
3568de757bac0b47256647504c186d17ca272f85rbb * We begin with the functions which deal with the linked list
3568de757bac0b47256647504c186d17ca272f85rbb * of modules which control just about all of the server operation.
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz/* total_modules is the number of modules that have been linked
3568de757bac0b47256647504c186d17ca272f85rbb * into the server.
3568de757bac0b47256647504c186d17ca272f85rbbstatic int total_modules = 0;
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz/* dynamic_modules is the number of modules that have been added
3568de757bac0b47256647504c186d17ca272f85rbb * after the pre-loaded ones have been set up. It shouldn't be larger
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * than DYNAMIC_MODULE_LIMIT.
3568de757bac0b47256647504c186d17ca272f85rbbstatic int dynamic_modules = 0;
3568de757bac0b47256647504c186d17ca272f85rbbtypedef void *(*dir_maker_func) (ap_context_t *, char *);
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantztypedef void *(*merger_func) (ap_context_t *, void *, void *);
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding/* Dealing with config vectors. These are associated with per-directory,
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz * per-server, and per-request configuration, and have a void* pointer for
3568de757bac0b47256647504c186d17ca272f85rbb * each modules. The nature of the structure pointed to is private to the
fc1efab92032301e317f07e1b3a00082d9d71f3frbb * module in question... the core doesn't (and can't) know. However, there
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz * are defined interfaces which allow it to create instances of its private
24b534291150023e6b68eca89ddd33e475ccddc0wrowe * per-directory and per-server structures, and to merge the per-directory
3568de757bac0b47256647504c186d17ca272f85rbb * structures of a directory and its subdirectory (producing a new one in
24b534291150023e6b68eca89ddd33e475ccddc0wrowe * which the defaults applying to the base directory have been properly
3568de757bac0b47256647504c186d17ca272f85rbb * overridden).
3568de757bac0b47256647504c186d17ca272f85rbbAPI_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantzAPI_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) *
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz return (void *) conf_vector;
3568de757bac0b47256647504c186d17ca272f85rbbstatic void *create_default_per_dir_config(ap_context_t *p)
3568de757bac0b47256647504c186d17ca272f85rbb void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
3568de757bac0b47256647504c186d17ca272f85rbb return (void *) conf_vector;
397df70abe0bdd78a84fb6c38c02641bcfeadceasf ap_merge_per_dir_configs(ap_context_t *p, void *base, void *new)
397df70abe0bdd78a84fb6c38c02641bcfeadceasf void **conf_vector = (void **) ap_palloc(p, sizeof(void *) * total_modules);
6653a33e820463abd4f81915b7a1eba0f602e200brianp conf_vector[i] = (*df) (p, base_vector[i], new_vector[i]);
41634f717c623556a16b27b25d7d909a66fe20f8wrowe conf_vector[i] = new_vector[i] ? new_vector[i] : base_vector[i];
6653a33e820463abd4f81915b7a1eba0f602e200brianp return (void *) conf_vector;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougmstatic void *create_server_config(ap_context_t *p, server_rec *s)
36c8049de63c446926139936c3d195330a0539cetrawick void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
d90b36a9e6f6ea9a583694f4db5e5edd54a750b3minfrin conf_vector[modp->module_index] = (*modp->create_server_config) (p, s);
d90b36a9e6f6ea9a583694f4db5e5edd54a750b3minfrin return (void *) conf_vector;
d90b36a9e6f6ea9a583694f4db5e5edd54a750b3minfrinstatic void merge_server_configs(ap_context_t *p, void *base, void *virt)
ca53a74f4012a45cbad48e940eddf27d866981f9dougm /* Can reuse the 'virt' vector for the spine of it, since we don't
ca53a74f4012a45cbad48e940eddf27d866981f9dougm * have to deal with the moral equivalent of .htaccess files here...
6653a33e820463abd4f81915b7a1eba0f602e200brianp virt_vector[i] = (*df) (p, base_vector[i], virt_vector[i]);
49aa87d735a13ae3d04012ee0df91ddb51f7c36esfCORE_EXPORT(void *) ap_create_per_dir_config(ap_context_t *p)
185aa71728867671e105178b4c66fbc22b65ae26sf * For speed/efficiency we generate a compact list of all the handlers
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard * and wildcard handlers. This means we won't have to scan the entire
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard * module list looking for handlers... where we'll find a whole whack
3568de757bac0b47256647504c186d17ca272f85rbb * of NULLs.
48d2edbfb84e5559b5da0f8d614ccab805cc67a8rbbtypedef struct {
9f979f5c8061f6f6f560d1824e0e378ff5b91931rpluem for (handp = modp->handlers; handp->content_type; ++handp) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard ph = handlers = ap_palloc(p, sizeof(*ph)*(nhandlers + 1));
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard pw = wildhandlers = ap_palloc(p, sizeof(*pw)*(nwildhandlers + 1));
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard for (handp = modp->handlers; handp->content_type; ++handp) {
95e04bdfdb8fbb70158afd18bbf0acc340615d65jorton const char *handler;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm handler = r->content_type ? r->content_type : ap_default_type(r);
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf if ((p = strchr(handler, ';')) != NULL) { /* MIME type arguments */
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf --p; /* strip trailing spaces */
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf /* Pass one --- direct matches */
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf for (handp = handlers; handp->hr.content_type; ++handp) {
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf && !strncmp(handler, handp->hr.content_type, handler_len)) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard /* Pass two --- wildcard matches */
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm for (handp = wildhandlers; handp->hr.content_type; ++handp) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard && !strncmp(handler, handp->hr.content_type, handp->len)) {
7cd5419264796cfeaf8215383cf0f89130a81fectrawick if (result == HTTP_INTERNAL_SERVER_ERROR && r->handler && r->filename) {
7cd5419264796cfeaf8215383cf0f89130a81fectrawick ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, r,
7cd5419264796cfeaf8215383cf0f89130a81fectrawick "handler \"%s\" not found for: %s", r->handler, r->filename);
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard/* One-time setup for precompiled modules --- NOT to be done on restart */
7cd5419264796cfeaf8215383cf0f89130a81fectrawick /* This could be called from an AddModule httpd.conf command,
7cd5419264796cfeaf8215383cf0f89130a81fectrawick * after the file has been linked and the module structure within it
7cd5419264796cfeaf8215383cf0f89130a81fectrawick * teased out...
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm fprintf(stderr, "%s: module \"%s\" is not compatible with this "
3568de757bac0b47256647504c186d17ca272f85rbb fprintf(stderr, "Please contact the vendor for the correct version.\n");
dcd19776e8e3d73519ffb0201d6dfea67f0aeb3ejim fprintf(stderr, "%s: module \"%s\" could not be loaded, because"
b5ffe4f30780fb159db08bd9f628980d2a092711sf fprintf(stderr, "module limit was reached. Please increase "
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard "DYNAMIC_MODULE_LIMIT and recompile.\n");
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard /* Some C compilers put a complete path into __FILE__, but we want
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard * only the filename (e.g. mod_includes.c). So check for path
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz * components (Unix and DOS), and remove them.
01d315c948a50cb511dbaee108b9571ee9a4d287jim#ifdef _OSD_POSIX /* __FILE__="*POSIX(/home/martin/apache/src/modules/standard/mod_info.c)" */
01d315c948a50cb511dbaee108b9571ee9a4d287jim /* We cannot fix the string in-place, because it's const */
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard char *tmp = strdup(m->name); /* FIXME:memory leak, albeit a small one */
83df3fbb3f37cf5337c8793b4559392a672e0696jim#endif /*_OSD_POSIX*/
3568de757bac0b47256647504c186d17ca272f85rbb /* FIXME: is this the right place to call this? */
f714f1a7002928d785e53e70349700a7f595fee3trawick * remove_module undoes what add_module did. There are some caveats:
f714f1a7002928d785e53e70349700a7f595fee3trawick * when the module is removed, its slot is lost so all the current
3568de757bac0b47256647504c186d17ca272f85rbb * per-dir and per-server configurations are invalid. So we should
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddard * only ever call this function when you are invalidating almost
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh * all our current data. I.e. when doing a restart.
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard if (modp == m) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard /* We are the top module, special case */
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard /* Not the top module, find use. When found modp will
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard * point to the module _before_ us in the list
3568de757bac0b47256647504c186d17ca272f85rbb /* Uh-oh, this module doesn't exist */
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddard ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, NULL,
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh "Cannot remove module %s: not found in module list",
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh /* Eliminate us from the module list */
3568de757bac0b47256647504c186d17ca272f85rbb m->module_index = -1; /* simulate being unloaded, should
663237d6bcc59ac0997d71d48a1baa55fa29a3d8jim * be unnecessary */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz * Add module pointer to top of chained module list
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard * And module pointer to list of loaded modules
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz * Notes: 1. ap_add_module() would already complain if no more space
3568de757bac0b47256647504c186d17ca272f85rbb * exists for adding a dynamically loaded module
3568de757bac0b47256647504c186d17ca272f85rbb * 2. ap_add_module() accepts double ap_context_t nclusion, so we have
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz * to accept this, too.
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf * Remove module pointer from chained module list
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf * Remove module pointer from list of loaded modules
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf * Note: 1. We cannot determine if the module was successfully
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf * removed by ap_remove_module().
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf * 2. We have not to complain explicity when the module
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf * is not found because ap_remove_module() did it
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf * for us already.
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf for (m = m2 = ap_loaded_modules, done = 0; *m2 != NULL; m2++) {
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf * Initialise total_modules variable and module indices
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf * Initialise list of loaded modules
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf sizeof(module *)*(total_modules+DYNAMIC_MODULE_LIMIT+1));
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf fprintf(stderr, "Ouch! Out of memory in ap_setup_prelinked_modules()!\n");
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf for (m = ap_preloaded_modules, m2 = ap_loaded_modules; *m != NULL; )
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf *m2++ = *m++;
49aa87d735a13ae3d04012ee0df91ddb51f7c36esf * Initialize chain of linked (=activate) modules
d69e1ed15b5db3d832c1f6c8c403ef397248857atrawickAPI_EXPORT(module *) ap_find_linked_module(const char *name)
3568de757bac0b47256647504c186d17ca272f85rbb/* Add a named module. Returns 1 if module found, 0 otherwise. */
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddardAPI_EXPORT(int) ap_add_named_module(const char *name)
8dfa8c6f60f12e0b65eebbb652b629f911f0f84bsf int i = 0;
8dfa8c6f60f12e0b65eebbb652b629f911f0f84bsf for (modp = ap_loaded_modules[i]; modp; modp = ap_loaded_modules[++i]) {
8dfa8c6f60f12e0b65eebbb652b629f911f0f84bsf /* Only add modules that are not already enabled. */
8e9734d1a4af74c141e2a0f880bb51bb061fa03atrawick/* Clear the internal list of modules, in preparation for starting over. */
3568de757bac0b47256647504c186d17ca272f85rbb while (*m) {
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard /* This is required; so we add it always. */
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard/*****************************************************************
3568de757bac0b47256647504c186d17ca272f85rbb * Resource, access, and .htaccess config files now parsed by a common
c0659e61002e9d6ff77b2dca72540e0af1b2ca64stoddard * command loop.
8dfa8c6f60f12e0b65eebbb652b629f911f0f84bsf * Let's begin with the basics; parsing the line and
8dfa8c6f60f12e0b65eebbb652b629f911f0f84bsf * invoking the function...
3568de757bac0b47256647504c186d17ca272f85rbbstatic const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick const char *errmsg;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick return ap_pstrcat(parms->pool, cmd->name, " not allowed here", NULL);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick return ((const char *(*)(cmd_parms *, void *, const char *))
2e7f1d7da527c09e717251e186deffe55e6fbd0ftrawick return ap_pstrcat(parms->pool, cmd->name, " takes no arguments",
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm return ((const char *(*)(cmd_parms *, void *))
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz return ap_pstrcat(parms->pool, cmd->name, " takes one argument",
e8f95a682820a599fe41b22977010636be5c2717jim return ((const char *(*)(cmd_parms *, void *, const char *))
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm return ap_pstrcat(parms->pool, cmd->name, " takes two arguments",
36c8049de63c446926139936c3d195330a0539cetrawick return ((const char *(*)(cmd_parms *, void *, const char *,
36c8049de63c446926139936c3d195330a0539cetrawick const char *)) (cmd->func)) (parms, mconfig, w, w2);
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm return ap_pstrcat(parms->pool, cmd->name, " takes 1-2 arguments",
36c8049de63c446926139936c3d195330a0539cetrawick return ((const char *(*)(cmd_parms *, void *, const char *,
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm if (*w == '\0' || *w2 == '\0' || *w3 == '\0' || *args != 0)
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick return ap_pstrcat(parms->pool, cmd->name, " takes three arguments",
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick return ((const char *(*)(cmd_parms *, void *, const char *,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick " takes two or three arguments",
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick return ((const char *(*)(cmd_parms *, void *, const char *,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick " takes one, two or three arguments",
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick return ((const char *(*)(cmd_parms *, void *, const char *,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
f886987cd0bd4220c14043c4d9be77ec22902e73trawick w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm " takes one or three arguments",
3568de757bac0b47256647504c186d17ca272f85rbb return ((const char *(*)(cmd_parms *, void *, const char *,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick while (*(w = ap_getword_conf(parms->pool, &args)) != '\0')
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick if ((errmsg = ((const char *(*)(cmd_parms *, void *,
c96bab2ce71bdf8e8b0e0e617ab5f2074ab6e3eejim " requires at least two arguments",
2e7f1d7da527c09e717251e186deffe55e6fbd0ftrawick while (*(w2 = ap_getword_conf(parms->pool, &args)) != '\0')
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick if ((errmsg = ((const char *(*)(cmd_parms *, void *,
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick if (*w == '\0' || (strcasecmp(w, "on") && strcasecmp(w, "off")))
e8f95a682820a599fe41b22977010636be5c2717jim return ap_pstrcat(parms->pool, cmd->name, " must be On or Off",
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick return ((const char *(*)(cmd_parms *, void *, int))
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick (cmd->func)) (parms, mconfig, strcasecmp(w, "off") != 0);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick " is improperly configured internally (server bug)",
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawickCORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds)
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawickCORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod)
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick if (modp->cmds && (cmdp = ap_find_command(cmd_name, modp->cmds))) {
e8f95a682820a599fe41b22977010636be5c2717jimCORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod)
f886987cd0bd4220c14043c4d9be77ec22902e73trawick void *sconfig = ap_get_module_config(parms->server->module_config, mod);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawick mconfig = (*mod->create_dir_config) (parms->pool, parms->path);
64c351fd973428b5bb4c28e983fa86875ea4e60fdougm sconfig = (*mod->create_server_config) (parms->pool, parms->server);
3568de757bac0b47256647504c186d17ca272f85rbb ap_set_module_config(parms->server->module_config, mod, sconfig);
8bfe865d8d61be4ba4a89e45427a3c4211ebabdctrawickCORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l)
44d2e75323651320b480d8bc2f098448a08de4fcwrowe if ((l[0] == '#') || (!l[0]))
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz if (!(cmd = ap_find_command_in_modules(cmd_name, &mod))) {
3568de757bac0b47256647504c186d17ca272f85rbb return ap_pstrcat(parms->pool, "Invalid command '", cmd_name,
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe "', perhaps mis-spelled or defined by a module "
f886987cd0bd4220c14043c4d9be77ec22902e73trawick void *mconfig = ap_set_config_vectors(parms,config, mod);
f886987cd0bd4220c14043c4d9be77ec22902e73trawick mod = mod->next; /* Next time around, skip this one */
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantzAPI_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config)
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz const char *errmsg = ap_handle_command(parms, config, l);
98fb535f829e2a95aabd82420931f476661fa8e3jorton * Generic command functions...
98fb535f829e2a95aabd82420931f476661fa8e3jortonAPI_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
3568de757bac0b47256647504c186d17ca272f85rbb /* This one's pretty generic... */
0f081398cf0eef8cc7c66a535d450110a92dc8aefieldingAPI_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
0cb6873985efbf0cc9644114925df6baa4b32d5awrowe /* This one's pretty generic... */
3568de757bac0b47256647504c186d17ca272f85rbbAPI_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
3568de757bac0b47256647504c186d17ca272f85rbb /* This one's pretty generic too... */
3568de757bac0b47256647504c186d17ca272f85rbbAPI_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, char *struct_ptr, char *arg)
ec020ca384efb30d501a5af796ddc3bb237d7b8fgregames /* Prepend server_root to relative arg.
3568de757bac0b47256647504c186d17ca272f85rbb This allows .htaccess to be independent of server_root,
ce03576b2434cec77f2921db9d5b6a0510581c23rederpj so the server can be moved or mirrored with less pain. */
3568de757bac0b47256647504c186d17ca272f85rbb/*****************************************************************
7cd5419264796cfeaf8215383cf0f89130a81fectrawick * Reading whole config files...
7cd5419264796cfeaf8215383cf0f89130a81fectrawick{NULL, 0, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
7cd5419264796cfeaf8215383cf0f89130a81fectrawickAPI_EXPORT(const char *) ap_server_root_relative(ap_context_t *p, const char *file)
7cd5419264796cfeaf8215383cf0f89130a81fectrawick/* This structure and the following functions are needed for the
ca53a74f4012a45cbad48e940eddf27d866981f9dougm * table-based config file reading. They are passed to the
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * cfg_open_custom() routine.
302dc1f7b3feee23a91ad8f3cf3cb2edd95a557bmanoj/* Structure to be passed to cfg_open_custom(): it contains an
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz * index which is incremented from 0 to nelts on each call to
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz * cfg_getline() (which in turn calls arr_elts_getstr())
28c170ac8e99644de58cad454c6e0f9b4b359be6jerenkrantz * and an ap_array_header_t pointer for the string array.
0cb6873985efbf0cc9644114925df6baa4b32d5awrowetypedef struct {
return NULL;
return buf;
const char *errmsg;
if (errmsg) {
void ap_process_resource_config(server_rec *s, const char *fname, ap_context_t *p, ap_context_t *ptemp)
const char *errmsg;
/* don't require conf/httpd.conf if we have a -C or -c switch */
if (errmsg) {
const char *d, const char *access_name)
const char *errmsg;
return OK;
while (access_name[0]) {
ap_cfg_closefile(f);
if (errmsg) {
return HTTP_INTERNAL_SERVER_ERROR;
filename);
return HTTP_FORBIDDEN;
return OK;
#ifdef RLIMIT_NOFILE
s->timeout = 0;
s->keep_alive_timeout = 0;
*ps = s;
s->port = 0;
fixup_virtual_hosts(p, s);
ap_fini_vhost_config(p, s);
if (m->create_server_config)
(*m->create_server_config)(p, s));
if (m->create_dir_config)
void ap_post_config_hook(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s)
void ap_show_directives()
for (n = 0; ap_loaded_modules[n]; ++n)
void ap_show_modules()
for (n = 0; ap_loaded_modules[n]; ++n)