00001 /* Copyright 1999-2005 The Apache Software Foundation or its licensors, as 00002 * applicable. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef APACHE_HTTP_CONFIG_H 00018 #define APACHE_HTTP_CONFIG_H 00019 00020 #include "apr_hooks.h" 00021 #include "util_cfgtree.h" 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /** 00028 * @file http_config.h 00029 * @brief Apache Configuration 00030 */ 00031 00032 /* 00033 * The central data structures around here... 00034 */ 00035 00036 /* Command dispatch structures... */ 00037 00038 /** 00039 * How the directives arguments should be parsed. 00040 * @remark Note that for all of these except RAW_ARGS, the config routine is 00041 * passed a freshly allocated string which can be modified or stored 00042 * or whatever... 00043 */ 00044 enum cmd_how { 00045 RAW_ARGS, /**< cmd_func parses command line itself */ 00046 TAKE1, /**< one argument only */ 00047 TAKE2, /**< two arguments only */ 00048 ITERATE, /**< one argument, occuring multiple times 00049 * (e.g., IndexIgnore) 00050 */ 00051 ITERATE2, /**< two arguments, 2nd occurs multiple times 00052 * (e.g., AddIcon) 00053 */ 00054 FLAG, /**< One of 'On' or 'Off' */ 00055 NO_ARGS, /**< No args at all, e.g. </Directory> */ 00056 TAKE12, /**< one or two arguments */ 00057 TAKE3, /**< three arguments only */ 00058 TAKE23, /**< two or three arguments */ 00059 TAKE123, /**< one, two or three arguments */ 00060 TAKE13 /**< one or three arguments */ 00061 }; 00062 /** 00063 * This structure is passed to a command which is being invoked, 00064 * to carry a large variety of miscellaneous data which is all of 00065 * use to *somebody*... 00066 */ 00067 typedef struct cmd_parms_struct cmd_parms; 00068 00069 #if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN) 00070 00071 /** 00072 * All the types of functions that can be used in directives 00073 * @internal 00074 */ 00075 typedef union { 00076 /** function to call for a no-args */ 00077 const char *(*no_args) (cmd_parms *parms, void *mconfig); 00078 /** function to call for a raw-args */ 00079 const char *(*raw_args) (cmd_parms *parms, void *mconfig, 00080 const char *args); 00081 /** function to call for a take1 */ 00082 const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w); 00083 /** function to call for a take2 */ 00084 const char *(*take2) (cmd_parms *parms, void *mconfig, const char *w, 00085 const char *w2); 00086 /** function to call for a take3 */ 00087 const char *(*take3) (cmd_parms *parms, void *mconfig, const char *w, 00088 const char *w2, const char *w3); 00089 /** function to call for a flag */ 00090 const char *(*flag) (cmd_parms *parms, void *mconfig, int on); 00091 } cmd_func; 00092 00093 /** This configuration directive does not take any arguments */ 00094 # define AP_NO_ARGS func.no_args 00095 /** This configuration directive will handle it's own parsing of arguments*/ 00096 # define AP_RAW_ARGS func.raw_args 00097 /** This configuration directive takes 1 argument*/ 00098 # define AP_TAKE1 func.take1 00099 /** This configuration directive takes 2 arguments */ 00100 # define AP_TAKE2 func.take2 00101 /** This configuration directive takes 3 arguments */ 00102 # define AP_TAKE3 func.take3 00103 /** This configuration directive takes a flag (on/off) as a argument*/ 00104 # define AP_FLAG func.flag 00105 00106 /** method of declaring a directive with no arguments */ 00107 # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \ 00108 { directive, { .no_args=func }, mconfig, where, RAW_ARGS, help } 00109 /** method of declaring a directive with raw argument parsing */ 00110 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \ 00111 { directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help } 00112 /** method of declaring a directive which takes 1 argument */ 00113 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \ 00114 { directive, { .take1=func }, mconfig, where, TAKE1, help } 00115 /** method of declaring a directive which takes multiple arguments */ 00116 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \ 00117 { directive, { .take1=func }, mconfig, where, ITERATE, help } 00118 /** method of declaring a directive which takes 2 arguments */ 00119 # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \ 00120 { directive, { .take2=func }, mconfig, where, TAKE2, help } 00121 /** method of declaring a directive which takes 1 or 2 arguments */ 00122 # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \ 00123 { directive, { .take2=func }, mconfig, where, TAKE12, help } 00124 /** method of declaring a directive which takes multiple 2 arguments */ 00125 # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \ 00126 { directive, { .take2=func }, mconfig, where, ITERATE2, help } 00127 /** method of declaring a directive which takes 1 or 3 arguments */ 00128 # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \ 00129 { directive, { .take3=func }, mconfig, where, TAKE13, help } 00130 /** method of declaring a directive which takes 2 or 3 arguments */ 00131 # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \ 00132 { directive, { .take3=func }, mconfig, where, TAKE23, help } 00133 /** method of declaring a directive which takes 1 to 3 arguments */ 00134 # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \ 00135 { directive, { .take3=func }, mconfig, where, TAKE123, help } 00136 /** method of declaring a directive which takes 3 arguments */ 00137 # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \ 00138 { directive, { .take3=func }, mconfig, where, TAKE3, help } 00139 /** method of declaring a directive which takes a flag (on/off) as a argument*/ 00140 # define AP_INIT_FLAG(directive, func, mconfig, where, help) \ 00141 { directive, { .flag=func }, mconfig, where, FLAG, help } 00142 00143 #else /* AP_HAVE_DESIGNATED_INITIALIZER */ 00144 00145 typedef const char *(*cmd_func) (); 00146 00147 # define AP_NO_ARGS func 00148 # define AP_RAW_ARGS func 00149 # define AP_TAKE1 func 00150 # define AP_TAKE2 func 00151 # define AP_TAKE3 func 00152 # define AP_FLAG func 00153 00154 # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \ 00155 { directive, func, mconfig, where, RAW_ARGS, help } 00156 # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \ 00157 { directive, func, mconfig, where, RAW_ARGS, help } 00158 # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \ 00159 { directive, func, mconfig, where, TAKE1, help } 00160 # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \ 00161 { directive, func, mconfig, where, ITERATE, help } 00162 # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \ 00163 { directive, func, mconfig, where, TAKE2, help } 00164 # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \ 00165 { directive, func, mconfig, where, TAKE12, help } 00166 # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \ 00167 { directive, func, mconfig, where, ITERATE2, help } 00168 # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \ 00169 { directive, func, mconfig, where, TAKE13, help } 00170 # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \ 00171 { directive, func, mconfig, where, TAKE23, help } 00172 # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \ 00173 { directive, func, mconfig, where, TAKE123, help } 00174 # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \ 00175 { directive, func, mconfig, where, TAKE3, help } 00176 # define AP_INIT_FLAG(directive, func, mconfig, where, help) \ 00177 { directive, func, mconfig, where, FLAG, help } 00178 00179 #endif /* AP_HAVE_DESIGNATED_INITIALIZER */ 00180 00181 /** 00182 * The command record structure. Each modules can define a table of these 00183 * to define the directives it will implement. 00184 */ 00185 typedef struct command_struct command_rec; 00186 struct command_struct { 00187 /** Name of this command */ 00188 const char *name; 00189 /** The function to be called when this directive is parsed */ 00190 cmd_func func; 00191 /** Extra data, for functions which implement multiple commands... */ 00192 void *cmd_data; 00193 /** What overrides need to be allowed to enable this command. */ 00194 int req_override; 00195 /** What the command expects as arguments 00196 * @defvar cmd_how args_how*/ 00197 enum cmd_how args_how; 00198 00199 /** 'usage' message, in case of syntax errors */ 00200 const char *errmsg; 00201 }; 00202 00203 /** 00204 * @defgroup ConfigDirectives Allowed locations for configuration directives. 00205 * 00206 * The allowed locations for a configuration directive are the union of 00207 * those indicated by each set bit in the req_override mask. 00208 * 00209 * @{ 00210 */ 00211 #define OR_NONE 0 /**< *.conf is not available anywhere in this override */ 00212 #define OR_LIMIT 1 /**< *.conf inside <Directory> or <Location> 00213 and .htaccess when AllowOverride Limit */ 00214 #define OR_OPTIONS 2 /**< *.conf anywhere 00215 and .htaccess when AllowOverride Options */ 00216 #define OR_FILEINFO 4 /**< *.conf anywhere 00217 and .htaccess when AllowOverride FileInfo */ 00218 #define OR_AUTHCFG 8 /**< *.conf inside <Directory> or <Location> 00219 and .htaccess when AllowOverride AuthConfig */ 00220 #define OR_INDEXES 16 /**< *.conf anywhere 00221 and .htaccess when AllowOverride Indexes */ 00222 #define OR_UNSET 32 /**< unset a directive (in Allow) */ 00223 #define ACCESS_CONF 64 /**< *.conf inside <Directory> or <Location> */ 00224 #define RSRC_CONF 128 /**< *.conf outside <Directory> or <Location> */ 00225 #define EXEC_ON_READ 256 /**< force directive to execute a command 00226 which would modify the configuration (like including another 00227 file, or IFModule */ 00228 /** this directive can be placed anywhere */ 00229 #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES) 00230 00231 /** @} */ 00232 00233 /** 00234 * This can be returned by a function if they don't wish to handle 00235 * a command. Make it something not likely someone will actually use 00236 * as an error code. 00237 */ 00238 #define DECLINE_CMD "\a\b" 00239 00240 /** Common structure for reading of config files / passwd files etc. */ 00241 typedef struct ap_configfile_t ap_configfile_t; 00242 struct ap_configfile_t { 00243 int (*getch) (void *param); /**< a getc()-like function */ 00244 void *(*getstr) (void *buf, size_t bufsiz, void *param); 00245 /**< a fgets()-like function */ 00246 int (*close) (void *param); /**< a close handler function */ 00247 void *param; /**< the argument passed to getch/getstr/close */ 00248 const char *name; /**< the filename / description */ 00249 unsigned line_number; /**< current line number, starting at 1 */ 00250 }; 00251 00252 /** 00253 * This structure is passed to a command which is being invoked, 00254 * to carry a large variety of miscellaneous data which is all of 00255 * use to *somebody*... 00256 */ 00257 struct cmd_parms_struct { 00258 /** Argument to command from cmd_table */ 00259 void *info; 00260 /** Which allow-override bits are set */ 00261 int override; 00262 /** Which methods are <Limit>ed */ 00263 apr_int64_t limited; 00264 /** methods which are limited */ 00265 apr_array_header_t *limited_xmethods; 00266 /** methods which are xlimited */ 00267 ap_method_list_t *xlimited; 00268 00269 /** Config file structure. */ 00270 ap_configfile_t *config_file; 00271 /** the directive specifying this command */ 00272 ap_directive_t *directive; 00273 00274 /** Pool to allocate new storage in */ 00275 apr_pool_t *pool; 00276 /** Pool for scratch memory; persists during configuration, but 00277 * wiped before the first request is served... */ 00278 apr_pool_t *temp_pool; 00279 /** Server_rec being configured for */ 00280 server_rec *server; 00281 /** If configuring for a directory, pathname of that directory. 00282 * NOPE! That's what it meant previous to the existance of <Files>, 00283 * <Location> and regex matching. Now the only usefulness that can be 00284 * derived from this field is whether a command is being called in a 00285 * server context (path == NULL) or being called in a dir context 00286 * (path != NULL). */ 00287 char *path; 00288 /** configuration command */ 00289 const command_rec *cmd; 00290 00291 /** per_dir_config vector passed to handle_command */ 00292 struct ap_conf_vector_t *context; 00293 /** directive with syntax error */ 00294 const ap_directive_t *err_directive; 00295 }; 00296 00297 /** 00298 * Module structures. Just about everything is dispatched through 00299 * these, directly or indirectly (through the command and handler 00300 * tables). 00301 */ 00302 typedef struct module_struct module; 00303 struct module_struct { 00304 /** API version, *not* module version; check that module is 00305 * compatible with this version of the server. 00306 */ 00307 int version; 00308 /** API minor version. Provides API feature milestones. Not checked 00309 * during module init */ 00310 int minor_version; 00311 /** Index to this modules structures in config vectors. */ 00312 int module_index; 00313 00314 /** The name of the module's C file */ 00315 const char *name; 00316 /** The handle for the DSO. Internal use only */ 00317 void *dynamic_load_handle; 00318 00319 /** A pointer to the next module in the list 00320 * @defvar module_struct *next */ 00321 struct module_struct *next; 00322 00323 /** Magic Cookie to identify a module structure; It's mainly 00324 * important for the DSO facility (see also mod_so). */ 00325 unsigned long magic; 00326 00327 /** Function to allow MPMs to re-write command line arguments. This 00328 * hook is only available to MPMs. 00329 * @param The process that the server is running in. 00330 */ 00331 void (*rewrite_args) (process_rec *process); 00332 /** Function to allow all modules to create per directory configuration 00333 * structures. 00334 * @param p The pool to use for all allocations. 00335 * @param dir The directory currently being processed. 00336 * @return The per-directory structure created 00337 */ 00338 void *(*create_dir_config) (apr_pool_t *p, char *dir); 00339 /** Function to allow all modules to merge the per directory configuration 00340 * structures for two directories. 00341 * @param p The pool to use for all allocations. 00342 * @param base_conf The directory structure created for the parent directory. 00343 * @param new_conf The directory structure currently being processed. 00344 * @return The new per-directory structure created 00345 */ 00346 void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf); 00347 /** Function to allow all modules to create per server configuration 00348 * structures. 00349 * @param p The pool to use for all allocations. 00350 * @param s The server currently being processed. 00351 * @return The per-server structure created 00352 */ 00353 void *(*create_server_config) (apr_pool_t *p, server_rec *s); 00354 /** Function to allow all modules to merge the per server configuration 00355 * structures for two servers. 00356 * @param p The pool to use for all allocations. 00357 * @param base_conf The directory structure created for the parent directory. 00358 * @param new_conf The directory structure currently being processed. 00359 * @return The new per-directory structure created 00360 */ 00361 void *(*merge_server_config) (apr_pool_t *p, void *base_conf, 00362 void *new_conf); 00363 00364 /** A command_rec table that describes all of the directives this module 00365 * defines. */ 00366 const command_rec *cmds; 00367 00368 /** A hook to allow modules to hook other points in the request processing. 00369 * In this function, modules should call the ap_hook_*() functions to 00370 * register an interest in a specific step in processing the current 00371 * request. 00372 * @param p the pool to use for all allocations 00373 */ 00374 void (*register_hooks) (apr_pool_t *p); 00375 }; 00376 00377 /** 00378 * @defgroup ModuleInit Module structure initializers 00379 * 00380 * Initializer for the first few module slots, which are only 00381 * really set up once we start running. Note that the first two slots 00382 * provide a version check; this should allow us to deal with changes to 00383 * the API. The major number should reflect changes to the API handler table 00384 * itself or removal of functionality. The minor number should reflect 00385 * additions of functionality to the existing API. (the server can detect 00386 * an old-format module, and either handle it back-compatibly, or at least 00387 * signal an error). See src/include/ap_mmn.h for MMN version history. 00388 * @{ 00389 */ 00390 00391 /** The one used in Apache 1.3, which will deliberately cause an error */ 00392 #define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0 00393 00394 /** Use this in all standard modules */ 00395 #define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \ 00396 MODULE_MAGIC_NUMBER_MINOR, \ 00397 -1, \ 00398 __FILE__, \ 00399 NULL, \ 00400 NULL, \ 00401 MODULE_MAGIC_COOKIE, \ 00402 NULL /* rewrite args spot */ 00403 00404 /** Use this only in MPMs */ 00405 #define MPM20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \ 00406 MODULE_MAGIC_NUMBER_MINOR, \ 00407 -1, \ 00408 __FILE__, \ 00409 NULL, \ 00410 NULL, \ 00411 MODULE_MAGIC_COOKIE 00412 00413 /** @} */ 00414 00415 /* CONFIGURATION VECTOR FUNCTIONS */ 00416 00417 /** configuration vector structure */ 00418 typedef struct ap_conf_vector_t ap_conf_vector_t; 00419 00420 /** 00421 * Generic accessors for other modules to get at their own module-specific 00422 * data 00423 * @param conf_vector The vector in which the modules configuration is stored. 00424 * usually r->per_dir_config or s->module_config 00425 * @param m The module to get the data for. 00426 * @return The module-specific data 00427 */ 00428 AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv, 00429 const module *m); 00430 00431 /** 00432 * Generic accessors for other modules to set at their own module-specific 00433 * data 00434 * @param conf_vector The vector in which the modules configuration is stored. 00435 * usually r->per_dir_config or s->module_config 00436 * @param m The module to set the data for. 00437 * @param val The module-specific data to set 00438 */ 00439 AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m, 00440 void *val); 00441 00442 #if !defined(AP_DEBUG) 00443 00444 #define ap_get_module_config(v,m) \ 00445 (((void **)(v))[(m)->module_index]) 00446 #define ap_set_module_config(v,m,val) \ 00447 ((((void **)(v))[(m)->module_index]) = (val)) 00448 00449 #endif /* AP_DEBUG */ 00450 00451 00452 /** 00453 * Generic command handling function for strings 00454 * @param cmd The command parameters for this directive 00455 * @param struct_ptr pointer into a given type 00456 * @param arg The argument to the directive 00457 * @return An error string or NULL on success 00458 */ 00459 AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd, 00460 void *struct_ptr, 00461 const char *arg); 00462 00463 /** 00464 * Generic command handling function for integers 00465 * @param cmd The command parameters for this directive 00466 * @param struct_ptr pointer into a given type 00467 * @param arg The argument to the directive 00468 * @return An error string or NULL on success 00469 */ 00470 AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd, 00471 void *struct_ptr, 00472 const char *arg); 00473 00474 /** 00475 * Return true if the specified method is limited by being listed in 00476 * a <Limit> container, or by *not* being listed in a <LimiteExcept> 00477 * container. 00478 * 00479 * @param method Pointer to a string specifying the method to check. 00480 * @param cmd Pointer to the cmd_parms structure passed to the 00481 * directive handler. 00482 * @return 0 if the method is not limited in the current scope 00483 */ 00484 AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method); 00485 00486 /** 00487 * Generic command handling function for strings, always sets the value 00488 * to a lowercase string 00489 * @param cmd The command parameters for this directive 00490 * @param struct_ptr pointer into a given type 00491 * @param arg The argument to the directive 00492 * @return An error string or NULL on success 00493 */ 00494 AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd, 00495 void *struct_ptr, 00496 const char *arg); 00497 /** 00498 * Generic command handling function for flags 00499 * @param cmd The command parameters for this directive 00500 * @param struct_ptr pointer into a given type 00501 * @param arg The argument to the directive (either 1 or 0) 00502 * @return An error string or NULL on success 00503 */ 00504 AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd, 00505 void *struct_ptr, 00506 int arg); 00507 /** 00508 * Generic command handling function for files 00509 * @param cmd The command parameters for this directive 00510 * @param struct_ptr pointer into a given type 00511 * @param arg The argument to the directive 00512 * @return An error string or NULL on success 00513 */ 00514 AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, 00515 void *struct_ptr, 00516 const char *arg); 00517 /** 00518 * Generic command handling function to respond with cmd->help as an error 00519 * @param cmd The command parameters for this directive 00520 * @param struct_ptr pointer into a given type 00521 * @param arg The argument to the directive 00522 * @return The cmd->help value as the error string 00523 * @tip This allows simple declarations such as; 00524 * <pre> 00525 * AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL, 00526 * "The Foo directive is no longer supported, use Bar"), 00527 * </pre> 00528 */ 00529 AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd, 00530 void *struct_ptr, 00531 const char *arg); 00532 /** 00533 * For modules which need to read config files, open logs, etc. this returns 00534 * the canonical form of fname made absolute to ap_server_root. 00535 * @param p pool to allocate data from 00536 * @param fname The file name 00537 */ 00538 AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname); 00539 00540 /* Finally, the hook for dynamically loading modules in... */ 00541 00542 /** 00543 * Add a module to the server 00544 * @param m The module structure of the module to add 00545 * @param p The pool of the same lifetime as the module 00546 */ 00547 AP_DECLARE(void) ap_add_module(module *m, apr_pool_t *p); 00548 00549 /** 00550 * Remove a module from the server. There are some caveats: 00551 * when the module is removed, its slot is lost so all the current 00552 * per-dir and per-server configurations are invalid. So we should 00553 * only ever call this function when you are invalidating almost 00554 * all our current data. I.e. when doing a restart. 00555 * @param m the module structure of the module to remove 00556 */ 00557 AP_DECLARE(void) ap_remove_module(module *m); 00558 /** 00559 * Add a module to the chained modules list and the list of loaded modules 00560 * @param m The module structure of the module to add 00561 * @param p The pool with the same lifetime as the module 00562 */ 00563 AP_DECLARE(void) ap_add_loaded_module(module *mod, apr_pool_t *p); 00564 /** 00565 * Remove a module fromthe chained modules list and the list of loaded modules 00566 * @param m the module structure of the module to remove 00567 */ 00568 AP_DECLARE(void) ap_remove_loaded_module(module *mod); 00569 /** 00570 * Add a module to the list of loaded module based on the name of the 00571 * module 00572 * @param name The name of the module 00573 * @param p The pool valid for the lifetime of the module 00574 * @return 1 on success, 0 on failure 00575 */ 00576 AP_DECLARE(int) ap_add_named_module(const char *name, apr_pool_t *p); 00577 /** 00578 * Find the name of the specified module 00579 * @param m The module to get the name for 00580 * @return the name of the module 00581 */ 00582 AP_DECLARE(const char *) ap_find_module_name(module *m); 00583 /** 00584 * Find a module based on the name of the module 00585 * @param name the name of the module 00586 * @return the module structure if found, NULL otherwise 00587 */ 00588 AP_DECLARE(module *) ap_find_linked_module(const char *name); 00589 00590 /** 00591 * Open a ap_configfile_t as apr_file_t 00592 * @param ret_cfg open ap_configfile_t struct pointer 00593 * @param p The pool to allocate the structure from 00594 * @param name the name of the file to open 00595 */ 00596 AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg, 00597 apr_pool_t *p, const char *name); 00598 00599 /** 00600 * Allocate a ap_configfile_t handle with user defined functions and params 00601 * @param p The pool to allocate from 00602 * @param descr The name of the file 00603 * @param param The argument passed to getch/getstr/close 00604 * @param getc_func The getch function 00605 * @param gets_func The getstr function 00606 * @param close_func The close function 00607 */ 00608 AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p, 00609 const char *descr, 00610 void *param, 00611 int(*getc_func)(void*), 00612 void *(*gets_func) (void *buf, size_t bufsiz, void *param), 00613 int(*close_func)(void *param)); 00614 00615 /** 00616 * Read one line from open ap_configfile_t, strip LF, increase line number 00617 * @param buf place to store the line read 00618 * @param bufsize size of the buffer 00619 * @param cfp File to read from 00620 * @return 1 on success, 0 on failure 00621 */ 00622 AP_DECLARE(int) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp); 00623 00624 /** 00625 * Read one char from open configfile_t, increase line number upon LF 00626 * @param cfp The file to read from 00627 * @return the character read 00628 */ 00629 AP_DECLARE(int) ap_cfg_getc(ap_configfile_t *cfp); 00630 00631 /** 00632 * Detach from open ap_configfile_t, calling the close handler 00633 * @param cfp The file to close 00634 * @return 1 on sucess, 0 on failure 00635 */ 00636 AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp); 00637 00638 /** 00639 * Read all data between the current <foo> and the matching </foo>. All 00640 * of this data is forgotten immediately. 00641 * @param cmd The cmd_parms to pass to the directives inside the container 00642 * @param directive The directive name to read until 00643 * @return Error string on failure, NULL on success 00644 */ 00645 AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive); 00646 00647 /** 00648 * Read all data between the current <foo> and the matching </foo> and build 00649 * a config tree from it 00650 * @param p pool to allocate from 00651 * @param temp_pool Temporary pool to allocate from 00652 * @param parms The cmd_parms to pass to all directives read 00653 * @param current The current node in the tree 00654 * @param curr_parent The current parent node 00655 * @param orig_directive The directive to read until hit. 00656 * @return Error string on failure, NULL on success 00657 */ 00658 AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p, 00659 apr_pool_t *temp_pool, 00660 cmd_parms *parms, 00661 ap_directive_t **current, 00662 ap_directive_t **curr_parent, 00663 char *orig_directive); 00664 00665 /** 00666 * Build a config tree from a config file 00667 * @param parms The cmd_parms to pass to all of the directives in the file 00668 * @param conf_pool The pconf pool 00669 * @param temp_pool The temporary pool 00670 * @param conftree Place to store the root node of the config tree 00671 * @return Error string on erro, NULL otherwise 00672 */ 00673 AP_DECLARE(const char *) ap_build_config(cmd_parms *parms, 00674 apr_pool_t *conf_pool, 00675 apr_pool_t *temp_pool, 00676 ap_directive_t **conftree); 00677 00678 /** 00679 * Walk a config tree and setup the server's internal structures 00680 * @param conftree The config tree to walk 00681 * @param parms The cmd_parms to pass to all functions 00682 * @param section_vector The per-section config vector. 00683 * @return Error string on error, NULL otherwise 00684 */ 00685 AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree, 00686 cmd_parms *parms, 00687 ap_conf_vector_t *section_vector); 00688 00689 /** 00690 * @defgroup ap_check_cmd_context ap_check_cmd_context 00691 * @{ 00692 */ 00693 /** 00694 * Check the context a command is used in. 00695 * @param cmd The command to check 00696 * @param forbidden Where the command is forbidden. 00697 * @return Error string on error, NULL on success 00698 */ 00699 AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd, 00700 unsigned forbidden); 00701 00702 #define NOT_IN_VIRTUALHOST 0x01 /**< Forbidden in <Virtualhost> */ 00703 #define NOT_IN_LIMIT 0x02 /**< Forbidden in <Limit> */ 00704 #define NOT_IN_DIRECTORY 0x04 /**< Forbidden in <Directory> */ 00705 #define NOT_IN_LOCATION 0x08 /**< Forbidden in <Location> */ 00706 #define NOT_IN_FILES 0x10 /**< Forbidden in <Files> */ 00707 /** Forbidden in <Directory>/<Location>/<Files>*/ 00708 #define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) 00709 /** Forbidden in <VirtualHost>/<Limit>/<Directory>/<Location>/<Files> */ 00710 #define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE) 00711 00712 /** @} */ 00713 00714 #ifdef CORE_PRIVATE 00715 00716 /** 00717 * The topmost module in the list 00718 * @defvar module *ap_top_module 00719 */ 00720 AP_DECLARE_DATA extern module *ap_top_module; 00721 00722 /** 00723 * Array of all statically linked modules 00724 * @defvar module *ap_prelinked_modules[] 00725 */ 00726 AP_DECLARE_DATA extern module *ap_prelinked_modules[]; 00727 /** 00728 * Array of all preloaded modules 00729 * @defvar module *ap_preloaded_modules[] 00730 */ 00731 AP_DECLARE_DATA extern module *ap_preloaded_modules[]; 00732 /** 00733 * Array of all loaded modules 00734 * @defvar module **ap_loaded_modules 00735 */ 00736 AP_DECLARE_DATA extern module **ap_loaded_modules; 00737 00738 /* For mod_so.c... */ 00739 /** Run a single module's two create_config hooks 00740 * @param p the pool to allocate from 00741 * @param s The server to configure for. 00742 * @param m The module to configure 00743 */ 00744 AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s, 00745 module *m); 00746 00747 /* For http_main.c... */ 00748 /** 00749 * Add all of the prelinked modules into the loaded module list 00750 * @param process The process that is currently running the server 00751 */ 00752 AP_DECLARE(void) ap_setup_prelinked_modules(process_rec *process); 00753 00754 /** 00755 * Show the preloaded configuration directives, the help string explaining 00756 * the directive arguments, in what module they are handled, and in 00757 * what parts of the configuration they are allowed. Used for httpd -h. 00758 */ 00759 AP_DECLARE(void) ap_show_directives(void); 00760 00761 /** 00762 * Show the preloaded module names. Used for httpd -l. 00763 */ 00764 AP_DECLARE(void) ap_show_modules(void); 00765 00766 /** 00767 * Show the MPM name. Used in reporting modules such as mod_info to 00768 * provide extra information to the user 00769 */ 00770 AP_DECLARE(const char *) ap_show_mpm(void); 00771 00772 /** 00773 * Read all config files and setup the server 00774 * @param process The process running the server 00775 * @param temp_pool A pool to allocate temporary data from. 00776 * @param config_name The name of the config file 00777 * @param conftree Place to store the root of the config tree 00778 * @return The setup server_rec list. 00779 */ 00780 AP_DECLARE(server_rec *) ap_read_config(process_rec *process, 00781 apr_pool_t *temp_pool, 00782 const char *config_name, 00783 ap_directive_t **conftree); 00784 00785 /** 00786 * Run all rewrite args hooks for loaded modules 00787 * @param process The process currently running the server 00788 */ 00789 AP_DECLARE(void) ap_run_rewrite_args(process_rec *process); 00790 00791 /** 00792 * Run the register hooks function for a specified module 00793 * @param m The module to run the register hooks function fo 00794 * @param p The pool valid for the lifetime of the module 00795 */ 00796 AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p); 00797 00798 /** 00799 * Setup all virtual hosts 00800 * @param p The pool to allocate from 00801 * @param main_server The head of the server_rec list 00802 */ 00803 AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, 00804 server_rec *main_server); 00805 00806 /* For http_request.c... */ 00807 00808 /** 00809 * Setup the config vector for a request_rec 00810 * @param p The pool to allocate the config vector from 00811 * @return The config vector 00812 */ 00813 AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p); 00814 00815 /** 00816 * Setup the config vector for per dir module configs 00817 * @param p The pool to allocate the config vector from 00818 * @return The config vector 00819 */ 00820 AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p); 00821 00822 /** 00823 * Run all of the modules merge per dir config functions 00824 * @param p The pool to pass to the merge functions 00825 * @param base The base directory config structure 00826 * @param new_conf The new directory config structure 00827 */ 00828 AP_CORE_DECLARE(ap_conf_vector_t*) ap_merge_per_dir_configs(apr_pool_t *p, 00829 ap_conf_vector_t *base, 00830 ap_conf_vector_t *new_conf); 00831 00832 /* For http_connection.c... */ 00833 /** 00834 * Setup the config vector for a connection_rec 00835 * @param p The pool to allocate the config vector from 00836 * @return The config vector 00837 */ 00838 AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_conn_config(apr_pool_t *p); 00839 00840 /* For http_core.c... (<Directory> command and virtual hosts) */ 00841 00842 /** 00843 * parse an htaccess file 00844 * @param resulting htaccess_result 00845 * @param r The request currently being served 00846 * @param override Which overrides are active 00847 * @param path The path to the htaccess file 00848 * @param access_name The list of possible names for .htaccess files 00849 * int The status of the current request 00850 */ 00851 AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result, 00852 request_rec *r, int override, 00853 const char *path, 00854 const char *access_name); 00855 00856 /** 00857 * Setup a virtual host 00858 * @param p The pool to allocate all memory from 00859 * @param hostname The hostname of the virtual hsot 00860 * @param main_server The main server for this Apache configuration 00861 * @param ps Place to store the new server_rec 00862 * return Error string on error, NULL on success 00863 */ 00864 AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p, 00865 const char *hostname, 00866 server_rec *main_server, 00867 server_rec **); 00868 00869 /** 00870 * Process the config file for Apache 00871 * @param s The server rec to use for the command parms 00872 * @param fname The name of the config file 00873 * @param conftree The root node of the created config tree 00874 * @param p Pool for general allocation 00875 * @param ptem Pool for temporary allocation 00876 */ 00877 AP_DECLARE(void) ap_process_resource_config(server_rec *s, const char *fname, 00878 ap_directive_t **conftree, 00879 apr_pool_t *p, apr_pool_t *ptemp); 00880 00881 /** 00882 * Process all directives in the config tree 00883 * @param s The server rec to use in the command parms 00884 * @param conftree The config tree to process 00885 * @param p The pool for general allocation 00886 * @param ptemp The pool for temporary allocations 00887 */ 00888 AP_DECLARE(void) ap_process_config_tree(server_rec *s, ap_directive_t *conftree, 00889 apr_pool_t *p, apr_pool_t *ptemp); 00890 00891 /* Module-method dispatchers, also for http_request.c */ 00892 /** 00893 * Run the handler phase of each module until a module accepts the 00894 * responsibility of serving the request 00895 * @param r The current request 00896 * @return The status of the current request 00897 */ 00898 AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r); 00899 00900 /* for mod_perl */ 00901 00902 /** 00903 * Find a given directive in a command_rec table 00904 * @param name The directive to search for 00905 * @param cmds The table to search 00906 * @return The directive definition of the specified directive 00907 */ 00908 AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name, 00909 const command_rec *cmds); 00910 00911 /** 00912 * Find a given directive in a list module 00913 * @param cmd_name The directive to search for 00914 * @param mod The module list to search 00915 * @return The directive definition of the specified directive 00916 */ 00917 AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name, 00918 module **mod); 00919 00920 /** 00921 * Ask a module to create per-server and per-section (dir/loc/file) configs 00922 * (if it hasn't happened already). The results are stored in the server's 00923 * config, and the specified per-section config vector. 00924 * @param server The server to operate upon. 00925 * @param section_vector The per-section config vector. 00926 * @param section Which section to create a config for. 00927 * @param mod The module which is defining the config data. 00928 * @param pconf A pool for all configuration allocations. 00929 * @return The (new) per-section config data. 00930 */ 00931 AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server, 00932 ap_conf_vector_t *section_vector, 00933 const char *section, 00934 module *mod, apr_pool_t *pconf); 00935 00936 #endif 00937 00938 /* Hooks */ 00939 00940 /** 00941 * Run the header parser functions for each module 00942 * @param r The current request 00943 * @return OK or DECLINED 00944 */ 00945 AP_DECLARE_HOOK(int,header_parser,(request_rec *r)) 00946 00947 /** 00948 * Run the pre_config function for each module 00949 * @param pconf The config pool 00950 * @param plog The logging streams pool 00951 * @param ptemp The temporary pool 00952 * @return OK or DECLINED on success anything else is a error 00953 */ 00954 AP_DECLARE_HOOK(int,pre_config,(apr_pool_t *pconf,apr_pool_t *plog, 00955 apr_pool_t *ptemp)) 00956 00957 00958 /** 00959 * Run the post_config function for each module 00960 * @param pconf The config pool 00961 * @param plog The logging streams pool 00962 * @param ptemp The temporary pool 00963 * @param s The list of server_recs 00964 * @return OK or DECLINED on success anything else is a error 00965 */ 00966 AP_DECLARE_HOOK(int,post_config,(apr_pool_t *pconf,apr_pool_t *plog, 00967 apr_pool_t *ptemp,server_rec *s)) 00968 00969 /** 00970 * Run the open_logs functions for each module 00971 * @param pconf The config pool 00972 * @param plog The logging streams pool 00973 * @param ptemp The temporary pool 00974 * @param s The list of server_recs 00975 * @return OK or DECLINED on success anything else is a error 00976 */ 00977 AP_DECLARE_HOOK(int,open_logs,(apr_pool_t *pconf,apr_pool_t *plog, 00978 apr_pool_t *ptemp,server_rec *s)) 00979 00980 /** 00981 * Run the child_init functions for each module 00982 * @param pchild The child pool 00983 * @param s The list of server_recs in this server 00984 */ 00985 AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s)) 00986 00987 /** 00988 * Run the handler functions for each module 00989 * @param r The request_rec 00990 * @remark non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST 00991 */ 00992 AP_DECLARE_HOOK(int,handler,(request_rec *r)) 00993 00994 /** 00995 * Run the quick handler functions for each module. The quick_handler 00996 * is run before any other requests hooks are called (location_walk, 00997 * directory_walk, access checking, et. al.). This hook was added 00998 * to provide a quick way to serve content from a URI keyed cache. 00999 * 01000 * @param r The request_rec 01001 * @param lookup_uri Controls whether the caller actually wants content or not. 01002 * lookup is set when the quick_handler is called out of 01003 * ap_sub_req_lookup_uri() 01004 */ 01005 AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri)) 01006 01007 /** 01008 * Retrieve the optional functions for each module. 01009 * This is run immediately before the server starts. Optional functions should 01010 * be registered during the hook registration phase. 01011 */ 01012 AP_DECLARE_HOOK(void,optional_fn_retrieve,(void)) 01013 01014 #ifdef __cplusplus 01015 } 01016 #endif 01017 01018 #endif /* !APACHE_HTTP_CONFIG_H */