home *** CD-ROM | disk | FTP | other *** search
/ PC World Plus! (NZ) 2001 October / PCW1001.iso / Linux / apache / apache_1.3.20-win32-no_src-r2.msi / Data.Cab / F160736_http_config.h < prev    next >
C/C++ Source or Header  |  2001-05-15  |  17KB  |  417 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000 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. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65.  
  66. /*
  67.  * The central data structures around here...
  68.  */
  69.  
  70. /* Command dispatch structures... */
  71.  
  72. /* Note that for all of these except RAW_ARGS, the config routine is
  73.  * passed a freshly allocated string which can be modified or stored
  74.  * or whatever... it's only necessary to do pstrdup() stuff with
  75.  * RAW_ARGS.
  76.  */
  77. enum cmd_how {
  78.     RAW_ARGS,            /* cmd_func parses command line itself */
  79.     TAKE1,            /* one argument only */
  80.     TAKE2,            /* two arguments only */
  81.     ITERATE,            /* one argument, occuring multiple times
  82.                  * (e.g., IndexIgnore)
  83.                  */
  84.     ITERATE2,            /* two arguments, 2nd occurs multiple times
  85.                  * (e.g., AddIcon)
  86.                  */
  87.     FLAG,            /* One of 'On' or 'Off' */
  88.     NO_ARGS,            /* No args at all, e.g. </Directory> */
  89.     TAKE12,            /* one or two arguments */
  90.     TAKE3,            /* three arguments only */
  91.     TAKE23,            /* two or three arguments */
  92.     TAKE123,            /* one, two or three arguments */
  93.     TAKE13            /* one or three arguments */
  94. };
  95.  
  96. typedef struct command_struct {
  97.     const char *name;        /* Name of this command */
  98.     const char *(*func) ();    /* Function invoked */
  99.     void *cmd_data;        /* Extra data, for functions which
  100.                  * implement multiple commands...
  101.                  */
  102.     int req_override;        /* What overrides need to be allowed to
  103.                  * enable this command.
  104.                  */
  105.     enum cmd_how args_how;    /* What the command expects as arguments */
  106.  
  107.     const char *errmsg;        /* 'usage' message, in case of syntax errors */
  108. } command_rec;
  109.  
  110. /* The allowed locations for a configuration directive are the union of
  111.  * those indicated by each set bit in the req_override mask.
  112.  *
  113.  * (req_override & RSRC_CONF)   => *.conf outside <Directory> or <Location>
  114.  * (req_override & ACCESS_CONF) => *.conf inside <Directory> or <Location>
  115.  * (req_override & OR_AUTHCFG)  => *.conf inside <Directory> or <Location>
  116.  *                                 and .htaccess when AllowOverride AuthConfig
  117.  * (req_override & OR_LIMIT)    => *.conf inside <Directory> or <Location>
  118.  *                                 and .htaccess when AllowOverride Limit
  119.  * (req_override & OR_OPTIONS)  => *.conf anywhere
  120.  *                                 and .htaccess when AllowOverride Options
  121.  * (req_override & OR_FILEINFO) => *.conf anywhere
  122.  *                                 and .htaccess when AllowOverride FileInfo
  123.  * (req_override & OR_INDEXES)  => *.conf anywhere
  124.  *                                 and .htaccess when AllowOverride Indexes
  125.  */
  126. #define OR_NONE 0
  127. #define OR_LIMIT 1
  128. #define OR_OPTIONS 2
  129. #define OR_FILEINFO 4
  130. #define OR_AUTHCFG 8
  131. #define OR_INDEXES 16
  132. #define OR_UNSET 32
  133. #define ACCESS_CONF 64
  134. #define RSRC_CONF 128
  135. #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
  136.  
  137. /* This can be returned by a function if they don't wish to handle
  138.  * a command. Make it something not likely someone will actually use
  139.  * as an error code.
  140.  */
  141.  
  142. #define DECLINE_CMD "\a\b"
  143.  
  144. /*
  145.  * This structure is passed to a command which is being invoked,
  146.  * to carry a large variety of miscellaneous data which is all of
  147.  * use to *somebody*...
  148.  */
  149.  
  150. typedef struct {
  151.     void *info;            /* Argument to command from cmd_table */
  152.     int override;        /* Which allow-override bits are set */
  153.     int limited;        /* Which methods are <Limit>ed */
  154.  
  155.     configfile_t *config_file;    /* Config file structure from pcfg_openfile() */
  156.  
  157.     ap_pool *pool;            /* Pool to allocate new storage in */
  158.     struct pool *temp_pool;        /* Pool for scratch memory; persists during
  159.                  * configuration, but wiped before the first
  160.                  * request is served...
  161.                  */
  162.     server_rec *server;        /* Server_rec being configured for */
  163.     char *path;            /* If configuring for a directory,
  164.                  * pathname of that directory.
  165.                  * NOPE!  That's what it meant previous to the
  166.                  * existance of <Files>, <Location> and regex
  167.                  * matching.  Now the only usefulness that can
  168.                  * be derived from this field is whether a command
  169.                  * is being called in a server context (path == NULL)
  170.                  * or being called in a dir context (path != NULL).
  171.                  */
  172.     const command_rec *cmd;    /* configuration command */
  173.     const char *end_token;    /* end token required to end a nested section */
  174.     void *context;        /* per_dir_config vector passed 
  175.                  * to handle_command */
  176. } cmd_parms;
  177.  
  178. /* This structure records the existence of handlers in a module... */
  179.  
  180. typedef struct {
  181.     const char *content_type;    /* MUST be all lower case */
  182.     int (*handler) (request_rec *);
  183. } handler_rec;
  184.  
  185. /*
  186.  * Module structures.  Just about everything is dispatched through
  187.  * these, directly or indirectly (through the command and handler
  188.  * tables).
  189.  */
  190.  
  191. typedef struct module_struct {
  192.     int version;        /* API version, *not* module version;
  193.                  * check that module is compatible with this
  194.                  * version of the server.
  195.                  */
  196.     int minor_version;          /* API minor version. Provides API feature
  197.                                  * milestones. Not checked during module init
  198.                  */
  199.     int module_index;        /* Index to this modules structures in
  200.                  * config vectors.
  201.                  */
  202.  
  203.     const char *name;
  204.     void *dynamic_load_handle;
  205.  
  206.     struct module_struct *next;
  207.  
  208.     unsigned long magic;        /* Magic Cookie to identify a module structure;
  209.                                  * It's mainly important for the DSO facility
  210.                                  * (see also mod_so).
  211.                                  */
  212.  
  213.     /* init() occurs after config parsing, but before any children are
  214.      * forked.
  215.      * Modules should not rely on the order in which create_server_config
  216.      * and create_dir_config are called.
  217.      */
  218. #ifdef ULTRIX_BRAIN_DEATH
  219.     void (*init) ();
  220.     void *(*create_dir_config) ();
  221.     void *(*merge_dir_config) ();
  222.     void *(*create_server_config) ();
  223.     void *(*merge_server_config) ();
  224. #else
  225.     void (*init) (server_rec *, pool *);
  226.     void *(*create_dir_config) (pool *p, char *dir);
  227.     void *(*merge_dir_config) (pool *p, void *base_conf, void *new_conf);
  228.     void *(*create_server_config) (pool *p, server_rec *s);
  229.     void *(*merge_server_config) (pool *p, void *base_conf, void *new_conf);
  230. #endif
  231.  
  232.     const command_rec *cmds;
  233.     const handler_rec *handlers;
  234.  
  235.     /* Hooks for getting into the middle of server ops...
  236.  
  237.      * translate_handler --- translate URI to filename
  238.      * access_checker --- check access by host address, etc.   All of these
  239.      *                    run; if all decline, that's still OK.
  240.      * check_user_id --- get and validate user id from the HTTP request
  241.      * auth_checker --- see if the user (from check_user_id) is OK *here*.
  242.      *                  If all of *these* decline, the request is rejected
  243.      *                  (as a SERVER_ERROR, since the module which was
  244.      *                  supposed to handle this was configured wrong).
  245.      * type_checker --- Determine MIME type of the requested entity;
  246.      *                  sets content_type, _encoding and _language fields.
  247.      * logger --- log a transaction.
  248.      * post_read_request --- run right after read_request or internal_redirect,
  249.      *                  and not run during any subrequests.
  250.      */
  251.  
  252.     int (*translate_handler) (request_rec *);
  253.     int (*ap_check_user_id) (request_rec *);
  254.     int (*auth_checker) (request_rec *);
  255.     int (*access_checker) (request_rec *);
  256.     int (*type_checker) (request_rec *);
  257.     int (*fixer_upper) (request_rec *);
  258.     int (*logger) (request_rec *);
  259.     int (*header_parser) (request_rec *);
  260.  
  261.     /* Regardless of the model the server uses for managing "units of
  262.      * execution", i.e. multi-process, multi-threaded, hybrids of those,
  263.      * there is the concept of a "heavy weight process".  That is, a
  264.      * process with its own memory space, file spaces, etc.  This method,
  265.      * child_init, is called once for each heavy-weight process before
  266.      * any requests are served.  Note that no provision is made yet for
  267.      * initialization per light-weight process (i.e. thread).  The
  268.      * parameters passed here are the same as those passed to the global
  269.      * init method above.
  270.      */
  271. #ifdef ULTRIX_BRAIN_DEATH
  272.     void (*child_init) ();
  273.     void (*child_exit) ();
  274. #else
  275.     void (*child_init) (server_rec *, pool *);
  276.     void (*child_exit) (server_rec *, pool *);
  277. #endif
  278.     int (*post_read_request) (request_rec *);
  279. } module;
  280.  
  281. /* Initializer for the first few module slots, which are only
  282.  * really set up once we start running.  Note that the first two slots
  283.  * provide a version check; this should allow us to deal with changes to
  284.  * the API. The major number should reflect changes to the API handler table
  285.  * itself or removal of functionality. The minor number should reflect
  286.  * additions of functionality to the existing API. (the server can detect
  287.  * an old-format module, and either handle it back-compatibly, or at least
  288.  * signal an error). See src/include/ap_mmn.h for MMN version history.
  289.  */
  290.  
  291. #define STANDARD_MODULE_STUFF    MODULE_MAGIC_NUMBER_MAJOR, \
  292.                 MODULE_MAGIC_NUMBER_MINOR, \
  293.                 -1, \
  294.                 __FILE__, \
  295.                 NULL, \
  296.                 NULL, \
  297.                 MODULE_MAGIC_COOKIE
  298.  
  299. /* Generic accessors for other modules to get at their own module-specific
  300.  * data
  301.  */
  302.  
  303. API_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m);
  304. API_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val);
  305.  
  306. #define ap_get_module_config(v,m)    \
  307.     (((void **)(v))[(m)->module_index])
  308. #define ap_set_module_config(v,m,val)    \
  309.     ((((void **)(v))[(m)->module_index]) = (val))
  310.  
  311. /* Generic command handling function... */
  312.  
  313. API_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *, char *, char *);
  314. API_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *, char *, char *);
  315. API_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *, char *, int);
  316. API_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *, char *, char *);
  317.  
  318. /* For modules which need to read config files, open logs, etc. ...
  319.  * this returns the fname argument if it begins with '/'; otherwise
  320.  * it relativizes it wrt server_root.
  321.  */
  322.  
  323. API_EXPORT(char *) ap_server_root_relative(pool *p, char *fname);
  324.  
  325. /* Finally, the hook for dynamically loading modules in... */
  326.  
  327. API_EXPORT(void) ap_add_module(module *m);
  328. API_EXPORT(void) ap_remove_module(module *m);
  329. API_EXPORT(void) ap_add_loaded_module(module *mod);
  330. API_EXPORT(void) ap_remove_loaded_module(module *mod);
  331. API_EXPORT(int) ap_add_named_module(const char *name);
  332. API_EXPORT(void) ap_clear_module_list(void);
  333. API_EXPORT(const char *) ap_find_module_name(module *m);
  334. API_EXPORT(module *) ap_find_linked_module(const char *name);
  335.  
  336. /* for implementing subconfigs and customized config files */
  337. API_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config);
  338.  
  339. #ifdef CORE_PRIVATE
  340.  
  341. extern API_VAR_EXPORT module *top_module;
  342.  
  343. extern module *ap_prelinked_modules[];
  344. extern module *ap_preloaded_modules[];
  345. extern API_VAR_EXPORT module **ap_loaded_modules;
  346.  
  347. /* For mod_so.c... */
  348.  
  349. void ap_single_module_configure(pool *p, server_rec *s, module *m);
  350.  
  351. /* For http_main.c... */
  352.  
  353. server_rec *ap_read_config(pool *conf_pool, pool *temp_pool, char *config_name);
  354. void ap_init_modules(pool *p, server_rec *s);
  355. void ap_child_init_modules(pool *p, server_rec *s);
  356. void ap_child_exit_modules(pool *p, server_rec *s);
  357. void ap_setup_prelinked_modules(void);
  358. void ap_show_directives(void);
  359. void ap_show_modules(void);
  360. void ap_cleanup_method_ptrs(void);
  361.  
  362. /* For http_request.c... */
  363.  
  364. void *ap_create_request_config(pool *p);
  365. CORE_EXPORT(void *) ap_create_per_dir_config(pool *p);
  366. void *ap_merge_per_dir_configs(pool *p, void *base, void *new);
  367.  
  368. /* For http_core.c... (<Directory> command and virtual hosts) */
  369.  
  370. int ap_parse_htaccess(void **result, request_rec *r, int override,
  371.         const char *path, const char *access_name);
  372.  
  373. CORE_EXPORT(const char *) ap_init_virtual_host(pool *p, const char *hostname,
  374.                 server_rec *main_server, server_rec **);
  375. void ap_process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp);
  376.  
  377. /* ap_check_cmd_context() definitions: */
  378. API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden);
  379.  
  380. /* ap_check_cmd_context():              Forbidden in: */
  381. #define  NOT_IN_VIRTUALHOST     0x01 /* <Virtualhost> */
  382. #define  NOT_IN_LIMIT           0x02 /* <Limit> */
  383. #define  NOT_IN_DIRECTORY       0x04 /* <Directory> */
  384. #define  NOT_IN_LOCATION        0x08 /* <Location> */
  385. #define  NOT_IN_FILES           0x10 /* <Files> */
  386. #define  NOT_IN_DIR_LOC_FILE    (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) /* <Directory>/<Location>/<Files>*/
  387. #define  GLOBAL_ONLY            (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
  388.  
  389.  
  390. /* Module-method dispatchers, also for http_request.c */
  391.  
  392. int ap_translate_name(request_rec *);
  393. int ap_check_access(request_rec *);    /* check access on non-auth basis */
  394. int ap_check_user_id(request_rec *);    /* obtain valid username from client auth */
  395. int ap_check_auth(request_rec *);    /* check (validated) user is authorized here */
  396. int ap_find_types(request_rec *);    /* identify MIME type */
  397. int ap_run_fixups(request_rec *);    /* poke around for other metainfo, etc.... */
  398. int ap_invoke_handler(request_rec *);
  399. int ap_log_transaction(request_rec *r);
  400. int ap_header_parse(request_rec *);
  401. int ap_run_post_read_request(request_rec *);
  402.  
  403. /* for mod_perl */
  404.  
  405. CORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds);
  406. CORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod);
  407. CORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod);
  408. CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l);
  409.  
  410. #endif
  411.  
  412. #ifdef __cplusplus
  413. }
  414. #endif
  415.  
  416. #endif    /* !APACHE_HTTP_CONFIG_H */
  417.