1 /* ====================================================================
2 * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the Apache Group
19 * for use in the Apache HTTP server project (http://www.apache.org/)."
21 * 4. The names "Apache Server" and "Apache Group" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
26 * 5. Products derived from this software may not be called "Apache"
27 * nor may "Apache" appear in their names without prior written
28 * permission of the Apache Group.
30 * 6. Redistributions of any form whatsoever must retain the following
32 * "This product includes software developed by the Apache Group
33 * for use in the Apache HTTP server project (http://www.apache.org/)."
35 * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Group and was originally based
51 * on public domain software written at the National Center for
52 * Supercomputing Applications, University of Illinois, Urbana-Champaign.
53 * For more information on the Apache Group and the Apache HTTP server
54 * project, please see <http://www.apache.org/>.
58 #ifndef APACHE_HTTP_CONFIG_H
59 #define APACHE_HTTP_CONFIG_H
68 * The central data structures around here...
71 /* Command dispatch structures... */
73 /* Note that for all of these except RAW_ARGS, the config routine is
74 * passed a freshly allocated string which can be modified or stored
75 * or whatever... it's only necessary to do pstrdup() stuff with
79 RAW_ARGS, /* cmd_func parses command line itself */
80 TAKE1, /* one argument only */
81 TAKE2, /* two arguments only */
82 ITERATE, /* one argument, occuring multiple times
85 ITERATE2, /* two arguments, 2nd occurs multiple times
88 FLAG, /* One of 'On' or 'Off' */
89 NO_ARGS, /* No args at all, e.g. </Directory> */
90 TAKE12, /* one or two arguments */
91 TAKE3, /* three arguments only */
92 TAKE23, /* two or three arguments */
93 TAKE123, /* one, two or three arguments */
94 TAKE13 /* one or three arguments */
97 typedef struct command_struct {
98 const char *name; /* Name of this command */
99 const char *(*func) (); /* Function invoked */
100 void *cmd_data; /* Extra data, for functions which
101 * implement multiple commands...
103 int req_override; /* What overrides need to be allowed to
104 * enable this command.
106 enum cmd_how args_how; /* What the command expects as arguments */
108 const char *errmsg; /* 'usage' message, in case of syntax errors */
111 /* The allowed locations for a configuration directive are the union of
112 * those indicated by each set bit in the req_override mask.
114 * (req_override & RSRC_CONF) => *.conf outside <Directory> or <Location>
115 * (req_override & ACCESS_CONF) => *.conf inside <Directory> or <Location>
116 * (req_override & OR_AUTHCFG) => *.conf inside <Directory> or <Location>
117 * and .htaccess when AllowOverride AuthConfig
118 * (req_override & OR_LIMIT) => *.conf inside <Directory> or <Location>
119 * and .htaccess when AllowOverride Limit
120 * (req_override & OR_OPTIONS) => *.conf anywhere
121 * and .htaccess when AllowOverride Options
122 * (req_override & OR_FILEINFO) => *.conf anywhere
123 * and .htaccess when AllowOverride FileInfo
124 * (req_override & OR_INDEXES) => *.conf anywhere
125 * and .htaccess when AllowOverride Indexes
130 #define OR_FILEINFO 4
132 #define OR_INDEXES 16
134 #define ACCESS_CONF 64
135 #define RSRC_CONF 128
136 #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
138 /* This can be returned by a function if they don't wish to handle
139 * a command. Make it something not likely someone will actually use
143 #define DECLINE_CMD "\a\b"
146 * This structure is passed to a command which is being invoked,
147 * to carry a large variety of miscellaneous data which is all of
148 * use to *somebody*...
152 void *info; /* Argument to command from cmd_table */
153 int override; /* Which allow-override bits are set */
154 int limited; /* Which methods are <Limit>ed */
156 configfile_t *config_file; /* Config file structure from pcfg_openfile() */
158 ap_pool *pool; /* Pool to allocate new storage in */
159 struct pool *temp_pool; /* Pool for scratch memory; persists during
160 * configuration, but wiped before the first
161 * request is served...
163 server_rec *server; /* Server_rec being configured for */
164 char *path; /* If configuring for a directory,
165 * pathname of that directory.
166 * NOPE! That's what it meant previous to the
167 * existance of <Files>, <Location> and regex
168 * matching. Now the only usefulness that can
169 * be derived from this field is whether a command
170 * is being called in a server context (path == NULL)
171 * or being called in a dir context (path != NULL).
173 const command_rec *cmd; /* configuration command */
174 const char *end_token; /* end token required to end a nested section */
175 void *context; /* per_dir_config vector passed
176 * to handle_command */
179 /* This structure records the existence of handlers in a module... */
182 const char *content_type; /* MUST be all lower case */
183 int (*handler) (request_rec *);
187 * Module structures. Just about everything is dispatched through
188 * these, directly or indirectly (through the command and handler
192 typedef struct module_struct {
193 int version; /* API version, *not* module version;
194 * check that module is compatible with this
195 * version of the server.
197 int minor_version; /* API minor version. Provides API feature
198 * milestones. Not checked during module init
200 int module_index; /* Index to this modules structures in
205 void *dynamic_load_handle;
207 struct module_struct *next;
209 unsigned long magic; /* Magic Cookie to identify a module structure;
210 * It's mainly important for the DSO facility
214 void *(*create_dir_config) (pool *p, char *dir);
215 void *(*merge_dir_config) (pool *p, void *base_conf, void *new_conf);
216 void *(*create_server_config) (pool *p, server_rec *s);
217 void *(*merge_server_config) (pool *p, void *base_conf, void *new_conf);
219 const command_rec *cmds;
220 const handler_rec *handlers;
222 /* Hooks for getting into the middle of server ops...
224 * translate_handler --- translate URI to filename
225 * access_checker --- check access by host address, etc. All of these
226 * run; if all decline, that's still OK.
227 * check_user_id --- get and validate user id from the HTTP request
228 * auth_checker --- see if the user (from check_user_id) is OK *here*.
229 * If all of *these* decline, the request is rejected
230 * (as a SERVER_ERROR, since the module which was
231 * supposed to handle this was configured wrong).
232 * type_checker --- Determine MIME type of the requested entity;
233 * sets content_type, _encoding and _language fields.
236 void (*register_hooks) (void);
239 /* Initializer for the first few module slots, which are only
240 * really set up once we start running. Note that the first two slots
241 * provide a version check; this should allow us to deal with changes to
242 * the API. The major number should reflect changes to the API handler table
243 * itself or removal of functionality. The minor number should reflect
244 * additions of functionality to the existing API. (the server can detect
245 * an old-format module, and either handle it back-compatibly, or at least
246 * signal an error). See src/include/ap_mmn.h for MMN version history.
249 #define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0
251 #define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
252 MODULE_MAGIC_NUMBER_MINOR, \
259 /* Generic accessors for other modules to get at their own module-specific
263 API_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m);
264 API_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val);
266 #define ap_get_module_config(v,m) \
267 (((void **)(v))[(m)->module_index])
268 #define ap_set_module_config(v,m,val) \
269 ((((void **)(v))[(m)->module_index]) = (val))
271 /* Generic command handling function... */
273 API_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *, char *, char *);
274 API_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *, char *, char *);
275 API_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *, char *, int);
276 API_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *, char *, char *);
278 /* For modules which need to read config files, open logs, etc. ...
279 * this returns the fname argument if it begins with '/'; otherwise
280 * it relativizes it wrt server_root.
283 API_EXPORT(const char *) ap_server_root_relative(pool *p, const char *fname);
285 /* Finally, the hook for dynamically loading modules in... */
287 API_EXPORT(void) ap_add_module(module *m);
288 API_EXPORT(void) ap_remove_module(module *m);
289 API_EXPORT(void) ap_add_loaded_module(module *mod);
290 API_EXPORT(void) ap_remove_loaded_module(module *mod);
291 API_EXPORT(int) ap_add_named_module(const char *name);
292 API_EXPORT(void) ap_clear_module_list(void);
293 API_EXPORT(const char *) ap_find_module_name(module *m);
294 API_EXPORT(module *) ap_find_linked_module(const char *name);
296 /* for implementing subconfigs and customized config files */
297 API_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config);
299 /* ap_check_cmd_context() definitions: */
300 API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden);
302 /* ap_check_cmd_context(): Forbidden in: */
303 #define NOT_IN_VIRTUALHOST 0x01 /* <Virtualhost> */
304 #define NOT_IN_LIMIT 0x02 /* <Limit> */
305 #define NOT_IN_DIRECTORY 0x04 /* <Directory> */
306 #define NOT_IN_LOCATION 0x08 /* <Location> */
307 #define NOT_IN_FILES 0x10 /* <Files> */
308 #define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) /* <Directory>/<Location>/<Files>*/
309 #define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
314 extern API_VAR_EXPORT module *top_module;
316 extern module *ap_prelinked_modules[];
317 extern module *ap_preloaded_modules[];
318 extern API_VAR_EXPORT module **ap_loaded_modules;
320 /* For mod_so.c... */
322 void ap_single_module_configure(pool *p, server_rec *s, module *m);
324 /* For http_main.c... */
326 void ap_setup_prelinked_modules(void);
327 void ap_show_directives(void);
328 void ap_show_modules(void);
329 server_rec *ap_read_config(pool *conf_pool, pool *temp_pool, const char *config_name);
330 void ap_post_config_hook(pool *pconf, pool *plog, pool *ptemp, server_rec *s);
331 void ap_child_init_hook(pool *pchild, server_rec *s);
333 /* For http_request.c... */
335 void *ap_create_request_config(pool *p);
336 CORE_EXPORT(void *) ap_create_per_dir_config(pool *p);
337 void *ap_merge_per_dir_configs(pool *p, void *base, void *new);
339 /* For http_connection.c... */
341 void *ap_create_conn_config(pool *p);
343 /* For http_core.c... (<Directory> command and virtual hosts) */
345 int ap_parse_htaccess(void **result, request_rec *r, int override,
346 const char *path, const char *access_name);
348 CORE_EXPORT(const char *) ap_init_virtual_host(pool *p, const char *hostname,
349 server_rec *main_server, server_rec **);
350 void ap_process_resource_config(server_rec *s, const char *fname, pool *p, pool *ptemp);
352 /* Module-method dispatchers, also for http_request.c */
354 int ap_translate_name(request_rec *);
355 int ap_check_user_id(request_rec *); /* obtain valid username from client auth */
356 int ap_invoke_handler(request_rec *);
360 CORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds);
361 CORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod);
362 CORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod);
363 CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l);
368 DECLARE_HOOK(int,header_parser,(request_rec *))
369 DECLARE_HOOK(void,pre_config,(pool *pconf,pool *plog,pool *ptemp))
370 DECLARE_HOOK(void,post_config,
371 (pool *pconf,pool *plog,pool *ptemp,server_rec *s))
372 DECLARE_HOOK(void,open_logs,
373 (pool *pconf,pool *plog,pool *ptemp,server_rec *s))
374 DECLARE_HOOK(void,child_init,(pool *pchild, server_rec *s))
380 #endif /* !APACHE_HTTP_CONFIG_H */