#ifndef APACHE_HTTP_CONFIG_H
#define APACHE_HTTP_CONFIG_H
-#include "apr_hooks.h"
#include "util_cfgtree.h"
#include "ap_config.h"
* or whatever...
*/
enum cmd_how {
- RAW_ARGS, /**< cmd_func parses command line itself */
- TAKE1, /**< one argument only */
- TAKE2, /**< two arguments only */
- ITERATE, /**< one argument, occuring multiple times
- * (e.g., IndexIgnore)
- */
- ITERATE2, /**< two arguments, 2nd occurs multiple times
- * (e.g., AddIcon)
- */
- FLAG, /**< One of 'On' or 'Off' */
- NO_ARGS, /**< No args at all, e.g. </Directory> */
- TAKE12, /**< one or two arguments */
- TAKE3, /**< three arguments only */
- TAKE23, /**< two or three arguments */
- TAKE123, /**< one, two or three arguments */
- TAKE13, /**< one or three arguments */
- TAKE_ARGV /**< an argc and argv are passed */
+ RAW_ARGS, /**< cmd_func parses command line itself */
+ TAKE1, /**< one argument only */
+ TAKE2, /**< two arguments only */
+ ITERATE, /**< one argument, occuring multiple times
+ * (e.g., IndexIgnore)
+ */
+ ITERATE2, /**< two arguments, 2nd occurs multiple times
+ * (e.g., AddIcon)
+ */
+ FLAG, /**< One of 'On' or 'Off' */
+ NO_ARGS, /**< No args at all, e.g. </Directory> */
+ TAKE12, /**< one or two arguments */
+ TAKE3, /**< three arguments only */
+ TAKE23, /**< two or three arguments */
+ TAKE123, /**< one, two or three arguments */
+ TAKE13, /**< one or three arguments */
+ TAKE_ARGV /**< an argc and argv are passed */
};
/**
#if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN)
-/**
+/**
* All the types of functions that can be used in directives
* @internal
*/
const char *(*no_args) (cmd_parms *parms, void *mconfig);
/** function to call for a raw-args */
const char *(*raw_args) (cmd_parms *parms, void *mconfig,
- const char *args);
+ const char *args);
/** function to call for a argv/argc */
const char *(*take_argv) (cmd_parms *parms, void *mconfig,
- int argc, char *const argv[]);
+ int argc, char *const argv[]);
/** function to call for a take1 */
const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w);
/** function to call for a take2 */
const char *(*take2) (cmd_parms *parms, void *mconfig, const char *w,
- const char *w2);
+ const char *w2);
/** function to call for a take3 */
const char *(*take3) (cmd_parms *parms, void *mconfig, const char *w,
- const char *w2, const char *w3);
+ const char *w2, const char *w3);
/** function to call for a flag */
const char *(*flag) (cmd_parms *parms, void *mconfig, int on);
} cmd_func;
/** This configuration directive does not take any arguments */
-# define AP_NO_ARGS func.no_args
+# define AP_NO_ARGS func.no_args
/** This configuration directive will handle its own parsing of arguments*/
-# define AP_RAW_ARGS func.raw_args
+# define AP_RAW_ARGS func.raw_args
/** This configuration directive will handle its own parsing of arguments*/
-# define AP_TAKE_ARGV func.take_argv
+# define AP_TAKE_ARGV func.take_argv
/** This configuration directive takes 1 argument*/
-# define AP_TAKE1 func.take1
+# define AP_TAKE1 func.take1
/** This configuration directive takes 2 arguments */
-# define AP_TAKE2 func.take2
+# define AP_TAKE2 func.take2
/** This configuration directive takes 3 arguments */
-# define AP_TAKE3 func.take3
+# define AP_TAKE3 func.take3
/** This configuration directive takes a flag (on/off) as a argument*/
-# define AP_FLAG func.flag
+# define AP_FLAG func.flag
/** mechanism for declaring a directive with no arguments */
# define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
* The command record structure. Each modules can define a table of these
* to define the directives it will implement.
*/
-typedef struct command_struct command_rec;
+typedef struct command_struct command_rec;
struct command_struct {
/** Name of this command */
const char *name;
/** The function to be called when this directive is parsed */
cmd_func func;
/** Extra data, for functions which implement multiple commands... */
- void *cmd_data;
+ void *cmd_data;
/** What overrides need to be allowed to enable this command. */
int req_override;
/** What the command expects as arguments */
* @{
*/
#define OR_NONE 0 /**< *.conf is not available anywhere in this override */
-#define OR_LIMIT 1 /**< *.conf inside <Directory> or <Location>
- and .htaccess when AllowOverride Limit */
+#define OR_LIMIT 1 /**< *.conf inside <Directory> or <Location>
+ and .htaccess when AllowOverride Limit */
#define OR_OPTIONS 2 /**< *.conf anywhere
and .htaccess when AllowOverride Options */
#define OR_FILEINFO 4 /**< *.conf anywhere
- and .htaccess when AllowOverride FileInfo */
+ and .htaccess when AllowOverride FileInfo */
#define OR_AUTHCFG 8 /**< *.conf inside <Directory> or <Location>
- and .htaccess when AllowOverride AuthConfig */
+ and .htaccess when AllowOverride AuthConfig */
#define OR_INDEXES 16 /**< *.conf anywhere
- and .htaccess when AllowOverride Indexes */
-#define OR_UNSET 32 /**< unset a directive (in Allow) */
+ and .htaccess when AllowOverride Indexes */
+#define OR_UNSET 32 /**< bit to indicate that AllowOverride has not been set */
#define ACCESS_CONF 64 /**< *.conf inside <Directory> or <Location> */
-#define RSRC_CONF 128 /**< *.conf outside <Directory> or <Location> */
-#define EXEC_ON_READ 256 /**< force directive to execute a command
+#define RSRC_CONF 128 /**< *.conf outside <Directory> or <Location> */
+#define EXEC_ON_READ 256 /**< force directive to execute a command
which would modify the configuration (like including another
file, or IFModule */
/** this directive can be placed anywhere */
/** Common structure for reading of config files / passwd files etc. */
typedef struct ap_configfile_t ap_configfile_t;
struct ap_configfile_t {
- int (*getch) (void *param); /**< a getc()-like function */
- void *(*getstr) (void *buf, size_t bufsiz, void *param);
- /**< a fgets()-like function */
- int (*close) (void *param); /**< a close handler function */
- void *param; /**< the argument passed to getch/getstr/close */
- const char *name; /**< the filename / description */
- unsigned line_number; /**< current line number, starting at 1 */
+ /**< an apr_file_getc()-like function */
+ apr_status_t (*getch) (char *ch, void *param);
+ /**< an apr_file_gets()-like function */
+ apr_status_t (*getstr) (void *buf, size_t bufsiz, void *param);
+ /**< a close handler function */
+ apr_status_t (*close) (void *param);
+ /**< the argument passed to getch/getstr/close */
+ void *param;
+ /**< the filename / description */
+ const char *name;
+ /**< current line number, starting at 1 */
+ unsigned line_number;
};
/**
/** Pool to allocate new storage in */
apr_pool_t *pool;
- /** Pool for scratch memory; persists during configuration, but
+ /** Pool for scratch memory; persists during configuration, but
* wiped before the first request is served... */
apr_pool_t *temp_pool;
/** Server_rec being configured for */
server_rec *server;
- /** If configuring for a directory, pathname of that directory.
- * NOPE! That's what it meant previous to the existence of <Files>,
- * <Location> and regex matching. Now the only usefulness that can be
- * derived from this field is whether a command is being called in a
- * server context (path == NULL) or being called in a dir context
+ /** If configuring for a directory, pathname of that directory.
+ * NOPE! That's what it meant previous to the existence of <Files>,
+ * <Location> and regex matching. Now the only usefulness that can be
+ * derived from this field is whether a command is being called in a
+ * server context (path == NULL) or being called in a dir context
* (path != NULL). */
char *path;
/** configuration command */
*/
typedef struct module_struct module;
struct module_struct {
- /** API version, *not* module version; check that module is
+ /** API version, *not* module version; check that module is
* compatible with this version of the server.
*/
int version;
- /** API minor version. Provides API feature milestones. Not checked
+ /** API minor version. Provides API feature milestones. Not checked
* during module init */
int minor_version;
/** Index to this modules structures in config vectors. */
*/
struct module_struct *next;
- /** Magic Cookie to identify a module structure; It's mainly
+ /** Magic Cookie to identify a module structure; It's mainly
* important for the DSO facility (see also mod_so). */
unsigned long magic;
* @param new_conf The directory structure currently being processed.
* @return The new per-directory structure created
*/
- void *(*merge_server_config) (apr_pool_t *p, void *base_conf,
+ void *(*merge_server_config) (apr_pool_t *p, void *base_conf,
void *new_conf);
/** A command_rec table that describes all of the directives this module
* APLOG_USE_MODULE indirectly sets APLOG_MODULE_INDEX and APLOG_MARK.
*
* If a module should be backward compatible with versions before 2.3.6,
- * APLOG_USE_MODULE needs to be enclosed in a #ifdef APLOG_USE_MODULE block.
+ * APLOG_USE_MODULE needs to be enclosed in a ifdef APLOG_USE_MODULE block.
*
* @param foo name of the module symbol of the current module, without the
* trailing "_module" part
*/
/** The one used in Apache 1.3, which will deliberately cause an error */
-#define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0
+#define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0
/** Use this in all standard modules */
-#define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
- MODULE_MAGIC_NUMBER_MINOR, \
- -1, \
- __FILE__, \
- NULL, \
- NULL, \
- MODULE_MAGIC_COOKIE, \
+#define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
+ MODULE_MAGIC_NUMBER_MINOR, \
+ -1, \
+ __FILE__, \
+ NULL, \
+ NULL, \
+ MODULE_MAGIC_COOKIE, \
NULL /* rewrite args spot */
/** Use this only in MPMs */
-#define MPM20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
- MODULE_MAGIC_NUMBER_MINOR, \
- -1, \
- __FILE__, \
- NULL, \
- NULL, \
- MODULE_MAGIC_COOKIE
+#define MPM20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
+ MODULE_MAGIC_NUMBER_MINOR, \
+ -1, \
+ __FILE__, \
+ NULL, \
+ NULL, \
+ MODULE_MAGIC_COOKIE
/** @} */
#if !defined(AP_DEBUG)
-#define ap_get_module_config(v,m) \
+#define ap_get_module_config(v,m) \
(((void **)(v))[(m)->module_index])
-#define ap_set_module_config(v,m,val) \
+#define ap_set_module_config(v,m,val) \
((((void **)(v))[(m)->module_index]) = (val))
#endif /* AP_DEBUG */
* @param arg The argument to the directive
* @return An error string or NULL on success
*/
-AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
+AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
void *struct_ptr,
const char *arg);
* @param arg The argument to the directive
* @return An error string or NULL on success
*/
-AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd,
+AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd,
void *struct_ptr,
const char *arg);
* @param arg The argument to the directive
* @return An error string or NULL on success
*/
-AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
- void *struct_ptr,
+AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
+ void *struct_ptr,
const char *arg);
/**
* Generic command handling function for flags stored in an int
* @param arg The argument to the directive (either 1 or 0)
* @return An error string or NULL on success
*/
-AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
- void *struct_ptr,
+AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
+ void *struct_ptr,
int arg);
/**
* Generic command handling function for flags stored in a char
* @param arg The argument to the directive (either 1 or 0)
* @return An error string or NULL on success
*/
-AP_DECLARE_NONSTD(const char *) ap_set_flag_slot_char(cmd_parms *cmd,
- void *struct_ptr,
+AP_DECLARE_NONSTD(const char *) ap_set_flag_slot_char(cmd_parms *cmd,
+ void *struct_ptr,
int arg);
/**
* Generic command handling function for files
* @param arg The argument to the directive
* @return An error string or NULL on success
*/
-AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd,
- void *struct_ptr,
+AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd,
+ void *struct_ptr,
const char *arg);
/**
* Generic command handling function to respond with cmd->help as an error
* @return The cmd->help value as the error string
* @note This allows simple declarations such as:
* @code
- * AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL,
+ * AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL,
* "The Foo directive is no longer supported, use Bar"),
* @endcode
*/
-AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd,
- void *struct_ptr,
+AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd,
+ void *struct_ptr,
const char *arg);
/**
* For modules which need to read config files, open logs, etc. this returns
* @param p The pool to allocate the structure from
* @param name the name of the file to open
*/
-AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg,
+AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg,
apr_pool_t *p, const char *name);
/**
- * Allocate a ap_configfile_t handle with user defined functions and params
+ * Allocate a ap_configfile_t handle with user defined functions and params
* @param p The pool to allocate from
* @param descr The name of the file
* @param param The argument passed to getch/getstr/close
* @param gets_func The getstr function
* @param close_func The close function
*/
-AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p,
+AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p,
const char *descr,
void *param,
- int(*getc_func)(void*),
- void *(*gets_func) (void *buf, size_t bufsiz, void *param),
- int(*close_func)(void *param));
+ apr_status_t (*getc_func) (char *ch, void *param),
+ apr_status_t (*gets_func) (void *buf, size_t bufsiz, void *param),
+ apr_status_t (*close_func) (void *param));
/**
- * Read one line from open ap_configfile_t, strip LF, increase line number
+ * Read one line from open ap_configfile_t, strip leading and trailing
+ * whitespace, increase line number
* @param buf place to store the line read
* @param bufsize size of the buffer
* @param cfp File to read from
- * @return 1 on success, 0 on failure
+ * @return error status, APR_ENOSPC if bufsize is too small for the line
*/
-AP_DECLARE(int) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp);
+AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp);
/**
- * Read one char from open configfile_t, increase line number upon LF
+ * Read one char from open configfile_t, increase line number upon LF
+ * @param ch place to store the char read
* @param cfp The file to read from
- * @return the character read
+ * @return error status
*/
-AP_DECLARE(int) ap_cfg_getc(ap_configfile_t *cfp);
+AP_DECLARE(apr_status_t) ap_cfg_getc(char *ch, ap_configfile_t *cfp);
/**
* Detach from open ap_configfile_t, calling the close handler
*/
AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp);
+/**
+ * Convert a return value from ap_cfg_getline or ap_cfg_getc to a user friendly
+ * string.
+ * @param p The pool to allocate the string from
+ * @param cfp The config file
+ * @return The error string, NULL if rc == APR_SUCCESS
+ */
+AP_DECLARE(const char *) ap_pcfg_strerror(apr_pool_t *p, ap_configfile_t *cfp,
+ apr_status_t rc);
+
/**
* Read all data between the current <foo> and the matching </foo>. All
- * of this data is forgotten immediately.
+ * of this data is forgotten immediately.
* @param cmd The cmd_parms to pass to the directives inside the container
* @param directive The directive name to read until
* @return Error string on failure, NULL on success
* @param orig_directive The directive to read until hit.
* @return Error string on failure, NULL on success
*/
-AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p,
+AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p,
apr_pool_t *temp_pool,
cmd_parms *parms,
ap_directive_t **current,
* @param forbidden Where the command is forbidden.
* @return Error string on error, NULL on success
*/
-AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
+AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
unsigned forbidden);
#define NOT_IN_VIRTUALHOST 0x01 /**< Forbidden in <VirtualHost> */
#define NOT_IN_LOCATION 0x08 /**< Forbidden in <Location> */
#define NOT_IN_FILES 0x10 /**< Forbidden in <Files> */
/** Forbidden in <Directory>/<Location>/<Files>*/
-#define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES)
+#define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES)
/** Forbidden in <VirtualHost>/<Limit>/<Directory>/<Location>/<Files> */
-#define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
+#define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
/** @} */
* @param s The server to configure for.
* @param m The module to configure
*/
-AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s,
+AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s,
module *m);
/* For http_main.c... */
*/
AP_DECLARE(void) ap_show_directives(void);
-/**
- * Show the preloaded module names. Used for httpd -l.
+/**
+ * Show the preloaded module names. Used for httpd -l.
*/
AP_DECLARE(void) ap_show_modules(void);
-/**
+/**
* Show the MPM name. Used in reporting modules such as mod_info to
* provide extra information to the user
*/
* @param conftree Place to store the root of the config tree
* @return The setup server_rec list.
*/
-AP_DECLARE(server_rec *) ap_read_config(process_rec *process,
- apr_pool_t *temp_pool,
- const char *config_name,
+AP_DECLARE(server_rec *) ap_read_config(process_rec *process,
+ apr_pool_t *temp_pool,
+ const char *config_name,
ap_directive_t **conftree);
/**
* @param p The pool to allocate from
* @param main_server The head of the server_rec list
*/
-AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p,
+AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p,
server_rec *main_server);
+/**
+ * Reserve some modules slots for modules loaded by other means than
+ * EXEC_ON_READ directives.
+ * Relevant modules should call this in the pre_config stage.
+ * @param count The number of slots to reserve.
+ */
+AP_DECLARE(void) ap_reserve_module_slots(int count);
+
+/**
+ * Reserve some modules slots for modules loaded by a specific
+ * non-EXEC_ON_READ config directive.
+ * This counts how often the given directive is used in the config and calls
+ * ap_reserve_module_slots() accordingly.
+ * @param directive The name of the directive
+ */
+AP_DECLARE(void) ap_reserve_module_slots_directive(const char *directive);
+
/* For http_request.c... */
/**
* @param p The pool to allocate the config vector from
* @return The config vector
*/
-AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p);
+AP_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p);
/**
* Setup the config vector for per dir module configs
* @param access_name The list of possible names for .htaccess files
* int The status of the current request
*/
-AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result,
+AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result,
request_rec *r,
int override,
int override_opts,
- const char *path,
+ const char *path,
const char *access_name);
/**
* @param ps Place to store the new server_rec
* return Error string on error, NULL on success
*/
-AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p,
+AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p,
const char *hostname,
- server_rec *main_server,
+ server_rec *main_server,
server_rec **ps);
/**
* @return Address of previously retained data structure, or NULL if not yet saved
*/
AP_DECLARE(void *) ap_retained_data_get(const char *key);
-
+
/* Module-method dispatchers, also for http_request.c */
/**
* Run the handler phase of each module until a module accepts the
* @param cmds The table to search
* @return The directive definition of the specified directive
*/
-AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name,
+AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name,
const command_rec *cmds);
/**
* @param mod The module list to search
* @return The directive definition of the specified directive
*/
-AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name,
+AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name,
module **mod);
/**
/**
* Run the child_init functions for each module
* @param pchild The child pool
- * @param s The list of server_recs in this server
+ * @param s The list of server_recs in this server
*/
AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s))
* is run before any other requests hooks are called (location_walk,
* directory_walk, access checking, et. al.). This hook was added
* to provide a quick way to serve content from a URI keyed cache.
- *
+ *
* @param r The request_rec
* @param lookup_uri Controls whether the caller actually wants content or not.
- * lookup is set when the quick_handler is called out of
+ * lookup is set when the quick_handler is called out of
* ap_sub_req_lookup_uri()
*/
AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri))
}
#endif
-#endif /* !APACHE_HTTP_CONFIG_H */
+#endif /* !APACHE_HTTP_CONFIG_H */
/** @} */