1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * @brief Apache Configuration
21 * @defgroup APACHE_CORE_CONFIG Configuration
22 * @ingroup APACHE_CORE
26 #ifndef APACHE_HTTP_CONFIG_H
27 #define APACHE_HTTP_CONFIG_H
29 #include "util_cfgtree.h"
30 #include "ap_config.h"
37 * The central data structures around here...
40 /* Command dispatch structures... */
43 * How the directives arguments should be parsed.
44 * @remark Note that for all of these except RAW_ARGS, the config routine is
45 * passed a freshly allocated string which can be modified or stored
49 RAW_ARGS, /**< cmd_func parses command line itself */
50 TAKE1, /**< one argument only */
51 TAKE2, /**< two arguments only */
52 ITERATE, /**< one argument, occuring multiple times
55 ITERATE2, /**< two arguments, 2nd occurs multiple times
58 FLAG, /**< One of 'On' or 'Off' */
59 NO_ARGS, /**< No args at all, e.g. </Directory> */
60 TAKE12, /**< one or two arguments */
61 TAKE3, /**< three arguments only */
62 TAKE23, /**< two or three arguments */
63 TAKE123, /**< one, two or three arguments */
64 TAKE13, /**< one or three arguments */
65 TAKE_ARGV /**< an argc and argv are passed */
69 * This structure is passed to a command which is being invoked,
70 * to carry a large variety of miscellaneous data which is all of
71 * use to *somebody*...
73 typedef struct cmd_parms_struct cmd_parms;
75 #if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN)
78 * All the types of functions that can be used in directives
82 /** function to call for a no-args */
83 const char *(*no_args) (cmd_parms *parms, void *mconfig);
84 /** function to call for a raw-args */
85 const char *(*raw_args) (cmd_parms *parms, void *mconfig,
87 /** function to call for a argv/argc */
88 const char *(*take_argv) (cmd_parms *parms, void *mconfig,
89 int argc, char *const argv[]);
90 /** function to call for a take1 */
91 const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w);
92 /** function to call for a take2 */
93 const char *(*take2) (cmd_parms *parms, void *mconfig, const char *w,
95 /** function to call for a take3 */
96 const char *(*take3) (cmd_parms *parms, void *mconfig, const char *w,
97 const char *w2, const char *w3);
98 /** function to call for a flag */
99 const char *(*flag) (cmd_parms *parms, void *mconfig, int on);
102 /** This configuration directive does not take any arguments */
103 # define AP_NO_ARGS func.no_args
104 /** This configuration directive will handle its own parsing of arguments*/
105 # define AP_RAW_ARGS func.raw_args
106 /** This configuration directive will handle its own parsing of arguments*/
107 # define AP_TAKE_ARGV func.take_argv
108 /** This configuration directive takes 1 argument*/
109 # define AP_TAKE1 func.take1
110 /** This configuration directive takes 2 arguments */
111 # define AP_TAKE2 func.take2
112 /** This configuration directive takes 3 arguments */
113 # define AP_TAKE3 func.take3
114 /** This configuration directive takes a flag (on/off) as a argument*/
115 # define AP_FLAG func.flag
117 /** mechanism for declaring a directive with no arguments */
118 # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
119 { directive, { .no_args=func }, mconfig, where, RAW_ARGS, help }
120 /** mechanism for declaring a directive with raw argument parsing */
121 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
122 { directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help }
123 /** mechanism for declaring a directive with raw argument parsing */
124 # define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
125 { directive, { .take_argv=func }, mconfig, where, TAKE_ARGV, help }
126 /** mechanism for declaring a directive which takes 1 argument */
127 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
128 { directive, { .take1=func }, mconfig, where, TAKE1, help }
129 /** mechanism for declaring a directive which takes multiple arguments */
130 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
131 { directive, { .take1=func }, mconfig, where, ITERATE, help }
132 /** mechanism for declaring a directive which takes 2 arguments */
133 # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
134 { directive, { .take2=func }, mconfig, where, TAKE2, help }
135 /** mechanism for declaring a directive which takes 1 or 2 arguments */
136 # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
137 { directive, { .take2=func }, mconfig, where, TAKE12, help }
138 /** mechanism for declaring a directive which takes multiple 2 arguments */
139 # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
140 { directive, { .take2=func }, mconfig, where, ITERATE2, help }
141 /** mechanism for declaring a directive which takes 1 or 3 arguments */
142 # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
143 { directive, { .take3=func }, mconfig, where, TAKE13, help }
144 /** mechanism for declaring a directive which takes 2 or 3 arguments */
145 # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
146 { directive, { .take3=func }, mconfig, where, TAKE23, help }
147 /** mechanism for declaring a directive which takes 1 to 3 arguments */
148 # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
149 { directive, { .take3=func }, mconfig, where, TAKE123, help }
150 /** mechanism for declaring a directive which takes 3 arguments */
151 # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
152 { directive, { .take3=func }, mconfig, where, TAKE3, help }
153 /** mechanism for declaring a directive which takes a flag (on/off) argument */
154 # define AP_INIT_FLAG(directive, func, mconfig, where, help) \
155 { directive, { .flag=func }, mconfig, where, FLAG, help }
157 #else /* AP_HAVE_DESIGNATED_INITIALIZER */
159 typedef const char *(*cmd_func) ();
161 # define AP_NO_ARGS func
162 # define AP_RAW_ARGS func
163 # define AP_TAKE_ARGV func
164 # define AP_TAKE1 func
165 # define AP_TAKE2 func
166 # define AP_TAKE3 func
167 # define AP_FLAG func
169 # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
170 { directive, func, mconfig, where, RAW_ARGS, help }
171 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
172 { directive, func, mconfig, where, RAW_ARGS, help }
173 # define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
174 { directive, func, mconfig, where, TAKE_ARGV, help }
175 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
176 { directive, func, mconfig, where, TAKE1, help }
177 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
178 { directive, func, mconfig, where, ITERATE, help }
179 # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
180 { directive, func, mconfig, where, TAKE2, help }
181 # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
182 { directive, func, mconfig, where, TAKE12, help }
183 # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
184 { directive, func, mconfig, where, ITERATE2, help }
185 # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
186 { directive, func, mconfig, where, TAKE13, help }
187 # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
188 { directive, func, mconfig, where, TAKE23, help }
189 # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
190 { directive, func, mconfig, where, TAKE123, help }
191 # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
192 { directive, func, mconfig, where, TAKE3, help }
193 # define AP_INIT_FLAG(directive, func, mconfig, where, help) \
194 { directive, func, mconfig, where, FLAG, help }
196 #endif /* AP_HAVE_DESIGNATED_INITIALIZER */
199 * The command record structure. Each modules can define a table of these
200 * to define the directives it will implement.
202 typedef struct command_struct command_rec;
203 struct command_struct {
204 /** Name of this command */
206 /** The function to be called when this directive is parsed */
208 /** Extra data, for functions which implement multiple commands... */
210 /** What overrides need to be allowed to enable this command. */
212 /** What the command expects as arguments */
213 enum cmd_how args_how;
215 /** 'usage' message, in case of syntax errors */
220 * @defgroup ConfigDirectives Allowed locations for configuration directives.
222 * The allowed locations for a configuration directive are the union of
223 * those indicated by each set bit in the req_override mask.
227 #define OR_NONE 0 /**< *.conf is not available anywhere in this override */
228 #define OR_LIMIT 1 /**< *.conf inside <Directory> or <Location>
229 and .htaccess when AllowOverride Limit */
230 #define OR_OPTIONS 2 /**< *.conf anywhere
231 and .htaccess when AllowOverride Options */
232 #define OR_FILEINFO 4 /**< *.conf anywhere
233 and .htaccess when AllowOverride FileInfo */
234 #define OR_AUTHCFG 8 /**< *.conf inside <Directory> or <Location>
235 and .htaccess when AllowOverride AuthConfig */
236 #define OR_INDEXES 16 /**< *.conf anywhere
237 and .htaccess when AllowOverride Indexes */
238 #define OR_UNSET 32 /**< bit to indicate that AllowOverride has not been set */
239 #define ACCESS_CONF 64 /**< *.conf inside <Directory> or <Location> */
240 #define RSRC_CONF 128 /**< *.conf outside <Directory> or <Location> */
241 #define EXEC_ON_READ 256 /**< force directive to execute a command
242 which would modify the configuration (like including another
244 /** this directive can be placed anywhere */
245 #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
250 * This can be returned by a function if they don't wish to handle
251 * a command. Make it something not likely someone will actually use
254 #define DECLINE_CMD "\a\b"
256 /** Common structure for reading of config files / passwd files etc. */
257 typedef struct ap_configfile_t ap_configfile_t;
258 struct ap_configfile_t {
259 /**< an apr_file_getc()-like function */
260 apr_status_t (*getch) (char *ch, void *param);
261 /**< an apr_file_gets()-like function */
262 apr_status_t (*getstr) (void *buf, size_t bufsiz, void *param);
263 /**< a close handler function */
264 apr_status_t (*close) (void *param);
265 /**< the argument passed to getch/getstr/close */
267 /**< the filename / description */
269 /**< current line number, starting at 1 */
270 unsigned line_number;
274 * This structure is passed to a command which is being invoked,
275 * to carry a large variety of miscellaneous data which is all of
276 * use to *somebody*...
278 struct cmd_parms_struct {
279 /** Argument to command from cmd_table */
281 /** Which allow-override bits are set */
283 /** Which allow-override-opts bits are set */
285 /** Which methods are <Limit>ed */
287 /** methods which are limited */
288 apr_array_header_t *limited_xmethods;
289 /** methods which are xlimited */
290 ap_method_list_t *xlimited;
292 /** Config file structure. */
293 ap_configfile_t *config_file;
294 /** the directive specifying this command */
295 ap_directive_t *directive;
297 /** Pool to allocate new storage in */
299 /** Pool for scratch memory; persists during configuration, but
300 * wiped before the first request is served... */
301 apr_pool_t *temp_pool;
302 /** Server_rec being configured for */
304 /** If configuring for a directory, pathname of that directory.
305 * NOPE! That's what it meant previous to the existence of <Files>,
306 * <Location> and regex matching. Now the only usefulness that can be
307 * derived from this field is whether a command is being called in a
308 * server context (path == NULL) or being called in a dir context
311 /** configuration command */
312 const command_rec *cmd;
314 /** per_dir_config vector passed to handle_command */
315 struct ap_conf_vector_t *context;
316 /** directive with syntax error */
317 const ap_directive_t *err_directive;
322 * Module structures. Just about everything is dispatched through
323 * these, directly or indirectly (through the command and handler
326 typedef struct module_struct module;
327 struct module_struct {
328 /** API version, *not* module version; check that module is
329 * compatible with this version of the server.
332 /** API minor version. Provides API feature milestones. Not checked
333 * during module init */
335 /** Index to this modules structures in config vectors. */
338 /** The name of the module's C file */
340 /** The handle for the DSO. Internal use only */
341 void *dynamic_load_handle;
343 /** A pointer to the next module in the list
344 * @var module_struct *next
346 struct module_struct *next;
348 /** Magic Cookie to identify a module structure; It's mainly
349 * important for the DSO facility (see also mod_so). */
352 /** Function to allow MPMs to re-write command line arguments. This
353 * hook is only available to MPMs.
354 * @param The process that the server is running in.
356 void (*rewrite_args) (process_rec *process);
357 /** Function to allow all modules to create per directory configuration
359 * @param p The pool to use for all allocations.
360 * @param dir The directory currently being processed.
361 * @return The per-directory structure created
363 void *(*create_dir_config) (apr_pool_t *p, char *dir);
364 /** Function to allow all modules to merge the per directory configuration
365 * structures for two directories.
366 * @param p The pool to use for all allocations.
367 * @param base_conf The directory structure created for the parent directory.
368 * @param new_conf The directory structure currently being processed.
369 * @return The new per-directory structure created
371 void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf);
372 /** Function to allow all modules to create per server configuration
374 * @param p The pool to use for all allocations.
375 * @param s The server currently being processed.
376 * @return The per-server structure created
378 void *(*create_server_config) (apr_pool_t *p, server_rec *s);
379 /** Function to allow all modules to merge the per server configuration
380 * structures for two servers.
381 * @param p The pool to use for all allocations.
382 * @param base_conf The directory structure created for the parent directory.
383 * @param new_conf The directory structure currently being processed.
384 * @return The new per-directory structure created
386 void *(*merge_server_config) (apr_pool_t *p, void *base_conf,
389 /** A command_rec table that describes all of the directives this module
391 const command_rec *cmds;
393 /** A hook to allow modules to hook other points in the request processing.
394 * In this function, modules should call the ap_hook_*() functions to
395 * register an interest in a specific step in processing the current
397 * @param p the pool to use for all allocations
399 void (*register_hooks) (apr_pool_t *p);
403 * The APLOG_USE_MODULE macro is used choose which module a file belongs to.
404 * This is necessary to allow per-module loglevel configuration.
406 * APLOG_USE_MODULE indirectly sets APLOG_MODULE_INDEX and APLOG_MARK.
408 * If a module should be backward compatible with versions before 2.3.6,
409 * APLOG_USE_MODULE needs to be enclosed in a ifdef APLOG_USE_MODULE block.
411 * @param foo name of the module symbol of the current module, without the
412 * trailing "_module" part
415 #define APLOG_USE_MODULE(foo) \
416 extern module AP_MODULE_DECLARE_DATA foo##_module; \
417 static int * const aplog_module_index = &(foo##_module.module_index)
420 * AP_DECLARE_MODULE is a convenience macro that combines a call of
421 * APLOG_USE_MODULE with the definition of the module symbol.
423 * If a module should be backward compatible with versions before 2.3.6,
424 * APLOG_USE_MODULE should be used explicitly instead of AP_DECLARE_MODULE.
426 #define AP_DECLARE_MODULE(foo) \
427 APLOG_USE_MODULE(foo); \
428 module AP_MODULE_DECLARE_DATA foo##_module
431 * @defgroup ModuleInit Module structure initializers
433 * Initializer for the first few module slots, which are only
434 * really set up once we start running. Note that the first two slots
435 * provide a version check; this should allow us to deal with changes to
436 * the API. The major number should reflect changes to the API handler table
437 * itself or removal of functionality. The minor number should reflect
438 * additions of functionality to the existing API. (the server can detect
439 * an old-format module, and either handle it back-compatibly, or at least
440 * signal an error). See src/include/ap_mmn.h for MMN version history.
444 /** The one used in Apache 1.3, which will deliberately cause an error */
445 #define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0
447 /** Use this in all standard modules */
448 #define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
449 MODULE_MAGIC_NUMBER_MINOR, \
454 MODULE_MAGIC_COOKIE, \
455 NULL /* rewrite args spot */
457 /** Use this only in MPMs */
458 #define MPM20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
459 MODULE_MAGIC_NUMBER_MINOR, \
468 /* CONFIGURATION VECTOR FUNCTIONS */
470 /** configuration vector structure */
471 typedef struct ap_conf_vector_t ap_conf_vector_t;
474 * Generic accessors for other modules to get at their own module-specific
476 * @param cv The vector in which the modules configuration is stored.
477 * usually r->per_dir_config or s->module_config
478 * @param m The module to get the data for.
479 * @return The module-specific data
481 AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
485 * Generic accessors for other modules to set at their own module-specific
487 * @param cv The vector in which the modules configuration is stored.
488 * usually r->per_dir_config or s->module_config
489 * @param m The module to set the data for.
490 * @param val The module-specific data to set
492 AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
495 #if !defined(AP_DEBUG)
497 #define ap_get_module_config(v,m) \
498 (((void **)(v))[(m)->module_index])
499 #define ap_set_module_config(v,m,val) \
500 ((((void **)(v))[(m)->module_index]) = (val))
502 #endif /* AP_DEBUG */
506 * Generic accessor for modules to get the module-specific loglevel
507 * @param s The server from which to get the loglevel.
508 * @param index The module_index of the module to get the loglevel for.
509 * @return The module-specific loglevel
511 AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int index);
514 * Generic accessor for modules the module-specific loglevel
515 * @param c The connection from which to get the loglevel.
516 * @param index The module_index of the module to get the loglevel for.
517 * @return The module-specific loglevel
519 AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int index);
522 * Generic accessor for modules the module-specific loglevel
523 * @param c The connection from which to get the loglevel.
524 * @param s The server from which to get the loglevel if c does not have a
525 * specific loglevel configuration.
526 * @param index The module_index of the module to get the loglevel for.
527 * @return The module-specific loglevel
529 AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c,
534 * Generic accessor for modules to get the module-specific loglevel
535 * @param r The request from which to get the loglevel.
536 * @param index The module_index of the module to get the loglevel for.
537 * @return The module-specific loglevel
539 AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int index);
542 * Accessor to set module-specific loglevel
544 * @param l The ap_logconf struct to modify.
545 * @param index The module_index of the module to set the loglevel for.
546 * @param level The new log level
548 AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, struct ap_logconf *l,
549 int index, int level);
551 #if !defined(AP_DEBUG)
553 #define ap_get_conn_logconf(c) \
554 ((c)->log ? (c)->log : \
555 &(c)->base_server->log)
557 #define ap_get_conn_server_logconf(c,s) \
558 ( ( (c)->log != &(c)->base_server->log && (c)->log != NULL ) ? \
562 #define ap_get_request_logconf(r) \
563 ((r)->log ? (r)->log : \
564 (r)->connection->log ? (r)->connection->log : \
567 #define ap_get_module_loglevel(l,i) \
568 (((i) < 0 || (l)->module_levels == NULL || (l)->module_levels[i] < 0) ? \
570 (l)->module_levels[i])
572 #define ap_get_server_module_loglevel(s,i) \
573 (ap_get_module_loglevel(&(s)->log,i))
575 #define ap_get_conn_module_loglevel(c,i) \
576 (ap_get_module_loglevel(ap_get_conn_logconf(c),i))
578 #define ap_get_conn_server_module_loglevel(c,s,i) \
579 (ap_get_module_loglevel(ap_get_conn_server_logconf(c,s),i))
581 #define ap_get_request_module_loglevel(r,i) \
582 (ap_get_module_loglevel(ap_get_request_logconf(r),i))
584 #endif /* AP_DEBUG */
587 * Set all module-specific loglevels to val
588 * @param l The log config for which to set the loglevels.
589 * @param val the value to set all loglevels to
591 AP_DECLARE(void) ap_reset_module_loglevels(struct ap_logconf *l, int val);
594 * Generic command handling function for strings
595 * @param cmd The command parameters for this directive
596 * @param struct_ptr pointer into a given type
597 * @param arg The argument to the directive
598 * @return An error string or NULL on success
600 AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
605 * Generic command handling function for integers
606 * @param cmd The command parameters for this directive
607 * @param struct_ptr pointer into a given type
608 * @param arg The argument to the directive
609 * @return An error string or NULL on success
611 AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd,
616 * Parsing function for log level
617 * @param str The string to parse
618 * @param val The parsed log level
619 * @return An error string or NULL on success
621 AP_DECLARE(const char *) ap_parse_log_level(const char *str, int *val);
624 * Return true if the specified method is limited by being listed in
625 * a <Limit> container, or by *not* being listed in a <LimitExcept>
628 * @param method Pointer to a string specifying the method to check.
629 * @param cmd Pointer to the cmd_parms structure passed to the
631 * @return 0 if the method is not limited in the current scope
633 AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method);
636 * Generic command handling function for strings, always sets the value
637 * to a lowercase string
638 * @param cmd The command parameters for this directive
639 * @param struct_ptr pointer into a given type
640 * @param arg The argument to the directive
641 * @return An error string or NULL on success
643 AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
647 * Generic command handling function for flags stored in an int
648 * @param cmd The command parameters for this directive
649 * @param struct_ptr pointer into a given type
650 * @param arg The argument to the directive (either 1 or 0)
651 * @return An error string or NULL on success
653 AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
657 * Generic command handling function for flags stored in a char
658 * @param cmd The command parameters for this directive
659 * @param struct_ptr pointer into a given type
660 * @param arg The argument to the directive (either 1 or 0)
661 * @return An error string or NULL on success
663 AP_DECLARE_NONSTD(const char *) ap_set_flag_slot_char(cmd_parms *cmd,
667 * Generic command handling function for files
668 * @param cmd The command parameters for this directive
669 * @param struct_ptr pointer into a given type
670 * @param arg The argument to the directive
671 * @return An error string or NULL on success
673 AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd,
677 * Generic command handling function to respond with cmd->help as an error
678 * @param cmd The command parameters for this directive
679 * @param struct_ptr pointer into a given type
680 * @param arg The argument to the directive
681 * @return The cmd->help value as the error string
682 * @note This allows simple declarations such as:
684 * AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL,
685 * "The Foo directive is no longer supported, use Bar"),
688 AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd,
692 * For modules which need to read config files, open logs, etc. this returns
693 * the canonical form of fname made absolute to ap_server_root.
694 * @param p pool to allocate data from
695 * @param fname The file name
697 AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
699 /* Finally, the hook for dynamically loading modules in... */
702 * Add a module to the server
703 * @param m The module structure of the module to add
704 * @param p The pool of the same lifetime as the module
705 * @param s The module's symbol name (used for logging)
707 AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
711 * Remove a module from the server. There are some caveats:
712 * when the module is removed, its slot is lost so all the current
713 * per-dir and per-server configurations are invalid. So we should
714 * only ever call this function when you are invalidating almost
715 * all our current data. I.e. when doing a restart.
716 * @param m the module structure of the module to remove
718 AP_DECLARE(void) ap_remove_module(module *m);
720 * Add a module to the chained modules list and the list of loaded modules
721 * @param mod The module structure of the module to add
722 * @param p The pool with the same lifetime as the module
723 * @param s The module's symbol name (used for logging)
725 AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p,
728 * Remove a module fromthe chained modules list and the list of loaded modules
729 * @param mod the module structure of the module to remove
731 AP_DECLARE(void) ap_remove_loaded_module(module *mod);
733 * Find the name of the specified module
734 * @param m The module to get the name for
735 * @return the name of the module
737 AP_DECLARE(const char *) ap_find_module_name(module *m);
739 * Find the short name of the module identified by the specified module index
740 * @param module_index The module index to get the name for
741 * @return the name of the module, NULL if not found
743 AP_DECLARE(const char *) ap_find_module_short_name(int module_index);
745 * Find a module based on the name of the module
746 * @param name the name of the module
747 * @return the module structure if found, NULL otherwise
749 AP_DECLARE(module *) ap_find_linked_module(const char *name);
752 * Open a ap_configfile_t as apr_file_t
753 * @param ret_cfg open ap_configfile_t struct pointer
754 * @param p The pool to allocate the structure from
755 * @param name the name of the file to open
757 AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg,
758 apr_pool_t *p, const char *name);
761 * Allocate a ap_configfile_t handle with user defined functions and params
762 * @param p The pool to allocate from
763 * @param descr The name of the file
764 * @param param The argument passed to getch/getstr/close
765 * @param getc_func The getch function
766 * @param gets_func The getstr function
767 * @param close_func The close function
769 AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p,
772 apr_status_t (*getc_func) (char *ch, void *param),
773 apr_status_t (*gets_func) (void *buf, size_t bufsiz, void *param),
774 apr_status_t (*close_func) (void *param));
777 * Read one line from open ap_configfile_t, strip leading and trailing
778 * whitespace, increase line number
779 * @param buf place to store the line read
780 * @param bufsize size of the buffer
781 * @param cfp File to read from
782 * @return error status, APR_ENOSPC if bufsize is too small for the line
784 AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp);
787 * Read one char from open configfile_t, increase line number upon LF
788 * @param ch place to store the char read
789 * @param cfp The file to read from
790 * @return error status
792 AP_DECLARE(apr_status_t) ap_cfg_getc(char *ch, ap_configfile_t *cfp);
795 * Detach from open ap_configfile_t, calling the close handler
796 * @param cfp The file to close
797 * @return 1 on sucess, 0 on failure
799 AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp);
802 * Convert a return value from ap_cfg_getline or ap_cfg_getc to a user friendly
804 * @param p The pool to allocate the string from
805 * @param cfp The config file
806 * @return The error string, NULL if rc == APR_SUCCESS
808 AP_DECLARE(const char *) ap_pcfg_strerror(apr_pool_t *p, ap_configfile_t *cfp,
812 * Read all data between the current <foo> and the matching </foo>. All
813 * of this data is forgotten immediately.
814 * @param cmd The cmd_parms to pass to the directives inside the container
815 * @param directive The directive name to read until
816 * @return Error string on failure, NULL on success
818 AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive);
821 * Read all data between the current <foo> and the matching </foo> and build
822 * a config tree from it
823 * @param p pool to allocate from
824 * @param temp_pool Temporary pool to allocate from
825 * @param parms The cmd_parms to pass to all directives read
826 * @param current The current node in the tree
827 * @param curr_parent The current parent node
828 * @param orig_directive The directive to read until hit.
829 * @return Error string on failure, NULL on success
831 AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p,
832 apr_pool_t *temp_pool,
834 ap_directive_t **current,
835 ap_directive_t **curr_parent,
836 char *orig_directive);
839 * Build a config tree from a config file
840 * @param parms The cmd_parms to pass to all of the directives in the file
841 * @param conf_pool The pconf pool
842 * @param temp_pool The temporary pool
843 * @param conftree Place to store the root node of the config tree
844 * @return Error string on erro, NULL otherwise
846 AP_DECLARE(const char *) ap_build_config(cmd_parms *parms,
847 apr_pool_t *conf_pool,
848 apr_pool_t *temp_pool,
849 ap_directive_t **conftree);
852 * Walk a config tree and setup the server's internal structures
853 * @param conftree The config tree to walk
854 * @param parms The cmd_parms to pass to all functions
855 * @param section_vector The per-section config vector.
856 * @return Error string on error, NULL otherwise
858 AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree,
860 ap_conf_vector_t *section_vector);
863 * @defgroup ap_check_cmd_context Check command context
867 * Check the context a command is used in.
868 * @param cmd The command to check
869 * @param forbidden Where the command is forbidden.
870 * @return Error string on error, NULL on success
872 AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
875 #define NOT_IN_VIRTUALHOST 0x01 /**< Forbidden in <VirtualHost> */
876 #define NOT_IN_LIMIT 0x02 /**< Forbidden in <Limit> */
877 #define NOT_IN_DIRECTORY 0x04 /**< Forbidden in <Directory> */
878 #define NOT_IN_LOCATION 0x08 /**< Forbidden in <Location> */
879 #define NOT_IN_FILES 0x10 /**< Forbidden in <Files> */
880 /** Forbidden in <Directory>/<Location>/<Files>*/
881 #define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES)
882 /** Forbidden in <VirtualHost>/<Limit>/<Directory>/<Location>/<Files> */
883 #define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
888 * @brief This structure is used to assign symbol names to module pointers
893 } ap_module_symbol_t;
896 * The topmost module in the list
897 * @var module *ap_top_module
899 AP_DECLARE_DATA extern module *ap_top_module;
902 * Array of all statically linked modules
903 * @var module *ap_prelinked_modules[]
905 AP_DECLARE_DATA extern module *ap_prelinked_modules[];
907 * Array of all statically linked modulenames (symbols)
908 * @var ap_module_symbol_t ap_prelinked_module_symbols[]
910 AP_DECLARE_DATA extern ap_module_symbol_t ap_prelinked_module_symbols[];
912 * Array of all preloaded modules
913 * @var module *ap_preloaded_modules[]
915 AP_DECLARE_DATA extern module *ap_preloaded_modules[];
917 * Array of all loaded modules
918 * @var module **ap_loaded_modules
920 AP_DECLARE_DATA extern module **ap_loaded_modules;
922 /* For mod_so.c... */
923 /** Run a single module's two create_config hooks
924 * @param p the pool to allocate from
925 * @param s The server to configure for.
926 * @param m The module to configure
928 AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s,
931 /* For http_main.c... */
933 * Add all of the prelinked modules into the loaded module list
934 * @param process The process that is currently running the server
936 AP_DECLARE(const char *) ap_setup_prelinked_modules(process_rec *process);
939 * Show the preloaded configuration directives, the help string explaining
940 * the directive arguments, in what module they are handled, and in
941 * what parts of the configuration they are allowed. Used for httpd -h.
943 AP_DECLARE(void) ap_show_directives(void);
946 * Show the preloaded module names. Used for httpd -l.
948 AP_DECLARE(void) ap_show_modules(void);
951 * Show the MPM name. Used in reporting modules such as mod_info to
952 * provide extra information to the user
954 AP_DECLARE(const char *) ap_show_mpm(void);
957 * Read all config files and setup the server
958 * @param process The process running the server
959 * @param temp_pool A pool to allocate temporary data from.
960 * @param config_name The name of the config file
961 * @param conftree Place to store the root of the config tree
962 * @return The setup server_rec list.
964 AP_DECLARE(server_rec *) ap_read_config(process_rec *process,
965 apr_pool_t *temp_pool,
966 const char *config_name,
967 ap_directive_t **conftree);
970 * Run all rewrite args hooks for loaded modules
971 * @param process The process currently running the server
973 AP_DECLARE(void) ap_run_rewrite_args(process_rec *process);
976 * Run the register hooks function for a specified module
977 * @param m The module to run the register hooks function fo
978 * @param p The pool valid for the lifetime of the module
980 AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p);
983 * Setup all virtual hosts
984 * @param p The pool to allocate from
985 * @param main_server The head of the server_rec list
987 AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p,
988 server_rec *main_server);
991 * Reserve some modules slots for modules loaded by other means than
992 * EXEC_ON_READ directives.
993 * Relevant modules should call this in the pre_config stage.
994 * @param count The number of slots to reserve.
996 AP_DECLARE(void) ap_reserve_module_slots(int count);
999 * Reserve some modules slots for modules loaded by a specific
1000 * non-EXEC_ON_READ config directive.
1001 * This counts how often the given directive is used in the config and calls
1002 * ap_reserve_module_slots() accordingly.
1003 * @param directive The name of the directive
1005 AP_DECLARE(void) ap_reserve_module_slots_directive(const char *directive);
1007 /* For http_request.c... */
1010 * Setup the config vector for a request_rec
1011 * @param p The pool to allocate the config vector from
1012 * @return The config vector
1014 AP_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p);
1017 * Setup the config vector for per dir module configs
1018 * @param p The pool to allocate the config vector from
1019 * @return The config vector
1021 AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p);
1024 * Run all of the modules merge per dir config functions
1025 * @param p The pool to pass to the merge functions
1026 * @param base The base directory config structure
1027 * @param new_conf The new directory config structure
1029 AP_CORE_DECLARE(ap_conf_vector_t*) ap_merge_per_dir_configs(apr_pool_t *p,
1030 ap_conf_vector_t *base,
1031 ap_conf_vector_t *new_conf);
1034 * Allocate new ap_logconf and make (deep) copy of old ap_logconf
1035 * @param p The pool to alloc from
1036 * @param old The ap_logconf to copy (may be NULL)
1037 * @return The new ap_logconf struct
1039 AP_DECLARE(struct ap_logconf *) ap_new_log_config(apr_pool_t *p,
1040 const struct ap_logconf *old);
1043 * Merge old ap_logconf into new ap_logconf.
1044 * old and new must have the same life time.
1045 * @param old_conf The ap_logconf to merge from
1046 * @param new_conf The ap_logconf to merge into
1048 AP_DECLARE(void) ap_merge_log_config(const struct ap_logconf *old_conf,
1049 struct ap_logconf *new_conf);
1051 /* For http_connection.c... */
1053 * Setup the config vector for a connection_rec
1054 * @param p The pool to allocate the config vector from
1055 * @return The config vector
1057 AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_conn_config(apr_pool_t *p);
1059 /* For http_core.c... (<Directory> command and virtual hosts) */
1062 * parse an htaccess file
1063 * @param result htaccess_result
1064 * @param r The request currently being served
1065 * @param override Which overrides are active
1066 * @param override_opts Which allow-override-opts bits are set
1067 * @param path The path to the htaccess file
1068 * @param access_name The list of possible names for .htaccess files
1069 * int The status of the current request
1071 AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result,
1076 const char *access_name);
1079 * Setup a virtual host
1080 * @param p The pool to allocate all memory from
1081 * @param hostname The hostname of the virtual hsot
1082 * @param main_server The main server for this Apache configuration
1083 * @param ps Place to store the new server_rec
1084 * return Error string on error, NULL on success
1086 AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p,
1087 const char *hostname,
1088 server_rec *main_server,
1092 * Process a config file for Apache
1093 * @param s The server rec to use for the command parms
1094 * @param fname The name of the config file
1095 * @param conftree The root node of the created config tree
1096 * @param p Pool for general allocation
1097 * @param ptemp Pool for temporary allocation
1099 AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
1101 ap_directive_t **conftree,
1106 * Process all matching files as Apache configs
1107 * @param s The server rec to use for the command parms
1108 * @param fname The filename pattern of the config file
1109 * @param conftree The root node of the created config tree
1110 * @param p Pool for general allocation
1111 * @param ptemp Pool for temporary allocation
1112 * @param optional Whether a no-match wildcard is allowed
1113 * @see apr_fnmatch for pattern handling
1115 AP_DECLARE(const char *) ap_process_fnmatch_configs(server_rec *s,
1117 ap_directive_t **conftree,
1123 * Process all directives in the config tree
1124 * @param s The server rec to use in the command parms
1125 * @param conftree The config tree to process
1126 * @param p The pool for general allocation
1127 * @param ptemp The pool for temporary allocations
1128 * @return OK if no problems
1130 AP_DECLARE(int) ap_process_config_tree(server_rec *s,
1131 ap_directive_t *conftree,
1136 * Store data which will be retained across unload/load of modules
1137 * @param key The unique key associated with this module's retained data
1138 * @param size in bytes of the retained data (to be allocated)
1139 * @return Address of new retained data structure, initially cleared
1141 AP_DECLARE(void *) ap_retained_data_create(const char *key, apr_size_t size);
1144 * Retrieve data which was stored by ap_retained_data_create()
1145 * @param key The unique key associated with this module's retained data
1146 * @return Address of previously retained data structure, or NULL if not yet saved
1148 AP_DECLARE(void *) ap_retained_data_get(const char *key);
1150 /* Module-method dispatchers, also for http_request.c */
1152 * Run the handler phase of each module until a module accepts the
1153 * responsibility of serving the request
1154 * @param r The current request
1155 * @return The status of the current request
1157 AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r);
1162 * Find a given directive in a command_rec table
1163 * @param name The directive to search for
1164 * @param cmds The table to search
1165 * @return The directive definition of the specified directive
1167 AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name,
1168 const command_rec *cmds);
1171 * Find a given directive in a list module
1172 * @param cmd_name The directive to search for
1173 * @param mod The module list to search
1174 * @return The directive definition of the specified directive
1176 AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name,
1180 * Ask a module to create per-server and per-section (dir/loc/file) configs
1181 * (if it hasn't happened already). The results are stored in the server's
1182 * config, and the specified per-section config vector.
1183 * @param server The server to operate upon.
1184 * @param section_vector The per-section config vector.
1185 * @param section Which section to create a config for.
1186 * @param mod The module which is defining the config data.
1187 * @param pconf A pool for all configuration allocations.
1188 * @return The (new) per-section config data.
1190 AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server,
1191 ap_conf_vector_t *section_vector,
1192 const char *section,
1193 module *mod, apr_pool_t *pconf);
1198 * Run the header parser functions for each module
1199 * @param r The current request
1200 * @return OK or DECLINED
1202 AP_DECLARE_HOOK(int,header_parser,(request_rec *r))
1205 * Run the pre_config function for each module
1206 * @param pconf The config pool
1207 * @param plog The logging streams pool
1208 * @param ptemp The temporary pool
1209 * @return OK or DECLINED on success anything else is a error
1211 AP_DECLARE_HOOK(int,pre_config,(apr_pool_t *pconf,apr_pool_t *plog,
1215 * Run the check_config function for each module
1216 * @param pconf The config pool
1217 * @param plog The logging streams pool
1218 * @param ptemp The temporary pool
1219 * @param s the server to operate upon
1220 * @return OK or DECLINED on success anything else is a error
1222 AP_DECLARE_HOOK(int,check_config,(apr_pool_t *pconf, apr_pool_t *plog,
1223 apr_pool_t *ptemp, server_rec *s))
1226 * Run the test_config function for each module; this hook is run
1227 * only if the server was invoked to test the configuration syntax.
1228 * @param pconf The config pool
1229 * @param s The list of server_recs
1231 AP_DECLARE_HOOK(void,test_config,(apr_pool_t *pconf, server_rec *s))
1234 * Run the post_config function for each module
1235 * @param pconf The config pool
1236 * @param plog The logging streams pool
1237 * @param ptemp The temporary pool
1238 * @param s The list of server_recs
1239 * @return OK or DECLINED on success anything else is a error
1241 AP_DECLARE_HOOK(int,post_config,(apr_pool_t *pconf,apr_pool_t *plog,
1242 apr_pool_t *ptemp,server_rec *s))
1245 * Run the open_logs functions for each module
1246 * @param pconf The config pool
1247 * @param plog The logging streams pool
1248 * @param ptemp The temporary pool
1249 * @param s The list of server_recs
1250 * @return OK or DECLINED on success anything else is a error
1252 AP_DECLARE_HOOK(int,open_logs,(apr_pool_t *pconf,apr_pool_t *plog,
1253 apr_pool_t *ptemp,server_rec *s))
1256 * Run the child_init functions for each module
1257 * @param pchild The child pool
1258 * @param s The list of server_recs in this server
1260 AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s))
1263 * Run the handler functions for each module
1264 * @param r The request_rec
1265 * @remark non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST
1267 AP_DECLARE_HOOK(int,handler,(request_rec *r))
1270 * Run the quick handler functions for each module. The quick_handler
1271 * is run before any other requests hooks are called (location_walk,
1272 * directory_walk, access checking, et. al.). This hook was added
1273 * to provide a quick way to serve content from a URI keyed cache.
1275 * @param r The request_rec
1276 * @param lookup_uri Controls whether the caller actually wants content or not.
1277 * lookup is set when the quick_handler is called out of
1278 * ap_sub_req_lookup_uri()
1280 AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri))
1283 * Retrieve the optional functions for each module.
1284 * This is run immediately before the server starts. Optional functions should
1285 * be registered during the hook registration phase.
1287 AP_DECLARE_HOOK(void,optional_fn_retrieve,(void))
1290 * A generic pool cleanup that will reset a pointer to NULL. For use with
1291 * apr_pool_cleanup_register.
1292 * @param data The address of the pointer
1293 * @return APR_SUCCESS
1295 AP_DECLARE_NONSTD(apr_status_t) ap_pool_cleanup_set_null(void *data);
1301 #endif /* !APACHE_HTTP_CONFIG_H */