1 /* ====================================================================
2 * The Apache Software License, Version 1.1
4 * Copyright (c) 2000 The Apache Software Foundation. All rights
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
19 * 3. The end-user documentation included with the redistribution,
20 * if any, must include the following acknowledgment:
21 * "This product includes software developed by the
22 * Apache Software Foundation (http://www.apache.org/)."
23 * Alternately, this acknowledgment may appear in the software itself,
24 * if and wherever such third-party acknowledgments normally appear.
26 * 4. The names "Apache" and "Apache Software Foundation" must
27 * not be used to endorse or promote products derived from this
28 * software without prior written permission. For written
29 * permission, please contact apache@apache.org.
31 * 5. Products derived from this software may not be called "Apache",
32 * nor may "Apache" appear in their name, without prior written
33 * permission of the Apache Software Foundation.
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * ====================================================================
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation. For more
51 * information on the Apache Software Foundation, please see
52 * <http://www.apache.org/>.
54 * Portions of this software are based upon public domain software
55 * originally written at the National Center for Supercomputing Applications,
56 * University of Illinois, Urbana-Champaign.
60 * http_config.c: once was auxillary functions for reading httpd's config
61 * file and converting filenames into a namespace
65 * Wall-to-wall rewrite for Apache... commands which are part of the
66 * server core can now be found next door in "http_core.c". Now contains
67 * general command loop, and functions which do bookkeeping for the new
68 * Apache config stuff (modules and configuration vectors).
76 #include "ap_config.h"
77 #include "apr_portable.h"
78 #include "apr_file_io.h"
80 #include "http_config.h"
81 #include "http_core.h"
82 #include "http_log.h" /* for errors in parse_htaccess */
83 #include "http_request.h" /* for default_handler (see invoke_handler) */
84 #include "http_main.h"
85 #include "http_vhost.h"
86 #include "util_cfgtree.h"
88 API_VAR_EXPORT const char *ap_server_argv0;
90 API_VAR_EXPORT const char *ap_server_root;
92 API_VAR_EXPORT ap_array_header_t *ap_server_pre_read_config;
93 API_VAR_EXPORT ap_array_header_t *ap_server_post_read_config;
94 API_VAR_EXPORT ap_array_header_t *ap_server_config_defines;
97 AP_HOOK_LINK(header_parser)
98 AP_HOOK_LINK(pre_config)
99 AP_HOOK_LINK(post_config)
100 AP_HOOK_LINK(open_logs)
101 AP_HOOK_LINK(child_init)
104 AP_IMPLEMENT_HOOK_RUN_ALL(int,header_parser,
105 (request_rec *r),(r),OK,DECLINED)
106 AP_IMPLEMENT_HOOK_VOID(pre_config,
107 (ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp),
109 AP_IMPLEMENT_HOOK_VOID(post_config,
110 (ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp,
111 server_rec *s),(pconf,plog,ptemp,s))
112 AP_IMPLEMENT_HOOK_VOID(open_logs,
113 (ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp,
114 server_rec *s),(pconf,plog,ptemp,s))
115 AP_IMPLEMENT_HOOK_VOID(child_init,
116 (ap_pool_t *pchild, server_rec *s),(pchild,s))
118 /****************************************************************
120 * We begin with the functions which deal with the linked list
121 * of modules which control just about all of the server operation.
124 /* total_modules is the number of modules that have been linked
127 static int total_modules = 0;
128 /* dynamic_modules is the number of modules that have been added
129 * after the pre-loaded ones have been set up. It shouldn't be larger
130 * than DYNAMIC_MODULE_LIMIT.
132 static int dynamic_modules = 0;
133 API_VAR_EXPORT module *top_module = NULL;
134 API_VAR_EXPORT module **ap_loaded_modules=NULL;
136 typedef int (*handler_func) (request_rec *);
137 typedef void *(*dir_maker_func) (ap_pool_t *, char *);
138 typedef void *(*merger_func) (ap_pool_t *, void *, void *);
140 /* Dealing with config vectors. These are associated with per-directory,
141 * per-server, and per-request configuration, and have a void* pointer for
142 * each modules. The nature of the structure pointed to is private to the
143 * module in question... the core doesn't (and can't) know. However, there
144 * are defined interfaces which allow it to create instances of its private
145 * per-directory and per-server structures, and to merge the per-directory
146 * structures of a directory and its subdirectory (producing a new one in
147 * which the defaults applying to the base directory have been properly
151 #ifndef ap_get_module_config
152 API_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m)
154 void **confv = (void **) conf_vector;
155 return confv[m->module_index];
159 #ifndef ap_set_module_config
160 API_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val)
162 void **confv = (void **) conf_vector;
163 confv[m->module_index] = val;
167 static void *create_empty_config(ap_pool_t *p)
169 void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) *
170 (total_modules + DYNAMIC_MODULE_LIMIT));
171 return (void *) conf_vector;
174 static void *create_default_per_dir_config(ap_pool_t *p)
176 void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
179 for (modp = top_module; modp; modp = modp->next) {
180 dir_maker_func df = modp->create_dir_config;
183 conf_vector[modp->module_index] = (*df) (p, NULL);
186 return (void *) conf_vector;
190 ap_merge_per_dir_configs(ap_pool_t *p, void *base, void *new)
192 void **conf_vector = (void **) ap_palloc(p, sizeof(void *) * total_modules);
193 void **base_vector = (void **) base;
194 void **new_vector = (void **) new;
197 for (modp = top_module; modp; modp = modp->next) {
198 merger_func df = modp->merge_dir_config;
199 int i = modp->module_index;
201 if (df && new_vector[i])
202 conf_vector[i] = (*df) (p, base_vector[i], new_vector[i]);
204 conf_vector[i] = new_vector[i] ? new_vector[i] : base_vector[i];
207 return (void *) conf_vector;
210 static void *create_server_config(ap_pool_t *p, server_rec *s)
212 void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
215 for (modp = top_module; modp; modp = modp->next) {
216 if (modp->create_server_config)
217 conf_vector[modp->module_index] = (*modp->create_server_config) (p, s);
220 return (void *) conf_vector;
223 static void merge_server_configs(ap_pool_t *p, void *base, void *virt)
225 /* Can reuse the 'virt' vector for the spine of it, since we don't
226 * have to deal with the moral equivalent of .htaccess files here...
229 void **base_vector = (void **) base;
230 void **virt_vector = (void **) virt;
233 for (modp = top_module; modp; modp = modp->next) {
234 merger_func df = modp->merge_server_config;
235 int i = modp->module_index;
238 virt_vector[i] = base_vector[i];
240 virt_vector[i] = (*df) (p, base_vector[i], virt_vector[i]);
244 void *ap_create_request_config(ap_pool_t *p)
246 return create_empty_config(p);
249 void *ap_create_conn_config(ap_pool_t *p)
251 return create_empty_config(p);
254 CORE_EXPORT(void *) ap_create_per_dir_config(ap_pool_t *p)
256 return create_empty_config(p);
260 * For speed/efficiency we generate a compact list of all the handlers
261 * and wildcard handlers. This means we won't have to scan the entire
262 * module list looking for handlers... where we'll find a whole whack
270 static fast_handler_rec *handlers;
271 static fast_handler_rec *wildhandlers;
273 static void init_handlers(ap_pool_t *p)
277 int nwildhandlers = 0;
278 const handler_rec *handp;
279 fast_handler_rec *ph, *pw;
282 for (modp = top_module; modp; modp = modp->next) {
285 for (handp = modp->handlers; handp->content_type; ++handp) {
286 if (strchr(handp->content_type, '*')) {
293 ph = handlers = ap_palloc(p, sizeof(*ph)*(nhandlers + 1));
294 pw = wildhandlers = ap_palloc(p, sizeof(*pw)*(nwildhandlers + 1));
295 for (modp = top_module; modp; modp = modp->next) {
298 for (handp = modp->handlers; handp->content_type; ++handp) {
299 if ((starp = strchr(handp->content_type, '*'))) {
300 pw->hr.content_type = handp->content_type;
301 pw->hr.handler = handp->handler;
302 pw->len = starp - handp->content_type;
305 ph->hr.content_type = handp->content_type;
306 ph->hr.handler = handp->handler;
307 ph->len = strlen(handp->content_type);
312 pw->hr.content_type = NULL;
313 pw->hr.handler = NULL;
314 ph->hr.content_type = NULL;
315 ph->hr.handler = NULL;
318 int ap_invoke_handler(request_rec *r)
320 fast_handler_rec *handp;
324 int result = HTTP_INTERNAL_SERVER_ERROR;
327 handler = r->handler;
328 handler_len = strlen(handler);
331 handler = r->content_type ? r->content_type : ap_default_type(r);
332 if ((p = strchr(handler, ';')) != NULL) { /* MIME type arguments */
333 while (p > handler && p[-1] == ' ')
334 --p; /* strip trailing spaces */
335 handler_len = p - handler;
338 handler_len = strlen(handler);
342 /* Pass one --- direct matches */
344 for (handp = handlers; handp->hr.content_type; ++handp) {
345 if (handler_len == handp->len
346 && !strncmp(handler, handp->hr.content_type, handler_len)) {
347 result = (*handp->hr.handler) (r);
349 if (result != DECLINED)
354 /* Pass two --- wildcard matches */
356 for (handp = wildhandlers; handp->hr.content_type; ++handp) {
357 if (handler_len >= handp->len
358 && !strncmp(handler, handp->hr.content_type, handp->len)) {
359 result = (*handp->hr.handler) (r);
361 if (result != DECLINED)
366 if (result == HTTP_INTERNAL_SERVER_ERROR && r->handler && r->filename) {
367 ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,
368 "handler \"%s\" not found for: %s", r->handler, r->filename);
370 return HTTP_INTERNAL_SERVER_ERROR;
373 API_EXPORT(void) ap_register_hooks(module *m)
375 if(m->register_hooks)
377 if(getenv("SHOW_HOOKS"))
379 printf("Registering hooks for %s\n",m->name);
380 ap_debug_module_hooks=1;
382 ap_debug_module_name=m->name;
387 /* One-time setup for precompiled modules --- NOT to be done on restart */
389 API_EXPORT(void) ap_add_module(module *m)
391 /* This could be called from an AddModule httpd.conf command,
392 * after the file has been linked and the module structure within it
396 if (m->version != MODULE_MAGIC_NUMBER_MAJOR) {
397 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
398 "%s: module \"%s\" is not compatible with this "
399 "version of Apache.", ap_server_argv0, m->name);
400 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Please contact the vendor for the correct version.");
404 if (m->next == NULL) {
405 m->next = top_module;
408 if (m->module_index == -1) {
409 m->module_index = total_modules++;
412 if (dynamic_modules > DYNAMIC_MODULE_LIMIT) {
413 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
414 "%s: module \"%s\" could not be loaded, because"
415 " the dynamic", ap_server_argv0, m->name);
416 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
417 "module limit was reached. Please increase "
418 "DYNAMIC_MODULE_LIMIT and recompile.");
423 /* Some C compilers put a complete path into __FILE__, but we want
424 * only the filename (e.g. mod_includes.c). So check for path
425 * components (Unix and DOS), and remove them.
428 if (strrchr(m->name, '/'))
429 m->name = 1 + strrchr(m->name, '/');
430 if (strrchr(m->name, '\\'))
431 m->name = 1 + strrchr(m->name, '\\');
433 #ifdef _OSD_POSIX /* __FILE__="*POSIX(/home/martin/apache/src/modules/standard/mod_info.c)" */
434 /* We cannot fix the string in-place, because it's const */
435 if (m->name[strlen(m->name)-1]==')') {
436 char *tmp = strdup(m->name); /* FIXME:memory leak, albeit a small one */
437 tmp[strlen(tmp)-1] = '\0';
440 #endif /*_OSD_POSIX*/
442 /* FIXME: is this the right place to call this? */
443 ap_register_hooks(m);
447 * remove_module undoes what add_module did. There are some caveats:
448 * when the module is removed, its slot is lost so all the current
449 * per-dir and per-server configurations are invalid. So we should
450 * only ever call this function when you are invalidating almost
451 * all our current data. I.e. when doing a restart.
454 API_EXPORT(void) ap_remove_module(module *m)
460 /* We are the top module, special case */
461 top_module = modp->next;
465 /* Not the top module, find use. When found modp will
466 * point to the module _before_ us in the list
469 while (modp && modp->next != m) {
473 /* Uh-oh, this module doesn't exist */
474 ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, NULL,
475 "Cannot remove module %s: not found in module list",
479 /* Eliminate us from the module list */
480 modp->next = modp->next->next;
483 m->module_index = -1; /* simulate being unloaded, should
489 API_EXPORT(void) ap_add_loaded_module(module *mod)
494 * Add module pointer to top of chained module list
499 * And module pointer to list of loaded modules
501 * Notes: 1. ap_add_module() would already complain if no more space
502 * exists for adding a dynamically loaded module
503 * 2. ap_add_module() accepts double inclusion, so we have
504 * to accept this, too.
506 for (m = ap_loaded_modules; *m != NULL; m++)
512 API_EXPORT(void) ap_remove_loaded_module(module *mod)
519 * Remove module pointer from chained module list
521 ap_remove_module(mod);
524 * Remove module pointer from list of loaded modules
526 * Note: 1. We cannot determine if the module was successfully
527 * removed by ap_remove_module().
528 * 2. We have not to complain explicity when the module
529 * is not found because ap_remove_module() did it
532 for (m = m2 = ap_loaded_modules, done = 0; *m2 != NULL; m2++) {
533 if (*m2 == mod && done == 0)
541 API_EXPORT(void) ap_setup_prelinked_modules(process_rec *process)
546 ap_global_hook_pool=process->pconf;
549 * Initialise total_modules variable and module indices
552 for (m = ap_preloaded_modules; *m != NULL; m++)
553 (*m)->module_index = total_modules++;
556 * Initialise list of loaded modules
558 ap_loaded_modules = (module **)ap_palloc(process->pool,
559 sizeof(module *)*(total_modules+DYNAMIC_MODULE_LIMIT+1));
560 if (ap_loaded_modules == NULL) {
561 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
562 "Ouch! Out of memory in ap_setup_prelinked_modules()!");
564 for (m = ap_preloaded_modules, m2 = ap_loaded_modules; *m != NULL; )
569 * Initialize chain of linked (=activate) modules
571 for (m = ap_prelinked_modules; *m != NULL; m++)
577 API_EXPORT(const char *) ap_find_module_name(module *m)
582 API_EXPORT(module *) ap_find_linked_module(const char *name)
586 for (modp = top_module; modp; modp = modp->next) {
587 if (strcmp(modp->name, name) == 0)
593 /* Add a named module. Returns 1 if module found, 0 otherwise. */
594 API_EXPORT(int) ap_add_named_module(const char *name)
599 for (modp = ap_loaded_modules[i]; modp; modp = ap_loaded_modules[++i]) {
600 if (strcmp(modp->name, name) == 0) {
601 /* Only add modules that are not already enabled. */
602 if (modp->next == NULL) {
612 /* Clear the internal list of modules, in preparation for starting over. */
613 API_EXPORT(void) ap_clear_module_list()
615 module **m = &top_module;
619 next_m = &((*m)->next);
624 /* This is required; so we add it always. */
625 ap_add_named_module("http_core.c");
628 /*****************************************************************
630 * Resource, access, and .htaccess config files now parsed by a common
633 * Let's begin with the basics; parsing the line and
634 * invoking the function...
637 static const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
638 void *mconfig, const char *args)
643 if ((parms->override & cmd->req_override) == 0)
644 return ap_pstrcat(parms->pool, cmd->name, " not allowed here", NULL);
646 parms->info = cmd->cmd_data;
649 switch (cmd->args_how) {
651 #ifdef RESOLVE_ENV_PER_TOKEN
652 args = ap_resolve_env(parms->pool,args);
654 return ((const char *(*)(cmd_parms *, void *, const char *))
655 (cmd->func)) (parms, mconfig, args);
659 return ap_pstrcat(parms->pool, cmd->name, " takes no arguments",
662 return ((const char *(*)(cmd_parms *, void *))
663 (cmd->func)) (parms, mconfig);
666 w = ap_getword_conf(parms->pool, &args);
668 if (*w == '\0' || *args != 0)
669 return ap_pstrcat(parms->pool, cmd->name, " takes one argument",
670 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
672 return ((const char *(*)(cmd_parms *, void *, const char *))
673 (cmd->func)) (parms, mconfig, w);
677 w = ap_getword_conf(parms->pool, &args);
678 w2 = ap_getword_conf(parms->pool, &args);
680 if (*w == '\0' || *w2 == '\0' || *args != 0)
681 return ap_pstrcat(parms->pool, cmd->name, " takes two arguments",
682 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
684 return ((const char *(*)(cmd_parms *, void *, const char *,
685 const char *)) (cmd->func)) (parms, mconfig, w, w2);
689 w = ap_getword_conf(parms->pool, &args);
690 w2 = ap_getword_conf(parms->pool, &args);
692 if (*w == '\0' || *args != 0)
693 return ap_pstrcat(parms->pool, cmd->name, " takes 1-2 arguments",
694 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
696 return ((const char *(*)(cmd_parms *, void *, const char *,
697 const char *)) (cmd->func)) (parms, mconfig, w,
702 w = ap_getword_conf(parms->pool, &args);
703 w2 = ap_getword_conf(parms->pool, &args);
704 w3 = ap_getword_conf(parms->pool, &args);
706 if (*w == '\0' || *w2 == '\0' || *w3 == '\0' || *args != 0)
707 return ap_pstrcat(parms->pool, cmd->name, " takes three arguments",
708 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
710 return ((const char *(*)(cmd_parms *, void *, const char *,
711 const char *, const char *)) (cmd->func)) (parms,
716 w = ap_getword_conf(parms->pool, &args);
717 w2 = ap_getword_conf(parms->pool, &args);
718 w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
720 if (*w == '\0' || *w2 == '\0' || *args != 0)
721 return ap_pstrcat(parms->pool, cmd->name,
722 " takes two or three arguments",
723 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
725 return ((const char *(*)(cmd_parms *, void *, const char *,
726 const char *, const char *)) (cmd->func)) (parms,
731 w = ap_getword_conf(parms->pool, &args);
732 w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
733 w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
735 if (*w == '\0' || *args != 0)
736 return ap_pstrcat(parms->pool, cmd->name,
737 " takes one, two or three arguments",
738 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
740 return ((const char *(*)(cmd_parms *, void *, const char *,
741 const char *, const char *)) (cmd->func)) (parms,
746 w = ap_getword_conf(parms->pool, &args);
747 w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
748 w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
750 if (*w == '\0' || (w2 && *w2 && !w3) || *args != 0)
751 return ap_pstrcat(parms->pool, cmd->name,
752 " takes one or three arguments",
753 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
755 return ((const char *(*)(cmd_parms *, void *, const char *,
756 const char *, const char *)) (cmd->func)) (parms,
761 while (*(w = ap_getword_conf(parms->pool, &args)) != '\0')
762 if ((errmsg = ((const char *(*)(cmd_parms *, void *,
763 const char *)) (cmd->func)) (parms, mconfig, w)))
770 w = ap_getword_conf(parms->pool, &args);
772 if (*w == '\0' || *args == 0)
773 return ap_pstrcat(parms->pool, cmd->name,
774 " requires at least two arguments",
775 cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
778 while (*(w2 = ap_getword_conf(parms->pool, &args)) != '\0')
779 if ((errmsg = ((const char *(*)(cmd_parms *, void *,
780 const char *, const char *)) (cmd->func)) (parms,
788 w = ap_getword_conf(parms->pool, &args);
790 if (*w == '\0' || (strcasecmp(w, "on") && strcasecmp(w, "off")))
791 return ap_pstrcat(parms->pool, cmd->name, " must be On or Off",
794 return ((const char *(*)(cmd_parms *, void *, int))
795 (cmd->func)) (parms, mconfig, strcasecmp(w, "off") != 0);
799 return ap_pstrcat(parms->pool, cmd->name,
800 " is improperly configured internally (server bug)",
805 CORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds)
808 if (!strcasecmp(name, cmds->name))
816 CORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod)
818 const command_rec *cmdp;
821 for (modp = *mod; modp; modp = modp->next)
822 if (modp->cmds && (cmdp = ap_find_command(cmd_name, modp->cmds))) {
830 CORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod)
832 void *mconfig = ap_get_module_config(config, mod);
833 void *sconfig = ap_get_module_config(parms->server->module_config, mod);
835 if (!mconfig && mod->create_dir_config) {
836 mconfig = (*mod->create_dir_config) (parms->pool, parms->path);
837 ap_set_module_config(config, mod, mconfig);
840 if (!sconfig && mod->create_server_config) {
841 sconfig = (*mod->create_server_config) (parms->pool, parms->server);
842 ap_set_module_config(parms->server->module_config, mod, sconfig);
847 static const char *execute_now(char *cmd_line, const char *args, cmd_parms *parms,
848 ap_pool_t *p, ap_pool_t *ptemp,
849 ap_directive_t **sub_tree, ap_directive_t *parent);
851 static const char * ap_build_config_sub(ap_pool_t *p, ap_pool_t *temp_pool,
852 const char *l, cmd_parms *parms,
853 ap_directive_t **current,
854 ap_directive_t **curr_parent)
858 ap_directive_t *newdir;
859 module *mod = top_module;
860 const command_rec *cmd;
862 if (*l == '#' || *l == '\0')
865 #if RESOLVE_ENV_PER_TOKEN
868 args = ap_resolve_env(temp_pool, l);
870 cmd_name = ap_getword_conf(p, &args);
871 if (*cmd_name == '\0') {
872 /* Note: this branch should not occur. An empty line should have
873 * triggered the exit further above.
878 if ((cmd = ap_find_command_in_modules(cmd_name, &mod)) != NULL) {
879 if (cmd->req_override & EXEC_ON_READ) {
881 ap_directive_t *sub_tree = NULL;
883 retval = execute_now(cmd_name, args, parms, p, temp_pool,
884 &sub_tree, *curr_parent);
886 (*current)->next = sub_tree;
889 (*current) = sub_tree;
891 (*curr_parent)->first_child = (*current);
894 (*current)->parent = (*curr_parent);
898 while ((*current)->next != NULL) {
899 (*current) = (*current)->next;
900 (*current)->parent = (*curr_parent);
907 newdir = ap_pcalloc(p, sizeof(ap_directive_t));
908 newdir->filename = parms->config_file->name;
909 newdir->line_num = parms->config_file->line_number;
910 newdir->directive = cmd_name;
911 newdir->args = ap_pstrdup(p, args);
913 if (cmd_name[0] == '<') {
914 if (cmd_name[1] != '/') {
915 (*current) = ap_add_node(curr_parent, *current, newdir, 1);
917 else if (*curr_parent == NULL) {
918 parms->err_directive = newdir;
919 return ap_pstrcat(p, cmd_name,
920 " without matching <", cmd_name + 2,
924 char *bracket = cmd_name + strlen(cmd_name) - 1;
926 if (*bracket != '>') {
927 return ap_pstrcat(p, cmd_name,
928 "> directive missing closing '>'", NULL);
931 if (strcasecmp(cmd_name + 2,
932 (*curr_parent)->directive + 1) != 0) {
933 return ap_pstrcat(p, "Expected </",
934 (*curr_parent)->directive + 1, "> but saw ",
935 cmd_name, ">", NULL);
939 /* done with this section; move up a level */
940 *current = *curr_parent;
941 *curr_parent = (*current)->parent;
945 *current = ap_add_node(curr_parent, *current, newdir, 0);
951 const char * ap_build_cont_config(ap_pool_t *p, ap_pool_t *temp_pool,
953 ap_directive_t **current,
954 ap_directive_t **curr_parent,
955 char *orig_directive)
957 char l[MAX_STRING_LEN];
960 ap_directive_t *conftree = NULL;
962 bracket = ap_pstrcat(p, orig_directive + 1, ">", NULL);
963 while(!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
964 if ((strcasecmp(l + 2, bracket) == 0) &&
965 (*curr_parent == NULL)) {
968 retval = ap_build_config_sub(p, temp_pool, l, parms, current,
972 if (conftree == NULL && curr_parent != NULL) {
973 conftree = *curr_parent;
975 if (conftree == NULL && current != NULL) {
983 static const char *ap_walk_config_sub(const ap_directive_t *current,
984 cmd_parms *parms, void *config)
986 module *mod = top_module;
989 const command_rec *cmd;
991 if (!(cmd = ap_find_command_in_modules(current->directive, &mod))) {
992 parms->err_directive = current;
993 return ap_pstrcat(parms->pool, "Invalid command '",
995 "', perhaps mis-spelled or defined by a module "
996 "not included in the server configuration",
1000 void *mconfig = ap_set_config_vectors(parms,config, mod);
1003 retval = invoke_cmd(cmd, parms, mconfig, current->args);
1004 if (retval == NULL) {
1007 if (strcmp(retval, DECLINE_CMD) != 0) {
1008 /* If the directive in error has already been set, don't
1009 * replace it. Otherwise, an error inside a container
1010 * will be reported as occuring on the first line of the
1013 if (!parms->err_directive) {
1014 parms->err_directive = current;
1019 mod = mod->next; /* Next time around, skip this one */
1025 API_EXPORT(const char *) ap_walk_config(ap_directive_t *current,
1026 cmd_parms *parms, void *config)
1028 void *oldconfig = parms->context;
1030 parms->context = config;
1032 /* scan through all directives, executing each one */
1033 for (; current != NULL; current = current->next) {
1036 parms->directive = current;
1038 /* actually parse the command and execute the correct function */
1039 errmsg = ap_walk_config_sub(current, parms, config);
1040 if (errmsg != NULL) {
1041 /* restore the context (just in case) */
1042 parms->context = oldconfig;
1047 parms->context = oldconfig;
1052 API_EXPORT(const char *) ap_build_config(cmd_parms *parms,
1053 ap_pool_t *p, ap_pool_t *temp_pool,
1054 ap_directive_t **conftree)
1056 ap_directive_t *current = *conftree;
1057 ap_directive_t *curr_parent = NULL;
1058 char l[MAX_STRING_LEN];
1061 if (current != NULL) {
1062 while (current->next) {
1063 current = current->next;
1067 while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
1069 errmsg = ap_build_config_sub(p, temp_pool, l, parms,
1070 ¤t, &curr_parent);
1074 if (*conftree == NULL && curr_parent != NULL) {
1075 *conftree = curr_parent;
1077 if (*conftree == NULL && current != NULL) {
1078 *conftree = current;
1082 if (curr_parent != NULL) {
1084 while (curr_parent != NULL) {
1085 errmsg = ap_psprintf(p, "%s%s%s:%u: %s> was not closed.",
1087 *errmsg == '\0' ? "" : "\n",
1088 curr_parent->filename,
1089 curr_parent->line_num,
1090 curr_parent->directive);
1091 curr_parent = curr_parent->parent;
1100 * Generic command functions...
1103 API_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
1104 char *struct_ptr, char *arg)
1106 /* This one's pretty generic... */
1108 int offset = (int) (long) cmd->info;
1109 *(char **) (struct_ptr + offset) = arg;
1113 API_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
1114 char *struct_ptr, char *arg)
1116 /* This one's pretty generic... */
1118 int offset = (int) (long) cmd->info;
1119 ap_str_tolower(arg);
1120 *(char **) (struct_ptr + offset) = arg;
1124 API_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
1125 char *struct_ptr, int arg)
1127 /* This one's pretty generic too... */
1129 int offset = (int) (long) cmd->info;
1130 *(int *) (struct_ptr + offset) = arg ? 1 : 0;
1134 API_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, char *struct_ptr, char *arg)
1136 /* Prepend server_root to relative arg.
1137 This allows .htaccess to be independent of server_root,
1138 so the server can be moved or mirrored with less pain. */
1140 int offset = (int) (long) cmd->info;
1141 if (ap_os_is_path_absolute(arg))
1144 p = ap_make_full_path(cmd->pool, ap_server_root, arg);
1145 *(char **) (struct_ptr + offset) = p;
1149 /*****************************************************************
1151 * Reading whole config files...
1154 static cmd_parms default_parms =
1155 {NULL, 0, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
1157 API_EXPORT(const char *) ap_server_root_relative(ap_pool_t *p, const char *file)
1159 if(ap_os_is_path_absolute(file))
1161 return ap_make_full_path(p, ap_server_root, file);
1164 API_EXPORT(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive)
1166 char l[MAX_STRING_LEN];
1170 while(!(ap_cfg_getline(l, MAX_STRING_LEN, cmd->config_file))) {
1171 #if RESOLVE_ENV_PER_TOKEN
1174 args = ap_resolve_env(cmd->temp_pool, l);
1176 cmd_name = ap_getword_conf(cmd->pool, &args);
1177 if (cmd_name[0] == '<') {
1178 if (cmd_name[1] == '/') {
1179 cmd_name[strlen(cmd_name) - 1] = '\0';
1180 if (strcasecmp(cmd_name + 2, directive + 1) != 0) {
1181 return ap_pstrcat(cmd->pool, "Expected </",
1182 directive + 1, "> but saw ",
1183 cmd_name, ">", NULL);
1188 ap_soak_end_container(cmd, cmd_name);
1195 static const char *execute_now(char *cmd_line, const char *args, cmd_parms *parms,
1196 ap_pool_t *p, ap_pool_t *ptemp,
1197 ap_directive_t **sub_tree, ap_directive_t *parent)
1199 module *mod = top_module;
1200 const command_rec *cmd;
1202 if (!(cmd = ap_find_command_in_modules(cmd_line, &mod))) {
1203 return ap_pstrcat(parms->pool, "Invalid command '",
1205 "', perhaps mis-spelled or defined by a module "
1206 "not included in the server configuration",
1210 return invoke_cmd(cmd, parms, sub_tree, args);
1214 /* This structure and the following functions are needed for the
1215 * table-based config file reading. They are passed to the
1216 * cfg_open_custom() routine.
1219 /* Structure to be passed to cfg_open_custom(): it contains an
1220 * index which is incremented from 0 to nelts on each call to
1221 * cfg_getline() (which in turn calls arr_elts_getstr())
1222 * and an ap_array_header_t pointer for the string array.
1225 ap_array_header_t *array;
1230 /* arr_elts_getstr() returns the next line from the string array. */
1231 static void *arr_elts_getstr(void *buf, size_t bufsiz, void *param)
1233 arr_elts_param_t *arr_param = (arr_elts_param_t *) param;
1235 /* End of array reached? */
1236 if (++arr_param->curr_idx > arr_param->array->nelts)
1239 /* return the line */
1240 ap_cpystrn(buf, ((char **) arr_param->array->elts)[arr_param->curr_idx - 1], bufsiz);
1246 /* arr_elts_close(): dummy close routine (makes sure no more lines can be read) */
1247 static int arr_elts_close(void *param)
1249 arr_elts_param_t *arr_param = (arr_elts_param_t *) param;
1250 arr_param->curr_idx = arr_param->array->nelts;
1254 static void process_command_config(server_rec *s, ap_array_header_t *arr,
1255 ap_directive_t **conftree, ap_pool_t *p,
1260 arr_elts_param_t arr_parms;
1262 arr_parms.curr_idx = 0;
1263 arr_parms.array = arr;
1265 parms = default_parms;
1267 parms.temp_pool = ptemp;
1269 parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
1271 parms.config_file = ap_pcfg_open_custom(p, "-c/-C directives",
1273 arr_elts_getstr, arr_elts_close);
1275 errmsg = ap_build_config(&parms, p, ptemp, conftree);
1277 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1278 "Syntax error in -C/-c directive:\n%s", errmsg);
1282 ap_cfg_closefile(parms.config_file);
1285 void ap_process_resource_config(server_rec *s, const char *fname,
1286 ap_directive_t **conftree, ap_pool_t *p,
1294 fname = ap_server_root_relative(p, fname);
1296 /* don't require conf/httpd.conf if we have a -C or -c switch */
1297 if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) &&
1298 !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
1299 if (ap_stat(&finfo, fname, p) != APR_SUCCESS)
1303 /* GCC's initialization extensions are soooo nice here... */
1305 parms = default_parms;
1307 parms.temp_pool = ptemp;
1309 parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
1311 if (ap_pcfg_openfile(&cfp, p, fname) != APR_SUCCESS) {
1312 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1313 "%s: could not open document config file %s",
1314 ap_server_argv0, fname);
1318 parms.config_file = cfp;
1320 errmsg = ap_build_config(&parms, p, ptemp, conftree);
1322 if (errmsg != NULL) {
1323 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1324 "Syntax error on line %d of %s:",
1325 parms.err_directive->line_num,
1326 parms.err_directive->filename);
1327 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1332 ap_cfg_closefile(cfp);
1335 API_EXPORT(void)ap_process_config_tree(server_rec *s, ap_directive_t *conftree,
1336 ap_pool_t *p, ap_pool_t *ptemp)
1341 parms = default_parms;
1343 parms.temp_pool = ptemp;
1345 parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
1347 errmsg = ap_walk_config(conftree, &parms, s->lookup_defaults);
1349 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1350 "Syntax error on line %d of %s:",
1351 parms.err_directive->line_num,
1352 parms.err_directive->filename);
1353 ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
1359 int ap_parse_htaccess(void **result, request_rec *r, int override,
1360 const char *d, const char *access_name)
1362 configfile_t *f = NULL;
1364 char *filename = NULL;
1365 const struct htaccess_result *cache;
1366 struct htaccess_result *new;
1370 /* firstly, search cache */
1371 for (cache = r->htaccess; cache != NULL; cache = cache->next)
1372 if (cache->override == override && strcmp(cache->dir, d) == 0) {
1373 if (cache->htaccess != NULL)
1374 *result = cache->htaccess;
1378 parms = default_parms;
1379 parms.override = override;
1380 parms.pool = r->pool;
1381 parms.temp_pool = r->pool;
1382 parms.server = r->server;
1383 parms.path = ap_pstrdup(r->pool, d);
1385 /* loop through the access names and find the first one */
1387 while (access_name[0]) {
1388 filename = ap_make_full_path(r->pool, d,
1389 ap_getword_conf(r->pool, &access_name));
1390 status = ap_pcfg_openfile(&f, r->pool, filename);
1392 if (status == APR_SUCCESS) {
1394 ap_directive_t *conftree;
1396 dc = ap_create_per_dir_config(r->pool);
1398 parms.config_file = f;
1399 errmsg = ap_build_config(&parms, r->pool, r->pool, &conftree);
1401 errmsg = ap_walk_config(conftree, &parms, dc);
1403 ap_cfg_closefile(f);
1406 ap_log_rerror(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, r,
1407 "%s: %s", filename, errmsg);
1408 return HTTP_INTERNAL_SERVER_ERROR;
1413 ap_status_t cerr = ap_canonical_error(status);
1415 if (cerr != APR_ENOENT && cerr != APR_ENOTDIR) {
1416 ap_log_rerror(APLOG_MARK, APLOG_CRIT, status, r,
1417 "%s pcfg_openfile: unable to check htaccess file, "
1418 "ensure it is readable",
1420 ap_table_setn(r->notes, "error-notes",
1421 "Server unable to read htaccess file, denying "
1422 "access to be safe");
1423 return HTTP_FORBIDDEN;
1429 new = ap_palloc(r->pool, sizeof(struct htaccess_result));
1430 new->dir = parms.path;
1431 new->override = override;
1433 /* add to head of list */
1434 new->next = r->htaccess;
1441 CORE_EXPORT(const char *) ap_init_virtual_host(ap_pool_t *p, const char *hostname,
1442 server_rec *main_server, server_rec **ps)
1444 server_rec *s = (server_rec *) ap_pcalloc(p, sizeof(server_rec));
1446 /* TODO: this crap belongs in http_core */
1447 s->process = main_server->process;
1448 s->server_admin = NULL;
1449 s->server_hostname = NULL;
1450 s->error_fname = NULL;
1452 s->keep_alive_timeout = 0;
1454 s->keep_alive_max = -1;
1455 s->error_log = main_server->error_log;
1456 s->loglevel = main_server->loglevel;
1457 /* useful default, otherwise we get a port of 0 on redirects */
1458 s->port = main_server->port;
1462 s->names = ap_make_array(p, 4, sizeof(char **));
1463 s->wild_names = ap_make_array(p, 4, sizeof(char **));
1465 s->module_config = create_empty_config(p);
1466 s->lookup_defaults = ap_create_per_dir_config(p);
1469 s->server_uid = ap_user_id;
1470 s->server_gid = ap_group_id;
1473 s->limit_req_line = main_server->limit_req_line;
1474 s->limit_req_fieldsize = main_server->limit_req_fieldsize;
1475 s->limit_req_fields = main_server->limit_req_fields;
1479 return ap_parse_vhost_addrs(p, hostname, s);
1483 API_EXPORT(void) ap_fixup_virtual_hosts(ap_pool_t *p, server_rec *main_server)
1487 for (virt = main_server->next; virt; virt = virt->next) {
1488 merge_server_configs(p, main_server->module_config,
1489 virt->module_config);
1491 virt->lookup_defaults =
1492 ap_merge_per_dir_configs(p, main_server->lookup_defaults,
1493 virt->lookup_defaults);
1495 if (virt->server_admin == NULL)
1496 virt->server_admin = main_server->server_admin;
1498 if (virt->timeout == 0)
1499 virt->timeout = main_server->timeout;
1501 if (virt->keep_alive_timeout == 0)
1502 virt->keep_alive_timeout = main_server->keep_alive_timeout;
1504 if (virt->keep_alive == -1)
1505 virt->keep_alive = main_server->keep_alive;
1507 if (virt->keep_alive_max == -1)
1508 virt->keep_alive_max = main_server->keep_alive_max;
1510 /* XXX: this is really something that should be dealt with by a
1511 * post-config api phase */
1512 ap_core_reorder_directories(p, virt);
1514 ap_core_reorder_directories(p, main_server);
1517 /*****************************************************************
1519 * Getting *everything* configured...
1522 static void init_config_globals(ap_pool_t *p)
1524 /* Global virtual host hash bucket pointers. Init to null. */
1525 ap_init_vhost_config(p);
1528 static server_rec *init_server_config(process_rec *process, ap_pool_t *p)
1530 server_rec *s = (server_rec *) ap_pcalloc(p, sizeof(server_rec));
1532 ap_open_stderr(&s->error_log, p);
1533 s->process = process;
1535 s->server_admin = DEFAULT_ADMIN;
1536 s->server_hostname = NULL;
1537 s->error_fname = DEFAULT_ERRORLOG;
1538 s->loglevel = DEFAULT_LOGLEVEL;
1539 s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE;
1540 s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE;
1541 s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS;
1542 s->timeout = DEFAULT_TIMEOUT;
1543 s->keep_alive_timeout = DEFAULT_KEEPALIVE_TIMEOUT;
1544 s->keep_alive_max = DEFAULT_KEEPALIVE;
1547 s->addrs = ap_pcalloc(p, sizeof(server_addr_rec));
1548 /* NOT virtual host; don't match any real network interface */
1549 s->addrs->host_addr.s_addr = htonl(INADDR_ANY);
1550 s->addrs->host_port = 0; /* matches any port */
1551 s->addrs->virthost = ""; /* must be non-NULL */
1552 s->names = s->wild_names = NULL;
1554 s->module_config = create_server_config(p, s);
1555 s->lookup_defaults = create_default_per_dir_config(p);
1561 API_EXPORT(server_rec*) ap_read_config(process_rec *process, ap_pool_t *ptemp,
1562 const char *confname,
1563 ap_directive_t **conftree)
1565 ap_pool_t *p = process->pconf;
1566 server_rec *s = init_server_config(process, p);
1568 init_config_globals(p);
1570 /* All server-wide config files now have the SAME syntax... */
1572 process_command_config(s, ap_server_pre_read_config, conftree,
1575 ap_process_resource_config(s, confname, conftree, p, ptemp);
1577 process_command_config(s, ap_server_post_read_config, conftree,
1583 void ap_single_module_configure(ap_pool_t *p, server_rec *s, module *m)
1585 if (m->create_server_config)
1586 ap_set_module_config(s->module_config, m,
1587 (*m->create_server_config)(p, s));
1588 if (m->create_dir_config)
1589 ap_set_module_config(s->lookup_defaults, m,
1590 (*m->create_dir_config)(p, NULL));
1593 API_EXPORT(void) ap_run_rewrite_args(process_rec *process)
1597 for (m = top_module; m; m = m->next)
1598 if (m->rewrite_args)
1599 (*m->rewrite_args) (process);
1602 API_EXPORT(void) ap_post_config_hook(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp, server_rec *s)
1604 ap_run_post_config(pconf,plog,ptemp,s);
1605 init_handlers(pconf);
1608 void ap_child_init_hook(ap_pool_t *pchild, server_rec *s)
1610 /* TODO: uh this seems ugly, is there a better way? */
1611 /*ap_child_init_alloc(); PUT THIS BACK IN XXXXX */
1613 ap_run_child_init(pchild,s);
1616 /********************************************************************
1617 * Configuration directives are restricted in terms of where they may
1618 * appear in the main configuration files and/or .htaccess files according
1619 * to the bitmask req_override in the command_rec structure.
1620 * If any of the overrides set in req_override are also allowed in the
1621 * context in which the command is read, then the command is allowed.
1622 * The context is determined as follows:
1624 * inside *.conf --> override = (RSRC_CONF|OR_ALL)&~(OR_AUTHCFG|OR_LIMIT);
1625 * within <Directory> or <Location> --> override = OR_ALL|ACCESS_CONF;
1626 * within .htaccess --> override = AllowOverride for current directory;
1628 * the result is, well, a rather confusing set of possibilities for when
1629 * a particular directive is allowed to be used. This procedure prints
1630 * in English where the given (pc) directive can be used.
1632 static void show_overrides(const command_rec *pc, module *pm)
1636 printf("\tAllowed in *.conf ");
1637 if ((pc->req_override & (OR_OPTIONS | OR_FILEINFO | OR_INDEXES)) ||
1638 ((pc->req_override & RSRC_CONF) &&
1639 ((pc->req_override & (ACCESS_CONF | OR_AUTHCFG | OR_LIMIT)))))
1641 else if (pc->req_override & RSRC_CONF)
1642 printf("only outside <Directory>, <Files> or <Location>");
1644 printf("only inside <Directory>, <Files> or <Location>");
1646 /* Warn if the directive is allowed inside <Directory> or .htaccess
1647 * but module doesn't support per-dir configuration */
1649 if ((pc->req_override & (OR_ALL | ACCESS_CONF)) && !pm->create_dir_config)
1650 printf(" [no per-dir config]");
1652 if (pc->req_override & OR_ALL) {
1653 printf(" and in .htaccess\n\twhen AllowOverride");
1655 if ((pc->req_override & OR_ALL) == OR_ALL)
1656 printf(" isn't None");
1658 printf(" includes ");
1660 if (pc->req_override & OR_AUTHCFG) {
1663 printf("AuthConfig");
1665 if (pc->req_override & OR_LIMIT) {
1670 if (pc->req_override & OR_OPTIONS) {
1675 if (pc->req_override & OR_FILEINFO) {
1680 if (pc->req_override & OR_INDEXES) {
1690 /* Show the preloaded configuration directives, the help string explaining
1691 * the directive arguments, in what module they are handled, and in
1692 * what parts of the configuration they are allowed. Used for httpd -h.
1694 API_EXPORT(void) ap_show_directives()
1696 const command_rec *pc;
1699 for (n = 0; ap_loaded_modules[n]; ++n)
1700 for (pc = ap_loaded_modules[n]->cmds; pc && pc->name; ++pc) {
1701 printf("%s (%s)\n", pc->name, ap_loaded_modules[n]->name);
1703 printf("\t%s\n", pc->errmsg);
1704 show_overrides(pc, ap_loaded_modules[n]);
1708 /* Show the preloaded module names. Used for httpd -l. */
1709 API_EXPORT(void) ap_show_modules()
1713 printf("Compiled in modules:\n");
1714 for (n = 0; ap_loaded_modules[n]; ++n)
1715 printf(" %s\n", ap_loaded_modules[n]->name);