]> granicus.if.org Git - apache/blob - include/http_config.h
92c0812a5614d3d7597242393cc2fe9bda54e2df
[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 "apr_hooks.h"
30 #include "util_cfgtree.h"
31 #include "ap_config.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 it's own parsing of arguments*/
106 # define AP_RAW_ARGS    func.raw_args
107 /** This configuration directive will handle it's 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, RAW_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, RAW_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.  Each 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          /**< unset a directive (in Allow) */
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 /** this directive can be placed anywhere */
246 #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
247
248 /** @} */
249
250 /**
251  * This can be returned by a function if they don't wish to handle
252  * a command. Make it something not likely someone will actually use
253  * as an error code.
254  */
255 #define DECLINE_CMD "\a\b"
256
257 /** Common structure for reading of config files / passwd files etc. */
258 typedef struct ap_configfile_t ap_configfile_t;
259 struct ap_configfile_t {
260     int (*getch) (void *param);     /**< a getc()-like function */
261     void *(*getstr) (void *buf, size_t bufsiz, void *param);
262                                     /**< a fgets()-like function */
263     int (*close) (void *param);     /**< a close handler function */
264     void *param;                    /**< the argument passed to getch/getstr/close */
265     const char *name;               /**< the filename / description */
266     unsigned line_number;           /**< current line number, starting at 1 */
267 };
268
269 /**
270  * This structure is passed to a command which is being invoked,
271  * to carry a large variety of miscellaneous data which is all of
272  * use to *somebody*...
273  */
274 struct cmd_parms_struct {
275     /** Argument to command from cmd_table */
276     void *info;
277     /** Which allow-override bits are set */
278     int override;
279     /** Which methods are &lt;Limit&gt;ed */
280     apr_int64_t limited;
281     /** methods which are limited */
282     apr_array_header_t *limited_xmethods;
283     /** methods which are xlimited */
284     ap_method_list_t *xlimited;
285
286     /** Config file structure. */
287     ap_configfile_t *config_file;
288     /** the directive specifying this command */
289     ap_directive_t *directive;
290
291     /** Pool to allocate new storage in */
292     apr_pool_t *pool;
293     /** Pool for scratch memory; persists during configuration, but 
294      *  wiped before the first request is served...  */
295     apr_pool_t *temp_pool;
296     /** Server_rec being configured for */
297     server_rec *server;
298     /** If configuring for a directory, pathname of that directory.  
299      *  NOPE!  That's what it meant previous to the existance of &lt;Files&gt;, 
300      * &lt;Location&gt; and regex matching.  Now the only usefulness that can be 
301      * derived from this field is whether a command is being called in a 
302      * server context (path == NULL) or being called in a dir context 
303      * (path != NULL).  */
304     char *path;
305     /** configuration command */
306     const command_rec *cmd;
307
308     /** per_dir_config vector passed to handle_command */
309     struct ap_conf_vector_t *context;
310     /** directive with syntax error */
311     const ap_directive_t *err_directive;
312
313     /** Which allow-override-opts bits are set */
314     int override_opts;
315 };
316
317 /**
318  * Module structures.  Just about everything is dispatched through
319  * these, directly or indirectly (through the command and handler
320  * tables).
321  */
322 typedef struct module_struct module;
323 struct module_struct {
324     /** API version, *not* module version; check that module is 
325      * compatible with this version of the server.
326      */
327     int version;
328     /** API minor version. Provides API feature milestones. Not checked 
329      *  during module init */
330     int minor_version;
331     /** Index to this modules structures in config vectors.  */
332     int module_index;
333
334     /** The name of the module's C file */
335     const char *name;
336     /** The handle for the DSO.  Internal use only */
337     void *dynamic_load_handle;
338
339     /** A pointer to the next module in the list
340      *  @var module_struct *next
341      */
342     struct module_struct *next;
343
344     /** Magic Cookie to identify a module structure;  It's mainly 
345      *  important for the DSO facility (see also mod_so).  */
346     unsigned long magic;
347
348     /** Function to allow MPMs to re-write command line arguments.  This
349      *  hook is only available to MPMs.
350      *  @param The process that the server is running in.
351      */
352     void (*rewrite_args) (process_rec *process);
353     /** Function to allow all modules to create per directory configuration
354      *  structures.
355      *  @param p The pool to use for all allocations.
356      *  @param dir The directory currently being processed.
357      *  @return The per-directory structure created
358      */
359     void *(*create_dir_config) (apr_pool_t *p, char *dir);
360     /** Function to allow all modules to merge the per directory configuration
361      *  structures for two directories.
362      *  @param p The pool to use for all allocations.
363      *  @param base_conf The directory structure created for the parent directory.
364      *  @param new_conf The directory structure currently being processed.
365      *  @return The new per-directory structure created
366      */
367     void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf);
368     /** Function to allow all modules to create per server configuration
369      *  structures.
370      *  @param p The pool to use for all allocations.
371      *  @param s The server currently being processed.
372      *  @return The per-server structure created
373      */
374     void *(*create_server_config) (apr_pool_t *p, server_rec *s);
375     /** Function to allow all modules to merge the per server configuration
376      *  structures for two servers.
377      *  @param p The pool to use for all allocations.
378      *  @param base_conf The directory structure created for the parent directory.
379      *  @param new_conf The directory structure currently being processed.
380      *  @return The new per-directory structure created
381      */
382     void *(*merge_server_config) (apr_pool_t *p, void *base_conf, 
383                                   void *new_conf);
384
385     /** A command_rec table that describes all of the directives this module
386      * defines. */
387     const command_rec *cmds;
388
389     /** A hook to allow modules to hook other points in the request processing.
390      *  In this function, modules should call the ap_hook_*() functions to
391      *  register an interest in a specific step in processing the current
392      *  request.
393      *  @param p the pool to use for all allocations
394      */
395     void (*register_hooks) (apr_pool_t *p);
396 };
397
398 /*
399  * Macro to choose which module a file belongs to, for logging.
400  */
401 #define APLOG_USE_MODULE(foo) \
402     extern module AP_MODULE_DECLARE_DATA foo##_module;                  \
403     static int * const aplog_module_index = &(foo##_module.module_index)
404
405 #define AP_DECLARE_MODULE(foo) \
406     APLOG_USE_MODULE(foo);                         \
407     module AP_MODULE_DECLARE_DATA foo##_module
408
409 /**
410  * @defgroup ModuleInit Module structure initializers
411  *
412  * Initializer for the first few module slots, which are only
413  * really set up once we start running.  Note that the first two slots
414  * provide a version check; this should allow us to deal with changes to
415  * the API. The major number should reflect changes to the API handler table
416  * itself or removal of functionality. The minor number should reflect
417  * additions of functionality to the existing API. (the server can detect
418  * an old-format module, and either handle it back-compatibly, or at least
419  * signal an error). See src/include/ap_mmn.h for MMN version history.
420  * @{
421  */
422
423 /** The one used in Apache 1.3, which will deliberately cause an error */
424 #define STANDARD_MODULE_STUFF   this_module_needs_to_be_ported_to_apache_2_0
425
426 /** Use this in all standard modules */
427 #define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
428                                 MODULE_MAGIC_NUMBER_MINOR, \
429                                 -1, \
430                                 __FILE__, \
431                                 NULL, \
432                                 NULL, \
433                                 MODULE_MAGIC_COOKIE, \
434                                 NULL      /* rewrite args spot */
435
436 /** Use this only in MPMs */
437 #define MPM20_MODULE_STUFF      MODULE_MAGIC_NUMBER_MAJOR, \
438                                 MODULE_MAGIC_NUMBER_MINOR, \
439                                 -1, \
440                                 __FILE__, \
441                                 NULL, \
442                                 NULL, \
443                                 MODULE_MAGIC_COOKIE
444
445 /** @} */
446
447 /* CONFIGURATION VECTOR FUNCTIONS */
448
449 /** configuration vector structure */
450 typedef struct ap_conf_vector_t ap_conf_vector_t;
451
452 /**
453  * Generic accessors for other modules to get at their own module-specific
454  * data
455  * @param cv The vector in which the modules configuration is stored.
456  *        usually r->per_dir_config or s->module_config
457  * @param m The module to get the data for.
458  * @return The module-specific data
459  */
460 AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
461                                         const module *m);
462
463 /**
464  * Generic accessors for other modules to set at their own module-specific
465  * data
466  * @param cv The vector in which the modules configuration is stored.
467  *        usually r->per_dir_config or s->module_config
468  * @param m The module to set the data for.
469  * @param val The module-specific data to set
470  */
471 AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
472                                       void *val);
473
474 #if !defined(AP_DEBUG)
475
476 #define ap_get_module_config(v,m)       \
477     (((void **)(v))[(m)->module_index])
478 #define ap_set_module_config(v,m,val)   \
479     ((((void **)(v))[(m)->module_index]) = (val))
480
481 #endif /* AP_DEBUG */
482
483
484 /**
485  * Generic accessor for modules to get the module-specific loglevel
486  * @param s The server from which to get the loglevel.
487  * @param index The module_index of the module to get the loglevel for.
488  * @return The module-specific loglevel
489  */
490 AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int index);
491
492 /**
493  * Generic accessor for modules the module-specific loglevel
494  * @param c The connection from which to get the loglevel.
495  * @param index The module_index of the module to get the loglevel for.
496  * @return The module-specific loglevel
497  */
498 AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int index);
499
500 /**
501  * Generic accessor for modules to get the module-specific loglevel
502  * @param r The request from which to get the loglevel.
503  * @param index The module_index of the module to get the loglevel for.
504  * @return The module-specific loglevel
505  */
506 AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int index);
507
508 /**
509  * Accessor to set module-specific loglevel
510  * @param p A pool
511  * @param s The server for which to set the loglevel.
512  * @param index The module_index of the module to set the loglevel for.
513  * @param level The new log level
514  * @return The module-specific loglevel
515  */
516 AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, struct ap_logconf *l,
517                                         int index, int level);
518
519 #if !defined(AP_DEBUG)
520
521 #define ap_get_conn_logconf(c)                     \
522     ((c)->log             ? (c)->log             : \
523      &(c)->base_server->log)
524
525 #define ap_get_request_logconf(r)                  \
526     ((r)->log             ? (r)->log             : \
527      (r)->connection->log ? (r)->connection->log : \
528      &(r)->server->log)
529
530 #define ap_get_module_loglevel(l,i)                                     \
531     (((i) < 0 || (l)->module_levels == NULL || (l)->module_levels[i] < 0) ?  \
532      (l)->level :                                                         \
533      (l)->module_levels[i])
534
535 #define ap_get_server_module_loglevel(s,i)  \
536     (ap_get_module_loglevel(&(s)->log,i))
537
538 #define ap_get_conn_module_loglevel(c,i)  \
539     (ap_get_module_loglevel(ap_get_conn_logconf(c),i))
540
541 #define ap_get_request_module_loglevel(r,i)  \
542     (ap_get_module_loglevel(ap_get_request_logconf(r),i))
543
544 #endif /* AP_DEBUG */
545
546 /**
547  * Set all module-specific loglevels to val
548  * @param l The log config for which to set the loglevels.
549  * @param val the value to set all loglevels to
550  */
551 AP_DECLARE(void) ap_reset_module_loglevels(struct ap_logconf *l, int val);
552
553 /**
554  * Generic command handling function for strings
555  * @param cmd The command parameters for this directive
556  * @param struct_ptr pointer into a given type
557  * @param arg The argument to the directive
558  * @return An error string or NULL on success
559  */
560 AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd, 
561                                                    void *struct_ptr,
562                                                    const char *arg);
563
564 /**
565  * Generic command handling function for integers
566  * @param cmd The command parameters for this directive
567  * @param struct_ptr pointer into a given type
568  * @param arg The argument to the directive
569  * @return An error string or NULL on success
570  */
571 AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd, 
572                                                 void *struct_ptr,
573                                                 const char *arg);
574
575 /**
576  * Parsing function for log level
577  * @param str The string to parse
578  * @param val The parsed log level
579  * @return An error string or NULL on success
580  */
581 AP_DECLARE(const char *) ap_parse_log_level(const char *str, int *val);
582
583 /**
584  * Return true if the specified method is limited by being listed in
585  * a &lt;Limit&gt; container, or by *not* being listed in a &lt;LimitExcept&gt;
586  * container.
587  *
588  * @param   method  Pointer to a string specifying the method to check.
589  * @param   cmd     Pointer to the cmd_parms structure passed to the
590  *                  directive handler.
591  * @return  0 if the method is not limited in the current scope
592  */
593 AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method);
594
595 /**
596  * Generic command handling function for strings, always sets the value
597  * to a lowercase string
598  * @param cmd The command parameters for this directive
599  * @param struct_ptr pointer into a given type
600  * @param arg The argument to the directive
601  * @return An error string or NULL on success
602  */
603 AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd, 
604                                                          void *struct_ptr, 
605                                                          const char *arg);
606 /**
607  * Generic command handling function for flags
608  * @param cmd The command parameters for this directive
609  * @param struct_ptr pointer into a given type
610  * @param arg The argument to the directive (either 1 or 0)
611  * @return An error string or NULL on success
612  */
613 AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd, 
614                                                  void *struct_ptr, 
615                                                  int arg);
616 /**
617  * Generic command handling function for files
618  * @param cmd The command parameters for this directive
619  * @param struct_ptr pointer into a given type
620  * @param arg The argument to the directive
621  * @return An error string or NULL on success
622  */
623 AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, 
624                                                  void *struct_ptr, 
625                                                  const char *arg);
626 /**
627  * Generic command handling function to respond with cmd->help as an error
628  * @param cmd The command parameters for this directive
629  * @param struct_ptr pointer into a given type
630  * @param arg The argument to the directive
631  * @return The cmd->help value as the error string
632  * @note This allows simple declarations such as:
633  * @code
634  *     AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL, 
635  *         "The Foo directive is no longer supported, use Bar"),
636  * @endcode
637  */
638 AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd, 
639                                                   void *struct_ptr, 
640                                                   const char *arg);
641 /**
642  * For modules which need to read config files, open logs, etc. this returns
643  * the canonical form of fname made absolute to ap_server_root.
644  * @param p pool to allocate data from
645  * @param fname The file name
646  */
647 AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
648
649 /* Finally, the hook for dynamically loading modules in... */
650
651 /**
652  * Add a module to the server
653  * @param m The module structure of the module to add
654  * @param p The pool of the same lifetime as the module
655  */
656 AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p);
657
658 /**
659  * Remove a module from the server.  There are some caveats:
660  * when the module is removed, its slot is lost so all the current
661  * per-dir and per-server configurations are invalid. So we should
662  * only ever call this function when you are invalidating almost
663  * all our current data. I.e. when doing a restart.
664  * @param m the module structure of the module to remove
665  */
666 AP_DECLARE(void) ap_remove_module(module *m);
667 /**
668  * Add a module to the chained modules list and the list of loaded modules
669  * @param mod The module structure of the module to add
670  * @param p The pool with the same lifetime as the module
671  */
672 AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p);
673 /**
674  * Remove a module fromthe chained modules list and the list of loaded modules
675  * @param mod the module structure of the module to remove
676  */
677 AP_DECLARE(void) ap_remove_loaded_module(module *mod);
678 /**
679  * Find the name of the specified module
680  * @param m The module to get the name for
681  * @return the name of the module
682  */
683 AP_DECLARE(const char *) ap_find_module_name(module *m);
684 /**
685  * Find a module based on the name of the module
686  * @param name the name of the module
687  * @return the module structure if found, NULL otherwise
688  */
689 AP_DECLARE(module *) ap_find_linked_module(const char *name);
690
691 /**
692  * Open a ap_configfile_t as apr_file_t
693  * @param ret_cfg open ap_configfile_t struct pointer
694  * @param p The pool to allocate the structure from
695  * @param name the name of the file to open
696  */
697 AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg, 
698                                           apr_pool_t *p, const char *name);
699
700 /**
701  * Allocate a ap_configfile_t handle with user defined functions and params 
702  * @param p The pool to allocate from
703  * @param descr The name of the file
704  * @param param The argument passed to getch/getstr/close
705  * @param getc_func The getch function
706  * @param gets_func The getstr function
707  * @param close_func The close function
708  */
709 AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p, 
710     const char *descr,
711     void *param,
712     int(*getc_func)(void*),
713     void *(*gets_func) (void *buf, size_t bufsiz, void *param),
714     int(*close_func)(void *param));
715
716 /**
717  * Read one line from open ap_configfile_t, strip LF, increase line number
718  * @param buf place to store the line read
719  * @param bufsize size of the buffer
720  * @param cfp File to read from
721  * @return 1 on success, 0 on failure
722  */
723 AP_DECLARE(int) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp);
724
725 /**
726  * Read one char from open configfile_t, increase line number upon LF 
727  * @param cfp The file to read from
728  * @return the character read
729  */
730 AP_DECLARE(int) ap_cfg_getc(ap_configfile_t *cfp);
731
732 /**
733  * Detach from open ap_configfile_t, calling the close handler
734  * @param cfp The file to close
735  * @return 1 on sucess, 0 on failure
736  */
737 AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp);
738
739 /**
740  * Read all data between the current &lt;foo&gt; and the matching &lt;/foo&gt;.  All
741  * of this data is forgotten immediately.  
742  * @param cmd The cmd_parms to pass to the directives inside the container
743  * @param directive The directive name to read until
744  * @return Error string on failure, NULL on success
745  */
746 AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive);
747
748 /**
749  * Read all data between the current &lt;foo&gt; and the matching &lt;/foo&gt; and build
750  * a config tree from it
751  * @param p pool to allocate from
752  * @param temp_pool Temporary pool to allocate from
753  * @param parms The cmd_parms to pass to all directives read
754  * @param current The current node in the tree
755  * @param curr_parent The current parent node
756  * @param orig_directive The directive to read until hit.
757  * @return Error string on failure, NULL on success
758 */
759 AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p, 
760                                               apr_pool_t *temp_pool,
761                                               cmd_parms *parms,
762                                               ap_directive_t **current,
763                                               ap_directive_t **curr_parent,
764                                               char *orig_directive);
765
766 /**
767  * Build a config tree from a config file
768  * @param parms The cmd_parms to pass to all of the directives in the file
769  * @param conf_pool The pconf pool
770  * @param temp_pool The temporary pool
771  * @param conftree Place to store the root node of the config tree
772  * @return Error string on erro, NULL otherwise
773  */
774 AP_DECLARE(const char *) ap_build_config(cmd_parms *parms,
775                                          apr_pool_t *conf_pool,
776                                          apr_pool_t *temp_pool,
777                                          ap_directive_t **conftree);
778
779 /**
780  * Walk a config tree and setup the server's internal structures
781  * @param conftree The config tree to walk
782  * @param parms The cmd_parms to pass to all functions
783  * @param section_vector The per-section config vector.
784  * @return Error string on error, NULL otherwise
785  */
786 AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree,
787                                         cmd_parms *parms,
788                                         ap_conf_vector_t *section_vector);
789
790 /**
791  * @defgroup ap_check_cmd_context Check command context
792  * @{
793  */
794 /**
795  * Check the context a command is used in.
796  * @param cmd The command to check
797  * @param forbidden Where the command is forbidden.
798  * @return Error string on error, NULL on success
799  */
800 AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd, 
801                                               unsigned forbidden);
802
803 #define  NOT_IN_VIRTUALHOST     0x01 /**< Forbidden in &lt;VirtualHost&gt; */
804 #define  NOT_IN_LIMIT           0x02 /**< Forbidden in &lt;Limit&gt; */
805 #define  NOT_IN_DIRECTORY       0x04 /**< Forbidden in &lt;Directory&gt; */
806 #define  NOT_IN_LOCATION        0x08 /**< Forbidden in &lt;Location&gt; */
807 #define  NOT_IN_FILES           0x10 /**< Forbidden in &lt;Files&gt; */
808 /** Forbidden in &lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt;*/
809 #define  NOT_IN_DIR_LOC_FILE    (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) 
810 /** Forbidden in &lt;VirtualHost&gt;/&lt;Limit&gt;/&lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt; */
811 #define  GLOBAL_ONLY            (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE) 
812
813 /** @} */
814
815 /**
816  * @brief This structure is used to assign symbol names to module pointers
817  */
818 typedef struct {
819     const char *name;
820     module *modp;
821 } ap_module_symbol_t;
822
823 /**
824  * The topmost module in the list
825  * @var module *ap_top_module
826  */
827 AP_DECLARE_DATA extern module *ap_top_module;
828
829 /**
830  * Array of all statically linked modules
831  * @var module *ap_prelinked_modules[]
832  */
833 AP_DECLARE_DATA extern module *ap_prelinked_modules[];
834 /**
835  * Array of all statically linked modulenames (symbols)
836  * @var ap_module_symbol_t ap_prelinked_module_symbols[]
837  */
838 AP_DECLARE_DATA extern ap_module_symbol_t ap_prelinked_module_symbols[];
839 /**
840  * Array of all preloaded modules
841  * @var module *ap_preloaded_modules[]
842  */
843 AP_DECLARE_DATA extern module *ap_preloaded_modules[];
844 /**
845  * Array of all loaded modules
846  * @var module **ap_loaded_modules
847  */
848 AP_DECLARE_DATA extern module **ap_loaded_modules;
849
850 /* For mod_so.c... */
851 /** Run a single module's two create_config hooks
852  *  @param p the pool to allocate from
853  *  @param s The server to configure for.
854  *  @param m The module to configure
855  */
856 AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s, 
857                                             module *m);
858
859 /* For http_main.c... */
860 /**
861  * Add all of the prelinked modules into the loaded module list
862  * @param process The process that is currently running the server
863  */
864 AP_DECLARE(const char *) ap_setup_prelinked_modules(process_rec *process);
865
866 /**
867  * Show the preloaded configuration directives, the help string explaining
868  * the directive arguments, in what module they are handled, and in
869  * what parts of the configuration they are allowed.  Used for httpd -h.
870  */
871 AP_DECLARE(void) ap_show_directives(void);
872
873 /** 
874  * Show the preloaded module names.  Used for httpd -l. 
875  */
876 AP_DECLARE(void) ap_show_modules(void);
877
878 /** 
879  * Show the MPM name.  Used in reporting modules such as mod_info to
880  * provide extra information to the user
881  */
882 AP_DECLARE(const char *) ap_show_mpm(void);
883
884 /**
885  * Read all config files and setup the server
886  * @param process The process running the server
887  * @param temp_pool A pool to allocate temporary data from.
888  * @param config_name The name of the config file
889  * @param conftree Place to store the root of the config tree
890  * @return The setup server_rec list.
891  */
892 AP_DECLARE(server_rec *) ap_read_config(process_rec *process, 
893                                         apr_pool_t *temp_pool, 
894                                         const char *config_name, 
895                                         ap_directive_t **conftree);
896
897 /**
898  * Run all rewrite args hooks for loaded modules
899  * @param process The process currently running the server
900  */
901 AP_DECLARE(void) ap_run_rewrite_args(process_rec *process);
902
903 /**
904  * Run the register hooks function for a specified module
905  * @param m The module to run the register hooks function fo
906  * @param p The pool valid for the lifetime of the module
907  */
908 AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p);
909
910 /**
911  * Setup all virtual hosts
912  * @param p The pool to allocate from
913  * @param main_server The head of the server_rec list
914  */
915 AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, 
916                                         server_rec *main_server);
917
918 /* For http_request.c... */
919
920 /**
921  * Setup the config vector for a request_rec
922  * @param p The pool to allocate the config vector from
923  * @return The config vector
924  */
925 AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p);
926
927 /**
928  * Setup the config vector for per dir module configs
929  * @param p The pool to allocate the config vector from
930  * @return The config vector
931  */
932 AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p);
933
934 /**
935  * Run all of the modules merge per dir config functions
936  * @param p The pool to pass to the merge functions
937  * @param base The base directory config structure
938  * @param new_conf The new directory config structure
939  */
940 AP_CORE_DECLARE(ap_conf_vector_t*) ap_merge_per_dir_configs(apr_pool_t *p,
941                                            ap_conf_vector_t *base,
942                                            ap_conf_vector_t *new_conf);
943
944 /**
945  * Allocate new ap_logconf and make (deep) copy of old ap_logconf
946  * @param p The pool to alloc from
947  * @param old The ap_logconf to copy (may be NULL)
948  * @return The new ap_logconf struct
949  */
950 AP_DECLARE(struct ap_logconf *) ap_new_log_config(apr_pool_t *p,
951                                                   const struct ap_logconf *old);
952
953 /**
954  * Merge old ap_logconf into new ap_logconf.
955  * old and new must have the same life time.
956  * @param old The ap_logconf to merge from
957  * @param new The ap_logconf to merge into
958  */
959 AP_DECLARE(void) ap_merge_log_config(const struct ap_logconf *old,
960                                      struct ap_logconf *new);
961
962 /* For http_connection.c... */
963 /**
964  * Setup the config vector for a connection_rec
965  * @param p The pool to allocate the config vector from
966  * @return The config vector
967  */
968 AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_conn_config(apr_pool_t *p);
969
970 /* For http_core.c... (&lt;Directory&gt; command and virtual hosts) */
971
972 /**
973  * parse an htaccess file
974  * @param result htaccess_result
975  * @param r The request currently being served
976  * @param override Which overrides are active
977  * @param override_opts Which allow-override-opts bits are set
978  * @param path The path to the htaccess file
979  * @param access_name The list of possible names for .htaccess files
980  * int The status of the current request
981  */
982 AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result, 
983                                        request_rec *r,
984                                        int override,
985                                        int override_opts,
986                                        const char *path, 
987                                        const char *access_name);
988
989 /**
990  * Setup a virtual host
991  * @param p The pool to allocate all memory from
992  * @param hostname The hostname of the virtual hsot
993  * @param main_server The main server for this Apache configuration
994  * @param ps Place to store the new server_rec
995  * return Error string on error, NULL on success
996  */
997 AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p, 
998                                                    const char *hostname,
999                                                    server_rec *main_server, 
1000                                                    server_rec **ps);
1001
1002 /**
1003  * Process a config file for Apache
1004  * @param s The server rec to use for the command parms
1005  * @param fname The name of the config file
1006  * @param conftree The root node of the created config tree
1007  * @param p Pool for general allocation
1008  * @param ptemp Pool for temporary allocation
1009  */
1010 AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
1011                                                     const char *fname,
1012                                                     ap_directive_t **conftree,
1013                                                     apr_pool_t *p,
1014                                                     apr_pool_t *ptemp);
1015
1016 /**
1017  * Process all matching files as Apache configs
1018  * @param s The server rec to use for the command parms
1019  * @param fname The filename pattern of the config file
1020  * @param conftree The root node of the created config tree
1021  * @param p Pool for general allocation
1022  * @param ptemp Pool for temporary allocation
1023  * @param optional Whether a no-match wildcard is allowed
1024  * @see apr_fnmatch for pattern handling
1025  */
1026 AP_DECLARE(const char *) ap_process_fnmatch_configs(server_rec *s,
1027                                                     const char *fname,
1028                                                     ap_directive_t **conftree,
1029                                                     apr_pool_t *p,
1030                                                     apr_pool_t *ptemp,
1031                                                     int optional);
1032
1033 /**
1034  * Process all directives in the config tree
1035  * @param s The server rec to use in the command parms
1036  * @param conftree The config tree to process
1037  * @param p The pool for general allocation
1038  * @param ptemp The pool for temporary allocations
1039  * @return OK if no problems
1040  */
1041 AP_DECLARE(int) ap_process_config_tree(server_rec *s,
1042                                        ap_directive_t *conftree,
1043                                        apr_pool_t *p,
1044                                        apr_pool_t *ptemp);
1045
1046 /**
1047  * Store data which will be retained across unload/load of modules
1048  * @param key The unique key associated with this module's retained data
1049  * @param size in bytes of the retained data (to be allocated)
1050  * @return Address of new retained data structure, initially cleared
1051  */
1052 AP_DECLARE(void *) ap_retained_data_create(const char *key, apr_size_t size);
1053
1054 /**
1055  * Retrieve data which was stored by ap_retained_data_create()
1056  * @param key The unique key associated with this module's retained data
1057  * @return Address of previously retained data structure, or NULL if not yet saved
1058  */
1059 AP_DECLARE(void *) ap_retained_data_get(const char *key);
1060     
1061 /* Module-method dispatchers, also for http_request.c */
1062 /**
1063  * Run the handler phase of each module until a module accepts the
1064  * responsibility of serving the request
1065  * @param r The current request
1066  * @return The status of the current request
1067  */
1068 AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r);
1069
1070 /* for mod_perl */
1071
1072 /**
1073  * Find a given directive in a command_rec table
1074  * @param name The directive to search for
1075  * @param cmds The table to search
1076  * @return The directive definition of the specified directive
1077  */
1078 AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name, 
1079                                                      const command_rec *cmds);
1080
1081 /**
1082  * Find a given directive in a list module
1083  * @param cmd_name The directive to search for
1084  * @param mod The module list to search
1085  * @return The directive definition of the specified directive
1086  */
1087 AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name, 
1088                                                                 module **mod);
1089
1090 /**
1091  * Ask a module to create per-server and per-section (dir/loc/file) configs
1092  * (if it hasn't happened already). The results are stored in the server's
1093  * config, and the specified per-section config vector.
1094  * @param server The server to operate upon.
1095  * @param section_vector The per-section config vector.
1096  * @param section Which section to create a config for.
1097  * @param mod The module which is defining the config data.
1098  * @param pconf A pool for all configuration allocations.
1099  * @return The (new) per-section config data.
1100  */
1101 AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server,
1102                                               ap_conf_vector_t *section_vector,
1103                                               const char *section,
1104                                               module *mod, apr_pool_t *pconf);
1105
1106   /* Hooks */
1107
1108 /**
1109  * Run the header parser functions for each module
1110  * @param r The current request
1111  * @return OK or DECLINED
1112  */
1113 AP_DECLARE_HOOK(int,header_parser,(request_rec *r))
1114
1115 /**
1116  * Run the pre_config function for each module
1117  * @param pconf The config pool
1118  * @param plog The logging streams pool
1119  * @param ptemp The temporary pool
1120  * @return OK or DECLINED on success anything else is a error
1121  */
1122 AP_DECLARE_HOOK(int,pre_config,(apr_pool_t *pconf,apr_pool_t *plog,
1123                                 apr_pool_t *ptemp))
1124
1125 /**
1126  * Run the check_config function for each module
1127  * @param pconf The config pool
1128  * @param plog The logging streams pool
1129  * @param ptemp The temporary pool
1130  * @param s the server to operate upon
1131  * @return OK or DECLINED on success anything else is a error
1132  */
1133 AP_DECLARE_HOOK(int,check_config,(apr_pool_t *pconf, apr_pool_t *plog,
1134                                   apr_pool_t *ptemp, server_rec *s))
1135
1136 /**
1137  * Run the test_config function for each module; this hook is run
1138  * only if the server was invoked to test the configuration syntax.
1139  * @param pconf The config pool
1140  * @param s The list of server_recs
1141  */
1142 AP_DECLARE_HOOK(void,test_config,(apr_pool_t *pconf, server_rec *s))
1143
1144 /**
1145  * Run the post_config function for each module
1146  * @param pconf The config pool
1147  * @param plog The logging streams pool
1148  * @param ptemp The temporary pool
1149  * @param s The list of server_recs
1150  * @return OK or DECLINED on success anything else is a error
1151  */
1152 AP_DECLARE_HOOK(int,post_config,(apr_pool_t *pconf,apr_pool_t *plog,
1153                                  apr_pool_t *ptemp,server_rec *s))
1154
1155 /**
1156  * Run the open_logs functions for each module
1157  * @param pconf The config pool
1158  * @param plog The logging streams pool
1159  * @param ptemp The temporary pool
1160  * @param s The list of server_recs
1161  * @return OK or DECLINED on success anything else is a error
1162  */
1163 AP_DECLARE_HOOK(int,open_logs,(apr_pool_t *pconf,apr_pool_t *plog,
1164                                apr_pool_t *ptemp,server_rec *s))
1165
1166 /**
1167  * Run the child_init functions for each module
1168  * @param pchild The child pool
1169  * @param s The list of server_recs in this server 
1170  */
1171 AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s))
1172
1173 /**
1174  * Run the handler functions for each module
1175  * @param r The request_rec
1176  * @remark non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST
1177  */
1178 AP_DECLARE_HOOK(int,handler,(request_rec *r))
1179
1180 /**
1181  * Run the quick handler functions for each module. The quick_handler
1182  * is run before any other requests hooks are called (location_walk,
1183  * directory_walk, access checking, et. al.). This hook was added
1184  * to provide a quick way to serve content from a URI keyed cache.
1185  * 
1186  * @param r The request_rec
1187  * @param lookup_uri Controls whether the caller actually wants content or not.
1188  * lookup is set when the quick_handler is called out of 
1189  * ap_sub_req_lookup_uri()
1190  */
1191 AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri))
1192
1193 /**
1194  * Retrieve the optional functions for each module.
1195  * This is run immediately before the server starts. Optional functions should
1196  * be registered during the hook registration phase.
1197  */
1198 AP_DECLARE_HOOK(void,optional_fn_retrieve,(void))
1199
1200 #ifdef __cplusplus
1201 }
1202 #endif
1203
1204 #endif  /* !APACHE_HTTP_CONFIG_H */
1205 /** @} */