]> granicus.if.org Git - apache/blob - include/http_config.h
Support for OpenSSL 1.1.0:
[apache] / include / http_config.h
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file http_config.h
19  * @brief Apache Configuration
20  *
21  * @defgroup APACHE_CORE_CONFIG Configuration
22  * @ingroup  APACHE_CORE
23  * @{
24  */
25
26 #ifndef APACHE_HTTP_CONFIG_H
27 #define APACHE_HTTP_CONFIG_H
28
29 #include "util_cfgtree.h"
30 #include "ap_config.h"
31 #include "apr_tables.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 /*
38  * The central data structures around here...
39  */
40
41 /* Command dispatch structures... */
42
43 /**
44  * How the directives arguments should be parsed.
45  * @remark Note that for all of these except RAW_ARGS, the config routine is
46  *      passed a freshly allocated string which can be modified or stored
47  *      or whatever...
48  */
49 enum cmd_how {
50     RAW_ARGS,           /**< cmd_func parses command line itself */
51     TAKE1,              /**< one argument only */
52     TAKE2,              /**< two arguments only */
53     ITERATE,            /**< one argument, occuring multiple times
54                          * (e.g., IndexIgnore)
55                          */
56     ITERATE2,           /**< two arguments, 2nd occurs multiple times
57                          * (e.g., AddIcon)
58                          */
59     FLAG,               /**< One of 'On' or 'Off' */
60     NO_ARGS,            /**< No args at all, e.g. &lt;/Directory&gt; */
61     TAKE12,             /**< one or two arguments */
62     TAKE3,              /**< three arguments only */
63     TAKE23,             /**< two or three arguments */
64     TAKE123,            /**< one, two or three arguments */
65     TAKE13,             /**< one or three arguments */
66     TAKE_ARGV           /**< an argc and argv are passed */
67 };
68
69 /**
70  * This structure is passed to a command which is being invoked,
71  * to carry a large variety of miscellaneous data which is all of
72  * use to *somebody*...
73  */
74 typedef struct cmd_parms_struct cmd_parms;
75
76 #if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN)
77
78 /**
79  * All the types of functions that can be used in directives
80  * @internal
81  */
82 typedef union {
83     /** function to call for a no-args */
84     const char *(*no_args) (cmd_parms *parms, void *mconfig);
85     /** function to call for a raw-args */
86     const char *(*raw_args) (cmd_parms *parms, void *mconfig,
87                              const char *args);
88     /** function to call for a argv/argc */
89     const char *(*take_argv) (cmd_parms *parms, void *mconfig,
90                              int argc, char *const argv[]);
91     /** function to call for a take1 */
92     const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w);
93     /** function to call for a take2 */
94     const char *(*take2) (cmd_parms *parms, void *mconfig, const char *w,
95                           const char *w2);
96     /** function to call for a take3 */
97     const char *(*take3) (cmd_parms *parms, void *mconfig, const char *w,
98                           const char *w2, const char *w3);
99     /** function to call for a flag */
100     const char *(*flag) (cmd_parms *parms, void *mconfig, int on);
101 } cmd_func;
102
103 /** This configuration directive does not take any arguments */
104 # define AP_NO_ARGS     func.no_args
105 /** This configuration directive will handle its own parsing of arguments*/
106 # define AP_RAW_ARGS    func.raw_args
107 /** This configuration directive will handle its own parsing of arguments*/
108 # define AP_TAKE_ARGV   func.take_argv
109 /** This configuration directive takes 1 argument*/
110 # define AP_TAKE1       func.take1
111 /** This configuration directive takes 2 arguments */
112 # define AP_TAKE2       func.take2
113 /** This configuration directive takes 3 arguments */
114 # define AP_TAKE3       func.take3
115 /** This configuration directive takes a flag (on/off) as a argument*/
116 # define AP_FLAG        func.flag
117
118 /** mechanism for declaring a directive with no arguments */
119 # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
120     { directive, { .no_args=func }, mconfig, where, NO_ARGS, help }
121 /** mechanism for declaring a directive with raw argument parsing */
122 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
123     { directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help }
124 /** mechanism for declaring a directive with raw argument parsing */
125 # define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
126     { directive, { .take_argv=func }, mconfig, where, TAKE_ARGV, help }
127 /** mechanism for declaring a directive which takes 1 argument */
128 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
129     { directive, { .take1=func }, mconfig, where, TAKE1, help }
130 /** mechanism for declaring a directive which takes multiple arguments */
131 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
132     { directive, { .take1=func }, mconfig, where, ITERATE, help }
133 /** mechanism for declaring a directive which takes 2 arguments */
134 # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
135     { directive, { .take2=func }, mconfig, where, TAKE2, help }
136 /** mechanism for declaring a directive which takes 1 or 2 arguments */
137 # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
138     { directive, { .take2=func }, mconfig, where, TAKE12, help }
139 /** mechanism for declaring a directive which takes multiple 2 arguments */
140 # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
141     { directive, { .take2=func }, mconfig, where, ITERATE2, help }
142 /** mechanism for declaring a directive which takes 1 or 3 arguments */
143 # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
144     { directive, { .take3=func }, mconfig, where, TAKE13, help }
145 /** mechanism for declaring a directive which takes 2 or 3 arguments */
146 # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
147     { directive, { .take3=func }, mconfig, where, TAKE23, help }
148 /** mechanism for declaring a directive which takes 1 to 3 arguments */
149 # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
150     { directive, { .take3=func }, mconfig, where, TAKE123, help }
151 /** mechanism for declaring a directive which takes 3 arguments */
152 # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
153     { directive, { .take3=func }, mconfig, where, TAKE3, help }
154 /** mechanism for declaring a directive which takes a flag (on/off) argument */
155 # define AP_INIT_FLAG(directive, func, mconfig, where, help) \
156     { directive, { .flag=func }, mconfig, where, FLAG, help }
157
158 #else /* AP_HAVE_DESIGNATED_INITIALIZER */
159
160 typedef const char *(*cmd_func) ();
161
162 # define AP_NO_ARGS  func
163 # define AP_RAW_ARGS func
164 # define AP_TAKE_ARGV func
165 # define AP_TAKE1    func
166 # define AP_TAKE2    func
167 # define AP_TAKE3    func
168 # define AP_FLAG     func
169
170 # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
171     { directive, func, mconfig, where, NO_ARGS, help }
172 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
173     { directive, func, mconfig, where, RAW_ARGS, help }
174 # define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
175     { directive, func, mconfig, where, TAKE_ARGV, help }
176 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
177     { directive, func, mconfig, where, TAKE1, help }
178 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
179     { directive, func, mconfig, where, ITERATE, help }
180 # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
181     { directive, func, mconfig, where, TAKE2, help }
182 # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
183     { directive, func, mconfig, where, TAKE12, help }
184 # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
185     { directive, func, mconfig, where, ITERATE2, help }
186 # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
187     { directive, func, mconfig, where, TAKE13, help }
188 # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
189     { directive, func, mconfig, where, TAKE23, help }
190 # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
191     { directive, func, mconfig, where, TAKE123, help }
192 # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
193     { directive, func, mconfig, where, TAKE3, help }
194 # define AP_INIT_FLAG(directive, func, mconfig, where, help) \
195     { directive, func, mconfig, where, FLAG, help }
196
197 #endif /* AP_HAVE_DESIGNATED_INITIALIZER */
198
199 /**
200  * The command record structure.  Modules can define a table of these
201  * to define the directives it will implement.
202  */
203 typedef struct command_struct command_rec;
204 struct command_struct {
205     /** Name of this command */
206     const char *name;
207     /** The function to be called when this directive is parsed */
208     cmd_func func;
209     /** Extra data, for functions which implement multiple commands... */
210     void *cmd_data;
211     /** What overrides need to be allowed to enable this command. */
212     int req_override;
213     /** What the command expects as arguments */
214     enum cmd_how args_how;
215
216     /** 'usage' message, in case of syntax errors */
217     const char *errmsg;
218 };
219
220 /**
221  * @defgroup ConfigDirectives Allowed locations for configuration directives.
222  *
223  * The allowed locations for a configuration directive are the union of
224  * those indicated by each set bit in the req_override mask.
225  *
226  * @{
227  */
228 #define OR_NONE 0             /**< *.conf is not available anywhere in this override */
229 #define OR_LIMIT 1           /**< *.conf inside &lt;Directory&gt; or &lt;Location&gt;
230                                 and .htaccess when AllowOverride Limit */
231 #define OR_OPTIONS 2         /**< *.conf anywhere
232                                 and .htaccess when AllowOverride Options */
233 #define OR_FILEINFO 4        /**< *.conf anywhere
234                                 and .htaccess when AllowOverride FileInfo */
235 #define OR_AUTHCFG 8         /**< *.conf inside &lt;Directory&gt; or &lt;Location&gt;
236                                 and .htaccess when AllowOverride AuthConfig */
237 #define OR_INDEXES 16        /**< *.conf anywhere
238                                 and .htaccess when AllowOverride Indexes */
239 #define OR_UNSET 32          /**< bit to indicate that AllowOverride has not been set */
240 #define ACCESS_CONF 64       /**< *.conf inside &lt;Directory&gt; or &lt;Location&gt; */
241 #define RSRC_CONF 128        /**< *.conf outside &lt;Directory&gt; or &lt;Location&gt; */
242 #define EXEC_ON_READ 256     /**< force directive to execute a command
243                 which would modify the configuration (like including another
244                 file, or IFModule */
245 /* Flags to determine whether syntax errors in .htaccess should be
246  * treated as nonfatal (log and ignore errors)
247  */
248 #define NONFATAL_OVERRIDE 512    /* Violation of AllowOverride rule */
249 #define NONFATAL_UNKNOWN 1024    /* Unrecognised directive */
250 #define NONFATAL_ALL (NONFATAL_OVERRIDE|NONFATAL_UNKNOWN)
251
252 /** this directive can be placed anywhere */
253 #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
254
255 /** @} */
256
257 /**
258  * This can be returned by a function if they don't wish to handle
259  * a command. Make it something not likely someone will actually use
260  * as an error code.
261  */
262 #define DECLINE_CMD "\a\b"
263
264 /** Common structure for reading of config files / passwd files etc. */
265 typedef struct ap_configfile_t ap_configfile_t;
266 struct ap_configfile_t {
267     /**< an apr_file_getc()-like function */
268     apr_status_t (*getch) (char *ch, void *param);
269     /**< an apr_file_gets()-like function */
270     apr_status_t (*getstr) (void *buf, apr_size_t bufsiz, void *param);
271     /**< a close handler function */
272     apr_status_t (*close) (void *param);
273     /**< the argument passed to getch/getstr/close */
274     void *param;
275     /**< the filename / description */
276     const char *name;
277     /**< current line number, starting at 1 */
278     unsigned line_number;
279 };
280
281 /**
282  * This structure is passed to a command which is being invoked,
283  * to carry a large variety of miscellaneous data which is all of
284  * use to *somebody*...
285  */
286 struct cmd_parms_struct {
287     /** Argument to command from cmd_table */
288     void *info;
289     /** Which allow-override bits are set */
290     int override;
291     /** Which allow-override-opts bits are set */
292     int override_opts;
293     /** Table of directives allowed per AllowOverrideList */
294     apr_table_t *override_list;
295     /** Which methods are &lt;Limit&gt;ed */
296     apr_int64_t limited;
297     /** methods which are limited */
298     apr_array_header_t *limited_xmethods;
299     /** methods which are xlimited */
300     ap_method_list_t *xlimited;
301
302     /** Config file structure. */
303     ap_configfile_t *config_file;
304     /** the directive specifying this command */
305     ap_directive_t *directive;
306
307     /** Pool to allocate new storage in */
308     apr_pool_t *pool;
309     /** Pool for scratch memory; persists during configuration, but
310      *  wiped before the first request is served...  */
311     apr_pool_t *temp_pool;
312     /** Server_rec being configured for */
313     server_rec *server;
314     /** If configuring for a directory, pathname of that directory.
315      *  NOPE!  That's what it meant previous to the existence of &lt;Files&gt;,
316      * &lt;Location&gt; and regex matching.  Now the only usefulness that can be
317      * derived from this field is whether a command is being called in a
318      * server context (path == NULL) or being called in a dir context
319      * (path != NULL).  */
320     char *path;
321     /** configuration command */
322     const command_rec *cmd;
323
324     /** per_dir_config vector passed to handle_command */
325     struct ap_conf_vector_t *context;
326     /** directive with syntax error */
327     const ap_directive_t *err_directive;
328  
329     /** If the current directive is EXEC_ON_READ, this is the last 
330         (non-EXEC_ON_READ)  enclosing directive  */
331     ap_directive_t *parent;
332 };
333
334 /**
335  * Module structures.  Just about everything is dispatched through
336  * these, directly or indirectly (through the command and handler
337  * tables).
338  */
339 typedef struct module_struct module;
340 struct module_struct {
341     /** API version, *not* module version; check that module is
342      * compatible with this version of the server.
343      */
344     int version;
345     /** API minor version. Provides API feature milestones. Not checked
346      *  during module init */
347     int minor_version;
348     /** Index to this modules structures in config vectors.  */
349     int module_index;
350
351     /** The name of the module's C file */
352     const char *name;
353     /** The handle for the DSO.  Internal use only */
354     void *dynamic_load_handle;
355
356     /** A pointer to the next module in the list
357      *  @var module_struct *next
358      */
359     struct module_struct *next;
360
361     /** Magic Cookie to identify a module structure;  It's mainly
362      *  important for the DSO facility (see also mod_so).  */
363     unsigned long magic;
364
365     /** Function to allow MPMs to re-write command line arguments.  This
366      *  hook is only available to MPMs.
367      *  @param The process that the server is running in.
368      */
369     void (*rewrite_args) (process_rec *process);
370     /** Function to allow all modules to create per directory configuration
371      *  structures.
372      *  @param p The pool to use for all allocations.
373      *  @param dir The directory currently being processed.
374      *  @return The per-directory structure created
375      */
376     void *(*create_dir_config) (apr_pool_t *p, char *dir);
377     /** Function to allow all modules to merge the per directory configuration
378      *  structures for two directories.
379      *  @param p The pool to use for all allocations.
380      *  @param base_conf The directory structure created for the parent directory.
381      *  @param new_conf The directory structure currently being processed.
382      *  @return The new per-directory structure created
383      */
384     void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf);
385     /** Function to allow all modules to create per server configuration
386      *  structures.
387      *  @param p The pool to use for all allocations.
388      *  @param s The server currently being processed.
389      *  @return The per-server structure created
390      */
391     void *(*create_server_config) (apr_pool_t *p, server_rec *s);
392     /** Function to allow all modules to merge the per server configuration
393      *  structures for two servers.
394      *  @param p The pool to use for all allocations.
395      *  @param base_conf The directory structure created for the parent directory.
396      *  @param new_conf The directory structure currently being processed.
397      *  @return The new per-directory structure created
398      */
399     void *(*merge_server_config) (apr_pool_t *p, void *base_conf,
400                                   void *new_conf);
401
402     /** A command_rec table that describes all of the directives this module
403      * defines. */
404     const command_rec *cmds;
405
406     /** A hook to allow modules to hook other points in the request processing.
407      *  In this function, modules should call the ap_hook_*() functions to
408      *  register an interest in a specific step in processing the current
409      *  request.
410      *  @param p the pool to use for all allocations
411      */
412     void (*register_hooks) (apr_pool_t *p);
413 };
414
415 /**
416  * The AP_MAYBE_USELESS macro is used vor variable declarations that
417  * might potentially exhibit "unused var" warnings on some compilers if
418  * left untreated.
419  * Since static intializers are not part of the C language (C89), making
420  * (void) usage is not possible. However many compiler have proprietary 
421  * mechanism to suppress those warnings.  
422  */
423 #ifdef AP_MAYBE_USELESS
424 #elif defined(__GNUC__)
425 # define AP_MAYBE_USELESS(x) x __attribute__((unused)) 
426 #elif defined(__LCLINT__)
427 # define AP_MAYBE_USELESS(x) /*@unused@*/ x  
428 #else
429 # define AP_MAYBE_USELESS(x) x
430 #endif
431     
432 /**
433  * The APLOG_USE_MODULE macro is used choose which module a file belongs to.
434  * This is necessary to allow per-module loglevel configuration.
435  *
436  * APLOG_USE_MODULE indirectly sets APLOG_MODULE_INDEX and APLOG_MARK.
437  *
438  * If a module should be backward compatible with versions before 2.3.6,
439  * APLOG_USE_MODULE needs to be enclosed in a ifdef APLOG_USE_MODULE block.
440  *
441  * @param foo name of the module symbol of the current module, without the
442  *            trailing "_module" part
443  * @see APLOG_MARK
444  */
445 #define APLOG_USE_MODULE(foo) \
446     extern module AP_MODULE_DECLARE_DATA foo##_module;                  \
447     AP_MAYBE_USELESS(static int * const aplog_module_index) = &(foo##_module.module_index)
448
449 /**
450  * AP_DECLARE_MODULE is a convenience macro that combines a call of
451  * APLOG_USE_MODULE with the definition of the module symbol.
452  *
453  * If a module should be backward compatible with versions before 2.3.6,
454  * APLOG_USE_MODULE should be used explicitly instead of AP_DECLARE_MODULE.
455  */
456 #define AP_DECLARE_MODULE(foo) \
457     APLOG_USE_MODULE(foo);                         \
458     module AP_MODULE_DECLARE_DATA foo##_module
459
460 /**
461  * @defgroup ModuleInit Module structure initializers
462  *
463  * Initializer for the first few module slots, which are only
464  * really set up once we start running.  Note that the first two slots
465  * provide a version check; this should allow us to deal with changes to
466  * the API. The major number should reflect changes to the API handler table
467  * itself or removal of functionality. The minor number should reflect
468  * additions of functionality to the existing API. (the server can detect
469  * an old-format module, and either handle it back-compatibly, or at least
470  * signal an error). See src/include/ap_mmn.h for MMN version history.
471  * @{
472  */
473
474 /** The one used in Apache 1.3, which will deliberately cause an error */
475 #define STANDARD_MODULE_STUFF   this_module_needs_to_be_ported_to_apache_2_0
476
477 /** Use this in all standard modules */
478 #define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
479                                 MODULE_MAGIC_NUMBER_MINOR, \
480                                 -1, \
481                                 __FILE__, \
482                                 NULL, \
483                                 NULL, \
484                                 MODULE_MAGIC_COOKIE, \
485                                 NULL      /* rewrite args spot */
486
487 /** Use this only in MPMs */
488 #define MPM20_MODULE_STUFF      MODULE_MAGIC_NUMBER_MAJOR, \
489                                 MODULE_MAGIC_NUMBER_MINOR, \
490                                 -1, \
491                                 __FILE__, \
492                                 NULL, \
493                                 NULL, \
494                                 MODULE_MAGIC_COOKIE
495
496 /** @} */
497
498 /* CONFIGURATION VECTOR FUNCTIONS */
499
500 /** configuration vector structure */
501 typedef struct ap_conf_vector_t ap_conf_vector_t;
502
503 /**
504  * Generic accessors for other modules to get at their own module-specific
505  * data
506  * @param cv The vector in which the modules configuration is stored.
507  *        usually r->per_dir_config or s->module_config
508  * @param m The module to get the data for.
509  * @return The module-specific data
510  */
511 AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
512                                         const module *m);
513
514 /**
515  * Generic accessors for other modules to set their own module-specific
516  * data
517  * @param cv The vector in which the modules configuration is stored.
518  *        usually r->per_dir_config or s->module_config
519  * @param m The module to set the data for.
520  * @param val The module-specific data to set
521  */
522 AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
523                                       void *val);
524
525 #if !defined(AP_DEBUG)
526
527 #define ap_get_module_config(v,m)       \
528     (((void **)(v))[(m)->module_index])
529 #define ap_set_module_config(v,m,val)   \
530     ((((void **)(v))[(m)->module_index]) = (val))
531
532 #endif /* AP_DEBUG */
533
534
535 /**
536  * Generic accessor for modules to get the module-specific loglevel
537  * @param s The server from which to get the loglevel.
538  * @param index The module_index of the module to get the loglevel for.
539  * @return The module-specific loglevel
540  */
541 AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int index);
542
543 /**
544  * Generic accessor for modules the module-specific loglevel
545  * @param c The connection from which to get the loglevel.
546  * @param index The module_index of the module to get the loglevel for.
547  * @return The module-specific loglevel
548  */
549 AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int index);
550
551 /**
552  * Generic accessor for modules the module-specific loglevel
553  * @param c The connection from which to get the loglevel.
554  * @param s The server from which to get the loglevel if c does not have a
555  *          specific loglevel configuration.
556  * @param index The module_index of the module to get the loglevel for.
557  * @return The module-specific loglevel
558  */
559 AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c,
560                                                    const server_rec *s,
561                                                    int index);
562
563 /**
564  * Generic accessor for modules to get the module-specific loglevel
565  * @param r The request from which to get the loglevel.
566  * @param index The module_index of the module to get the loglevel for.
567  * @return The module-specific loglevel
568  */
569 AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int index);
570
571 /**
572  * Accessor to set module-specific loglevel
573  * @param p A pool
574  * @param l The ap_logconf struct to modify.
575  * @param index The module_index of the module to set the loglevel for.
576  * @param level The new log level
577  */
578 AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, struct ap_logconf *l,
579                                         int index, int level);
580
581 #if !defined(AP_DEBUG)
582
583 #define ap_get_conn_logconf(c)                     \
584     ((c)->log             ? (c)->log             : \
585      &(c)->base_server->log)
586
587 #define ap_get_conn_server_logconf(c,s)                             \
588     ( ( (c)->log != &(c)->base_server->log && (c)->log != NULL )  ? \
589       (c)->log                                                    : \
590       &(s)->log )
591
592 #define ap_get_request_logconf(r)                  \
593     ((r)->log             ? (r)->log             : \
594      (r)->connection->log ? (r)->connection->log : \
595      &(r)->server->log)
596
597 #define ap_get_module_loglevel(l,i)                                     \
598     (((i) < 0 || (l)->module_levels == NULL || (l)->module_levels[i] < 0) ?  \
599      (l)->level :                                                         \
600      (l)->module_levels[i])
601
602 #define ap_get_server_module_loglevel(s,i)  \
603     (ap_get_module_loglevel(&(s)->log,i))
604
605 #define ap_get_conn_module_loglevel(c,i)  \
606     (ap_get_module_loglevel(ap_get_conn_logconf(c),i))
607
608 #define ap_get_conn_server_module_loglevel(c,s,i)  \
609     (ap_get_module_loglevel(ap_get_conn_server_logconf(c,s),i))
610
611 #define ap_get_request_module_loglevel(r,i)  \
612     (ap_get_module_loglevel(ap_get_request_logconf(r),i))
613
614 #endif /* AP_DEBUG */
615
616 /**
617  * Set all module-specific loglevels to val
618  * @param l The log config for which to set the loglevels.
619  * @param val the value to set all loglevels to
620  */
621 AP_DECLARE(void) ap_reset_module_loglevels(struct ap_logconf *l, int val);
622
623 /**
624  * Generic command handling function for strings
625  * @param cmd The command parameters for this directive
626  * @param struct_ptr pointer into a given type
627  * @param arg The argument to the directive
628  * @return An error string or NULL on success
629  */
630 AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
631                                                    void *struct_ptr,
632                                                    const char *arg);
633
634 /**
635  * Generic command handling function for integers
636  * @param cmd The command parameters for this directive
637  * @param struct_ptr pointer into a given type
638  * @param arg The argument to the directive
639  * @return An error string or NULL on success
640  */
641 AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd,
642                                                 void *struct_ptr,
643                                                 const char *arg);
644
645 /**
646  * Parsing function for log level
647  * @param str The string to parse
648  * @param val The parsed log level
649  * @return An error string or NULL on success
650  */
651 AP_DECLARE(const char *) ap_parse_log_level(const char *str, int *val);
652
653 /**
654  * Return true if the specified method is limited by being listed in
655  * a &lt;Limit&gt; container, or by *not* being listed in a &lt;LimitExcept&gt;
656  * container.
657  *
658  * @param   method  Pointer to a string specifying the method to check.
659  * @param   cmd     Pointer to the cmd_parms structure passed to the
660  *                  directive handler.
661  * @return  0 if the method is not limited in the current scope
662  */
663 AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method);
664
665 /**
666  * Generic command handling function for strings, always sets the value
667  * to a lowercase string
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
672  */
673 AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
674                                                          void *struct_ptr,
675                                                          const char *arg);
676 /**
677  * Generic command handling function for flags stored in an int
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 (either 1 or 0)
681  * @return An error string or NULL on success
682  */
683 AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
684                                                  void *struct_ptr,
685                                                  int arg);
686 /**
687  * Generic command handling function for flags stored in a char
688  * @param cmd The command parameters for this directive
689  * @param struct_ptr pointer into a given type
690  * @param arg The argument to the directive (either 1 or 0)
691  * @return An error string or NULL on success
692  */
693 AP_DECLARE_NONSTD(const char *) ap_set_flag_slot_char(cmd_parms *cmd,
694                                                       void *struct_ptr,
695                                                       int arg);
696 /**
697  * Generic command handling function for files
698  * @param cmd The command parameters for this directive
699  * @param struct_ptr pointer into a given type
700  * @param arg The argument to the directive
701  * @return An error string or NULL on success
702  */
703 AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd,
704                                                  void *struct_ptr,
705                                                  const char *arg);
706 /**
707  * Generic command handling function to respond with cmd->help as an error
708  * @param cmd The command parameters for this directive
709  * @param struct_ptr pointer into a given type
710  * @param arg The argument to the directive
711  * @return The cmd->help value as the error string
712  * @note This allows simple declarations such as:
713  * @code
714  *     AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL,
715  *         "The Foo directive is no longer supported, use Bar"),
716  * @endcode
717  */
718 AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd,
719                                                   void *struct_ptr,
720                                                   const char *arg);
721 /**
722  * For modules which need to read config files, open logs, etc. this returns
723  * the canonical form of fname made absolute to ap_server_root.
724  * @param p pool to allocate data from
725  * @param fname The file name
726  */
727 AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
728
729 /**
730  * Compute the name of a run-time file (e.g., shared memory "file") relative
731  * to the appropriate run-time directory.  Absolute paths are returned as-is.
732  * The run-time directory is configured via the DefaultRuntimeDir directive or
733  * at build time.
734  */
735 AP_DECLARE(char *) ap_runtime_dir_relative(apr_pool_t *p, const char *fname);
736
737 /* Finally, the hook for dynamically loading modules in... */
738
739 /**
740  * Add a module to the server
741  * @param m The module structure of the module to add
742  * @param p The pool of the same lifetime as the module
743  * @param s The module's symbol name (used for logging)
744  */
745 AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
746                                        const char *s);
747
748 /**
749  * Remove a module from the server.  There are some caveats:
750  * when the module is removed, its slot is lost so all the current
751  * per-dir and per-server configurations are invalid. So we should
752  * only ever call this function when you are invalidating almost
753  * all our current data. I.e. when doing a restart.
754  * @param m the module structure of the module to remove
755  */
756 AP_DECLARE(void) ap_remove_module(module *m);
757 /**
758  * Add a module to the chained modules list and the list of loaded modules
759  * @param mod The module structure of the module to add
760  * @param p The pool with the same lifetime as the module
761  * @param s The module's symbol name (used for logging)
762  */
763 AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p,
764                                               const char *s);
765 /**
766  * Remove a module fromthe chained modules list and the list of loaded modules
767  * @param mod the module structure of the module to remove
768  */
769 AP_DECLARE(void) ap_remove_loaded_module(module *mod);
770 /**
771  * Find the name of the specified module
772  * @param m The module to get the name for
773  * @return the name of the module
774  */
775 AP_DECLARE(const char *) ap_find_module_name(module *m);
776 /**
777  * Find the short name of the module identified by the specified module index
778  * @param module_index The module index to get the name for
779  * @return the name of the module, NULL if not found
780  */
781 AP_DECLARE(const char *) ap_find_module_short_name(int module_index);
782 /**
783  * Find a module based on the name of the module
784  * @param name the name of the module
785  * @return the module structure if found, NULL otherwise
786  */
787 AP_DECLARE(module *) ap_find_linked_module(const char *name);
788
789 /**
790  * Open a ap_configfile_t as apr_file_t
791  * @param ret_cfg open ap_configfile_t struct pointer
792  * @param p The pool to allocate the structure from
793  * @param name the name of the file to open
794  */
795 AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg,
796                                           apr_pool_t *p, const char *name);
797
798 /**
799  * Allocate a ap_configfile_t handle with user defined functions and params
800  * @param p The pool to allocate from
801  * @param descr The name of the file
802  * @param param The argument passed to getch/getstr/close
803  * @param getc_func The getch function
804  * @param gets_func The getstr function
805  * @param close_func The close function
806  */
807 AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p,
808     const char *descr,
809     void *param,
810     apr_status_t (*getc_func) (char *ch, void *param),
811     apr_status_t (*gets_func) (void *buf, apr_size_t bufsiz, void *param),
812     apr_status_t (*close_func) (void *param));
813
814 /**
815  * Read one line from open ap_configfile_t, strip leading and trailing
816  * whitespace, increase line number
817  * @param buf place to store the line read
818  * @param bufsize size of the buffer
819  * @param cfp File to read from
820  * @return error status, APR_ENOSPC if bufsize is too small for the line
821  */
822 AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize, ap_configfile_t *cfp);
823
824 /**
825  * Read one char from open configfile_t, increase line number upon LF
826  * @param ch place to store the char read
827  * @param cfp The file to read from
828  * @return error status
829  */
830 AP_DECLARE(apr_status_t) ap_cfg_getc(char *ch, ap_configfile_t *cfp);
831
832 /**
833  * Detach from open ap_configfile_t, calling the close handler
834  * @param cfp The file to close
835  * @return 1 on sucess, 0 on failure
836  */
837 AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp);
838
839 /**
840  * Convert a return value from ap_cfg_getline or ap_cfg_getc to a user friendly
841  * string.
842  * @param p The pool to allocate the string from
843  * @param cfp The config file
844  * @param rc The return value to convert
845  * @return The error string, NULL if rc == APR_SUCCESS
846  */
847 AP_DECLARE(const char *) ap_pcfg_strerror(apr_pool_t *p, ap_configfile_t *cfp,
848                                           apr_status_t rc);
849
850 /**
851  * Read all data between the current &lt;foo&gt; and the matching &lt;/foo&gt;.  All
852  * of this data is forgotten immediately.
853  * @param cmd The cmd_parms to pass to the directives inside the container
854  * @param directive The directive name to read until
855  * @return Error string on failure, NULL on success
856  * @note If cmd->pool == cmd->temp_pool, ap_soak_end_container() will assume
857  *       .htaccess context and use a lower maximum line length.
858  */
859 AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive);
860
861 /**
862  * Read all data between the current &lt;foo&gt; and the matching &lt;/foo&gt; and build
863  * a config tree from it
864  * @param p pool to allocate from
865  * @param temp_pool Temporary pool to allocate from
866  * @param parms The cmd_parms to pass to all directives read
867  * @param current The current node in the tree
868  * @param curr_parent The current parent node
869  * @param orig_directive The directive to read until hit.
870  * @return Error string on failure, NULL on success
871  * @note If p == temp_pool, ap_build_cont_config() will assume .htaccess
872  *       context and use a lower maximum line length.
873 */
874 AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p,
875                                               apr_pool_t *temp_pool,
876                                               cmd_parms *parms,
877                                               ap_directive_t **current,
878                                               ap_directive_t **curr_parent,
879                                               char *orig_directive);
880
881 /**
882  * Build a config tree from a config file
883  * @param parms The cmd_parms to pass to all of the directives in the file
884  * @param conf_pool The pconf pool
885  * @param temp_pool The temporary pool
886  * @param conftree Place to store the root node of the config tree
887  * @return Error string on erro, NULL otherwise
888  * @note If conf_pool == temp_pool, ap_build_config() will assume .htaccess
889  *       context and use a lower maximum line length.
890  */
891 AP_DECLARE(const char *) ap_build_config(cmd_parms *parms,
892                                          apr_pool_t *conf_pool,
893                                          apr_pool_t *temp_pool,
894                                          ap_directive_t **conftree);
895
896 /**
897  * Walk a config tree and setup the server's internal structures
898  * @param conftree The config tree to walk
899  * @param parms The cmd_parms to pass to all functions
900  * @param section_vector The per-section config vector.
901  * @return Error string on error, NULL otherwise
902  */
903 AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree,
904                                         cmd_parms *parms,
905                                         ap_conf_vector_t *section_vector);
906
907 /**
908  * @defgroup ap_check_cmd_context Check command context
909  * @{
910  */
911 /**
912  * Check the context a command is used in.
913  * @param cmd The command to check
914  * @param forbidden Where the command is forbidden.
915  * @return Error string on error, NULL on success
916  */
917 AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
918                                               unsigned forbidden);
919
920 #define  NOT_IN_VIRTUALHOST     0x01 /**< Forbidden in &lt;VirtualHost&gt; */
921 #define  NOT_IN_LIMIT           0x02 /**< Forbidden in &lt;Limit&gt; */
922 #define  NOT_IN_DIRECTORY       0x04 /**< Forbidden in &lt;Directory&gt; */
923 #define  NOT_IN_LOCATION        0x08 /**< Forbidden in &lt;Location&gt; */
924 #define  NOT_IN_FILES           0x10 /**< Forbidden in &lt;Files&gt; or &lt;If&gt;*/
925 #define  NOT_IN_HTACCESS        0x20 /**< Forbidden in .htaccess files */
926 /** Forbidden in &lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt;&lt;If&gt;*/
927 #define  NOT_IN_DIR_LOC_FILE    (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES)
928 /** Forbidden in &lt;VirtualHost&gt;/&lt;Limit&gt;/&lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt;/&lt;If&gt; */
929 #define  GLOBAL_ONLY            (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
930
931 /** @} */
932
933 /**
934  * @brief This structure is used to assign symbol names to module pointers
935  */
936 typedef struct {
937     const char *name;
938     module *modp;
939 } ap_module_symbol_t;
940
941 /**
942  * The topmost module in the list
943  * @var module *ap_top_module
944  */
945 AP_DECLARE_DATA extern module *ap_top_module;
946
947 /**
948  * Array of all statically linked modules
949  * @var module *ap_prelinked_modules[]
950  */
951 AP_DECLARE_DATA extern module *ap_prelinked_modules[];
952 /**
953  * Array of all statically linked modulenames (symbols)
954  * @var ap_module_symbol_t ap_prelinked_module_symbols[]
955  */
956 AP_DECLARE_DATA extern ap_module_symbol_t ap_prelinked_module_symbols[];
957 /**
958  * Array of all preloaded modules
959  * @var module *ap_preloaded_modules[]
960  */
961 AP_DECLARE_DATA extern module *ap_preloaded_modules[];
962 /**
963  * Array of all loaded modules
964  * @var module **ap_loaded_modules
965  */
966 AP_DECLARE_DATA extern module **ap_loaded_modules;
967
968 /* For mod_so.c... */
969 /** Run a single module's two create_config hooks
970  *  @param p the pool to allocate from
971  *  @param s The server to configure for.
972  *  @param m The module to configure
973  */
974 AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s,
975                                             module *m);
976
977 /* For http_main.c... */
978 /**
979  * Add all of the prelinked modules into the loaded module list
980  * @param process The process that is currently running the server
981  */
982 AP_DECLARE(const char *) ap_setup_prelinked_modules(process_rec *process);
983
984 /**
985  * Show the preloaded configuration directives, the help string explaining
986  * the directive arguments, in what module they are handled, and in
987  * what parts of the configuration they are allowed.  Used for httpd -h.
988  */
989 AP_DECLARE(void) ap_show_directives(void);
990
991 /**
992  * Show the preloaded module names.  Used for httpd -l.
993  */
994 AP_DECLARE(void) ap_show_modules(void);
995
996 /**
997  * Show the MPM name.  Used in reporting modules such as mod_info to
998  * provide extra information to the user
999  */
1000 AP_DECLARE(const char *) ap_show_mpm(void);
1001
1002 /**
1003  * Read all config files and setup the server
1004  * @param process The process running the server
1005  * @param temp_pool A pool to allocate temporary data from.
1006  * @param config_name The name of the config file
1007  * @param conftree Place to store the root of the config tree
1008  * @return The setup server_rec list.
1009  */
1010 AP_DECLARE(server_rec *) ap_read_config(process_rec *process,
1011                                         apr_pool_t *temp_pool,
1012                                         const char *config_name,
1013                                         ap_directive_t **conftree);
1014
1015 /**
1016  * Run all rewrite args hooks for loaded modules
1017  * @param process The process currently running the server
1018  */
1019 AP_DECLARE(void) ap_run_rewrite_args(process_rec *process);
1020
1021 /**
1022  * Run the register hooks function for a specified module
1023  * @param m The module to run the register hooks function fo
1024  * @param p The pool valid for the lifetime of the module
1025  */
1026 AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p);
1027
1028 /**
1029  * Setup all virtual hosts
1030  * @param p The pool to allocate from
1031  * @param main_server The head of the server_rec list
1032  */
1033 AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p,
1034                                         server_rec *main_server);
1035
1036 /**
1037  * Reserve some modules slots for modules loaded by other means than
1038  * EXEC_ON_READ directives.
1039  * Relevant modules should call this in the pre_config stage.
1040  * @param count The number of slots to reserve.
1041  */
1042 AP_DECLARE(void) ap_reserve_module_slots(int count);
1043
1044 /**
1045  * Reserve some modules slots for modules loaded by a specific
1046  * non-EXEC_ON_READ config directive.
1047  * This counts how often the given directive is used in the config and calls
1048  * ap_reserve_module_slots() accordingly.
1049  * @param directive The name of the directive
1050  */
1051 AP_DECLARE(void) ap_reserve_module_slots_directive(const char *directive);
1052
1053 /* For http_request.c... */
1054
1055 /**
1056  * Setup the config vector for a request_rec
1057  * @param p The pool to allocate the config vector from
1058  * @return The config vector
1059  */
1060 AP_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p);
1061
1062 /**
1063  * Setup the config vector for per dir module configs
1064  * @param p The pool to allocate the config vector from
1065  * @return The config vector
1066  */
1067 AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p);
1068
1069 /**
1070  * Run all of the modules merge per dir config functions
1071  * @param p The pool to pass to the merge functions
1072  * @param base The base directory config structure
1073  * @param new_conf The new directory config structure
1074  */
1075 AP_CORE_DECLARE(ap_conf_vector_t*) ap_merge_per_dir_configs(apr_pool_t *p,
1076                                            ap_conf_vector_t *base,
1077                                            ap_conf_vector_t *new_conf);
1078
1079 /**
1080  * Allocate new ap_logconf and make (deep) copy of old ap_logconf
1081  * @param p The pool to alloc from
1082  * @param old The ap_logconf to copy (may be NULL)
1083  * @return The new ap_logconf struct
1084  */
1085 AP_DECLARE(struct ap_logconf *) ap_new_log_config(apr_pool_t *p,
1086                                                   const struct ap_logconf *old);
1087
1088 /**
1089  * Merge old ap_logconf into new ap_logconf.
1090  * old and new must have the same life time.
1091  * @param old_conf The ap_logconf to merge from
1092  * @param new_conf The ap_logconf to merge into
1093  */
1094 AP_DECLARE(void) ap_merge_log_config(const struct ap_logconf *old_conf,
1095                                      struct ap_logconf *new_conf);
1096
1097 /* For http_connection.c... */
1098 /**
1099  * Setup the config vector for a connection_rec
1100  * @param p The pool to allocate the config vector from
1101  * @return The config vector
1102  */
1103 AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_conn_config(apr_pool_t *p);
1104
1105 /* For http_core.c... (&lt;Directory&gt; command and virtual hosts) */
1106
1107 /**
1108  * parse an htaccess file
1109  * @param result htaccess_result
1110  * @param r The request currently being served
1111  * @param override Which overrides are active
1112  * @param override_opts Which allow-override-opts bits are set
1113  * @param override_list Table of directives allowed for override
1114  * @param path The path to the htaccess file
1115  * @param access_name The list of possible names for .htaccess files
1116  * int The status of the current request
1117  */
1118 AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result,
1119                                        request_rec *r,
1120                                        int override,
1121                                        int override_opts,
1122                                        apr_table_t *override_list,
1123                                        const char *path,
1124                                        const char *access_name);
1125
1126 /**
1127  * Setup a virtual host
1128  * @param p The pool to allocate all memory from
1129  * @param hostname The hostname of the virtual hsot
1130  * @param main_server The main server for this Apache configuration
1131  * @param ps Place to store the new server_rec
1132  * return Error string on error, NULL on success
1133  */
1134 AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p,
1135                                                    const char *hostname,
1136                                                    server_rec *main_server,
1137                                                    server_rec **ps);
1138
1139 /**
1140  * Process a config file for Apache
1141  * @param s The server rec to use for the command parms
1142  * @param fname The name of the config file
1143  * @param conftree The root node of the created config tree
1144  * @param p Pool for general allocation
1145  * @param ptemp Pool for temporary allocation
1146  */
1147 AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
1148                                                     const char *fname,
1149                                                     ap_directive_t **conftree,
1150                                                     apr_pool_t *p,
1151                                                     apr_pool_t *ptemp);
1152
1153 /**
1154  * Process all matching files as Apache configs
1155  * @param s The server rec to use for the command parms
1156  * @param fname The filename pattern of the config file
1157  * @param conftree The root node of the created config tree
1158  * @param p Pool for general allocation
1159  * @param ptemp Pool for temporary allocation
1160  * @param optional Whether a no-match wildcard is allowed
1161  * @see apr_fnmatch for pattern handling
1162  */
1163 AP_DECLARE(const char *) ap_process_fnmatch_configs(server_rec *s,
1164                                                     const char *fname,
1165                                                     ap_directive_t **conftree,
1166                                                     apr_pool_t *p,
1167                                                     apr_pool_t *ptemp,
1168                                                     int optional);
1169
1170 /**
1171  * Process all directives in the config tree
1172  * @param s The server rec to use in the command parms
1173  * @param conftree The config tree to process
1174  * @param p The pool for general allocation
1175  * @param ptemp The pool for temporary allocations
1176  * @return OK if no problems
1177  */
1178 AP_DECLARE(int) ap_process_config_tree(server_rec *s,
1179                                        ap_directive_t *conftree,
1180                                        apr_pool_t *p,
1181                                        apr_pool_t *ptemp);
1182
1183 /**
1184  * Store data which will be retained across unload/load of modules
1185  * @param key The unique key associated with this module's retained data
1186  * @param size in bytes of the retained data (to be allocated)
1187  * @return Address of new retained data structure, initially cleared
1188  */
1189 AP_DECLARE(void *) ap_retained_data_create(const char *key, apr_size_t size);
1190
1191 /**
1192  * Retrieve data which was stored by ap_retained_data_create()
1193  * @param key The unique key associated with this module's retained data
1194  * @return Address of previously retained data structure, or NULL if not yet saved
1195  */
1196 AP_DECLARE(void *) ap_retained_data_get(const char *key);
1197
1198 /* Module-method dispatchers, also for http_request.c */
1199 /**
1200  * Run the handler phase of each module until a module accepts the
1201  * responsibility of serving the request
1202  * @param r The current request
1203  * @return The status of the current request
1204  */
1205 AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r);
1206
1207 /* for mod_perl */
1208
1209 /**
1210  * Find a given directive in a command_rec table
1211  * @param name The directive to search for
1212  * @param cmds The table to search
1213  * @return The directive definition of the specified directive
1214  */
1215 AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name,
1216                                                      const command_rec *cmds);
1217
1218 /**
1219  * Find a given directive in a list of modules.
1220  * @param cmd_name The directive to search for
1221  * @param mod Pointer to the first module in the linked list; will be set to
1222  *            the module providing cmd_name
1223  * @return The directive definition of the specified directive.
1224  *         *mod will be changed to point to the module containing the
1225  *         directive.
1226  */
1227 AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name,
1228                                                                 module **mod);
1229
1230 /**
1231  * Ask a module to create per-server and per-section (dir/loc/file) configs
1232  * (if it hasn't happened already). The results are stored in the server's
1233  * config, and the specified per-section config vector.
1234  * @param server The server to operate upon.
1235  * @param section_vector The per-section config vector.
1236  * @param section Which section to create a config for.
1237  * @param mod The module which is defining the config data.
1238  * @param pconf A pool for all configuration allocations.
1239  * @return The (new) per-section config data.
1240  */
1241 AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server,
1242                                               ap_conf_vector_t *section_vector,
1243                                               const char *section,
1244                                               module *mod, apr_pool_t *pconf);
1245
1246   /* Hooks */
1247
1248 /**
1249  * Run the header parser functions for each module
1250  * @param r The current request
1251  * @return OK or DECLINED
1252  * @ingroup hooks
1253  */
1254 AP_DECLARE_HOOK(int,header_parser,(request_rec *r))
1255
1256 /**
1257  * Run the pre_config function for each module
1258  * @param pconf The config pool
1259  * @param plog The logging streams pool
1260  * @param ptemp The temporary pool
1261  * @return OK or DECLINED on success anything else is a error
1262  * @ingroup hooks
1263  */
1264 AP_DECLARE_HOOK(int,pre_config,(apr_pool_t *pconf,apr_pool_t *plog,
1265                                 apr_pool_t *ptemp))
1266
1267 /**
1268  * Run the check_config function for each module
1269  * @param pconf The config pool
1270  * @param plog The logging streams pool
1271  * @param ptemp The temporary pool
1272  * @param s the server to operate upon
1273  * @return OK or DECLINED on success anything else is a error
1274  * @ingroup hooks
1275  */
1276 AP_DECLARE_HOOK(int,check_config,(apr_pool_t *pconf, apr_pool_t *plog,
1277                                   apr_pool_t *ptemp, server_rec *s))
1278
1279 /**
1280  * Run the test_config function for each module; this hook is run
1281  * only if the server was invoked to test the configuration syntax.
1282  * @param pconf The config pool
1283  * @param s The list of server_recs
1284  * @note To avoid reordering problems due to different buffering, hook
1285  *       functions should only apr_file_*() to print to stdout/stderr and
1286  *       not simple printf()/fprintf().
1287  * @ingroup hooks
1288  */
1289 AP_DECLARE_HOOK(void,test_config,(apr_pool_t *pconf, server_rec *s))
1290
1291 /**
1292  * Run the post_config function for each module
1293  * @param pconf The config pool
1294  * @param plog The logging streams pool
1295  * @param ptemp The temporary pool
1296  * @param s The list of server_recs
1297  * @return OK or DECLINED on success anything else is a error
1298  * @ingroup hooks
1299  */
1300 AP_DECLARE_HOOK(int,post_config,(apr_pool_t *pconf,apr_pool_t *plog,
1301                                  apr_pool_t *ptemp,server_rec *s))
1302
1303 /**
1304  * Run the open_logs functions for each module
1305  * @param pconf The config pool
1306  * @param plog The logging streams pool
1307  * @param ptemp The temporary pool
1308  * @param s The list of server_recs
1309  * @return OK or DECLINED on success anything else is a error
1310  * @ingroup hooks
1311  */
1312 AP_DECLARE_HOOK(int,open_logs,(apr_pool_t *pconf,apr_pool_t *plog,
1313                                apr_pool_t *ptemp,server_rec *s))
1314
1315 /**
1316  * Run the child_init functions for each module
1317  * @param pchild The child pool
1318  * @param s The list of server_recs in this server
1319  * @ingroup hooks
1320  */
1321 AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s))
1322
1323 /**
1324  * Run the handler functions for each module
1325  * @param r The request_rec
1326  * @remark non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST
1327  * @ingroup hooks
1328  */
1329 AP_DECLARE_HOOK(int,handler,(request_rec *r))
1330
1331 /**
1332  * Run the quick handler functions for each module. The quick_handler
1333  * is run before any other requests hooks are called (location_walk,
1334  * directory_walk, access checking, et. al.). This hook was added
1335  * to provide a quick way to serve content from a URI keyed cache.
1336  *
1337  * @param r The request_rec
1338  * @param lookup_uri Controls whether the caller actually wants content or not.
1339  * lookup is set when the quick_handler is called out of
1340  * ap_sub_req_lookup_uri()
1341  * @ingroup hooks
1342  */
1343 AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri))
1344
1345 /**
1346  * Retrieve the optional functions for each module.
1347  * This is run immediately before the server starts. Optional functions should
1348  * be registered during the hook registration phase.
1349  * @ingroup hooks
1350  */
1351 AP_DECLARE_HOOK(void,optional_fn_retrieve,(void))
1352
1353 /**
1354  * Allow modules to open htaccess files or perform operations before doing so
1355  * @param r The current request
1356  * @param dir_name The directory for which the htaccess file should be opened
1357  * @param access_name The filename  for which the htaccess file should be opened
1358  * @param conffile Where the pointer to the opened ap_configfile_t must be
1359  *        stored
1360  * @param full_name Where the full file name of the htaccess file must be
1361  *        stored.
1362  * @return APR_SUCCESS on success,
1363  *         APR_ENOENT or APR_ENOTDIR if no htaccess file exists,
1364  *         AP_DECLINED to let later modules do the opening,
1365  *         any other error code on error.
1366  * @ingroup hooks
1367  */
1368 AP_DECLARE_HOOK(apr_status_t,open_htaccess,
1369                 (request_rec *r, const char *dir_name, const char *access_name,
1370                  ap_configfile_t **conffile, const char **full_name))
1371
1372 /**
1373  * Core internal function, use ap_run_open_htaccess() instead.
1374  */
1375 apr_status_t ap_open_htaccess(request_rec *r, const char *dir_name,
1376         const char *access_name, ap_configfile_t **conffile,
1377         const char **full_name);
1378
1379 /**
1380  * A generic pool cleanup that will reset a pointer to NULL. For use with
1381  * apr_pool_cleanup_register.
1382  * @param data The address of the pointer
1383  * @return APR_SUCCESS
1384  */
1385 AP_DECLARE_NONSTD(apr_status_t) ap_pool_cleanup_set_null(void *data);
1386
1387 #ifdef __cplusplus
1388 }
1389 #endif
1390
1391 #endif  /* !APACHE_HTTP_CONFIG_H */
1392 /** @} */