1 /* ====================================================================
2 * The Apache Software License, Version 1.1
4 * Copyright (c) 2000-2001 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.
59 #ifndef APACHE_HTTP_CONFIG_H
60 #define APACHE_HTTP_CONFIG_H
62 #include "apr_hooks.h"
63 #include "util_cfgtree.h"
71 * @brief Apache Configuration
75 * The central data structures around here...
78 /* Command dispatch structures... */
81 * How the directives arguments should be parsed.
82 * @remark Note that for all of these except RAW_ARGS, the config routine is
83 * passed a freshly allocated string which can be modified or stored
87 RAW_ARGS, /**< cmd_func parses command line itself */
88 TAKE1, /**< one argument only */
89 TAKE2, /**< two arguments only */
90 ITERATE, /**< one argument, occuring multiple times
93 ITERATE2, /**< two arguments, 2nd occurs multiple times
96 FLAG, /**< One of 'On' or 'Off' */
97 NO_ARGS, /**< No args at all, e.g. </Directory> */
98 TAKE12, /**< one or two arguments */
99 TAKE3, /**< three arguments only */
100 TAKE23, /**< two or three arguments */
101 TAKE123, /**< one, two or three arguments */
102 TAKE13 /**< one or three arguments */
105 * This structure is passed to a command which is being invoked,
106 * to carry a large variety of miscellaneous data which is all of
107 * use to *somebody*...
109 typedef struct cmd_parms_struct cmd_parms;
111 #if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN)
114 * All the types of functions that can be used in directives
118 /** function to call for a no-args */
119 const char *(*no_args) (cmd_parms *parms, void *mconfig);
120 /** function to call for a raw-args */
121 const char *(*raw_args) (cmd_parms *parms, void *mconfig,
123 /** function to call for a take1 */
124 const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w);
125 /** function to call for a take2 */
126 const char *(*take2) (cmd_parms *parms, void *mconfig, const char *w,
128 /** function to call for a take3 */
129 const char *(*take3) (cmd_parms *parms, void *mconfig, const char *w,
130 const char *w2, const char *w3);
131 /** function to call for a flag */
132 const char *(*flag) (cmd_parms *parms, void *mconfig, int on);
135 /** This configuration directive does not take any arguments */
136 # define AP_NO_ARGS func.no_args
137 /** This configuration directive will handle it's own parsing of arguments*/
138 # define AP_RAW_ARGS func.raw_args
139 /** This configuration directive takes 1 argument*/
140 # define AP_TAKE1 func.take1
141 /** This configuration directive takes 2 arguments */
142 # define AP_TAKE2 func.take2
143 /** This configuration directive takes 3 arguments */
144 # define AP_TAKE3 func.take3
145 /** This configuration directive takes a flag (on/off) as a argument*/
146 # define AP_FLAG func.flag
148 /** method of declaring a directive with no arguments */
149 # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
150 { directive, { .no_args=func }, mconfig, where, RAW_ARGS, help }
151 /** method of declaring a directive with raw argument parsing */
152 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
153 { directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help }
154 /** method of declaring a directive which takes 1 argument */
155 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
156 { directive, { .take1=func }, mconfig, where, TAKE1, help }
157 /** method of declaring a directive which takes multiple arguments */
158 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
159 { directive, { .take1=func }, mconfig, where, ITERATE, help }
160 /** method of declaring a directive which takes 2 arguments */
161 # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
162 { directive, { .take2=func }, mconfig, where, TAKE2, help }
163 /** method of declaring a directive which takes 1 or 2 arguments */
164 # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
165 { directive, { .take2=func }, mconfig, where, TAKE12, help }
166 /** method of declaring a directive which takes multiple 2 arguments */
167 # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
168 { directive, { .take2=func }, mconfig, where, ITERATE2, help }
169 /** method of declaring a directive which takes 2 or 3 arguments */
170 # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
171 { directive, { .take3=func }, mconfig, where, TAKE23, help }
172 /** method of declaring a directive which takes 3 arguments */
173 # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
174 { directive, { .take3=func }, mconfig, where, TAKE3, help }
175 /** method of declaring a directive which takes a flag (on/off) as a argument*/
176 # define AP_INIT_FLAG(directive, func, mconfig, where, help) \
177 { directive, { .flag=func }, mconfig, where, FLAG, help }
179 #else /* AP_HAVE_DESIGNATED_INITIALIZER */
181 typedef const char *(*cmd_func) ();
183 # define AP_NO_ARGS func
184 # define AP_RAW_ARGS func
185 # define AP_TAKE1 func
186 # define AP_TAKE2 func
187 # define AP_TAKE3 func
188 # define AP_FLAG func
190 # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
191 { directive, func, mconfig, where, RAW_ARGS, help }
192 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
193 { directive, func, mconfig, where, RAW_ARGS, help }
194 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
195 { directive, func, mconfig, where, TAKE1, help }
196 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
197 { directive, func, mconfig, where, ITERATE, help }
198 # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
199 { directive, func, mconfig, where, TAKE2, help }
200 # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
201 { directive, func, mconfig, where, TAKE12, help }
202 # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
203 { directive, func, mconfig, where, ITERATE2, help }
204 # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
205 { directive, func, mconfig, where, TAKE23, help }
206 # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
207 { directive, func, mconfig, where, TAKE3, help }
208 # define AP_INIT_FLAG(directive, func, mconfig, where, help) \
209 { directive, func, mconfig, where, FLAG, help }
211 #endif /* AP_HAVE_DESIGNATED_INITIALIZER */
214 * The command record structure. Each modules can define a table of these
215 * to define the directives it will implement.
217 typedef struct command_struct command_rec;
218 struct command_struct {
219 /** Name of this command */
221 /** The function to be called when this directive is parsed */
223 /** Extra data, for functions which implement multiple commands... */
225 /** What overrides need to be allowed to enable this command. */
227 /** What the command expects as arguments
228 * @defvar cmd_how args_how*/
229 enum cmd_how args_how;
231 /** 'usage' message, in case of syntax errors */
236 * @defgroup ConfigDirectives Allowed locations for configuration directives.
238 * The allowed locations for a configuration directive are the union of
239 * those indicated by each set bit in the req_override mask.
243 #define OR_NONE 0 /**< *.conf is not available anywhere in this override */
244 #define OR_LIMIT 1 /**< *.conf inside <Directory> or <Location>
245 and .htaccess when AllowOverride Limit */
246 #define OR_OPTIONS 2 /**< *.conf anywhere
247 and .htaccess when AllowOverride Options */
248 #define OR_FILEINFO 4 /**< *.conf anywhere
249 and .htaccess when AllowOverride FileInfo */
250 #define OR_AUTHCFG 8 /**< *.conf inside <Directory> or <Location>
251 and .htaccess when AllowOverride AuthConfig */
252 #define OR_INDEXES 16 /**< *.conf anywhere
253 and .htaccess when AllowOverride Indexes */
254 #define OR_UNSET 32 /**< unset a directive (in Allow) */
255 #define ACCESS_CONF 64 /**< *.conf inside <Directory> or <Location> */
256 #define RSRC_CONF 128 /**< *.conf outside <Directory> or <Location> */
257 #define EXEC_ON_READ 256 /**< force directive to execute a command
258 which would modify the conifguration (like including another
260 /** this directive can be placed anywhere */
261 #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
266 * This can be returned by a function if they don't wish to handle
267 * a command. Make it something not likely someone will actually use
270 #define DECLINE_CMD "\a\b"
272 /** Common structure for reading of config files / passwd files etc. */
273 typedef struct ap_configfile_t ap_configfile_t;
274 struct ap_configfile_t {
275 int (*getch) (void *param); /**< a getc()-like function */
276 void *(*getstr) (void *buf, size_t bufsiz, void *param);
277 /**< a fgets()-like function */
278 int (*close) (void *param); /**< a close handler function */
279 void *param; /**< the argument passed to getch/getstr/close */
280 const char *name; /**< the filename / description */
281 unsigned line_number; /**< current line number, starting at 1 */
285 * This structure is passed to a command which is being invoked,
286 * to carry a large variety of miscellaneous data which is all of
287 * use to *somebody*...
289 struct cmd_parms_struct {
290 /** Argument to command from cmd_table */
292 /** Which allow-override bits are set */
294 /** Which methods are <Limit>ed */
296 /** methods which are limited */
297 apr_array_header_t *limited_xmethods;
298 /** methods which are xlimited */
299 ap_method_list_t *xlimited;
301 /** Config file structure. */
302 ap_configfile_t *config_file;
303 /** the directive specifying this command */
304 ap_directive_t *directive;
306 /** Pool to allocate new storage in */
308 /** Pool for scratch memory; persists during configuration, but
309 * wiped before the first request is served... */
310 apr_pool_t *temp_pool;
311 /** Server_rec being configured for */
313 /** If configuring for a directory, pathname of that directory.
314 * NOPE! That's what it meant previous to the existance of <Files>,
315 * <Location> and regex matching. Now the only usefulness that can be
316 * derived from this field is whether a command is being called in a
317 * server context (path == NULL) or being called in a dir context
320 /** configuration command */
321 const command_rec *cmd;
323 /** per_dir_config vector passed to handle_command */
324 struct ap_conf_vector_t *context;
325 /** directive with syntax error */
326 const ap_directive_t *err_directive;
330 * Module structures. Just about everything is dispatched through
331 * these, directly or indirectly (through the command and handler
334 typedef struct module_struct module;
335 struct module_struct {
336 /** API version, *not* module version; check that module is
337 * compatible with this version of the server.
340 /** API minor version. Provides API feature milestones. Not checked
341 * during module init */
343 /** Index to this modules structures in config vectors. */
346 /** The name of the module's C file */
348 /** The handle for the DSO. Internal use only */
349 void *dynamic_load_handle;
351 /** A pointer to the next module in the list
352 * @defvar module_struct *next */
353 struct module_struct *next;
355 /** Magic Cookie to identify a module structure; It's mainly
356 * important for the DSO facility (see also mod_so). */
359 /** Function to allow MPMs to re-write command line arguments. This
360 * hook is only available to MPMs.
361 * @param The process that the server is running in.
363 void (*rewrite_args) (process_rec *process);
364 /** Function to allow all modules to create per directory configuration
366 * @param p The pool to use for all allocations.
367 * @param dir The directory currently being processed.
368 * @return The per-directory structure created
370 void *(*create_dir_config) (apr_pool_t *p, char *dir);
371 /** Function to allow all modules to merge the per directory configuration
372 * structures for two directories.
373 * @param p The pool to use for all allocations.
374 * @param base_conf The directory structure created for the parent directory.
375 * @param new_conf The directory structure currently being processed.
376 * @return The new per-directory structure created
378 void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf);
379 /** Function to allow all modules to create per server configuration
381 * @param p The pool to use for all allocations.
382 * @param s The server currently being processed.
383 * @return The per-server structure created
385 void *(*create_server_config) (apr_pool_t *p, server_rec *s);
386 /** Function to allow all modules to merge the per server configuration
387 * structures for two servers.
388 * @param p The pool to use for all allocations.
389 * @param base_conf The directory structure created for the parent directory.
390 * @param new_conf The directory structure currently being processed.
391 * @return The new per-directory structure created
393 void *(*merge_server_config) (apr_pool_t *p, void *base_conf, void *new_conf);
395 /** A command_rec table that describes all of the directives this module
397 const command_rec *cmds;
399 /** A hook to allow modules to hook other points in the request processing.
400 * In this function, modules should call the ap_hook_*() functions to
401 * register an interest in a specific step in processing the current
403 * @param p the pool to use for all allocations
405 void (*register_hooks) (apr_pool_t *p);
409 * @defgroup ModuleInit Module structure initializers
411 * Initializer for the first few module slots, which are only
412 * really set up once we start running. Note that the first two slots
413 * provide a version check; this should allow us to deal with changes to
414 * the API. The major number should reflect changes to the API handler table
415 * itself or removal of functionality. The minor number should reflect
416 * additions of functionality to the existing API. (the server can detect
417 * an old-format module, and either handle it back-compatibly, or at least
418 * signal an error). See src/include/ap_mmn.h for MMN version history.
422 /** The one used in Apache 1.3, which will deliberately cause an error */
423 #define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0
425 /** Use this in all standard modules */
426 #define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
427 MODULE_MAGIC_NUMBER_MINOR, \
432 MODULE_MAGIC_COOKIE, \
433 NULL /* rewrite args spot */
435 /** Use this only in MPMs */
436 #define MPM20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
437 MODULE_MAGIC_NUMBER_MINOR, \
446 /* CONFIGURATION VECTOR FUNCTIONS */
448 /** configuration vector structure */
449 typedef struct ap_conf_vector_t ap_conf_vector_t;
451 #if defined(AP_DEBUG) || defined(DOXYGEN)
453 * Generic accessors for other modules to get at their own module-specific
455 * @param conf_vector The vector in which the modules configuration is stored.
456 * usually r->per_dir_config or s->module_config
457 * @param m The module to get the data for.
458 * @return The module-specific data
460 AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
464 * Generic accessors for other modules to set at their own module-specific
466 * @param conf_vector The vector in which the modules configuration is stored.
467 * usually r->per_dir_config or s->module_config
468 * @param m The module to set the data for.
469 * @param val The module-specific data to set
471 AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
476 #define ap_get_module_config(v,m) \
477 (((void **)(v))[(m)->module_index])
478 #define ap_set_module_config(v,m,val) \
479 ((((void **)(v))[(m)->module_index]) = (val))
481 #endif /* AP_DEBUG */
485 * Generic command handling function for strings
486 * @param cmd The command parameters for this directive
487 * @param struct_ptr pointer into a given type
488 * @param arg The argument to the directive
489 * @return An error string or NULL on success
491 AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd, void *struct_ptr,
495 * Generic command handling function for integers
496 * @param cmd The command parameters for this directive
497 * @param struct_ptr pointer into a given type
498 * @param arg The argument to the directive
499 * @return An error string or NULL on success
501 AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd,
506 * Return true if the specified method is limited by being listed in
507 * a <Limit> container, or by *not* being listed in a <LimiteExcept>
510 * @param method Pointer to a string specifying the method to check.
511 * @param cmd Pointer to the cmd_parms structure passed to the
513 * @return 0 if the method is not limited in the current scope
515 AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method);
518 * Generic command handling function for strings, always sets the value
519 * to a lowercase string
520 * @param cmd The command parameters for this directive
521 * @param struct_ptr pointer into a given type
522 * @param arg The argument to the directive
523 * @return An error string or NULL on success
525 AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
526 void *struct_ptr, const char *arg);
528 * Generic command handling function for flags
529 * @param cmd The command parameters for this directive
530 * @param struct_ptr pointer into a given type
531 * @param arg The argument to the directive (either 1 or 0)
532 * @return An error string or NULL on success
534 AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd, void *struct_ptr, int arg);
536 * Generic command handling function for files
537 * @param cmd The command parameters for this directive
538 * @param struct_ptr pointer into a given type
539 * @param arg The argument to the directive
540 * @return An error string or NULL on success
542 AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, void *struct_ptr, const char *arg);
544 * Generic command handling function to respond with cmd->help as an error
545 * @param cmd The command parameters for this directive
546 * @param struct_ptr pointer into a given type
547 * @param arg The argument to the directive
548 * @return The cmd->help value as the error string
549 * @tip This allows simple declarations such as;
551 * AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL,
552 * "The Foo directive is no longer supported, use Bar"),
555 AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd, void *struct_ptr, const char *arg);
557 * For modules which need to read config files, open logs, etc. this returns
558 * the canonical form of fname made absolute to ap_server_root.
559 * @param p pool to allocate data from
560 * @param fname The file name
562 AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
564 /* Finally, the hook for dynamically loading modules in... */
567 * Add a module to the server
568 * @param m The module structure of the module to add
569 * @param p The pool of the same lifetime as the module
571 AP_DECLARE(void) ap_add_module(module *m, apr_pool_t *p);
574 * Remove a module from the server. There are some caveats:
575 * when the module is removed, its slot is lost so all the current
576 * per-dir and per-server configurations are invalid. So we should
577 * only ever call this function when you are invalidating almost
578 * all our current data. I.e. when doing a restart.
579 * @param m the module structure of the module to remove
581 AP_DECLARE(void) ap_remove_module(module *m);
583 * Add a module to the chained modules list and the list of loaded modules
584 * @param m The module structure of the module to add
585 * @param p The pool with the same lifetime as the module
587 AP_DECLARE(void) ap_add_loaded_module(module *mod, apr_pool_t *p);
589 * Remove a module fromthe chained modules list and the list of loaded modules
590 * @param m the module structure of the module to remove
592 AP_DECLARE(void) ap_remove_loaded_module(module *mod);
594 * Add a module to the list of loaded module based on the name of the
596 * @param name The name of the module
597 * @param p The pool valid for the lifetime of the module
598 * @return 1 on success, 0 on failure
600 AP_DECLARE(int) ap_add_named_module(const char *name, apr_pool_t *p);
602 * Find the name of the specified module
603 * @param m The module to get the name for
604 * @return the name of the module
606 AP_DECLARE(const char *) ap_find_module_name(module *m);
608 * Find a module based on the name of the module
609 * @param name the name of the module
610 * @return the module structure if found, NULL otherwise
612 AP_DECLARE(module *) ap_find_linked_module(const char *name);
615 * Open a ap_configfile_t as apr_file_t
616 * @param ret_cfg open ap_configfile_t struct pointer
617 * @param p The pool to allocate the structure from
618 * @param name the name of the file to open
620 AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg, apr_pool_t *p, const char *name);
623 * Allocate a ap_configfile_t handle with user defined functions and params
624 * @param p The pool to allocate from
625 * @param descr The name of the file
626 * @param param The argument passed to getch/getstr/close
627 * @param getc_func The getch function
628 * @param gets_func The getstr function
629 * @param close_func The close function
631 AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p, const char *descr,
633 int(*getc_func)(void*),
634 void *(*gets_func) (void *buf, size_t bufsiz, void *param),
635 int(*close_func)(void *param));
638 * Read one line from open ap_configfile_t, strip LF, increase line number
639 * @param buf place to store the line read
640 * @param bufsize size of the buffer
641 * @param cfp File to read from
642 * @return 1 on success, 0 on failure
644 AP_DECLARE(int) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp);
647 * Read one char from open configfile_t, increase line number upon LF
648 * @param cfp The file to read from
649 * @return the character read
651 AP_DECLARE(int) ap_cfg_getc(ap_configfile_t *cfp);
654 * Detach from open ap_configfile_t, calling the close handler
655 * @param cfp The file to close
656 * @return 1 on sucess, 0 on failure
658 AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp);
661 * Read all data between the current <foo> and the matching </foo>. All
662 * of this data is forgotten immediately.
663 * @param cmd The cmd_parms to pass to the directives inside the container
664 * @param directive The directive name to read until
665 * @return Error string on failure, NULL on success
667 AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive);
670 * Read all data between the current <foo> and the matching </foo> and build
671 * a config tree from it
672 * @param p pool to allocate from
673 * @param temp_pool Temporary pool to allocate from
674 * @param parms The cmd_parms to pass to all directives read
675 * @param current The current node in the tree
676 * @param curr_parent The current parent node
677 * @param orig_directive The directive to read until hit.
678 * @return Error string on failure, NULL on success
680 AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p,
681 apr_pool_t *temp_pool,
683 ap_directive_t **current,
684 ap_directive_t **curr_parent,
685 char *orig_directive);
688 * Build a config tree from a config file
689 * @param parms The cmd_parms to pass to all of the directives in the file
690 * @param conf_pool The pconf pool
691 * @param temp_pool The temporary pool
692 * @param conftree Place to store the root node of the config tree
693 * @return Error string on erro, NULL otherwise
695 AP_DECLARE(const char *) ap_build_config(cmd_parms *parms,
696 apr_pool_t *conf_pool,
697 apr_pool_t *temp_pool,
698 ap_directive_t **conftree);
701 * Walk a config tree and setup the server's internal structures
702 * @param conftree The config tree to walk
703 * @param parms The cmd_parms to pass to all functions
704 * @param section_vector The per-section config vector.
705 * @return Error string on error, NULL otherwise
707 AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree,
709 ap_conf_vector_t *section_vector);
712 * @defgroup ap_check_cmd_context ap_check_cmd_context
716 * Check the context a command is used in.
717 * @param cmd The command to check
718 * @param forbidden Where the command is forbidden.
719 * @return Error string on error, NULL on success
721 AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden);
723 #define NOT_IN_VIRTUALHOST 0x01 /**< Forbidden in <Virtualhost> */
724 #define NOT_IN_LIMIT 0x02 /**< Forbidden in <Limit> */
725 #define NOT_IN_DIRECTORY 0x04 /**< Forbidden in <Directory> */
726 #define NOT_IN_LOCATION 0x08 /**< Forbidden in <Location> */
727 #define NOT_IN_FILES 0x10 /**< Forbidden in <Files> */
728 /** Forbidden in <Directory>/<Location>/<Files>*/
729 #define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES)
730 /** Forbidden in <VirtualHost>/<Limit>/Directory>/<Location>/<Files> */
731 #define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
738 * The topmost module in the list
739 * @defvar module *ap_top_module
741 AP_DECLARE_DATA extern module *ap_top_module;
744 * Array of all statically linked modules
745 * @defvar module *ap_prelinked_modules[]
747 AP_DECLARE_DATA extern module *ap_prelinked_modules[];
749 * Array of all preloaded modules
750 * @defvar module *ap_preloaded_modules[]
752 AP_DECLARE_DATA extern module *ap_preloaded_modules[];
754 * Array of all loaded modules
755 * @defvar module **ap_loaded_modules
757 AP_DECLARE_DATA extern module **ap_loaded_modules;
759 /* For mod_so.c... */
760 /** Run a single module's two create_config hooks
761 * @param p the pool to allocate from
762 * @param s The server to configure for.
763 * @param m The module to configure
765 AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s,
768 /* For http_main.c... */
770 * Add all of the prelinked modules into the loaded module list
771 * @param process The process that is currently running the server
773 AP_DECLARE(void) ap_setup_prelinked_modules(process_rec *process);
776 * Show the preloaded configuration directives, the help string explaining
777 * the directive arguments, in what module they are handled, and in
778 * what parts of the configuration they are allowed. Used for httpd -h.
780 AP_DECLARE(void) ap_show_directives(void);
783 * Show the preloaded module names. Used for httpd -l.
785 AP_DECLARE(void) ap_show_modules(void);
788 * Show the MPM name. Used in reporting modules such as mod_info to
789 * provide extra information to the user
791 AP_DECLARE(const char *) ap_show_mpm(void);
794 * Read all config files and setup the server
795 * @param process The process running the server
796 * @param temp_pool A pool to allocate temporary data from.
797 * @param config_name The name of the config file
798 * @param conftree Place to store the root of the config tree
799 * @return The setup server_rec list.
801 AP_DECLARE(server_rec *) ap_read_config(process_rec *process, apr_pool_t *temp_pool, const char *config_name, ap_directive_t **conftree);
804 * Run all rewrite args hooks for loaded modules
805 * @param process The process currently running the server
807 AP_DECLARE(void) ap_run_rewrite_args(process_rec *process);
810 * Run the register hooks function for a specified module
811 * @param m The module to run the register hooks function fo
812 * @param p The pool valid for the lifetime of the module
814 AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p);
817 * Setup all virtual hosts
818 * @param p The pool to allocate from
819 * @param main_server The head of the server_rec list
821 AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server);
823 /* For http_request.c... */
826 * Setup the config vector for a request_rec
827 * @param p The pool to allocate the config vector from
828 * @return The config vector
830 AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p);
833 * Setup the config vector for per dir module configs
834 * @param p The pool to allocate the config vector from
835 * @return The config vector
837 AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p);
840 * Run all of the modules merge per dir config functions
841 * @param p The pool to pass to the merge functions
842 * @param base The base directory config structure
843 * @param new_conf The new directory config structure
845 AP_CORE_DECLARE(ap_conf_vector_t*) ap_merge_per_dir_configs(apr_pool_t *p,
846 ap_conf_vector_t *base,
847 ap_conf_vector_t *new_conf);
849 /* For http_connection.c... */
851 * Setup the config vector for a connection_rec
852 * @param p The pool to allocate the config vector from
853 * @return The config vector
855 AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_conn_config(apr_pool_t *p);
857 /* For http_core.c... (<Directory> command and virtual hosts) */
860 * parse an htaccess file
861 * @param resulting htaccess_result
862 * @param r The request currently being served
863 * @param override Which overrides are active
864 * @param path The path to the htaccess file
865 * @param access_name The list of possible names for .htaccess files
866 * int The status of the current request
868 AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result,
869 request_rec *r, int override,
870 const char *path, const char *access_name);
873 * Setup a virtual host
874 * @param p The pool to allocate all memory from
875 * @param hostname The hostname of the virtual hsot
876 * @param main_server The main server for this Apache configuration
877 * @param ps Place to store the new server_rec
878 * return Error string on error, NULL on success
880 AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p, const char *hostname,
881 server_rec *main_server, server_rec **);
884 * Process the config file for Apache
885 * @param s The server rec to use for the command parms
886 * @param fname The name of the config file
887 * @param conftree The root node of the created config tree
888 * @param p Pool for general allocation
889 * @param ptem Pool for temporary allocation
891 AP_DECLARE(void) ap_process_resource_config(server_rec *s, const char *fname,
892 ap_directive_t **conftree, apr_pool_t *p, apr_pool_t *ptemp);
895 * Process all directives in the config tree
896 * @param s The server rec to use in the command parms
897 * @param conftree The config tree to process
898 * @param p The pool for general allocation
899 * @param ptemp The pool for temporary allocations
901 AP_DECLARE(void) ap_process_config_tree(server_rec *s, ap_directive_t *conftree,
902 apr_pool_t *p, apr_pool_t *ptemp);
904 /* Module-method dispatchers, also for http_request.c */
906 * Run the handler phase of each module until a module accepts the
907 * responsibility of serving the request
908 * @param r The current request
909 * @return The status of the current request
911 AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r);
916 * Find a given directive in a command_rec table
917 * @param name The directive to search for
918 * @param cmds The table to search
919 * @return The directive definition of the specified directive
921 AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name, const command_rec *cmds);
924 * Find a given directive in a list module
925 * @param cmd_name The directive to search for
926 * @param mod The module list to search
927 * @return The directive definition of the specified directive
929 AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod);
932 * Ask a module to create per-server and per-section (dir/loc/file) configs
933 * (if it hasn't happened already). The results are stored in the server's
934 * config, and the specified per-section config vector.
935 * @param server The server to operate upon.
936 * @param section_vector The per-section config vector.
937 * @param section Which section to create a config for.
938 * @param mod The module which is defining the config data.
939 * @param pconf A pool for all configuration allocations.
940 * @return The (new) per-section config data.
942 AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server,
943 ap_conf_vector_t *section_vector,
945 module *mod, apr_pool_t *pconf);
952 * Run the header parser functions for each module
953 * @param r The current request
954 * @return OK or DECLINED
956 AP_DECLARE_HOOK(int,header_parser,(request_rec *r))
959 * Run the pre_config function for each module
960 * @param pconf The config pool
961 * @param plog The logging streams pool
962 * @param ptemp The temporary pool
964 AP_DECLARE_HOOK(void,pre_config,(apr_pool_t *pconf,apr_pool_t *plog,apr_pool_t *ptemp))
967 * Run the post_config function for each module
968 * @param pconf The config pool
969 * @param plog The logging streams pool
970 * @param ptemp The temporary pool
971 * @param s The list of server_recs
973 AP_DECLARE_HOOK(void,post_config,(apr_pool_t *pconf,apr_pool_t *plog,apr_pool_t *ptemp,server_rec *s))
976 * Run the open_logs functions for each module
977 * @param pconf The config pool
978 * @param plog The logging streams pool
979 * @param ptemp The temporary pool
980 * @param s The list of server_recs
982 AP_DECLARE_HOOK(void,open_logs,(apr_pool_t *pconf,apr_pool_t *plog,apr_pool_t *ptemp,server_rec *s))
985 * Run the child_init functions for each module
986 * @param pchild The child pool
987 * @param s The list of server_recs in this server
989 AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s))
992 * Run the handler functions for each module
993 * @param r The request_rec
994 * @remark non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST
996 AP_DECLARE_HOOK(int,handler,(request_rec *r))
999 * Run the quick handler functions for each module. The quick_handler
1000 * is run before any other requests hooks are called (location_walk,
1001 * directory_walk, access checking, et. al.). This hook was added
1002 * to provide a quick way to serve content from a URI keyed cache.
1003 * @param r The request_rec
1005 AP_DECLARE_HOOK(int,quick_handler,(request_rec *r))
1008 * Retrieve the optional functions for each module.
1009 * This is run immediately before the server starts. Optional functions should
1010 * be registered during the hook registration phase.
1012 AP_DECLARE_HOOK(void,optional_fn_retrieve,(void))
1018 #endif /* !APACHE_HTTP_CONFIG_H */