]> granicus.if.org Git - apache/blob - include/http_config.h
Use correct Doxygen keywords for functions and variables. TODO: figure out whether...
[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
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /*
37  * The central data structures around here...
38  */
39
40 /* Command dispatch structures... */
41
42 /**
43  * How the directives arguments should be parsed.
44  * @remark Note that for all of these except RAW_ARGS, the config routine is
45  *      passed a freshly allocated string which can be modified or stored
46  *      or whatever...
47  */
48 enum cmd_how {
49     RAW_ARGS,                   /**< cmd_func parses command line itself */
50     TAKE1,                      /**< one argument only */
51     TAKE2,                      /**< two arguments only */
52     ITERATE,                    /**< one argument, occuring multiple times
53                                  * (e.g., IndexIgnore)
54                                  */
55     ITERATE2,                   /**< two arguments, 2nd occurs multiple times
56                                  * (e.g., AddIcon)
57                                  */
58     FLAG,                       /**< One of 'On' or 'Off' */
59     NO_ARGS,                    /**< No args at all, e.g. &lt;/Directory&gt; */
60     TAKE12,                     /**< one or two arguments */
61     TAKE3,                      /**< three arguments only */
62     TAKE23,                     /**< two or three arguments */
63     TAKE123,                    /**< one, two or three arguments */
64     TAKE13,                     /**< one or three arguments */
65     TAKE_ARGV                   /**< an argc and argv are passed */
66 };
67 /**
68  * This structure is passed to a command which is being invoked,
69  * to carry a large variety of miscellaneous data which is all of
70  * use to *somebody*...
71  */
72 typedef struct cmd_parms_struct cmd_parms;
73
74 #if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN)
75
76 /** 
77  * All the types of functions that can be used in directives
78  * @internal
79  */
80 typedef union {
81     /** function to call for a no-args */
82     const char *(*no_args) (cmd_parms *parms, void *mconfig);
83     /** function to call for a raw-args */
84     const char *(*raw_args) (cmd_parms *parms, void *mconfig,
85                              const char *args);
86     /** function to call for a argv/argc */
87     const char *(*take_argv) (cmd_parms *parms, void *mconfig,
88                              int argc, char *const argv[]);
89     /** function to call for a take1 */
90     const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w);
91     /** function to call for a take2 */
92     const char *(*take2) (cmd_parms *parms, void *mconfig, const char *w,
93                           const char *w2);
94     /** function to call for a take3 */
95     const char *(*take3) (cmd_parms *parms, void *mconfig, const char *w,
96                           const char *w2, const char *w3);
97     /** function to call for a flag */
98     const char *(*flag) (cmd_parms *parms, void *mconfig, int on);
99 } cmd_func;
100
101 /** This configuration directive does not take any arguments */
102 # define AP_NO_ARGS     func.no_args
103 /** This configuration directive will handle it's own parsing of arguments*/
104 # define AP_RAW_ARGS    func.raw_args
105 /** This configuration directive will handle it's own parsing of arguments*/
106 # define AP_TAKE_ARGV   func.take_argv
107 /** This configuration directive takes 1 argument*/
108 # define AP_TAKE1       func.take1
109 /** This configuration directive takes 2 arguments */
110 # define AP_TAKE2       func.take2
111 /** This configuration directive takes 3 arguments */
112 # define AP_TAKE3       func.take3
113 /** This configuration directive takes a flag (on/off) as a argument*/
114 # define AP_FLAG        func.flag
115
116 /** method of declaring a directive with no arguments */
117 # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
118     { directive, { .no_args=func }, mconfig, where, RAW_ARGS, help }
119 /** method of declaring a directive with raw argument parsing */
120 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
121     { directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help }
122 /** method of declaring a directive with raw argument parsing */
123 # define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
124     { directive, { .take_argv=func }, mconfig, where, TAKE_ARGV, help }
125 /** method of declaring a directive which takes 1 argument */
126 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
127     { directive, { .take1=func }, mconfig, where, TAKE1, help }
128 /** method of declaring a directive which takes multiple arguments */
129 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
130     { directive, { .take1=func }, mconfig, where, ITERATE, help }
131 /** method of declaring a directive which takes 2 arguments */
132 # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
133     { directive, { .take2=func }, mconfig, where, TAKE2, help }
134 /** method of declaring a directive which takes 1 or 2 arguments */
135 # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
136     { directive, { .take2=func }, mconfig, where, TAKE12, help }
137 /** method of declaring a directive which takes multiple 2 arguments */
138 # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
139     { directive, { .take2=func }, mconfig, where, ITERATE2, help }
140 /** method of declaring a directive which takes 1 or 3 arguments */
141 # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
142     { directive, { .take3=func }, mconfig, where, TAKE13, help }
143 /** method of declaring a directive which takes 2 or 3 arguments */
144 # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
145     { directive, { .take3=func }, mconfig, where, TAKE23, help }
146 /** method of declaring a directive which takes 1 to 3 arguments */
147 # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
148     { directive, { .take3=func }, mconfig, where, TAKE123, help }
149 /** method of declaring a directive which takes 3 arguments */
150 # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
151     { directive, { .take3=func }, mconfig, where, TAKE3, help }
152 /** method of declaring a directive which takes a flag (on/off) as a argument*/
153 # define AP_INIT_FLAG(directive, func, mconfig, where, help) \
154     { directive, { .flag=func }, mconfig, where, FLAG, help }
155
156 #else /* AP_HAVE_DESIGNATED_INITIALIZER */
157
158 typedef const char *(*cmd_func) ();
159
160 # define AP_NO_ARGS  func
161 # define AP_RAW_ARGS func
162 # define AP_TAKE_ARGV func
163 # define AP_TAKE1    func
164 # define AP_TAKE2    func
165 # define AP_TAKE3    func
166 # define AP_FLAG     func
167
168 # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
169     { directive, func, mconfig, where, RAW_ARGS, help }
170 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
171     { directive, func, mconfig, where, RAW_ARGS, help }
172 # define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
173     { directive, func, mconfig, where, TAKE_ARGV, help }
174 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
175     { directive, func, mconfig, where, TAKE1, help }
176 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
177     { directive, func, mconfig, where, ITERATE, help }
178 # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
179     { directive, func, mconfig, where, TAKE2, help }
180 # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
181     { directive, func, mconfig, where, TAKE12, help }
182 # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
183     { directive, func, mconfig, where, ITERATE2, help }
184 # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
185     { directive, func, mconfig, where, TAKE13, help }
186 # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
187     { directive, func, mconfig, where, TAKE23, help }
188 # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
189     { directive, func, mconfig, where, TAKE123, help }
190 # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
191     { directive, func, mconfig, where, TAKE3, help }
192 # define AP_INIT_FLAG(directive, func, mconfig, where, help) \
193     { directive, func, mconfig, where, FLAG, help }
194
195 #endif /* AP_HAVE_DESIGNATED_INITIALIZER */
196
197 /**
198  * The command record structure.  Each modules can define a table of these
199  * to define the directives it will implement.
200  */
201 typedef struct command_struct command_rec; 
202 struct command_struct {
203     /** Name of this command */
204     const char *name;
205     /** The function to be called when this directive is parsed */
206     cmd_func func;
207     /** Extra data, for functions which implement multiple commands... */
208     void *cmd_data;             
209     /** What overrides need to be allowed to enable this command. */
210     int req_override;
211     /** What the command expects as arguments */
212     enum cmd_how args_how;
213
214     /** 'usage' message, in case of syntax errors */
215     const char *errmsg;
216 };
217
218 /**
219  * @defgroup ConfigDirectives Allowed locations for configuration directives.
220  *
221  * The allowed locations for a configuration directive are the union of
222  * those indicated by each set bit in the req_override mask.
223  *
224  * @{
225  */
226 #define OR_NONE 0             /**< *.conf is not available anywhere in this override */
227 #define OR_LIMIT 1           /**< *.conf inside &lt;Directory&gt; or &lt;Location&gt;
228                                 and .htaccess when AllowOverride Limit */
229 #define OR_OPTIONS 2         /**< *.conf anywhere
230                                 and .htaccess when AllowOverride Options */
231 #define OR_FILEINFO 4        /**< *.conf anywhere
232                                 and .htaccess when AllowOverride FileInfo */
233 #define OR_AUTHCFG 8         /**< *.conf inside &lt;Directory&gt; or &lt;Location&gt;
234                                 and .htaccess when AllowOverride AuthConfig */
235 #define OR_INDEXES 16        /**< *.conf anywhere
236                                 and .htaccess when AllowOverride Indexes */
237 #define OR_UNSET 32          /**< unset a directive (in Allow) */
238 #define ACCESS_CONF 64       /**< *.conf inside &lt;Directory&gt; or &lt;Location&gt; */
239 #define RSRC_CONF 128        /**< *.conf outside &lt;Directory&gt; or &lt;Location&gt; */
240 #define EXEC_ON_READ 256     /**< force directive to execute a command 
241                 which would modify the configuration (like including another
242                 file, or IFModule */
243 /** this directive can be placed anywhere */
244 #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
245
246 /** @} */
247
248 /**
249  * This can be returned by a function if they don't wish to handle
250  * a command. Make it something not likely someone will actually use
251  * as an error code.
252  */
253 #define DECLINE_CMD "\a\b"
254
255 /** Common structure for reading of config files / passwd files etc. */
256 typedef struct ap_configfile_t ap_configfile_t;
257 struct ap_configfile_t {
258     int (*getch) (void *param);     /**< a getc()-like function */
259     void *(*getstr) (void *buf, size_t bufsiz, void *param);
260                                     /**< a fgets()-like function */
261     int (*close) (void *param);     /**< a close handler function */
262     void *param;                    /**< the argument passed to getch/getstr/close */
263     const char *name;               /**< the filename / description */
264     unsigned line_number;           /**< current line number, starting at 1 */
265 };
266
267 /**
268  * This structure is passed to a command which is being invoked,
269  * to carry a large variety of miscellaneous data which is all of
270  * use to *somebody*...
271  */
272 struct cmd_parms_struct {
273     /** Argument to command from cmd_table */
274     void *info;
275     /** Which allow-override bits are set */
276     int override;
277     /** Which methods are &lt;Limit&gt;ed */
278     apr_int64_t limited;
279     /** methods which are limited */
280     apr_array_header_t *limited_xmethods;
281     /** methods which are xlimited */
282     ap_method_list_t *xlimited;
283
284     /** Config file structure. */
285     ap_configfile_t *config_file;
286     /** the directive specifying this command */
287     ap_directive_t *directive;
288
289     /** Pool to allocate new storage in */
290     apr_pool_t *pool;
291     /** Pool for scratch memory; persists during configuration, but 
292      *  wiped before the first request is served...  */
293     apr_pool_t *temp_pool;
294     /** Server_rec being configured for */
295     server_rec *server;
296     /** If configuring for a directory, pathname of that directory.  
297      *  NOPE!  That's what it meant previous to the existance of &lt;Files&gt;, 
298      * &lt;Location&gt; and regex matching.  Now the only usefulness that can be 
299      * derived from this field is whether a command is being called in a 
300      * server context (path == NULL) or being called in a dir context 
301      * (path != NULL).  */
302     char *path;
303     /** configuration command */
304     const command_rec *cmd;
305
306     /** per_dir_config vector passed to handle_command */
307     struct ap_conf_vector_t *context;
308     /** directive with syntax error */
309     const ap_directive_t *err_directive;
310
311     /** Which allow-override-opts bits are set */
312     int override_opts;
313 };
314
315 /**
316  * Module structures.  Just about everything is dispatched through
317  * these, directly or indirectly (through the command and handler
318  * tables).
319  */
320 typedef struct module_struct module;
321 struct module_struct {
322     /** API version, *not* module version; check that module is 
323      * compatible with this version of the server.
324      */
325     int version;
326     /** API minor version. Provides API feature milestones. Not checked 
327      *  during module init */
328     int minor_version;
329     /** Index to this modules structures in config vectors.  */
330     int module_index;
331
332     /** The name of the module's C file */
333     const char *name;
334     /** The handle for the DSO.  Internal use only */
335     void *dynamic_load_handle;
336
337     /** A pointer to the next module in the list
338      *  @var module_struct *next */
339     struct module_struct *next;
340
341     /** Magic Cookie to identify a module structure;  It's mainly 
342      *  important for the DSO facility (see also mod_so).  */
343     unsigned long magic;
344
345     /** Function to allow MPMs to re-write command line arguments.  This
346      *  hook is only available to MPMs.
347      *  @param The process that the server is running in.
348      */
349     void (*rewrite_args) (process_rec *process);
350     /** Function to allow all modules to create per directory configuration
351      *  structures.
352      *  @param p The pool to use for all allocations.
353      *  @param dir The directory currently being processed.
354      *  @return The per-directory structure created
355      */
356     void *(*create_dir_config) (apr_pool_t *p, char *dir);
357     /** Function to allow all modules to merge the per directory configuration
358      *  structures for two directories.
359      *  @param p The pool to use for all allocations.
360      *  @param base_conf The directory structure created for the parent directory.
361      *  @param new_conf The directory structure currently being processed.
362      *  @return The new per-directory structure created
363      */
364     void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf);
365     /** Function to allow all modules to create per server configuration
366      *  structures.
367      *  @param p The pool to use for all allocations.
368      *  @param s The server currently being processed.
369      *  @return The per-server structure created
370      */
371     void *(*create_server_config) (apr_pool_t *p, server_rec *s);
372     /** Function to allow all modules to merge the per server configuration
373      *  structures for two servers.
374      *  @param p The pool to use for all allocations.
375      *  @param base_conf The directory structure created for the parent directory.
376      *  @param new_conf The directory structure currently being processed.
377      *  @return The new per-directory structure created
378      */
379     void *(*merge_server_config) (apr_pool_t *p, void *base_conf, 
380                                   void *new_conf);
381
382     /** A command_rec table that describes all of the directives this module
383      * defines. */
384     const command_rec *cmds;
385
386     /** A hook to allow modules to hook other points in the request processing.
387      *  In this function, modules should call the ap_hook_*() functions to
388      *  register an interest in a specific step in processing the current
389      *  request.
390      *  @param p the pool to use for all allocations
391      */
392     void (*register_hooks) (apr_pool_t *p);
393 };
394
395 /**
396  * @defgroup ModuleInit Module structure initializers
397  *
398  * Initializer for the first few module slots, which are only
399  * really set up once we start running.  Note that the first two slots
400  * provide a version check; this should allow us to deal with changes to
401  * the API. The major number should reflect changes to the API handler table
402  * itself or removal of functionality. The minor number should reflect
403  * additions of functionality to the existing API. (the server can detect
404  * an old-format module, and either handle it back-compatibly, or at least
405  * signal an error). See src/include/ap_mmn.h for MMN version history.
406  * @{
407  */
408
409 /** The one used in Apache 1.3, which will deliberately cause an error */
410 #define STANDARD_MODULE_STUFF   this_module_needs_to_be_ported_to_apache_2_0
411
412 /** Use this in all standard modules */
413 #define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
414                                 MODULE_MAGIC_NUMBER_MINOR, \
415                                 -1, \
416                                 __FILE__, \
417                                 NULL, \
418                                 NULL, \
419                                 MODULE_MAGIC_COOKIE, \
420                                 NULL      /* rewrite args spot */
421
422 /** Use this only in MPMs */
423 #define MPM20_MODULE_STUFF      MODULE_MAGIC_NUMBER_MAJOR, \
424                                 MODULE_MAGIC_NUMBER_MINOR, \
425                                 -1, \
426                                 __FILE__, \
427                                 NULL, \
428                                 NULL, \
429                                 MODULE_MAGIC_COOKIE
430
431 /** @} */
432
433 /* CONFIGURATION VECTOR FUNCTIONS */
434
435 /** configuration vector structure */
436 typedef struct ap_conf_vector_t ap_conf_vector_t;
437
438 /**
439  * Generic accessors for other modules to get at their own module-specific
440  * data
441  * @param conf_vector The vector in which the modules configuration is stored.
442  *        usually r->per_dir_config or s->module_config
443  * @param m The module to get the data for.
444  * @return The module-specific data
445  */
446 AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
447                                         const module *m);
448
449 /**
450  * Generic accessors for other modules to set at their own module-specific
451  * data
452  * @param conf_vector The vector in which the modules configuration is stored.
453  *        usually r->per_dir_config or s->module_config
454  * @param m The module to set the data for.
455  * @param val The module-specific data to set
456  */
457 AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
458                                       void *val);
459
460 #if !defined(AP_DEBUG)
461
462 #define ap_get_module_config(v,m)       \
463     (((void **)(v))[(m)->module_index])
464 #define ap_set_module_config(v,m,val)   \
465     ((((void **)(v))[(m)->module_index]) = (val))
466
467 #endif /* AP_DEBUG */
468
469
470 /**
471  * Generic command handling function for strings
472  * @param cmd The command parameters for this directive
473  * @param struct_ptr pointer into a given type
474  * @param arg The argument to the directive
475  * @return An error string or NULL on success
476  */
477 AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd, 
478                                                    void *struct_ptr,
479                                                    const char *arg);
480
481 /**
482  * Generic command handling function for integers
483  * @param cmd The command parameters for this directive
484  * @param struct_ptr pointer into a given type
485  * @param arg The argument to the directive
486  * @return An error string or NULL on success
487  */
488 AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd, 
489                                                 void *struct_ptr,
490                                                 const char *arg);
491
492 /**
493  * Return true if the specified method is limited by being listed in
494  * a &lt;Limit&gt; container, or by *not* being listed in a &lt;LimitExcept&gt;
495  * container.
496  *
497  * @param   method  Pointer to a string specifying the method to check.
498  * @param   cmd     Pointer to the cmd_parms structure passed to the
499  *                  directive handler.
500  * @return  0 if the method is not limited in the current scope
501  */
502 AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method);
503
504 /**
505  * Generic command handling function for strings, always sets the value
506  * to a lowercase string
507  * @param cmd The command parameters for this directive
508  * @param struct_ptr pointer into a given type
509  * @param arg The argument to the directive
510  * @return An error string or NULL on success
511  */
512 AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd, 
513                                                          void *struct_ptr, 
514                                                          const char *arg);
515 /**
516  * Generic command handling function for flags
517  * @param cmd The command parameters for this directive
518  * @param struct_ptr pointer into a given type
519  * @param arg The argument to the directive (either 1 or 0)
520  * @return An error string or NULL on success
521  */
522 AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd, 
523                                                  void *struct_ptr, 
524                                                  int arg);
525 /**
526  * Generic command handling function for files
527  * @param cmd The command parameters for this directive
528  * @param struct_ptr pointer into a given type
529  * @param arg The argument to the directive
530  * @return An error string or NULL on success
531  */
532 AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, 
533                                                  void *struct_ptr, 
534                                                  const char *arg);
535 /**
536  * Generic command handling function to respond with cmd->help as an error
537  * @param cmd The command parameters for this directive
538  * @param struct_ptr pointer into a given type
539  * @param arg The argument to the directive
540  * @return The cmd->help value as the error string
541  * @tip This allows simple declarations such as;
542  * <pre>
543  *     AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL, 
544  *         "The Foo directive is no longer supported, use Bar"),
545  * </pre>
546  */
547 AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd, 
548                                                   void *struct_ptr, 
549                                                   const char *arg);
550 /**
551  * For modules which need to read config files, open logs, etc. this returns
552  * the canonical form of fname made absolute to ap_server_root.
553  * @param p pool to allocate data from
554  * @param fname The file name
555  */
556 AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
557
558 /* Finally, the hook for dynamically loading modules in... */
559
560 /**
561  * Add a module to the server
562  * @param m The module structure of the module to add
563  * @param p The pool of the same lifetime as the module
564  */
565 AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p);
566
567 /**
568  * Remove a module from the server.  There are some caveats:
569  * when the module is removed, its slot is lost so all the current
570  * per-dir and per-server configurations are invalid. So we should
571  * only ever call this function when you are invalidating almost
572  * all our current data. I.e. when doing a restart.
573  * @param m the module structure of the module to remove
574  */
575 AP_DECLARE(void) ap_remove_module(module *m);
576 /**
577  * Add a module to the chained modules list and the list of loaded modules
578  * @param m The module structure of the module to add
579  * @param p The pool with the same lifetime as the module
580  */
581 AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p);
582 /**
583  * Remove a module fromthe chained modules list and the list of loaded modules
584  * @param m the module structure of the module to remove
585  */
586 AP_DECLARE(void) ap_remove_loaded_module(module *mod);
587 /**
588  * Find the name of the specified module
589  * @param m The module to get the name for
590  * @return the name of the module
591  */
592 AP_DECLARE(const char *) ap_find_module_name(module *m);
593 /**
594  * Find a module based on the name of the module
595  * @param name the name of the module
596  * @return the module structure if found, NULL otherwise
597  */
598 AP_DECLARE(module *) ap_find_linked_module(const char *name);
599
600 /**
601  * Open a ap_configfile_t as apr_file_t
602  * @param ret_cfg open ap_configfile_t struct pointer
603  * @param p The pool to allocate the structure from
604  * @param name the name of the file to open
605  */
606 AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg, 
607                                           apr_pool_t *p, const char *name);
608
609 /**
610  * Allocate a ap_configfile_t handle with user defined functions and params 
611  * @param p The pool to allocate from
612  * @param descr The name of the file
613  * @param param The argument passed to getch/getstr/close
614  * @param getc_func The getch function
615  * @param gets_func The getstr function
616  * @param close_func The close function
617  */
618 AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p, 
619     const char *descr,
620     void *param,
621     int(*getc_func)(void*),
622     void *(*gets_func) (void *buf, size_t bufsiz, void *param),
623     int(*close_func)(void *param));
624
625 /**
626  * Read one line from open ap_configfile_t, strip LF, increase line number
627  * @param buf place to store the line read
628  * @param bufsize size of the buffer
629  * @param cfp File to read from
630  * @return 1 on success, 0 on failure
631  */
632 AP_DECLARE(int) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp);
633
634 /**
635  * Read one char from open configfile_t, increase line number upon LF 
636  * @param cfp The file to read from
637  * @return the character read
638  */
639 AP_DECLARE(int) ap_cfg_getc(ap_configfile_t *cfp);
640
641 /**
642  * Detach from open ap_configfile_t, calling the close handler
643  * @param cfp The file to close
644  * @return 1 on sucess, 0 on failure
645  */
646 AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp);
647
648 /**
649  * Read all data between the current &lt;foo&gt; and the matching &lt;/foo&gt;.  All
650  * of this data is forgotten immediately.  
651  * @param cmd The cmd_parms to pass to the directives inside the container
652  * @param directive The directive name to read until
653  * @return Error string on failure, NULL on success
654  */
655 AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive);
656
657 /**
658  * Read all data between the current &lt;foo&gt; and the matching &lt;/foo&gt; and build
659  * a config tree from it
660  * @param p pool to allocate from
661  * @param temp_pool Temporary pool to allocate from
662  * @param parms The cmd_parms to pass to all directives read
663  * @param current The current node in the tree
664  * @param curr_parent The current parent node
665  * @param orig_directive The directive to read until hit.
666  * @return Error string on failure, NULL on success
667 */
668 AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p, 
669                                               apr_pool_t *temp_pool,
670                                               cmd_parms *parms,
671                                               ap_directive_t **current,
672                                               ap_directive_t **curr_parent,
673                                               char *orig_directive);
674
675 /**
676  * Build a config tree from a config file
677  * @param parms The cmd_parms to pass to all of the directives in the file
678  * @param conf_pool The pconf pool
679  * @param temp_pool The temporary pool
680  * @param conftree Place to store the root node of the config tree
681  * @return Error string on erro, NULL otherwise
682  */
683 AP_DECLARE(const char *) ap_build_config(cmd_parms *parms,
684                                          apr_pool_t *conf_pool,
685                                          apr_pool_t *temp_pool,
686                                          ap_directive_t **conftree);
687
688 /**
689  * Walk a config tree and setup the server's internal structures
690  * @param conftree The config tree to walk
691  * @param parms The cmd_parms to pass to all functions
692  * @param section_vector The per-section config vector.
693  * @return Error string on error, NULL otherwise
694  */
695 AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree,
696                                         cmd_parms *parms,
697                                         ap_conf_vector_t *section_vector);
698
699 /**
700  * @defgroup ap_check_cmd_context Check command context
701  * @{
702  */
703 /**
704  * Check the context a command is used in.
705  * @param cmd The command to check
706  * @param forbidden Where the command is forbidden.
707  * @return Error string on error, NULL on success
708  */
709 AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd, 
710                                               unsigned forbidden);
711
712 #define  NOT_IN_VIRTUALHOST     0x01 /**< Forbidden in &lt;VirtualHost&gt; */
713 #define  NOT_IN_LIMIT           0x02 /**< Forbidden in &lt;Limit&gt; */
714 #define  NOT_IN_DIRECTORY       0x04 /**< Forbidden in &lt;Directory&gt; */
715 #define  NOT_IN_LOCATION        0x08 /**< Forbidden in &lt;Location&gt; */
716 #define  NOT_IN_FILES           0x10 /**< Forbidden in &lt;Files&gt; */
717 /** Forbidden in &lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt;*/
718 #define  NOT_IN_DIR_LOC_FILE    (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) 
719 /** Forbidden in &lt;VirtualHost&gt;/&lt;Limit&gt;/&lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt; */
720 #define  GLOBAL_ONLY            (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE) 
721
722 /** @} */
723
724 #ifdef CORE_PRIVATE
725
726 /**
727  * @brief This structure is used to assign symbol names to module pointers
728  */
729 typedef struct {
730     const char *name;
731     module *modp;
732 } ap_module_symbol_t;
733
734 /**
735  * The topmost module in the list
736  * @defvar module *ap_top_module
737  */
738 AP_DECLARE_DATA extern module *ap_top_module;
739
740 /**
741  * Array of all statically linked modules
742  * @defvar module *ap_prelinked_modules[]
743  */
744 AP_DECLARE_DATA extern module *ap_prelinked_modules[];
745 /**
746  * Array of all statically linked modulenames (symbols)
747  * @defvar ap_module_symbol_t ap_prelinked_modulenames[]
748  */
749 AP_DECLARE_DATA extern ap_module_symbol_t ap_prelinked_module_symbols[];
750 /**
751  * Array of all preloaded modules
752  * @defvar module *ap_preloaded_modules[]
753  */
754 AP_DECLARE_DATA extern module *ap_preloaded_modules[];
755 /**
756  * Array of all loaded modules
757  * @defvar module **ap_loaded_modules
758  */
759 AP_DECLARE_DATA extern module **ap_loaded_modules;
760
761 /* For mod_so.c... */
762 /** Run a single module's two create_config hooks
763  *  @param p the pool to allocate from
764  *  @param s The server to configure for.
765  *  @param m The module to configure
766  */
767 AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s, 
768                                             module *m);
769
770 /* For http_main.c... */
771 /**
772  * Add all of the prelinked modules into the loaded module list
773  * @param process The process that is currently running the server
774  */
775 AP_DECLARE(const char *) ap_setup_prelinked_modules(process_rec *process);
776
777 /**
778  * Show the preloaded configuration directives, the help string explaining
779  * the directive arguments, in what module they are handled, and in
780  * what parts of the configuration they are allowed.  Used for httpd -h.
781  */
782 AP_DECLARE(void) ap_show_directives(void);
783
784 /** 
785  * Show the preloaded module names.  Used for httpd -l. 
786  */
787 AP_DECLARE(void) ap_show_modules(void);
788
789 /** 
790  * Show the MPM name.  Used in reporting modules such as mod_info to
791  * provide extra information to the user
792  */
793 AP_DECLARE(const char *) ap_show_mpm(void);
794
795 /**
796  * Read all config files and setup the server
797  * @param process The process running the server
798  * @param temp_pool A pool to allocate temporary data from.
799  * @param config_name The name of the config file
800  * @param conftree Place to store the root of the config tree
801  * @return The setup server_rec list.
802  */
803 AP_DECLARE(server_rec *) ap_read_config(process_rec *process, 
804                                         apr_pool_t *temp_pool, 
805                                         const char *config_name, 
806                                         ap_directive_t **conftree);
807
808 /**
809  * Run all rewrite args hooks for loaded modules
810  * @param process The process currently running the server
811  */
812 AP_DECLARE(void) ap_run_rewrite_args(process_rec *process);
813
814 /**
815  * Run the register hooks function for a specified module
816  * @param m The module to run the register hooks function fo
817  * @param p The pool valid for the lifetime of the module
818  */
819 AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p);
820
821 /**
822  * Setup all virtual hosts
823  * @param p The pool to allocate from
824  * @param main_server The head of the server_rec list
825  */
826 AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, 
827                                         server_rec *main_server);
828
829 /* For http_request.c... */
830
831 /**
832  * Setup the config vector for a request_rec
833  * @param p The pool to allocate the config vector from
834  * @return The config vector
835  */
836 AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p);
837
838 /**
839  * Setup the config vector for per dir module configs
840  * @param p The pool to allocate the config vector from
841  * @return The config vector
842  */
843 AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p);
844
845 /**
846  * Run all of the modules merge per dir config functions
847  * @param p The pool to pass to the merge functions
848  * @param base The base directory config structure
849  * @param new_conf The new directory config structure
850  */
851 AP_CORE_DECLARE(ap_conf_vector_t*) ap_merge_per_dir_configs(apr_pool_t *p,
852                                            ap_conf_vector_t *base,
853                                            ap_conf_vector_t *new_conf);
854
855 /* For http_connection.c... */
856 /**
857  * Setup the config vector for a connection_rec
858  * @param p The pool to allocate the config vector from
859  * @return The config vector
860  */
861 AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_conn_config(apr_pool_t *p);
862
863 /* For http_core.c... (&lt;Directory&gt; command and virtual hosts) */
864
865 /**
866  * parse an htaccess file
867  * @param resulting htaccess_result
868  * @param r The request currently being served
869  * @param override Which overrides are active
870  * @param path The path to the htaccess file
871  * @param access_name The list of possible names for .htaccess files
872  * int The status of the current request
873  */
874 AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result, 
875                                        request_rec *r, int override,
876                                        int override_opts,
877                                        const char *path, 
878                                        const char *access_name);
879
880 /**
881  * Setup a virtual host
882  * @param p The pool to allocate all memory from
883  * @param hostname The hostname of the virtual hsot
884  * @param main_server The main server for this Apache configuration
885  * @param ps Place to store the new server_rec
886  * return Error string on error, NULL on success
887  */
888 AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p, 
889                                                    const char *hostname,
890                                                    server_rec *main_server, 
891                                                    server_rec **ps);
892
893 /**
894  * Process the config file for Apache
895  * @param s The server rec to use for the command parms
896  * @param fname The name of the config file
897  * @param conftree The root node of the created config tree
898  * @param p Pool for general allocation
899  * @param ptem Pool for temporary allocation
900  */
901 AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
902                                                     const char *fname,
903                                                     ap_directive_t **conftree,
904                                                     apr_pool_t *p,
905                                                     apr_pool_t *ptemp);
906
907 /**
908  * Process all directives in the config tree
909  * @param s The server rec to use in the command parms
910  * @param conftree The config tree to process
911  * @param p The pool for general allocation
912  * @param ptemp The pool for temporary allocations
913  * @return OK if no problems
914  */
915 AP_DECLARE(int) ap_process_config_tree(server_rec *s,
916                                        ap_directive_t *conftree,
917                                        apr_pool_t *p,
918                                        apr_pool_t *ptemp);
919
920 /* Module-method dispatchers, also for http_request.c */
921 /**
922  * Run the handler phase of each module until a module accepts the
923  * responsibility of serving the request
924  * @param r The current request
925  * @return The status of the current request
926  */
927 AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r);
928
929 /* for mod_perl */
930
931 /**
932  * Find a given directive in a command_rec table
933  * @param name The directive to search for
934  * @param cmds The table to search
935  * @return The directive definition of the specified directive
936  */
937 AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name, 
938                                                      const command_rec *cmds);
939
940 /**
941  * Find a given directive in a list module
942  * @param cmd_name The directive to search for
943  * @param mod The module list to search
944  * @return The directive definition of the specified directive
945  */
946 AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name, 
947                                                                 module **mod);
948
949 /**
950  * Ask a module to create per-server and per-section (dir/loc/file) configs
951  * (if it hasn't happened already). The results are stored in the server's
952  * config, and the specified per-section config vector.
953  * @param server The server to operate upon.
954  * @param section_vector The per-section config vector.
955  * @param section Which section to create a config for.
956  * @param mod The module which is defining the config data.
957  * @param pconf A pool for all configuration allocations.
958  * @return The (new) per-section config data.
959  */
960 AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server,
961                                               ap_conf_vector_t *section_vector,
962                                               const char *section,
963                                               module *mod, apr_pool_t *pconf);
964
965 #endif
966
967   /* Hooks */
968
969 /**
970  * Run the header parser functions for each module
971  * @param r The current request
972  * @return OK or DECLINED
973  */
974 AP_DECLARE_HOOK(int,header_parser,(request_rec *r))
975
976 /**
977  * Run the pre_config function for each module
978  * @param pconf The config pool
979  * @param plog The logging streams pool
980  * @param ptemp The temporary pool
981  * @return OK or DECLINED on success anything else is a error
982  */
983 AP_DECLARE_HOOK(int,pre_config,(apr_pool_t *pconf,apr_pool_t *plog,
984                                 apr_pool_t *ptemp))
985
986 /**
987  * Run the check_config function for each module
988  * @param pconf The config pool
989  * @param plog The logging streams pool
990  * @param ptemp The temporary pool
991  * @return OK or DECLINED on success anything else is a error
992  */
993 AP_DECLARE_HOOK(int,check_config,(apr_pool_t *pconf, apr_pool_t *plog,
994                                   apr_pool_t *ptemp, server_rec *s))
995
996 /**
997  * Run the test_config function for each module; this hook is run
998  * only if the server was invoked to test the configuration syntax.
999  * @param pconf The config pool
1000  * @param s The list of server_recs
1001  */
1002 AP_DECLARE_HOOK(void,test_config,(apr_pool_t *pconf, server_rec *s))
1003
1004 /**
1005  * Run the post_config function for each module
1006  * @param pconf The config pool
1007  * @param plog The logging streams pool
1008  * @param ptemp The temporary pool
1009  * @param s The list of server_recs
1010  * @return OK or DECLINED on success anything else is a error
1011  */
1012 AP_DECLARE_HOOK(int,post_config,(apr_pool_t *pconf,apr_pool_t *plog,
1013                                  apr_pool_t *ptemp,server_rec *s))
1014
1015 /**
1016  * Run the open_logs functions for each module
1017  * @param pconf The config pool
1018  * @param plog The logging streams pool
1019  * @param ptemp The temporary pool
1020  * @param s The list of server_recs
1021  * @return OK or DECLINED on success anything else is a error
1022  */
1023 AP_DECLARE_HOOK(int,open_logs,(apr_pool_t *pconf,apr_pool_t *plog,
1024                                apr_pool_t *ptemp,server_rec *s))
1025
1026 /**
1027  * Run the child_init functions for each module
1028  * @param pchild The child pool
1029  * @param s The list of server_recs in this server 
1030  */
1031 AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s))
1032
1033 /**
1034  * Run the handler functions for each module
1035  * @param r The request_rec
1036  * @remark non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST
1037  */
1038 AP_DECLARE_HOOK(int,handler,(request_rec *r))
1039
1040 /**
1041  * Run the quick handler functions for each module. The quick_handler
1042  * is run before any other requests hooks are called (location_walk,
1043  * directory_walk, access checking, et. al.). This hook was added
1044  * to provide a quick way to serve content from a URI keyed cache.
1045  * 
1046  * @param r The request_rec
1047  * @param lookup_uri Controls whether the caller actually wants content or not.
1048  * lookup is set when the quick_handler is called out of 
1049  * ap_sub_req_lookup_uri()
1050  */
1051 AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri))
1052
1053 /**
1054  * Retrieve the optional functions for each module.
1055  * This is run immediately before the server starts. Optional functions should
1056  * be registered during the hook registration phase.
1057  */
1058 AP_DECLARE_HOOK(void,optional_fn_retrieve,(void))
1059
1060 #ifdef __cplusplus
1061 }
1062 #endif
1063
1064 #endif  /* !APACHE_HTTP_CONFIG_H */
1065 /** @} */