Main Page | Modules | Namespace List | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

httpd.h

Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00035 #ifndef APACHE_HTTPD_H
00036 #define APACHE_HTTPD_H
00037 
00038 /* XXX - We need to push more stuff to other .h files, or even .c files, to
00039  * make this file smaller
00040  */
00041 
00042 /* Headers in which EVERYONE has an interest... */
00043 #include "ap_config.h"
00044 #include "ap_mmn.h"
00045 
00046 #include "ap_release.h"
00047 
00048 #include "apr.h"
00049 #include "apr_general.h"
00050 #include "apr_tables.h"
00051 #include "apr_pools.h"
00052 #include "apr_time.h"
00053 #include "apr_network_io.h"
00054 #include "apr_buckets.h"
00055 #include "apr_poll.h"
00056 
00057 #include "os.h"
00058 
00059 #include "ap_regex.h"
00060 
00061 #if APR_HAVE_STDLIB_H
00062 #include <stdlib.h>
00063 #endif
00064 
00065 /* Note: apr_uri.h is also included, see below */
00066 
00067 #ifdef __cplusplus
00068 extern "C" {
00069 #endif
00070 
00071 #ifdef CORE_PRIVATE
00072 
00073 /* ----------------------------- config dir ------------------------------ */
00074 
00078 #ifndef HTTPD_ROOT
00079 #ifdef OS2
00080 
00081 #define HTTPD_ROOT "/os2httpd"
00082 #elif defined(WIN32)
00083 
00084 #define HTTPD_ROOT "/apache"
00085 #elif defined (BEOS)
00086 
00087 #define HTTPD_ROOT "/boot/home/apache"
00088 #elif defined (NETWARE)
00089 
00090 #define HTTPD_ROOT "/apache"
00091 #else
00092 
00093 #define HTTPD_ROOT "/usr/local/apache"
00094 #endif
00095 #endif /* HTTPD_ROOT */
00096 
00097 /* 
00098  * --------- You shouldn't have to edit anything below this line ----------
00099  *
00100  * Any modifications to any defaults not defined above should be done in the 
00101  * respective configuration file. 
00102  *
00103  */
00104 
00109 #ifndef DOCUMENT_LOCATION
00110 #ifdef OS2
00111 /* Set default for OS/2 file system */
00112 #define DOCUMENT_LOCATION  HTTPD_ROOT "/docs"
00113 #else
00114 /* Set default for non OS/2 file system */
00115 #define DOCUMENT_LOCATION  HTTPD_ROOT "/htdocs"
00116 #endif
00117 #endif /* DOCUMENT_LOCATION */
00118 
00120 #ifndef DYNAMIC_MODULE_LIMIT
00121 #define DYNAMIC_MODULE_LIMIT 128
00122 #endif
00123 
00125 #define DEFAULT_ADMIN "[no address given]"
00126 
00128 #ifndef DEFAULT_ERRORLOG
00129 #if defined(OS2) || defined(WIN32)
00130 #define DEFAULT_ERRORLOG "logs/error.log"
00131 #else
00132 #define DEFAULT_ERRORLOG "logs/error_log"
00133 #endif
00134 #endif /* DEFAULT_ERRORLOG */
00135 
00137 #ifndef DEFAULT_ACCESS_FNAME
00138 #ifdef OS2
00139 /* Set default for OS/2 file system */
00140 #define DEFAULT_ACCESS_FNAME "htaccess"
00141 #else
00142 #define DEFAULT_ACCESS_FNAME ".htaccess"
00143 #endif
00144 #endif /* DEFAULT_ACCESS_FNAME */
00145 
00147 #ifndef SERVER_CONFIG_FILE
00148 #define SERVER_CONFIG_FILE "conf/httpd.conf"
00149 #endif
00150 
00152 #ifndef DEFAULT_PATH
00153 #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
00154 #endif
00155 
00157 #ifndef SUEXEC_BIN
00158 #define SUEXEC_BIN  HTTPD_ROOT "/bin/suexec"
00159 #endif
00160 
00162 #ifndef DEFAULT_TIMEOUT
00163 #define DEFAULT_TIMEOUT 300 
00164 #endif
00165 
00167 #ifndef DEFAULT_KEEPALIVE_TIMEOUT
00168 #define DEFAULT_KEEPALIVE_TIMEOUT 5
00169 #endif
00170 
00172 #ifndef DEFAULT_KEEPALIVE
00173 #define DEFAULT_KEEPALIVE 100
00174 #endif
00175 
00176 /*
00177  * Limits on the size of various request items.  These limits primarily
00178  * exist to prevent simple denial-of-service attacks on a server based
00179  * on misuse of the protocol.  The recommended values will depend on the
00180  * nature of the server resources -- CGI scripts and database backends
00181  * might require large values, but most servers could get by with much
00182  * smaller limits than we use below.  The request message body size can
00183  * be limited by the per-dir config directive LimitRequestBody.
00184  *
00185  * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE
00186  * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190.
00187  * These two limits can be lowered (but not raised) by the server config
00188  * directives LimitRequestLine and LimitRequestFieldsize, respectively.
00189  *
00190  * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by
00191  * the server config directive LimitRequestFields.
00192  */
00193 
00195 #ifndef DEFAULT_LIMIT_REQUEST_LINE
00196 #define DEFAULT_LIMIT_REQUEST_LINE 8190
00197 #endif 
00198 
00199 #ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE
00200 #define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190
00201 #endif 
00202 
00203 #ifndef DEFAULT_LIMIT_REQUEST_FIELDS
00204 #define DEFAULT_LIMIT_REQUEST_FIELDS 100
00205 #endif 
00206 
00211 #define DEFAULT_ADD_DEFAULT_CHARSET_NAME "iso-8859-1"
00212 
00213 #endif /* CORE_PRIVATE */
00214 
00216 #define AP_SERVER_PROTOCOL "HTTP/1.1"
00217 
00218 
00219 /* ------------------ stuff that modules are allowed to look at ----------- */
00220 
00222 #ifndef AP_DEFAULT_INDEX
00223 #define AP_DEFAULT_INDEX "index.html"
00224 #endif
00225 
00226 
00232 #ifndef DEFAULT_CONTENT_TYPE
00233 #define DEFAULT_CONTENT_TYPE "text/plain"
00234 #endif
00235 
00240 #ifndef NO_CONTENT_TYPE
00241 #define NO_CONTENT_TYPE "none"
00242 #endif
00243 
00245 #ifndef AP_TYPES_CONFIG_FILE
00246 #define AP_TYPES_CONFIG_FILE "conf/mime.types"
00247 #endif
00248 
00249 /*
00250  * Define the HTML doctype strings centrally.
00251  */
00253 #define DOCTYPE_HTML_2_0  "<!DOCTYPE HTML PUBLIC \"-//IETF//" \
00254                           "DTD HTML 2.0//EN\">\n"
00255 
00256 #define DOCTYPE_HTML_3_2  "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
00257                           "DTD HTML 3.2 Final//EN\">\n"
00258 
00259 #define DOCTYPE_HTML_4_0S "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
00260                           "DTD HTML 4.0//EN\"\n" \
00261                           "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
00262 
00263 #define DOCTYPE_HTML_4_0T "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
00264                           "DTD HTML 4.0 Transitional//EN\"\n" \
00265                           "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"
00266 
00267 #define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
00268                           "DTD HTML 4.0 Frameset//EN\"\n" \
00269                           "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n"
00270 
00271 #define DOCTYPE_XHTML_1_0S "<!DOCTYPE html PUBLIC \"-//W3C//" \
00272                            "DTD XHTML 1.0 Strict//EN\"\n" \
00273                            "\"http://www.w3.org/TR/xhtml1/DTD/" \
00274                            "xhtml1-strict.dtd\">\n"
00275 
00276 #define DOCTYPE_XHTML_1_0T "<!DOCTYPE html PUBLIC \"-//W3C//" \
00277                            "DTD XHTML 1.0 Transitional//EN\"\n" \
00278                            "\"http://www.w3.org/TR/xhtml1/DTD/" \
00279                            "xhtml1-transitional.dtd\">\n"
00280 
00281 #define DOCTYPE_XHTML_1_0F "<!DOCTYPE html PUBLIC \"-//W3C//" \
00282                            "DTD XHTML 1.0 Frameset//EN\"\n" \
00283                            "\"http://www.w3.org/TR/xhtml1/DTD/" \
00284                            "xhtml1-frameset.dtd\">"
00285 
00287 #define HTTP_VERSION(major,minor) (1000*(major)+(minor))
00288 
00289 #define HTTP_VERSION_MAJOR(number) ((number)/1000)
00290 
00291 #define HTTP_VERSION_MINOR(number) ((number)%1000)
00292 
00293 /* -------------- Port number for server running standalone --------------- */
00294 
00296 #define DEFAULT_HTTP_PORT       80
00297 
00298 #define DEFAULT_HTTPS_PORT      443
00299 
00305 #define ap_is_default_port(port,r)      ((port) == ap_default_port(r))
00306 
00310 #define ap_default_port(r)      ap_run_default_port(r)
00311 
00315 #define ap_http_scheme(r)       ap_run_http_scheme(r)
00316 
00318 #define MAX_STRING_LEN HUGE_STRING_LEN
00319 
00321 #define HUGE_STRING_LEN 8192
00322 
00324 #define AP_IOBUFSIZE 8192
00325 
00327 #define AP_MAX_REG_MATCH 10
00328 
00335 #define AP_MAX_SENDFILE 16777216  /* 2^24 */
00336 
00343 #define APEXIT_OK               0x0
00344 
00345 #define APEXIT_INIT             0x2
00346 
00347 #define APEXIT_CHILDINIT        0x3
00348 
00353 #define APEXIT_CHILDSICK        0x7
00354 
00359 #define APEXIT_CHILDFATAL       0xf
00360 
00361 #ifndef AP_DECLARE
00362 
00367 # define AP_DECLARE(type)    type
00368 #endif
00369 
00370 #ifndef AP_DECLARE_NONSTD
00371 
00378 # define AP_DECLARE_NONSTD(type)    type
00379 #endif
00380 #ifndef AP_DECLARE_DATA
00381 # define AP_DECLARE_DATA
00382 #endif
00383 
00384 #ifndef AP_MODULE_DECLARE
00385 # define AP_MODULE_DECLARE(type)    type
00386 #endif
00387 #ifndef AP_MODULE_DECLARE_NONSTD
00388 # define AP_MODULE_DECLARE_NONSTD(type)  type
00389 #endif
00390 #ifndef AP_MODULE_DECLARE_DATA
00391 # define AP_MODULE_DECLARE_DATA
00392 #endif
00393 
00398 #ifndef AP_CORE_DECLARE
00399 # define AP_CORE_DECLARE        AP_DECLARE
00400 #endif
00401 
00407 #ifndef AP_CORE_DECLARE_NONSTD
00408 # define AP_CORE_DECLARE_NONSTD AP_DECLARE_NONSTD
00409 #endif
00410 
00415 typedef struct {
00416     int major;              
00417     int minor;              
00418     int patch;              
00419     const char *add_string; 
00420 } ap_version_t;
00421 
00428 AP_DECLARE(void) ap_get_server_revision(ap_version_t *version);
00429 
00435 AP_DECLARE(const char *) ap_get_server_version(void);
00436 
00443 AP_DECLARE(const char *) ap_get_server_banner(void);
00444 
00452 AP_DECLARE(const char *) ap_get_server_description(void);
00453 
00461 AP_DECLARE(void) ap_add_version_component(apr_pool_t *pconf, const char *component);
00462 
00467 AP_DECLARE(const char *) ap_get_server_built(void);
00468 
00469 #define DECLINED -1             
00470 #define DONE -2                 
00473 #define OK 0                    
00485 #define RESPONSE_CODES 57
00486 
00487 #define HTTP_CONTINUE                      100
00488 #define HTTP_SWITCHING_PROTOCOLS           101
00489 #define HTTP_PROCESSING                    102
00490 #define HTTP_OK                            200
00491 #define HTTP_CREATED                       201
00492 #define HTTP_ACCEPTED                      202
00493 #define HTTP_NON_AUTHORITATIVE             203
00494 #define HTTP_NO_CONTENT                    204
00495 #define HTTP_RESET_CONTENT                 205
00496 #define HTTP_PARTIAL_CONTENT               206
00497 #define HTTP_MULTI_STATUS                  207
00498 #define HTTP_MULTIPLE_CHOICES              300
00499 #define HTTP_MOVED_PERMANENTLY             301
00500 #define HTTP_MOVED_TEMPORARILY             302
00501 #define HTTP_SEE_OTHER                     303
00502 #define HTTP_NOT_MODIFIED                  304
00503 #define HTTP_USE_PROXY                     305
00504 #define HTTP_TEMPORARY_REDIRECT            307
00505 #define HTTP_BAD_REQUEST                   400
00506 #define HTTP_UNAUTHORIZED                  401
00507 #define HTTP_PAYMENT_REQUIRED              402
00508 #define HTTP_FORBIDDEN                     403
00509 #define HTTP_NOT_FOUND                     404
00510 #define HTTP_METHOD_NOT_ALLOWED            405
00511 #define HTTP_NOT_ACCEPTABLE                406
00512 #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
00513 #define HTTP_REQUEST_TIME_OUT              408
00514 #define HTTP_CONFLICT                      409
00515 #define HTTP_GONE                          410
00516 #define HTTP_LENGTH_REQUIRED               411
00517 #define HTTP_PRECONDITION_FAILED           412
00518 #define HTTP_REQUEST_ENTITY_TOO_LARGE      413
00519 #define HTTP_REQUEST_URI_TOO_LARGE         414
00520 #define HTTP_UNSUPPORTED_MEDIA_TYPE        415
00521 #define HTTP_RANGE_NOT_SATISFIABLE         416
00522 #define HTTP_EXPECTATION_FAILED            417
00523 #define HTTP_UNPROCESSABLE_ENTITY          422
00524 #define HTTP_LOCKED                        423
00525 #define HTTP_FAILED_DEPENDENCY             424
00526 #define HTTP_UPGRADE_REQUIRED              426
00527 #define HTTP_INTERNAL_SERVER_ERROR         500
00528 #define HTTP_NOT_IMPLEMENTED               501
00529 #define HTTP_BAD_GATEWAY                   502
00530 #define HTTP_SERVICE_UNAVAILABLE           503
00531 #define HTTP_GATEWAY_TIME_OUT              504
00532 #define HTTP_VERSION_NOT_SUPPORTED         505
00533 #define HTTP_VARIANT_ALSO_VARIES           506
00534 #define HTTP_INSUFFICIENT_STORAGE          507
00535 #define HTTP_NOT_EXTENDED                  510
00536 
00538 #define ap_is_HTTP_INFO(x)         (((x) >= 100)&&((x) < 200))
00540 #define ap_is_HTTP_SUCCESS(x)      (((x) >= 200)&&((x) < 300))
00542 #define ap_is_HTTP_REDIRECT(x)     (((x) >= 300)&&((x) < 400))
00544 #define ap_is_HTTP_ERROR(x)        (((x) >= 400)&&((x) < 600))
00546 #define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
00548 #define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
00550 #define ap_is_HTTP_VALID_RESPONSE(x) (((x) >= 100)&&((x) < 600))
00551 
00553 #define ap_status_drops_connection(x) \
00554                                    (((x) == HTTP_BAD_REQUEST)           || \
00555                                     ((x) == HTTP_REQUEST_TIME_OUT)      || \
00556                                     ((x) == HTTP_LENGTH_REQUIRED)       || \
00557                                     ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
00558                                     ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
00559                                     ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
00560                                     ((x) == HTTP_SERVICE_UNAVAILABLE) || \
00561                                     ((x) == HTTP_NOT_IMPLEMENTED))
00578 #define M_GET                   0       
00579 #define M_PUT                   1       /*  :             */
00580 #define M_POST                  2
00581 #define M_DELETE                3
00582 #define M_CONNECT               4
00583 #define M_OPTIONS               5
00584 #define M_TRACE                 6       
00585 #define M_PATCH                 7       
00586 #define M_PROPFIND              8       
00587 #define M_PROPPATCH             9       /*  :               */
00588 #define M_MKCOL                 10
00589 #define M_COPY                  11
00590 #define M_MOVE                  12
00591 #define M_LOCK                  13
00592 #define M_UNLOCK                14      
00593 #define M_VERSION_CONTROL       15      
00594 #define M_CHECKOUT              16      /*  :                          */
00595 #define M_UNCHECKOUT            17
00596 #define M_CHECKIN               18
00597 #define M_UPDATE                19
00598 #define M_LABEL                 20
00599 #define M_REPORT                21
00600 #define M_MKWORKSPACE           22
00601 #define M_MKACTIVITY            23
00602 #define M_BASELINE_CONTROL      24
00603 #define M_MERGE                 25
00604 #define M_INVALID               26      
00610 #define METHODS     64
00611 
00615 #define AP_METHOD_BIT ((apr_int64_t)1)
00620 typedef struct ap_method_list_t ap_method_list_t;
00621 
00629 struct ap_method_list_t {
00631     apr_int64_t method_mask;
00633     apr_array_header_t *method_list;
00634 };
00635 
00641 #define CGI_MAGIC_TYPE "application/x-httpd-cgi"
00642 
00643 #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"
00644 
00645 #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3"
00646 
00647 #define DIR_MAGIC_TYPE "httpd/unix-directory"
00648 
00650 /* Just in case your linefeed isn't the one the other end is expecting. */
00651 #if !APR_CHARSET_EBCDIC
00652 
00653 #define LF 10
00654 
00655 #define CR 13
00656 
00657 #define CRLF "\015\012"
00658 #else /* APR_CHARSET_EBCDIC */
00659 /* For platforms using the EBCDIC charset, the transition ASCII->EBCDIC is done
00660  * in the buff package (bread/bputs/bwrite).  Everywhere else, we use
00661  * "native EBCDIC" CR and NL characters. These are therefore
00662  * defined as
00663  * '\r' and '\n'.
00664  */
00665 #define CR '\r'
00666 #define LF '\n'
00667 #define CRLF "\r\n"
00668 #endif /* APR_CHARSET_EBCDIC */                                   
00669 
00677 #define REQUEST_NO_BODY          0
00678 
00679 #define REQUEST_CHUNKED_ERROR    1
00680 
00681 #define REQUEST_CHUNKED_DECHUNK  2
00682 
00692 #define AP_REQ_ACCEPT_PATH_INFO    0
00693 
00694 #define AP_REQ_REJECT_PATH_INFO    1
00695 
00696 #define AP_REQ_DEFAULT_PATH_INFO   2
00697 
00701 /*
00702  * Things which may vary per file-lookup WITHIN a request ---
00703  * e.g., state of MIME config.  Basically, the name of an object, info
00704  * about the object, and any other info we may ahve which may need to
00705  * change as we go poking around looking for it (e.g., overridden by
00706  * .htaccess files).
00707  *
00708  * Note how the default state of almost all these things is properly
00709  * zero, so that allocating it with pcalloc does the right thing without
00710  * a whole lot of hairy initialization... so long as we are willing to
00711  * make the (fairly) portable assumption that the bit pattern of a NULL
00712  * pointer is, in fact, zero.
00713  */
00714 
00719 struct htaccess_result {
00721     const char *dir;
00723     int override;
00725     int override_opts;
00727     struct ap_conf_vector_t *htaccess;
00729     const struct htaccess_result *next;
00730 };
00731 
00732 /* The following four types define a hierarchy of activities, so that
00733  * given a request_rec r you can write r->connection->server->process
00734  * to get to the process_rec.  While this reduces substantially the
00735  * number of arguments that various hooks require beware that in
00736  * threaded versions of the server you must consider multiplexing
00737  * issues.  */
00738 
00739 
00741 typedef struct process_rec process_rec;
00743 typedef struct server_rec server_rec;
00745 typedef struct conn_rec conn_rec;
00747 typedef struct request_rec request_rec;
00749 typedef struct conn_state_t conn_state_t;
00750 
00751 /* ### would be nice to not include this from httpd.h ... */
00752 /* This comes after we have defined the request_rec type */
00753 #include "apr_uri.h"
00754 
00758 struct process_rec {
00760     apr_pool_t *pool;
00762     apr_pool_t *pconf;
00764     int argc;
00766     const char * const *argv;
00768     const char *short_name;
00769 };
00770 
00774 struct request_rec {
00776     apr_pool_t *pool;
00778     conn_rec *connection;
00780     server_rec *server;
00781 
00783     request_rec *next;
00785     request_rec *prev;
00786 
00789     request_rec *main;
00790 
00791     /* Info about the request itself... we begin with stuff that only
00792      * protocol.c should ever touch...
00793      */
00795     char *the_request;
00797     int assbackwards;
00802     int proxyreq;
00804     int header_only;
00806     char *protocol;
00808     int proto_num;
00810     const char *hostname;
00811 
00813     apr_time_t request_time;
00814 
00816     const char *status_line;
00818     int status;
00819 
00820     /* Request method, two ways; also, protocol, etc..  Outside of protocol.c,
00821      * look, but don't touch.
00822      */
00823 
00825     const char *method;
00827     int method_number;
00828 
00849     apr_int64_t allowed;
00851     apr_array_header_t *allowed_xmethods; 
00853     ap_method_list_t *allowed_methods; 
00854 
00856     apr_off_t sent_bodyct;
00858     apr_off_t bytes_sent;
00860     apr_time_t mtime;
00861 
00862     /* HTTP/1.1 connection-level features */
00863 
00865     int chunked;
00867     const char *range;
00869     apr_off_t clength;
00870 
00872     apr_off_t remaining;
00874     apr_off_t read_length;
00878     int read_body;
00880     int read_chunked;
00882     unsigned expecting_100;
00883 
00884     /* MIME header environments, in and out.  Also, an array containing
00885      * environment variables to be passed to subprocesses, so people can
00886      * write modules to add to that environment.
00887      *
00888      * The difference between headers_out and err_headers_out is that the
00889      * latter are printed even on error, and persist across internal redirects
00890      * (so the headers printed for ErrorDocument handlers will have them).
00891      *
00892      * The 'notes' apr_table_t is for notes from one module to another, with no
00893      * other set purpose in mind...
00894      */
00895 
00897     apr_table_t *headers_in;
00899     apr_table_t *headers_out;
00902     apr_table_t *err_headers_out;
00904     apr_table_t *subprocess_env;
00906     apr_table_t *notes;
00907 
00908     /* content_type, handler, content_encoding, and all content_languages 
00909      * MUST be lowercased strings.  They may be pointers to static strings;
00910      * they should not be modified in place.
00911      */
00913     const char *content_type;   /* Break these out --- we dispatch on 'em */
00915     const char *handler;        /* What we *really* dispatch on */
00916 
00918     const char *content_encoding;
00920     apr_array_header_t *content_languages;
00921 
00923     char *vlist_validator;
00924     
00926     char *user; 
00928     char *ap_auth_type;
00929 
00931     int no_cache;
00933     int no_local_copy;
00934 
00935     /* What object is being requested (either directly, or via include
00936      * or content-negotiation mapping).
00937      */
00938 
00940     char *unparsed_uri; 
00942     char *uri;
00944     char *filename;
00945     /* XXX: What does this mean? Please define "canonicalize" -aaron */
00947     char *canonical_filename;
00949     char *path_info;
00951     char *args; 
00953     apr_finfo_t finfo;
00955     apr_uri_t parsed_uri;
00956 
00965     int used_path_info;
00966 
00967     /* Various other config info which may change with .htaccess files
00968      * These are config vectors, with one void* pointer for each module
00969      * (the thing pointed to being the module's business).
00970      */
00971 
00973     struct ap_conf_vector_t *per_dir_config;
00975     struct ap_conf_vector_t *request_config;
00976 
00983     const struct htaccess_result *htaccess;
00984 
00986     struct ap_filter_t *output_filters;
00988     struct ap_filter_t *input_filters;
00989 
00992     struct ap_filter_t *proto_output_filters;
00995     struct ap_filter_t *proto_input_filters;
00996 
00998     int eos_sent;
00999 
01000 /* Things placed at the end of the record to avoid breaking binary
01001  * compatibility.  It would be nice to remember to reorder the entire
01002  * record to improve 64bit alignment the next time we need to break
01003  * binary compatibility for some other reason.
01004  */
01005 };
01006 
01017 #define PROXYREQ_NONE 0         
01018 #define PROXYREQ_PROXY 1        
01019 #define PROXYREQ_REVERSE 2      
01020 #define PROXYREQ_RESPONSE 3 
01022 /* @} */
01023 
01027 typedef enum {
01028     AP_CONN_UNKNOWN,
01029     AP_CONN_CLOSE,
01030     AP_CONN_KEEPALIVE
01031 } ap_conn_keepalive_e;
01032 
01036 struct conn_rec {
01038     apr_pool_t *pool;
01040     server_rec *base_server;
01042     void *vhost_lookup_data;
01043 
01044     /* Information about the connection itself */
01046     apr_sockaddr_t *local_addr;
01048     apr_sockaddr_t *remote_addr;
01049 
01051     char *remote_ip;
01055     char *remote_host;
01058     char *remote_logname;
01059 
01061     unsigned aborted:1;
01062 
01065     ap_conn_keepalive_e keepalive;
01066 
01069     signed int double_reverse:2;
01070 
01072     int keepalives;
01074     char *local_ip;
01077     char *local_host;
01078 
01080     long id; 
01083     struct ap_conf_vector_t *conn_config;
01086     apr_table_t *notes;
01088     struct ap_filter_t *input_filters;
01090     struct ap_filter_t *output_filters;
01092     void *sbh;
01094     struct apr_bucket_alloc_t *bucket_alloc;
01096     conn_state_t *cs;
01098     int data_in_input_filters;
01099     
01103     int clogging_input_filters;
01104 };
01105 
01109 typedef enum  {
01110     CONN_STATE_CHECK_REQUEST_LINE_READABLE,
01111     CONN_STATE_READ_REQUEST_LINE,
01112     CONN_STATE_LINGER
01113 } conn_state_e;
01114 
01118 struct conn_state_t {
01120     APR_RING_ENTRY(conn_state_t) timeout_list;
01122     apr_time_t expiration_time;
01124     conn_state_e state;
01126     conn_rec *c;
01128     apr_pool_t *p;
01130     apr_bucket_alloc_t *bucket_alloc;
01132     apr_pollfd_t pfd;
01133 };
01134 
01135 /* Per-vhost config... */
01136 
01141 #define DEFAULT_VHOST_ADDR 0xfffffffful
01142 
01143 
01148 typedef struct server_addr_rec server_addr_rec;
01149 struct server_addr_rec {
01151     server_addr_rec *next;
01153     apr_sockaddr_t *host_addr;
01155     apr_port_t host_port;
01157     char *virthost;
01158 };
01159 
01163 struct server_rec {
01165     process_rec *process;
01167     server_rec *next;
01168 
01170     const char *defn_name;
01172     unsigned defn_line_number;
01173 
01174     /* Contact information */
01175 
01177     char *server_admin;
01179     char *server_hostname;
01181     apr_port_t port;
01182 
01183     /* Log files --- note that transfer log is now in the modules... */
01184 
01186     char *error_fname;
01188     apr_file_t *error_log;
01190     int loglevel;
01191 
01192     /* Module-specific configuration for server, and defaults... */
01193 
01195     int is_virtual;
01198     struct ap_conf_vector_t *module_config; 
01200     struct ap_conf_vector_t *lookup_defaults;
01201 
01202     /* Transaction handling */
01203 
01205     server_addr_rec *addrs;
01207     apr_interval_time_t timeout;
01209     apr_interval_time_t keep_alive_timeout;
01211     int keep_alive_max;
01213     int keep_alive;
01214 
01216     const char *path;
01218     int pathlen;
01219 
01221     apr_array_header_t *names;
01223     apr_array_header_t *wild_names;
01224 
01226     int limit_req_line;
01228     int limit_req_fieldsize;
01230     int limit_req_fields; 
01231 
01233     const char *server_scheme;
01234 };
01235 
01236 typedef struct core_output_filter_ctx {
01237     apr_bucket_brigade *b;
01241     apr_pool_t *deferred_write_pool;
01242 } core_output_filter_ctx_t;
01243  
01244 typedef struct core_filter_ctx {
01245     apr_bucket_brigade *b;
01246     apr_bucket_brigade *tmpbb;
01247 } core_ctx_t;
01248  
01249 typedef struct core_net_rec {
01251     apr_socket_t *client_socket;
01252 
01254     conn_rec *c;
01255  
01256     core_output_filter_ctx_t *out_ctx;
01257     core_ctx_t *in_ctx;
01258 } core_net_rec;
01259 
01267 AP_DECLARE(char *) ap_field_noparam(apr_pool_t *p, const char *intype);
01268 
01277 AP_DECLARE(char *) ap_ht_time(apr_pool_t *p, apr_time_t t, const char *fmt, int gmt);
01278 
01279 /* String handling. The *_nc variants allow you to use non-const char **s as
01280    arguments (unfortunately C won't automatically convert a char ** to a const
01281    char **) */
01282 
01290 AP_DECLARE(char *) ap_getword(apr_pool_t *p, const char **line, char stop);
01291 
01300 AP_DECLARE(char *) ap_getword_nc(apr_pool_t *p, char **line, char stop);
01301 
01309 AP_DECLARE(char *) ap_getword_white(apr_pool_t *p, const char **line);
01310 
01319 AP_DECLARE(char *) ap_getword_white_nc(apr_pool_t *p, char **line);
01320 
01329 AP_DECLARE(char *) ap_getword_nulls(apr_pool_t *p, const char **line,
01330                                     char stop);
01331 
01341 AP_DECLARE(char *) ap_getword_nulls_nc(apr_pool_t *p, char **line, char stop);
01342 
01349 AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line);
01350 
01358 AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line);
01359 
01369 AP_DECLARE(const char *) ap_resolve_env(apr_pool_t *p, const char * word); 
01370 
01380 AP_DECLARE(const char *) ap_size_list_item(const char **field, int *len);
01381 
01392 AP_DECLARE(char *) ap_get_list_item(apr_pool_t *p, const char **field);
01393 
01402 AP_DECLARE(int) ap_find_list_item(apr_pool_t *p, const char *line, const char *tok);
01403 
01414 AP_DECLARE(char *) ap_get_token(apr_pool_t *p, const char **accept_line, int accept_white);
01415 
01423 AP_DECLARE(int) ap_find_token(apr_pool_t *p, const char *line, const char *tok);
01424 
01432 AP_DECLARE(int) ap_find_last_token(apr_pool_t *p, const char *line, const char *tok);
01433 
01439 AP_DECLARE(int) ap_is_url(const char *u);
01440 
01446 AP_DECLARE(int) ap_unescape_url(char *url);
01447 
01453 AP_DECLARE(int) ap_unescape_url_keep2f(char *url);
01454 
01459 AP_DECLARE(void) ap_no2slash(char *name);
01460 
01466 AP_DECLARE(void) ap_getparents(char *name);
01467 
01474 AP_DECLARE(char *) ap_escape_path_segment(apr_pool_t *p, const char *s);
01475 
01484 AP_DECLARE(char *) ap_os_escape_path(apr_pool_t *p, const char *path, int partial);
01485 
01487 #define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
01488 
01495 AP_DECLARE(char *) ap_escape_html(apr_pool_t *p, const char *s);
01496 
01503 AP_DECLARE(char *) ap_escape_logitem(apr_pool_t *p, const char *str);
01504 
01512 AP_DECLARE(apr_size_t) ap_escape_errorlog_item(char *dest, const char *source,
01513                                                apr_size_t buflen);
01514 
01523 AP_DECLARE(char *) ap_construct_server(apr_pool_t *p, const char *hostname,
01524                                     apr_port_t port, const request_rec *r);
01525 
01532 AP_DECLARE(char *) ap_escape_shell_cmd(apr_pool_t *p, const char *s);
01533 
01539 AP_DECLARE(int) ap_count_dirs(const char *path);
01540 
01552 AP_DECLARE(char *) ap_make_dirstr_prefix(char *d, const char *s, int n);
01553 
01561 AP_DECLARE(char *) ap_make_dirstr_parent(apr_pool_t *p, const char *s);
01562 
01575 AP_DECLARE(char *) ap_make_full_path(apr_pool_t *a, const char *dir, const char *f);
01576 
01585 AP_DECLARE(int) ap_os_is_path_absolute(apr_pool_t *p, const char *dir);
01586 
01594 AP_DECLARE(int) ap_is_matchexp(const char *str);
01595 
01602 AP_DECLARE(int) ap_strcmp_match(const char *str, const char *expected);
01603 
01611 AP_DECLARE(int) ap_strcasecmp_match(const char *str, const char *expected);
01612 
01620 AP_DECLARE(char *) ap_strcasestr(const char *s1, const char *s2);
01621 
01628 AP_DECLARE(const char *) ap_stripprefix(const char *bigstring,
01629                                         const char *prefix);
01630 
01637 AP_DECLARE(char *) ap_pbase64decode(apr_pool_t *p, const char *bufcoded);
01638 
01645 AP_DECLARE(char *) ap_pbase64encode(apr_pool_t *p, char *string); 
01646 
01659 AP_DECLARE(ap_regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern,
01660                                      int cflags);
01661 
01667 AP_DECLARE(void) ap_pregfree(apr_pool_t *p, ap_regex_t *reg);
01668 
01680 AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input, const char *source,
01681                               size_t nmatch, ap_regmatch_t pmatch[]);
01682 
01688 AP_DECLARE(void) ap_content_type_tolower(char *s);
01689 
01694 AP_DECLARE(void) ap_str_tolower(char *s);
01695 
01703 AP_DECLARE(int) ap_ind(const char *str, char c);        /* Sigh... */
01704 
01712 AP_DECLARE(int) ap_rind(const char *str, char c);
01713 
01720 AP_DECLARE(char *) ap_escape_quotes(apr_pool_t *p, const char *instring);
01721 
01732 AP_DECLARE(char *) ap_append_pid(apr_pool_t *p, const char *string,
01733                                  const char *delim);
01734 
01735 /* Misc system hackery */
01742 AP_DECLARE(int) ap_is_rdirectory(apr_pool_t *p, const char *name);
01743 
01750 AP_DECLARE(int) ap_is_directory(apr_pool_t *p, const char *name);
01751 
01752 #ifdef _OSD_POSIX
01753 extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
01754 #endif /* _OSD_POSIX */
01755 
01761 char *ap_get_local_host(apr_pool_t *p);
01762 
01769 AP_DECLARE(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
01770                             __attribute__((noreturn));
01771 
01775 #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
01776 
01784 #ifdef AP_DEBUG
01785 #define AP_DEBUG_ASSERT(exp) ap_assert(exp)
01786 #else
01787 #define AP_DEBUG_ASSERT(exp) ((void)0)
01788 #endif
01789 
01799 #define SIGSTOP_DETACH                  1
01801 #define SIGSTOP_MAKE_CHILD              2
01803 #define SIGSTOP_SPAWN_CHILD             4
01805 #define SIGSTOP_PIPED_LOG_SPAWN         8
01807 #define SIGSTOP_CGI_CHILD               16
01808 
01810 #ifdef DEBUG_SIGSTOP
01811 extern int raise_sigstop_flags;
01812 #define RAISE_SIGSTOP(x)        do { \
01813         if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
01814     } while (0)
01815 #else
01816 #define RAISE_SIGSTOP(x)
01817 #endif
01818 
01825 AP_DECLARE(const char *) ap_psignature(const char *prefix, request_rec *r);
01826 
01828 #ifdef strtoul
01829 #undef strtoul
01830 #endif
01831 #define strtoul strtoul_is_not_a_portable_function_use_strtol_instead
01832 
01833   /* The C library has functions that allow const to be silently dropped ...
01834      these macros detect the drop in maintainer mode, but use the native
01835      methods for normal builds
01836 
01837      Note that on some platforms (e.g., AIX with gcc, Solaris with gcc), string.h needs 
01838      to be included before the macros are defined or compilation will fail.
01839   */
01840 #include <string.h>
01841 
01842 AP_DECLARE(char *) ap_strchr(char *s, int c);
01843 AP_DECLARE(const char *) ap_strchr_c(const char *s, int c);
01844 AP_DECLARE(char *) ap_strrchr(char *s, int c);
01845 AP_DECLARE(const char *) ap_strrchr_c(const char *s, int c);
01846 AP_DECLARE(char *) ap_strstr(char *s, const char *c);
01847 AP_DECLARE(const char *) ap_strstr_c(const char *s, const char *c);
01848 
01849 #ifdef AP_DEBUG
01850 
01851 #undef strchr
01852 # define strchr(s, c)   ap_strchr(s,c)
01853 #undef strrchr
01854 # define strrchr(s, c)  ap_strrchr(s,c)
01855 #undef strstr
01856 # define strstr(s, c)  ap_strstr(s,c)
01857 
01858 #else
01859 
01861 # define ap_strchr(s, c)        strchr(s, c)
01863 # define ap_strchr_c(s, c)      strchr(s, c)
01865 # define ap_strrchr(s, c)       strrchr(s, c)
01867 # define ap_strrchr_c(s, c)     strrchr(s, c)
01869 # define ap_strstr(s, c)        strstr(s, c)
01871 # define ap_strstr_c(s, c)      strstr(s, c)
01872 
01873