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