home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Web / Servers / apache-1.2.4-MIHS / original-source / src / httpd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-22  |  26.1 KB  |  749 lines

  1. /* ====================================================================
  2.  * Copyright (c) 1995-1997 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.
  24.  *
  25.  * 5. Redistributions of any form whatsoever must retain the following
  26.  *    acknowledgment:
  27.  *    "This product includes software developed by the Apache Group
  28.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  29.  *
  30.  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  31.  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  32.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  33.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  34.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  35.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  36.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  37.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  40.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  41.  * OF THE POSSIBILITY OF SUCH DAMAGE.
  42.  * ====================================================================
  43.  *
  44.  * This software consists of voluntary contributions made by many
  45.  * individuals on behalf of the Apache Group and was originally based
  46.  * on public domain software written at the National Center for
  47.  * Supercomputing Applications, University of Illinois, Urbana-Champaign.
  48.  * For more information on the Apache Group and the Apache HTTP server
  49.  * project, please see <http://www.apache.org/>.
  50.  *
  51.  */
  52.  
  53. /*
  54.  * httpd.h: header for simple (ha! not anymore) http daemon
  55.  */
  56.  
  57. /* Headers in which EVERYONE has an interest... */
  58.  
  59. #include "conf.h"
  60. #include "alloc.h"
  61. #include "buff.h"
  62.  
  63. /* ----------------------------- config dir ------------------------------ */
  64.  
  65. /* Define this to be the default server home dir. Anything later in this
  66.  * file with a relative pathname will have this added.
  67.  */
  68. #ifndef HTTPD_ROOT
  69. #ifdef __EMX__
  70. /* Set default for OS/2 file system */ 
  71. #define HTTPD_ROOT "/os2httpd"
  72. #else
  73. #define HTTPD_ROOT "/usr/local/etc/httpd"
  74. #endif
  75. #endif
  76.  
  77. /* Root of server */
  78. #ifdef __EMX__
  79. /* Set default for OS/2 file system */ 
  80. #define DOCUMENT_LOCATION "/os2httpd/docs"
  81. #else
  82. #define DOCUMENT_LOCATION "/usr/local/etc/httpd/htdocs"
  83. #endif
  84.  
  85. /* Max. number of dynamically loaded modules */
  86. #define DYNAMIC_MODULE_LIMIT 64
  87.  
  88. /* Default administrator's address */
  89. #define DEFAULT_ADMIN "[no address given]"
  90.  
  91. /* 
  92.  * --------- You shouldn't have to edit anything below this line ----------
  93.  *
  94.  * Any modifications to any defaults not defined above should be done in the 
  95.  * respective config. file. 
  96.  *
  97.  */
  98.  
  99.  
  100. /* -------------- Port number for server running standalone --------------- */
  101.  
  102. #define DEFAULT_PORT 80
  103.  
  104. /* --------- Default user name and group name running standalone ---------- */
  105. /* --- These may be specified as numbers by placing a # before a number --- */
  106.  
  107. #ifndef DEFAULT_USER
  108. #define DEFAULT_USER "#-1"
  109. #endif
  110. #ifndef DEFAULT_GROUP
  111. #define DEFAULT_GROUP "#-1"
  112. #endif
  113.  
  114. /* The name of the log files */
  115. #ifdef __EMX__
  116. /* Set default for OS/2 file system */ 
  117. #define DEFAULT_XFERLOG "logs/access.log"
  118. #else
  119. #define DEFAULT_XFERLOG "logs/access_log"
  120. #endif
  121. #ifdef __EMX__
  122. /* Set default for OS/2 file system */ 
  123. #define DEFAULT_ERRORLOG "logs/error.log"
  124. #else
  125. #define DEFAULT_ERRORLOG "logs/error_log"
  126. #endif
  127. #define DEFAULT_PIDLOG "logs/httpd.pid"
  128. #define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  129. #define DEFAULT_LOCKFILE "logs/accept.lock"
  130.  
  131. /* Define this to be what your HTML directory content files are called */
  132. #define DEFAULT_INDEX "index.html"
  133.  
  134. /* Define this to 1 if you want fancy indexing, 0 otherwise */
  135. #define DEFAULT_INDEXING 0
  136.  
  137. /* Define this to be what type you'd like returned for files with unknown */
  138. /* suffixes */
  139. #define DEFAULT_TYPE "text/plain"
  140.  
  141. /* Define this to be what your per-directory security files are called */
  142. #ifdef __EMX__
  143. /* Set default for OS/2 file system */ 
  144. #define DEFAULT_ACCESS_FNAME "htaccess"
  145. #else
  146. #define DEFAULT_ACCESS_FNAME ".htaccess"
  147. #endif
  148.  
  149. /* The name of the server config file */
  150. #ifndef SERVER_CONFIG_FILE
  151. #define SERVER_CONFIG_FILE "conf/httpd.conf"
  152. #endif
  153.  
  154. /* The name of the document config file */
  155. #define RESOURCE_CONFIG_FILE "conf/srm.conf"
  156.  
  157. /* The name of the MIME types file */
  158. #define TYPES_CONFIG_FILE "conf/mime.types"
  159.  
  160. /* The name of the access file */
  161. #define ACCESS_CONFIG_FILE "conf/access.conf"
  162.  
  163. /* Whether we should enable rfc1413 identity checking */
  164. #define DEFAULT_RFC1413 0
  165. /* The default directory in user's home dir */
  166. #define DEFAULT_USER_DIR "public_html"
  167.  
  168. /* The default path for CGI scripts if none is currently set */
  169. #ifndef DEFAULT_PATH
  170. #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
  171. #endif
  172.  
  173. /* The path to the Bourne shell, for parsed docs */
  174. #ifndef SHELL_PATH
  175. #ifdef __EMX__
  176. /* Set default for OS/2 file system */ 
  177. #define SHELL_PATH "CMD.EXE"
  178. #else
  179. #define SHELL_PATH "/bin/sh"
  180. #endif
  181. #endif
  182.  
  183. /* The path to the suExec wrapper, can be overridden in Configuration */
  184. #ifndef SUEXEC_BIN
  185. #define SUEXEC_BIN "/usr/local/etc/httpd/sbin/suexec"
  186. #endif
  187.  
  188. /* The default string lengths */
  189. #define MAX_STRING_LEN HUGE_STRING_LEN
  190. #define HUGE_STRING_LEN 8192
  191.  
  192. /* The timeout for waiting for messages */
  193. #define DEFAULT_TIMEOUT 300
  194.  
  195. /* The timeout for waiting for keepalive timeout until next request */
  196. #define DEFAULT_KEEPALIVE_TIMEOUT 15
  197.  
  198. /* The number of requests to entertain per connection */
  199. #define DEFAULT_KEEPALIVE 100
  200.  
  201. /* The size of the server's internal read-write buffers */
  202. #define IOBUFSIZE 8192
  203.  
  204. /* Number of servers to spawn off by default --- also, if fewer than
  205.  * this free when the caretaker checks, it will spawn more.
  206.  */
  207. #define DEFAULT_START_DAEMON 5
  208.  
  209. /* Maximum number of *free* server processes --- more than this, and
  210.  * they will die off.
  211.  */
  212.  
  213. #define DEFAULT_MAX_FREE_DAEMON 10
  214.  
  215. /* Minimum --- fewer than this, and more will be created */
  216.  
  217. #define DEFAULT_MIN_FREE_DAEMON 5
  218.  
  219. /* Limit on the total --- clients will be locked out if more servers than
  220.  * this are needed.  It is intended solely to keep the server from crashing
  221.  * when things get out of hand.
  222.  *
  223.  * We keep a hard maximum number of servers, for two reasons --- first off,
  224.  * in case something goes seriously wrong, we want to stop the fork bomb
  225.  * short of actually crashing the machine we're running on by filling some
  226.  * kernel table.  Secondly, it keeps the size of the scoreboard file small
  227.  * enough that we can read the whole thing without worrying too much about
  228.  * the overhead.
  229.  */
  230. #ifndef HARD_SERVER_LIMIT
  231. #define HARD_SERVER_LIMIT 256
  232. #endif
  233.  
  234. /* Number of requests to try to handle in a single process.  If <= 0,
  235.  * the children don't die off.  That's the default here, since I'm still
  236.  * interested in finding and stanching leaks.
  237.  */
  238.  
  239. #define DEFAULT_MAX_REQUESTS_PER_CHILD 0
  240.  
  241. /* If you have altered Apache and wish to change the SERVER_VERSION
  242.  * identifier below, please keep to the HTTP specification.  This states that
  243.  * the identification string should consist of product tokens with an optional
  244.  * slash and version designator.  Sub-products which form a significant part 
  245.  * of the application can be listed, separated by whitespace, by adding
  246.  * their product tokens to EXTRA_CFLAGS in the Configuration file like so.
  247.  *
  248.  * EXTRA_CFLAGS="-DSERVER_SUBVERSION="MrWidget/0.1-alpha"
  249.  *
  250.  * The tokens are listed in order of their significance for identifying the
  251.  * application.
  252.  *
  253.  * "Product tokens should be short and to the point -- use of them for 
  254.  * advertizing or other non-essential information is explicitly forbidden."
  255.  *
  256.  * Example: "Apache/1.1.0 MrWidget/0.1-alpha" 
  257.  */
  258.  
  259. #define SERVER_BASEVERSION "Apache/1.2.4" /* SEE COMMENTS ABOVE */
  260. #ifdef SERVER_SUBVERSION
  261. #define SERVER_VERSION    SERVER_BASEVERSION " " SERVER_SUBVERSION
  262. #else
  263. #define SERVER_VERSION    SERVER_BASEVERSION
  264. #endif
  265.  
  266. /* Numeric release version identifier: major minor bugfix betaseq
  267.  * Always increases along the same track as the source branch.
  268.  */
  269. #define APACHE_RELEASE 1020499
  270.  
  271. #define SERVER_PROTOCOL "HTTP/1.1"
  272. #define SERVER_SUPPORT "http://www.apache.org/"
  273.  
  274. #define DECLINED -1        /* Module declines to handle */
  275. #define OK 0            /* Module has handled this stage. */
  276.  
  277.  
  278. /* ----------------------- HTTP Status Codes  ------------------------- */
  279.  
  280. #define RESPONSE_CODES 38
  281.  
  282. #define HTTP_CONTINUE                      100
  283. #define HTTP_SWITCHING_PROTOCOLS           101
  284. #define HTTP_OK                            200
  285. #define HTTP_CREATED                       201
  286. #define HTTP_ACCEPTED                      202
  287. #define HTTP_NON_AUTHORITATIVE             203
  288. #define HTTP_NO_CONTENT                    204
  289. #define HTTP_RESET_CONTENT                 205
  290. #define HTTP_PARTIAL_CONTENT               206
  291. #define HTTP_MULTIPLE_CHOICES              300
  292. #define HTTP_MOVED_PERMANENTLY             301
  293. #define HTTP_MOVED_TEMPORARILY             302
  294. #define HTTP_SEE_OTHER                     303
  295. #define HTTP_NOT_MODIFIED                  304
  296. #define HTTP_USE_PROXY                     305
  297. #define HTTP_BAD_REQUEST                   400
  298. #define HTTP_UNAUTHORIZED                  401
  299. #define HTTP_PAYMENT_REQUIRED              402
  300. #define HTTP_FORBIDDEN                     403
  301. #define HTTP_NOT_FOUND                     404
  302. #define HTTP_METHOD_NOT_ALLOWED            405
  303. #define HTTP_NOT_ACCEPTABLE                406
  304. #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
  305. #define HTTP_REQUEST_TIME_OUT              408
  306. #define HTTP_CONFLICT                      409
  307. #define HTTP_GONE                          410
  308. #define HTTP_LENGTH_REQUIRED               411
  309. #define HTTP_PRECONDITION_FAILED           412
  310. #define HTTP_REQUEST_ENTITY_TOO_LARGE      413
  311. #define HTTP_REQUEST_URI_TOO_LARGE         414
  312. #define HTTP_UNSUPPORTED_MEDIA_TYPE        415
  313. #define HTTP_INTERNAL_SERVER_ERROR         500
  314. #define HTTP_NOT_IMPLEMENTED               501
  315. #define HTTP_BAD_GATEWAY                   502
  316. #define HTTP_SERVICE_UNAVAILABLE           503
  317. #define HTTP_GATEWAY_TIME_OUT              504
  318. #define HTTP_VERSION_NOT_SUPPORTED         505
  319. #define HTTP_VARIANT_ALSO_VARIES           506
  320.  
  321. #define DOCUMENT_FOLLOWS    HTTP_OK
  322. #define PARTIAL_CONTENT     HTTP_PARTIAL_CONTENT
  323. #define MULTIPLE_CHOICES    HTTP_MULTIPLE_CHOICES
  324. #define MOVED               HTTP_MOVED_PERMANENTLY
  325. #define REDIRECT            HTTP_MOVED_TEMPORARILY
  326. #define USE_LOCAL_COPY      HTTP_NOT_MODIFIED
  327. #define BAD_REQUEST         HTTP_BAD_REQUEST
  328. #define AUTH_REQUIRED       HTTP_UNAUTHORIZED
  329. #define FORBIDDEN           HTTP_FORBIDDEN
  330. #define NOT_FOUND           HTTP_NOT_FOUND
  331. #define METHOD_NOT_ALLOWED  HTTP_METHOD_NOT_ALLOWED
  332. #define NOT_ACCEPTABLE      HTTP_NOT_ACCEPTABLE
  333. #define LENGTH_REQUIRED     HTTP_LENGTH_REQUIRED
  334. #define PRECONDITION_FAILED HTTP_PRECONDITION_FAILED
  335. #define SERVER_ERROR        HTTP_INTERNAL_SERVER_ERROR
  336. #define NOT_IMPLEMENTED     HTTP_NOT_IMPLEMENTED
  337. #define BAD_GATEWAY         HTTP_BAD_GATEWAY
  338. #define VARIANT_ALSO_VARIES HTTP_VARIANT_ALSO_VARIES
  339.  
  340. #define is_HTTP_INFO(x)         (((x) >= 100)&&((x) < 200))
  341. #define is_HTTP_SUCCESS(x)      (((x) >= 200)&&((x) < 300))
  342. #define is_HTTP_REDIRECT(x)     (((x) >= 300)&&((x) < 400))
  343. #define is_HTTP_ERROR(x)        (((x) >= 400)&&((x) < 600))
  344. #define is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
  345. #define is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
  346.  
  347. #define status_drops_connection(x) (((x) == HTTP_BAD_REQUEST)           || \
  348.                                     ((x) == HTTP_REQUEST_TIME_OUT)      || \
  349.                                     ((x) == HTTP_LENGTH_REQUIRED)       || \
  350.                                     ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
  351.                                     ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
  352.                                     ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
  353.                                     ((x) == HTTP_SERVICE_UNAVAILABLE))
  354.  
  355.  
  356. #define METHODS 8
  357. #define M_GET 0
  358. #define M_PUT 1
  359. #define M_POST 2
  360. #define M_DELETE 3
  361. #define M_CONNECT 4
  362. #define M_OPTIONS 5
  363. #define M_TRACE 6
  364. #define M_INVALID 7
  365.  
  366. #define CGI_MAGIC_TYPE "application/x-httpd-cgi"
  367. #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"
  368. #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3"
  369. #define MAP_FILE_MAGIC_TYPE "application/x-type-map"
  370. #define ASIS_MAGIC_TYPE "httpd/send-as-is"
  371. #define DIR_MAGIC_TYPE "httpd/unix-directory"
  372. #define STATUS_MAGIC_TYPE "application/x-httpd-status"
  373.  
  374. /* Just in case your linefeed isn't the one the other end is expecting. */
  375. #define LF 10
  376. #define CR 13
  377.  
  378. /* Possible values for request_rec.read_body (set by handling module):
  379.  *    REQUEST_NO_BODY          Send 413 error if message has any body
  380.  *    REQUEST_CHUNKED_ERROR    Send 411 error if body without Content-Length
  381.  *    REQUEST_CHUNKED_DECHUNK  If chunked, remove the chunks for me.
  382.  *    REQUEST_CHUNKED_PASS     Pass the chunks to me without removal.
  383.  */
  384. #define REQUEST_NO_BODY          0
  385. #define REQUEST_CHUNKED_ERROR    1
  386. #define REQUEST_CHUNKED_DECHUNK  2
  387. #define REQUEST_CHUNKED_PASS     3
  388.  
  389. /* Things which may vary per file-lookup WITHIN a request ---
  390.  * e.g., state of MIME config.  Basically, the name of an object, info
  391.  * about the object, and any other info we may ahve which may need to
  392.  * change as we go poking around looking for it (e.g., overridden by
  393.  * .htaccess files).
  394.  *
  395.  * Note how the default state of almost all these things is properly
  396.  * zero, so that allocating it with pcalloc does the right thing without
  397.  * a whole lot of hairy initialization... so long as we are willing to
  398.  * make the (fairly) portable assumption that the bit pattern of a NULL
  399.  * pointer is, in fact, zero.
  400.  */
  401.  
  402. /* This represents the result of calling htaccess; these are cached for
  403.  * each request.
  404.  */
  405. struct htaccess_result
  406. {
  407.     char *dir;              /* the directory to which this applies */
  408.     int override;           /* the overrides allowed for the .htaccess file */
  409.     void *htaccess;         /* the configuration directives */
  410. /* the next one, or NULL if no more; N.B. never change this */
  411.     const struct htaccess_result *next;
  412. };
  413.  
  414.  
  415. typedef struct conn_rec conn_rec;
  416. typedef struct server_rec server_rec;
  417. typedef struct request_rec request_rec;
  418. typedef struct listen_rec listen_rec;
  419.  
  420. struct request_rec {
  421.  
  422.   pool *pool;
  423.   conn_rec *connection;
  424.   server_rec *server;
  425.  
  426.   request_rec *next;        /* If we wind up getting redirected,
  427.                  * pointer to the request we redirected to.
  428.                  */
  429.   request_rec *prev;        /* If this is an internal redirect,
  430.                  * pointer to where we redirected *from*.
  431.                  */
  432.   
  433.   request_rec *main;        /* If this is a sub_request (see request.h) 
  434.                  * pointer back to the main request.
  435.                  */
  436.  
  437.   /* Info about the request itself... we begin with stuff that only
  438.    * protocol.c should ever touch...
  439.    */
  440.   
  441.   char *the_request;        /* First line of request, so we can log it */
  442.   int assbackwards;        /* HTTP/0.9, "simple" request */
  443.   int proxyreq;                 /* A proxy request */
  444.   int header_only;        /* HEAD request, as opposed to GET */
  445.   char *protocol;        /* Protocol, as given to us, or HTTP/0.9 */
  446.   int proto_num;        /* Number version of protocol; 1.1 = 1001 */
  447.   char *hostname;        /* Host, as set by full URI or Host: */
  448.   int hostlen;            /* Length of http://host:port in full URI */
  449.  
  450.   time_t request_time;        /* When the request started */
  451.  
  452.   char *status_line;        /* Status line, if set by script */
  453.   int status;            /* In any case */
  454.   
  455.   /* Request method, two ways; also, protocol, etc..  Outside of protocol.c,
  456.    * look, but don't touch.
  457.    */
  458.   
  459.   char *method;            /* GET, HEAD, POST, etc. */
  460.   int method_number;        /* M_GET, M_POST, etc. */
  461.   int allowed;            /* Allowed methods - for 405, OPTIONS, etc */
  462.  
  463.   int sent_bodyct;        /* byte count in stream is for body */
  464.   long bytes_sent;        /* body byte count, for easy access */
  465.  
  466.   /* HTTP/1.1 connection-level features */
  467.  
  468.   int chunked;            /* sending chunked transfer-coding */
  469.   int byterange;        /* number of byte ranges */
  470.   char *boundary;        /* multipart/byteranges boundary */
  471.   char *range;            /* The Range: header */
  472.   long clength;            /* The "real" content length */
  473.  
  474.   long remaining;        /* bytes left to read */
  475.   long read_length;        /* bytes that have been read */
  476.   int read_body;           /* how the request body should be read */
  477.   int read_chunked;        /* reading chunked transfer-coding */
  478.  
  479.   /* MIME header environments, in and out.  Also, an array containing
  480.    * environment variables to be passed to subprocesses, so people can
  481.    * write modules to add to that environment.
  482.    *
  483.    * The difference between headers_out and err_headers_out is that the
  484.    * latter are printed even on error, and persist across internal redirects
  485.    * (so the headers printed for ErrorDocument handlers will have them).
  486.    *
  487.    * The 'notes' table is for notes from one module to another, with no
  488.    * other set purpose in mind...
  489.    */
  490.   
  491.   table *headers_in;
  492.   table *headers_out;
  493.   table *err_headers_out;
  494.   table *subprocess_env;
  495.   table *notes;
  496.  
  497.   char *content_type;        /* Break these out --- we dispatch on 'em */
  498.   char *handler;        /* What we *really* dispatch on           */
  499.  
  500.   char *content_encoding;
  501.   char *content_language;    /* for back-compat. only -- do not use */
  502.   array_header *content_languages; /* array of (char*) */
  503.   
  504.   int no_cache;
  505.   int no_local_copy;
  506.   
  507.   /* What object is being requested (either directly, or via include
  508.    * or content-negotiation mapping).
  509.    */
  510.  
  511.   char *uri;                    /* complete URI for a proxy req, or
  512.                                    URL path for a non-proxy req */
  513.   char *filename;
  514.   char *path_info;
  515.   char *args;            /* QUERY_ARGS, if any */
  516.   struct stat finfo;        /* ST_MODE set to zero if no such file */
  517.   
  518.   /* Various other config info which may change with .htaccess files
  519.    * These are config vectors, with one void* pointer for each module
  520.    * (the thing pointed to being the module's business).
  521.    */
  522.   
  523.   void *per_dir_config;        /* Options set in config files, etc. */
  524.   void *request_config;        /* Notes on *this* request */
  525.  
  526. /*
  527.  * a linked list of the configuration directives in the .htaccess files
  528.  * accessed by this request.
  529.  * N.B. always add to the head of the list, _never_ to the end.
  530.  * that way, a sub request's list can (temporarily) point to a parent's list
  531.  */
  532.   const struct htaccess_result *htaccess;
  533. };
  534.  
  535.  
  536. /* Things which are per connection
  537.  */
  538.  
  539. struct conn_rec {
  540.   
  541.   pool *pool;
  542.   server_rec *server;
  543.   server_rec *base_server;      /* Physical vhost this conn come in on */
  544.   
  545.   /* Information about the connection itself */
  546.  
  547.   int child_num;                /* The number of the child handling conn_rec */
  548.   BUFF *client;            /* Connetion to the guy */
  549.   int aborted;            /* Are we still talking? */
  550.   
  551.   /* Who is the client? */
  552.   
  553.   struct sockaddr_in local_addr; /* local address */
  554.   struct sockaddr_in remote_addr;/* remote address */
  555.   char *remote_ip;        /* Client's IP address */
  556.   char *remote_host;        /* Client's DNS name, if known.
  557.                                  * NULL if DNS hasn't been checked,
  558.                                  * "" if it has and no address was found.
  559.                                  * N.B. Only access this though
  560.                  * get_remote_host() */
  561.   char *remote_logname;        /* Only ever set if doing rfc1413 lookups.
  562.                                  * N.B. Only access this through
  563.                  * get_remote_logname() */
  564.     char *user;            /* If an authentication check was made,
  565.                  * this gets set to the user name.  We assume
  566.                  * that there's only one user per connection(!)
  567.                  */
  568.   char *auth_type;        /* Ditto. */
  569.  
  570.   int keepalive;        /* Are we using HTTP Keep-Alive? */
  571.   int keptalive;        /* Did we use HTTP Keep-Alive? */
  572.   int keepalives;        /* How many times have we used it? */
  573. };
  574.  
  575. /* Per-vhost config... */
  576.  
  577. /* The address 255.255.255.255, when used as a virtualhost address,
  578.  * will become the "default" server when the ip doesn't match other vhosts.
  579.  */
  580. #define DEFAULT_VHOST_ADDR 0xfffffffful
  581.  
  582. typedef struct server_addr_rec server_addr_rec;
  583. struct server_addr_rec {
  584.     server_addr_rec *next;
  585.     struct in_addr host_addr;    /* The bound address, for this server */
  586.     unsigned short host_port;    /* The bound port, for this server */   
  587.     char *virthost;        /* The name given in <VirtualHost> */
  588. };
  589.  
  590.  
  591. struct server_rec {
  592.  
  593.     server_rec *next;
  594.   
  595.     /* Full locations of server config info */
  596.   
  597.     char *srm_confname;
  598.     char *access_confname;
  599.   
  600.     /* Contact information */
  601.   
  602.     char *server_admin;
  603.     char *server_hostname;
  604.     unsigned short port;           /* for redirects, etc. */
  605.   
  606.     /* Log files --- note that transfer log is now in the modules... */
  607.   
  608.     char *error_fname;
  609.     FILE *error_log;
  610.   
  611.     /* Module-specific configuration for server, and defaults... */
  612.  
  613.     int is_virtual;             /* true if this is the virtual server */
  614.     void *module_config;    /* Config vector containing pointers to
  615.                  * modules' per-server config structures.
  616.                  */
  617.     void *lookup_defaults;    /* MIME type info, etc., before we start
  618.                  * checking per-directory info.
  619.                  */
  620.     /* Transaction handling */
  621.  
  622.     server_addr_rec *addrs;
  623.     int timeout;        /* Timeout, in seconds, before we give up */
  624.     int keep_alive_timeout;    /* Seconds we'll wait for another request */
  625.     int keep_alive_max;        /* Maximum requests per connection */
  626.     int keep_alive;        /* Use persistent connections? */
  627.     int send_buffer_size;       /* size of TCP send buffer (in bytes) */
  628.  
  629.     char *path;            /* Pathname for ServerPath */
  630.     int pathlen;        /* Length of path */
  631.  
  632.     char *names;        /* Wildcarded names for ServerAlias servers */
  633.  
  634.     uid_t server_uid;        /* effective user id when calling exec wrapper */
  635.     gid_t server_gid;        /* effective group id when calling exec wrapper */
  636. };
  637.  
  638. /* These are more like real hosts than virtual hosts */
  639. struct listen_rec {
  640.     listen_rec *next;
  641.     struct sockaddr_in local_addr; /* local IP address and port */
  642.     int fd;
  643.     int used;    /* Only used during restart */
  644. /* more stuff here, like which protocol is bound to the port */
  645. };
  646.  
  647. /* Prototypes for utilities... util.c.
  648.  */
  649.  
  650. /* Time */
  651. extern const char month_snames[12][4];
  652.  
  653. struct tm *get_gmtoff(int *tz);
  654. char *get_time();
  655. char *ht_time (pool *p, time_t t, const char *fmt, int gmt);     
  656. char *gm_timestr_822(pool *p, time_t t);
  657.      
  658. /* String handling. The *_nc variants allow you to use non-const char **s as
  659. arguments (unfortunately C won't automatically convert a char ** to a const
  660. char **) */     
  661.      
  662. char *getword(pool *p, const char **line, char stop);
  663. char *getword_nc(pool *p, char **line, char stop);
  664. char *getword_white(pool *p, const char **line);
  665. char *getword_white_nc(pool *p, char **line);
  666. char *getword_nulls (pool *p, const char **line, char stop);
  667. char *getword_nulls_nc (pool *p, char **line, char stop);
  668. char *getword_conf (pool *p, const char **line);      
  669. char *getword_conf_nc (pool *p, char **line);      
  670.  
  671. char *get_token (pool *p, char **accept_line, int accept_white);
  672. int find_token (pool *p, const char *line, const char *tok);
  673. int find_last_token (pool *p, const char *line, const char *tok);
  674.      
  675. int is_url(const char *u);
  676. extern int unescape_url(char *url);
  677. void no2slash(char *name);
  678. void getparents(char *name);
  679. char *escape_path_segment(pool *p, const char *s);
  680. char *os_escape_path(pool *p,const char *path,int partial);
  681. #define escape_uri(ppool,path) os_escape_path(ppool,path,1)
  682. extern char *escape_html(pool *p, const char *s);
  683. char *construct_server(pool *p, const char *hostname, unsigned port);
  684. char *construct_url (pool *p, const char *path, const server_rec *s);     
  685. char *escape_shell_cmd (pool *p, const char *s);
  686.      
  687. int count_dirs(const char *path);
  688. char *make_dirstr(pool *a, const char *s, int n);
  689. char *make_full_path(pool *a, const char *dir, const char *f);
  690.      
  691. int is_matchexp(const char *str);
  692. int strcmp_match(const char *str, const char *exp);
  693. int strcasecmp_match(const char *str, const char *exp);
  694. char *uudecode (pool *, const char *);
  695.  
  696. char *pregsub(pool *p, const char *input, const char *source,
  697.           size_t nmatch, regmatch_t pmatch[]);
  698.  
  699. void str_tolower (char *);
  700. int ind (const char *, char);    /* Sigh... */
  701. int rind (const char *, char);     
  702.  
  703. int cfg_getline(char *s, int n, FILE *f);
  704.  
  705. #ifdef NEED_STRERROR
  706. char *strerror (int err);
  707. #endif
  708.  
  709. /* Misc system hackery */
  710.      
  711. uid_t uname2id(const char *name);
  712. gid_t gname2id(const char *name);
  713. int is_directory(const char *name);
  714. int can_exec(const struct stat *);     
  715. void chdir_file(const char *file);
  716.      
  717. char *get_local_host(pool *);
  718. unsigned long get_virthost_addr (const char *hostname, unsigned short *port);
  719.  
  720. extern time_t restart_time;
  721.  
  722. /*
  723.  * Apache tries to keep all of its long term filehandles (such as log files,
  724.  * and sockets) above this number.  This is to workaround problems in many
  725.  * third party libraries that are compiled with a small FD_SETSIZE.  There
  726.  * should be no reason to lower this, because it's only advisory.  If a file
  727.  * can't be allocated above this number then it will remain in the "slack"
  728.  * area.
  729.  *
  730.  * Only the low slack line is used by default.  If HIGH_SLACK_LINE is defined
  731.  * then an attempt is also made to keep all non-FILE * files above the high
  732.  * slack line.  This is to work around a Solaris C library limitation, where it
  733.  * uses an unsigned char to store the file descriptor.
  734.  */
  735. #ifndef LOW_SLACK_LINE
  736. #define LOW_SLACK_LINE    15
  737. #endif
  738. /* #define HIGH_SLACK_LINE    255 */
  739.  
  740. /*
  741.  * The ap_slack() function takes a fd, and tries to move it above the indicated
  742.  * line.  It returns an fd which may or may not have moved above the line, and
  743.  * never fails.  If the high line was requested and it fails it will also try
  744.  * the low line.
  745.  */
  746. int ap_slack (int fd, int line);
  747. #define AP_SLACK_LOW    1
  748. #define AP_SLACK_HIGH    2
  749.