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