home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 April / PCO0499.ISO / filesbbs / os2 / apach134.arj / APACH134.ZIP / src / include / http_core.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-01  |  10.0 KB  |  289 lines

  1. /* ====================================================================
  2.  * Copyright (c) 1995-1999 The Apache Group.  All rights reserved.
  3.  *
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  *
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer. 
  10.  *
  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
  14.  *    distribution.
  15.  *
  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/)."
  20.  *
  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
  24.  *    apache@apache.org.
  25.  *
  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.
  29.  *
  30.  * 6. Redistributions of any form whatsoever must retain the following
  31.  *    acknowledgment:
  32.  *    "This product includes software developed by the Apache Group
  33.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  34.  *
  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.  * ====================================================================
  48.  *
  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/>.
  55.  *
  56.  */
  57.  
  58. #ifndef APACHE_HTTP_CORE_H
  59. #define APACHE_HTTP_CORE_H
  60.  
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64.  
  65. /*****************************************************************
  66.  *
  67.  * The most basic server code is encapsulated in a single module
  68.  * known as the core, which is just *barely* functional enough to
  69.  * serve documents, though not terribly well.
  70.  *
  71.  * Largely for NCSA back-compatibility reasons, the core needs to
  72.  * make pieces of its config structures available to other modules.
  73.  * The accessors are declared here, along with the interpretation
  74.  * of one of them (allow_options).
  75.  */
  76.  
  77. #define OPT_NONE 0
  78. #define OPT_INDEXES 1
  79. #define OPT_INCLUDES 2
  80. #define OPT_SYM_LINKS 4
  81. #define OPT_EXECCGI 8
  82. #define OPT_UNSET 16
  83. #define OPT_INCNOEXEC 32
  84. #define OPT_SYM_OWNER 64
  85. #define OPT_MULTI 128
  86. #define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_SYM_LINKS|OPT_EXECCGI)
  87.  
  88. /* options for get_remote_host() */
  89. /* REMOTE_HOST returns the hostname, or NULL if the hostname
  90.  * lookup fails.  It will force a DNS lookup according to the
  91.  * HostnameLookups setting.
  92.  */
  93. #define REMOTE_HOST (0)
  94.  
  95. /* REMOTE_NAME returns the hostname, or the dotted quad if the
  96.  * hostname lookup fails.  It will force a DNS lookup according
  97.  * to the HostnameLookups setting.
  98.  */
  99. #define REMOTE_NAME (1)
  100.  
  101. /* REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
  102.  * never forced.
  103.  */
  104. #define REMOTE_NOLOOKUP (2)
  105.  
  106. /* REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
  107.  * a double reverse lookup, regardless of the HostnameLookups
  108.  * setting.  The result is the (double reverse checked) hostname,
  109.  * or NULL if any of the lookups fail.
  110.  */
  111. #define REMOTE_DOUBLE_REV (3)
  112.  
  113. #define SATISFY_ALL 0
  114. #define SATISFY_ANY 1
  115. #define SATISFY_NOSPEC 2
  116.  
  117. API_EXPORT(int) ap_allow_options (request_rec *);
  118. API_EXPORT(int) ap_allow_overrides (request_rec *);
  119. API_EXPORT(const char *) ap_default_type (request_rec *);     
  120. API_EXPORT(const char *) ap_document_root (request_rec *); /* Don't use this!  If your request went
  121.                       * through a Userdir, or something like
  122.                       * that, it'll screw you.  But it's
  123.                       * back-compatible...
  124.                       */
  125. API_EXPORT(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type);
  126. API_EXPORT(const char *) ap_get_remote_logname(request_rec *r);
  127.  
  128. /* Used for constructing self-referencing URLs, and things like SERVER_PORT,
  129.  * and SERVER_NAME.
  130.  */
  131. API_EXPORT(char *) ap_construct_url(pool *p, const char *uri, const request_rec *r);
  132. API_EXPORT(const char *) ap_get_server_name(const request_rec *r);
  133. API_EXPORT(unsigned) ap_get_server_port(const request_rec *r);
  134. API_EXPORT(unsigned long) ap_get_limit_req_body(const request_rec *r);
  135. API_EXPORT(void) ap_custom_response(request_rec *r, int status, char *string);
  136. API_EXPORT(int) ap_exists_config_define(char *name);
  137.  
  138. /* Authentication stuff.  This is one of the places where compatibility
  139.  * with the old config files *really* hurts; they don't discriminate at
  140.  * all between different authentication schemes, meaning that we need
  141.  * to maintain common state for all of them in the core, and make it
  142.  * available to the other modules through interfaces.
  143.  */
  144.     
  145. typedef struct {
  146.     int method_mask;
  147.     char *requirement;
  148. } require_line;
  149.      
  150. API_EXPORT(const char *) ap_auth_type (request_rec *);
  151. API_EXPORT(const char *) ap_auth_name (request_rec *);     
  152. API_EXPORT(int) ap_satisfies (request_rec *r);
  153. API_EXPORT(const array_header *) ap_requires (request_rec *);    
  154.  
  155. #ifdef CORE_PRIVATE
  156.  
  157. /*
  158.  * Core is also unlike other modules in being implemented in more than
  159.  * one file... so, data structures are declared here, even though most of
  160.  * the code that cares really is in http_core.c.  Also, another accessor.
  161.  */
  162.  
  163. char *ap_response_code_string (request_rec *r, int error_index);
  164.  
  165. extern API_VAR_EXPORT module core_module;
  166.  
  167. /* Per-directory configuration */
  168.  
  169. typedef unsigned char allow_options_t;
  170. typedef unsigned char overrides_t;
  171.  
  172. typedef struct {
  173.     /* path of the directory/regex/etc.  see also d_is_fnmatch below */
  174.     char *d;
  175.     /* the number of slashes in d */
  176.     unsigned d_components;
  177.  
  178.     /* If (opts & OPT_UNSET) then no absolute assignment to options has
  179.      * been made.
  180.      * invariant: (opts_add & opts_remove) == 0
  181.      * Which said another way means that the last relative (options + or -)
  182.      * assignment made to each bit is recorded in exactly one of opts_add
  183.      * or opts_remove.
  184.      */
  185.     allow_options_t opts;
  186.     allow_options_t opts_add;
  187.     allow_options_t opts_remove;
  188.     overrides_t override;
  189.     
  190.     /* MIME typing --- the core doesn't do anything at all with this,
  191.      * but it does know what to slap on a request for a document which
  192.      * goes untyped by other mechanisms before it slips out the door...
  193.      */
  194.     
  195.     char *ap_default_type;
  196.   
  197.     /* Authentication stuff.  Groan... */
  198.     
  199.     int satisfy;
  200.     char *ap_auth_type;
  201.     char *ap_auth_name;
  202.     array_header *ap_requires;
  203.  
  204.     /* Custom response config. These can contain text or a URL to redirect to.
  205.      * if response_code_strings is NULL then there are none in the config,
  206.      * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
  207.      * This lets us do quick merges in merge_core_dir_configs().
  208.      */
  209.   
  210.     char **response_code_strings;
  211.  
  212.     /* Hostname resolution etc */
  213. #define HOSTNAME_LOOKUP_OFF    0
  214. #define HOSTNAME_LOOKUP_ON    1
  215. #define HOSTNAME_LOOKUP_DOUBLE    2
  216. #define HOSTNAME_LOOKUP_UNSET    3
  217.     unsigned int hostname_lookups : 4;
  218.  
  219.     signed int do_rfc1413 : 2;   /* See if client is advertising a username? */
  220.  
  221.     signed int content_md5 : 2;  /* calculate Content-MD5? */
  222.  
  223.     unsigned use_canonical_name : 2; /* bit 0 = on/off, bit 1 = unset/set */
  224.  
  225.     /* since is_fnmatch(conf->d) was being called so frequently in
  226.      * directory_walk() and its relatives, this field was created and
  227.      * is set to the result of that call.
  228.      */
  229.     unsigned d_is_fnmatch : 1;
  230.  
  231.     /* System Resource Control */
  232. #ifdef RLIMIT_CPU
  233.     struct rlimit *limit_cpu;
  234. #endif
  235. #if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
  236.     struct rlimit *limit_mem;
  237. #endif
  238. #ifdef RLIMIT_NPROC
  239.     struct rlimit *limit_nproc;
  240. #endif
  241.     unsigned long limit_req_body;  /* limit on bytes in request msg body */
  242.  
  243.     /* logging options */
  244.     enum { srv_sig_off, srv_sig_on, srv_sig_withmail } server_signature;
  245.     int loglevel;
  246.     
  247.     /* Access control */
  248.     array_header *sec;
  249.     regex_t *r;
  250.  
  251. } core_dir_config;
  252.  
  253. /* Per-server core configuration */
  254.  
  255. typedef struct {
  256.   
  257. #ifdef GPROF
  258.     char *gprof_dir;
  259. #endif
  260.  
  261.     /* Name translations --- we want the core to be able to do *something*
  262.      * so it's at least a minimally functional web server on its own (and
  263.      * can be tested that way).  But let's keep it to the bare minimum:
  264.      */
  265.     char *ap_document_root;
  266.   
  267.     /* Access control */
  268.  
  269.     char *access_name;
  270.     array_header *sec;
  271.     array_header *sec_url;
  272. } core_server_config;
  273.  
  274. /* for http_config.c */
  275. void ap_core_reorder_directories(pool *, server_rec *);
  276.  
  277. /* for mod_perl */
  278. CORE_EXPORT(void) ap_add_per_dir_conf (server_rec *s, void *dir_config);
  279. CORE_EXPORT(void) ap_add_per_url_conf (server_rec *s, void *url_config);
  280. CORE_EXPORT_NONSTD(const char *) ap_limit_section (cmd_parms *cmd, void *dummy, const char *arg);
  281.  
  282. #endif
  283.  
  284. #ifdef __cplusplus
  285. }
  286. #endif
  287.  
  288. #endif    /* !APACHE_HTTP_CORE_H */
  289.