/packages/httpd13/src/httpd.inc
Pascal | 1267 lines | 438 code | 245 blank | 584 comment | 0 complexity | 93e1faf221c3824af4d8d324c233a8a6 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
1{ Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 } 16 17{ 18 * httpd.h: header for simple (ha! not anymore) http daemon 19 } 20 21{ Headers in which EVERYONE has an interest... } 22{$include ap_config.inc} 23{$include ap_alloc.inc} 24{$include buff.inc} 25{$include ap.inc} 26 27{$include util_uri.inc} 28 29{ ----------------------------- config dir ------------------------------ } 30 31{ Define this to be the default server home dir. Most things later in this 32 * file with a relative pathname will have this added. 33 } 34const 35 {$ifdef OS2} 36 { Set default for OS/2 file system } 37 HTTPD_ROOT = '/os2httpd'; 38 {$else}{$ifdef WINDOWS} 39 { Set default for Windows file system } 40 HTTPD_ROOT = '/apache'; 41 {$else}{$if defined(BEOS) or defined(BONE)} 42 { Set the default for BeOS } 43 HTTPD_ROOT = '/boot/home/apache'; 44 {$else}{$ifdef NETWARE} 45 { Set the default for NetWare } 46 HTTPD_ROOT = 'sys:/apache'; 47 {$else} 48 HTTPD_ROOT = '/usr/local/apache'; 49 {$endif} 50 {$endif} 51 {$endif} 52 {$endif} 53 54{ Default location of documents. Can be overridden by the DocumentRoot 55 * directive. 56 } 57 {$ifdef OS2} 58 { Set default for OS/2 file system } 59 DOCUMENT_LOCATION = HTTPD_ROOT + '/docs'; 60 {$else} 61 DOCUMENT_LOCATION = HTTPD_ROOT + '/htdocs'; 62 {$endif} 63 64 { Max. number of dynamically loaded modules } 65 DYNAMIC_MODULE_LIMIT = 64; 66 67 { Default administrator's address } 68 DEFAULT_ADMIN = '[no address given]'; 69 70 { The target name of the installed Apache } 71 TARGET = 'httpd'; 72 73{ 74 * --------- You shouldn't have to edit anything below this line ---------- 75 * 76 * Any modifications to any defaults not defined above should be done in the 77 * respective config. file. 78 * 79 } 80 81 82{ -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- } 83 84{#define HTTP_VERSION(major,minor) (1000*(major)+(minor)) 85#define HTTP_VERSION_MAJOR(number) ((number)/1000) 86#define HTTP_VERSION_MINOR(number) ((number)%1000)} 87 88 89{ -------------- Port number for server running standalone --------------- } 90 91 DEFAULT_HTTP_PORT = 80; 92 DEFAULT_HTTPS_PORT = 443; 93//#define ap_is_default_port(port,r) ((port) == ap_default_port(r)) 94{$ifdef NETWARE} 95#define ap_http_method(r) ap_os_http_method((void*)r) 96#define ap_default_port(r) ap_os_default_port((void*)r) 97{$else} 98// ap_http_method(r) = 'http'; 99// ap_default_port(r) = DEFAULT_HTTP_PORT; 100{$endif} 101 102{ --------- Default user name and group name running standalone ---------- } 103{ --- These may be specified as numbers by placing a # before a number --- } 104 105 DEFAULT_USER = '#-1'; 106 DEFAULT_GROUP = '#-1'; 107 108{$ifndef DEFAULT_ERRORLOG} 109{$if defined(OS2) or defined(WINDOWS)} 110 DEFAULT_ERRORLOG = 'logs/error.log'; 111{$else} 112 DEFAULT_ERRORLOG = 'logs/error_log'; 113{$endif} 114{$endif} { DEFAULT_ERRORLOG } 115 116 DEFAULT_PIDLOG = 'logs/httpd.pid'; 117 118 DEFAULT_SCOREBOARD = 'logs/apache_runtime_status'; 119 120 DEFAULT_LOCKFILE = 'logs/accept.lock'; 121 122{ Define this to be what your HTML directory content files are called } 123 124 DEFAULT_INDEX = 'index.html'; 125 126{ Define this to 1 if you want fancy indexing, 0 otherwise } 127 128 DEFAULT_INDEXING = 0; 129 130{ Define this to be what type you'd like returned for files with unknown } 131{ suffixes. MUST be all lower case. } 132 133 DEFAULT_CONTENT_TYPE = 'text/plain'; 134 135{ Define this to be what your per-directory security files are called } 136{$ifndef DEFAULT_ACCESS_FNAME} 137{$ifdef OS2} 138{ Set default for OS/2 file system } 139 DEFAULT_ACCESS_FNAME = 'htaccess'; 140{$else} 141 DEFAULT_ACCESS_FNAME = '.htaccess'; 142{$endif} 143{$endif} { DEFAULT_ACCESS_FNAME } 144 145{ The name of the server config file } 146 147 SERVER_CONFIG_FILE = 'conf/httpd.conf'; 148 149{ The name of the document config file } 150 151 RESOURCE_CONFIG_FILE = 'conf/srm.conf'; 152 153{ The name of the MIME types file } 154 155 TYPES_CONFIG_FILE = 'conf/mime.types'; 156 157{ The name of the access file } 158 159 ACCESS_CONFIG_FILE = 'conf/access.conf'; 160 161{ Whether we should enable rfc1413 identity checking } 162 163 DEFAULT_RFC1413 = 0; 164 165{ The default directory in user's home dir } 166 167 DEFAULT_USER_DIR = 'public_html'; 168 169{ The default path for CGI scripts if none is currently set } 170 171 DEFAULT_PATH = '/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin'; 172 173{ The path to the shell interpreter, for parsed docs } 174 175 {$if defined(OS2) or defined(WINDOWS)} 176{ Set default for OS/2 and Windows file system } 177 SHELL_PATH = 'CMD.EXE'; 178 {$else} 179 SHELL_PATH = '/bin/sh'; 180 {$endif} 181 182{ The path to the suExec wrapper, can be overridden in Configuration } 183 184 SUEXEC_BIN = HTTPD_ROOT + '/bin/suexec'; 185 186{ The default string lengths } 187 HUGE_STRING_LEN = 8192; 188 MAX_STRING_LEN = HUGE_STRING_LEN; 189 190{ The timeout for waiting for messages } 191 192 DEFAULT_TIMEOUT = 300; 193 194{ The timeout for waiting for keepalive timeout until next request } 195 196 DEFAULT_KEEPALIVE_TIMEOUT = 15; 197 198{ The number of requests to entertain per connection } 199 200 DEFAULT_KEEPALIVE = 100; 201 202{ The size of the server's internal read-write buffers } 203 IOBUFSIZE = 8192; 204 205{ The max number of regex captures that can be expanded by ap_pregsub } 206 AP_MAX_REG_MATCH = 10; 207 208{ Number of servers to spawn off by default --- also, if fewer than 209 * this free when the caretaker checks, it will spawn more. 210 } 211 212 DEFAULT_START_DAEMON = 5; 213 214{ Maximum number of *free* server processes --- more than this, and 215 * they will die off. 216 } 217 218 DEFAULT_MAX_FREE_DAEMON = 10; 219 220{ Minimum --- fewer than this, and more will be created } 221 222 DEFAULT_MIN_FREE_DAEMON = 5; 223 224{ Limit on the total --- clients will be locked out if more servers than 225 * this are needed. It is intended solely to keep the server from crashing 226 * when things get out of hand. 227 * 228 * We keep a hard maximum number of servers, for two reasons --- first off, 229 * in case something goes seriously wrong, we want to stop the fork bomb 230 * short of actually crashing the machine we're running on by filling some 231 * kernel table. Secondly, it keeps the size of the scoreboard file small 232 * enough that we can read the whole thing without worrying too much about 233 * the overhead. 234 } 235{$ifndef HARD_SERVER_LIMIT} 236{$ifdef WINDOWS} 237 HARD_SERVER_LIMIT = 1024; 238{$else}{$if defined(NETWARE)} 239 HARD_SERVER_LIMIT = 2048; 240{$else} 241 HARD_SERVER_LIMIT = 256; 242{$endif} 243{$endif} 244{$endif} 245 246{ 247 * Special Apache error codes. These are basically used 248 * in http_main.c so we can keep track of various errors. 249 * 250 * APEXIT_OK: 251 * A normal exit 252 * APEXIT_INIT: 253 * A fatal error arising during the server's init sequence 254 * APEXIT_CHILDINIT: 255 * The child died during it's init sequence 256 * APEXIT_CHILDFATAL: 257 * A fatal error, resulting in the whole server aborting. 258 * If a child exits with this error, the parent process 259 * considers this a server-wide fatal error and aborts. 260 * 261 } 262 APEXIT_OK = $0; 263 APEXIT_INIT = $2; 264 APEXIT_CHILDINIT = $3; 265 APEXIT_CHILDFATAL = $f; 266 267{ 268 * (Unix, OS/2 only) 269 * Interval, in microseconds, between scoreboard maintenance. During 270 * each scoreboard maintenance cycle the parent decides if it needs to 271 * spawn a new child (to meet MinSpareServers requirements), or kill off 272 * a child (to meet MaxSpareServers requirements). It will only spawn or 273 * kill one child per cycle. Setting this too low will chew cpu. The 274 * default is probably sufficient for everyone. But some people may want 275 * to raise this on servers which aren't dedicated to httpd and where they 276 * don't like the httpd waking up each second to see what's going on. 277 } 278 279 SCOREBOARD_MAINTENANCE_INTERVAL = 1000000; 280 281{ Number of requests to try to handle in a single process. If <= 0, 282 * the children don't die off. That's the default here, since I'm still 283 * interested in finding and stanching leaks. 284 } 285 286 DEFAULT_MAX_REQUESTS_PER_CHILD = 0; 287 288 DEFAULT_THREADS_PER_CHILD = 50; 289 290 DEFAULT_EXCESS_REQUESTS_PER_CHILD = 0; 291 292{ The maximum length of the queue of pending connections, as defined 293 * by listen(2). Under some systems, it should be increased if you 294 * are experiencing a heavy TCP SYN flood attack. 295 * 296 * It defaults to 511 instead of 512 because some systems store it 297 * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is 298 * 255 when truncated. 299 } 300 301 DEFAULT_LISTENBACKLOG = 511; 302 303{ Limits on the size of various request items. These limits primarily 304 * exist to prevent simple denial-of-service attacks on a server based 305 * on misuse of the protocol. The recommended values will depend on the 306 * nature of the server resources -- CGI scripts and database backends 307 * might require large values, but most servers could get by with much 308 * smaller limits than we use below. The request message body size can 309 * be limited by the per-dir config directive LimitRequestBody. 310 * 311 * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE 312 * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190. 313 * These two limits can be lowered (but not raised) by the server config 314 * directives LimitRequestLine and LimitRequestFieldsize, respectively. 315 * 316 * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by 317 * the server config directive LimitRequestFields. 318 } 319 320 { default limit on bytes in Request-Line (Method+URI+HTTP-version) } 321 DEFAULT_LIMIT_REQUEST_LINE = 8190; 322 323 { default limit on bytes in any one header field } 324 DEFAULT_LIMIT_REQUEST_FIELDSIZE = 8190; 325 326 { default limit on number of request header fields } 327 DEFAULT_LIMIT_REQUEST_FIELDS = 100; 328 329{ 330 * The default default character set name to add if AddDefaultCharset is 331 * enabled. Overridden with AddDefaultCharsetName. 332 } 333 DEFAULT_ADD_DEFAULT_CHARSET_NAME = 'iso-8859-1'; 334 335{ 336 * The below defines the base string of the Server: header. Additional 337 * tokens can be added via the ap_add_version_component() API call. 338 * 339 * The tokens are listed in order of their significance for identifying the 340 * application. 341 * 342 * "Product tokens should be short and to the point -- use of them for 343 * advertizing or other non-essential information is explicitly forbidden." 344 * 345 * Example: "Apache/1.1.0 MrWidget/0.1-alpha" 346 } 347 348 SERVER_BASEVENDOR = 'Apache Group'; 349 SERVER_BASEPRODUCT = 'Apache'; 350 SERVER_BASEREVISION = '1.3.37'; 351 SERVER_BASEVERSION = SERVER_BASEPRODUCT + '/' + SERVER_BASEREVISION; 352 353 SERVER_PRODUCT = SERVER_BASEPRODUCT; 354 SERVER_REVISION = SERVER_BASEREVISION; 355 SERVER_VERSION = SERVER_PRODUCT + '/' + SERVER_REVISION; 356 357type 358 server_token_type = ( 359 SrvTk_MIN, { eg: Apache/1.3.0 } 360 SrvTk_OS, { eg: Apache/1.3.0 (UNIX) } 361 SrvTk_FULL, { eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b } 362 SrvTk_PRODUCT_ONLY { eg: Apache } 363 ); 364 365//API_EXPORT(const char *) ap_get_server_version(void); 366//API_EXPORT(void) ap_add_version_component(const char *component); 367//API_EXPORT(const char *) ap_get_server_built(void); 368 369{ Numeric release version identifier: MMNNFFRBB: major minor fix final beta 370 * Always increases along the same track as the source branch. 371 * For example, Apache 1.4.2 would be '10402100', 2.5b7 would be '20500007'. 372 } 373const 374 APACHE_RELEASE = 10337100; 375 376 SERVER_PROTOCOL = 'HTTP/1.1'; 377 SERVER_SUPPORT = 'http://www.apache.org/'; 378 379 DECLINED = -1; { Module declines to handle } 380 DONE = -2; { Module has served the response completely 381 * - it's safe to die() with no more output 382 } 383 OK = 0; { Module has handled this stage. } 384 385 386{ ----------------------- HTTP Status Codes ------------------------- } 387 388{ The size of the static array in http_protocol.c for storing 389 * all of the potential response status-lines (a sparse table). 390 * A future version should dynamically generate the table at startup. 391 } 392 RESPONSE_CODES = 55; 393 394 HTTP_CONTINUE = 100; 395 HTTP_SWITCHING_PROTOCOLS = 101; 396 HTTP_PROCESSING = 102; 397 HTTP_OK = 200; 398 HTTP_CREATED = 201; 399 HTTP_ACCEPTED = 202; 400 HTTP_NON_AUTHORITATIVE = 203; 401 HTTP_NO_CONTENT = 204; 402 HTTP_RESET_CONTENT = 205; 403 HTTP_PARTIAL_CONTENT = 206; 404 HTTP_MULTI_STATUS = 207; 405 HTTP_MULTIPLE_CHOICES = 300; 406 HTTP_MOVED_PERMANENTLY = 301; 407 HTTP_MOVED_TEMPORARILY = 302; 408 HTTP_SEE_OTHER = 303; 409 HTTP_NOT_MODIFIED = 304; 410 HTTP_USE_PROXY = 305; 411 HTTP_TEMPORARY_REDIRECT = 307; 412 HTTP_BAD_REQUEST = 400; 413 HTTP_UNAUTHORIZED = 401; 414 HTTP_PAYMENT_REQUIRED = 402; 415 HTTP_FORBIDDEN = 403; 416 HTTP_NOT_FOUND = 404; 417 HTTP_METHOD_NOT_ALLOWED = 405; 418 HTTP_NOT_ACCEPTABLE = 406; 419 HTTP_PROXY_AUTHENTICATION_REQUIRED= 407; 420 HTTP_REQUEST_TIME_OUT = 408; 421 HTTP_CONFLICT = 409; 422 HTTP_GONE = 410; 423 HTTP_LENGTH_REQUIRED = 411; 424 HTTP_PRECONDITION_FAILED = 412; 425 HTTP_REQUEST_ENTITY_TOO_LARGE = 413; 426 HTTP_REQUEST_URI_TOO_LARGE = 414; 427 HTTP_UNSUPPORTED_MEDIA_TYPE = 415; 428 HTTP_RANGE_NOT_SATISFIABLE = 416; 429 HTTP_EXPECTATION_FAILED = 417; 430 HTTP_UNPROCESSABLE_ENTITY = 422; 431 HTTP_LOCKED = 423; 432 HTTP_FAILED_DEPENDENCY = 424; 433 HTTP_INTERNAL_SERVER_ERROR = 500; 434 HTTP_NOT_IMPLEMENTED = 501; 435 HTTP_BAD_GATEWAY = 502; 436 HTTP_SERVICE_UNAVAILABLE = 503; 437 HTTP_GATEWAY_TIME_OUT = 504; 438 HTTP_VERSION_NOT_SUPPORTED = 505; 439 HTTP_VARIANT_ALSO_VARIES = 506; 440 HTTP_INSUFFICIENT_STORAGE = 507; 441 HTTP_NOT_EXTENDED = 510; 442 443 DOCUMENT_FOLLOWS = HTTP_OK; 444 PARTIAL_CONTENT = HTTP_PARTIAL_CONTENT; 445 MULTIPLE_CHOICES = HTTP_MULTIPLE_CHOICES; 446 MOVED = HTTP_MOVED_PERMANENTLY; 447 REDIRECT = HTTP_MOVED_TEMPORARILY; 448 USE_LOCAL_COPY = HTTP_NOT_MODIFIED; 449 BAD_REQUEST = HTTP_BAD_REQUEST; 450 AUTH_REQUIRED = HTTP_UNAUTHORIZED; 451 FORBIDDEN = HTTP_FORBIDDEN; 452 NOT_FOUND = HTTP_NOT_FOUND; 453 METHOD_NOT_ALLOWED = HTTP_METHOD_NOT_ALLOWED; 454 NOT_ACCEPTABLE = HTTP_NOT_ACCEPTABLE; 455 LENGTH_REQUIRED = HTTP_LENGTH_REQUIRED; 456 PRECONDITION_FAILED= HTTP_PRECONDITION_FAILED; 457 SERVER_ERROR = HTTP_INTERNAL_SERVER_ERROR; 458 NOT_IMPLEMENTED = HTTP_NOT_IMPLEMENTED; 459 BAD_GATEWAY = HTTP_BAD_GATEWAY; 460 VARIANT_ALSO_VARIES= HTTP_VARIANT_ALSO_VARIES; 461 462{#define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200)) 463#define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300)) 464#define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400)) 465#define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600)) 466#define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500)) 467#define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600)) 468 469#define ap_status_drops_connection(x) \ 470 (((x) == HTTP_BAD_REQUEST) || \ 471 ((x) == HTTP_REQUEST_TIME_OUT) || \ 472 ((x) == HTTP_LENGTH_REQUIRED) || \ 473 ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \ 474 ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \ 475 ((x) == HTTP_INTERNAL_SERVER_ERROR) || \ 476 ((x) == HTTP_SERVICE_UNAVAILABLE) || \ 477 ((x) == HTTP_NOT_IMPLEMENTED))} 478 479{ Methods recognized (but not necessarily handled) by the server. 480 * These constants are used in bit shifting masks of size int, so it is 481 * unsafe to have more methods than bits in an int. HEAD == M_GET. 482 } 483 M_GET = 0; 484 M_PUT = 1; 485 M_POST = 2; 486 M_DELETE = 3; 487 M_CONNECT = 4; 488 M_OPTIONS = 5; 489 M_TRACE = 6; 490 M_PATCH = 7; 491 M_PROPFIND = 8; 492 M_PROPPATCH = 9; 493 M_MKCOL = 10; 494 M_COPY = 11; 495 M_MOVE = 12; 496 M_LOCK = 13; 497 M_UNLOCK = 14; 498 M_INVALID = 15; 499 500 METHODS = 16; 501 502 CGI_MAGIC_TYPE = 'application/x-httpd-cgi'; 503 INCLUDES_MAGIC_TYPE = 'text/x-server-parsed-html'; 504 INCLUDES_MAGIC_TYPE3 = 'text/x-server-parsed-html3'; 505{$ifdef CHARSET_EBCDIC} 506 ASCIITEXT_MAGIC_TYPE_PREFIX = 'text/x-ascii-'; { Text files whose content-type starts with this are passed thru unconverted } 507{$endif} {CHARSET_EBCDIC} 508 MAP_FILE_MAGIC_TYPE = 'application/x-type-map'; 509 ASIS_MAGIC_TYPE = 'httpd/send-as-is'; 510 DIR_MAGIC_TYPE = 'httpd/unix-directory'; 511 STATUS_MAGIC_TYPE = 'application/x-httpd-status'; 512 513{ 514 * Define the HTML doctype strings centrally. 515 } 516 DOCTYPE_HTML_2_0 = '<!DOCTYPE HTML PUBLIC "-//IETF//' + 517 'DTD HTML 2.0//EN">' + LineEnding; 518 DOCTYPE_HTML_3_2 = '<!DOCTYPE HTML PUBLIC "-//W3C//' + 519 'DTD HTML 3.2 Final//EN">' + LineEnding; 520 DOCTYPE_HTML_4_0S = '<!DOCTYPE HTML PUBLIC "-//W3C//' + 521 'DTD HTML 4.0//EN"' + LineEnding + 522 '"http://www.w3.org/TR/REC-html40/strict.dtd">' + LineEnding; 523 DOCTYPE_HTML_4_0T = '<!DOCTYPE HTML PUBLIC "-//W3C//' + 524 'DTD HTML 4.0 Transitional//EN"' + LineEnding + 525 '"http://www.w3.org/TR/REC-html40/loose.dtd">' + LineEnding; 526 DOCTYPE_HTML_4_0F = '<!DOCTYPE HTML PUBLIC "-//W3C//' + 527 'DTD HTML 4.0 Frameset//EN"' + LineEnding + 528 '"http://www.w3.org/TR/REC-html40/frameset.dtd">' + LineEnding; 529 530{ Just in case your linefeed isn't the one the other end is expecting. } 531{$ifndef CHARSET_EBCDIC} 532 LF = 10; 533 CR = 13; 534 CRLF = #15#12; 535//#define OS_ASC(c) (c) 536{$else} { CHARSET_EBCDIC } 537//#include "ap_ebcdic.h" 538{ OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in 539 * the buff package (bread/bputs/bwrite), so everywhere else, we use 540 * "native EBCDIC" CR and NL characters. These are therefore defined as 541 * '\r' and '\n'. 542 * NB: this is not the whole truth - sometimes \015 and \012 are contained 543 * in literal (EBCDIC!) strings, so these are not converted but passed. 544 } 545 CR = '\r'; 546 LF = '\n'; 547 CRLF = '\r\n'; 548#define OS_ASC(c) (os_toascii[c]) 549{$endif} { CHARSET_EBCDIC } 550 551{ Possible values for request_rec.read_body (set by handling module): 552 * REQUEST_NO_BODY Send 413 error if message has any body 553 * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length 554 * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me. 555 * REQUEST_CHUNKED_PASS Pass the chunks to me without removal. 556 } 557 REQUEST_NO_BODY = 0; 558 REQUEST_CHUNKED_ERROR = 1; 559 REQUEST_CHUNKED_DECHUNK = 2; 560 REQUEST_CHUNKED_PASS = 3; 561 562 { Things moved up } 563 564 DEFAULT_VHOST_ADDR = $ffffffff; 565 566{ Things which may vary per file-lookup WITHIN a request --- 567 * e.g., state of MIME config. Basically, the name of an object, info 568 * about the object, and any other info we may ahve which may need to 569 * change as we go poking around looking for it (e.g., overridden by 570 * .htaccess files). 571 * 572 * Note how the default state of almost all these things is properly 573 * zero, so that allocating it with pcalloc does the right thing without 574 * a whole lot of hairy initialization... so long as we are willing to 575 * make the (fairly) portable assumption that the bit pattern of a NULL 576 * pointer is, in fact, zero. 577 } 578 579{ This represents the result of calling htaccess; these are cached for 580 * each request. 581 } 582type 583 Phtaccess_result = ^htaccess_result; 584 585 htaccess_result = record 586 dir: PChar; { the directory to which this applies } 587 override_: cint; { the overrides allowed for the .htaccess file } 588 htaccess: Pointer; { the configuration directives } 589{ the next one, or NULL if no more; N.B. never change this } 590 next: Phtaccess_result; 591 end; 592 593 Pconn_rec = ^conn_rec; 594 Pserver_rec = ^server_rec; 595 Prequest_rec = ^request_rec; 596 Plisten_rec = ^listen_rec; 597 598{.$include util_uri.inc} 599 600 proxyreqtype = ( 601 NOT_PROXY=0, 602 STD_PROXY, 603 PROXY_PASS 604 ); 605 606 request_rec = record 607 608 pool: Pap_pool; 609 connection: Pconn_rec; 610 server: Pserver_rec; 611 612 next: Prequest_rec; { If we wind up getting redirected, 613 * pointer to the request we redirected to. 614 } 615 prev: Prequest_rec; { If this is an internal redirect, 616 * pointer to where we redirected *from*. 617 } 618 619 main: Prequest_rec; { If this is a sub_request (see request.h) 620 * pointer back to the main request. 621 } 622 623 { Info about the request itself... we begin with stuff that only 624 * protocol.c should ever touch... 625 } 626 627 the_request: PChar; { First line of request, so we can log it } 628 assbackwards: cint; { HTTP/0.9, "simple" request } 629 proxyreq: proxyreqtype; { A proxy request (calculated during 630 * post_read_request or translate_name) } 631 header_only: cint; { HEAD request, as opposed to GET } 632 protocol: PChar; { Protocol, as given to us, or HTTP/0.9 } 633 proto_num: cint; { Number version of protocol; 1.1 = 1001 } 634 hostname: PChar; { Host, as set by full URI or Host: } 635 636 request_time: time_t; { When the request started } 637 638 status_line: PChar; { Status line, if set by script } 639 status: cint; { In any case } 640 641 { Request method, two ways; also, protocol, etc.. Outside of protocol.c, 642 * look, but don't touch. 643 } 644 645 method: PChar; { GET, HEAD, POST, etc. } 646 method_number: cint; { M_GET, M_POST, etc. } 647 648 { 649 allowed is a bitvector of the allowed methods. 650 651 A handler must ensure that the request method is one that 652 it is capable of handling. Generally modules should DECLINE 653 any request methods they do not handle. Prior to aborting the 654 handler like this the handler should set r->allowed to the list 655 of methods that it is willing to handle. This bitvector is used 656 to construct the "Allow:" header required for OPTIONS requests, 657 and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes. 658 659 Since the default_handler deals with OPTIONS, all modules can 660 usually decline to deal with OPTIONS. TRACE is always allowed, 661 modules don't need to set it explicitly. 662 663 Since the default_handler will always handle a GET, a 664 module which does *not* implement GET should probably return 665 METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET 666 handler can't be installed by mod_actions. 667 } 668 allowed: cint; { Allowed methods - for 405, OPTIONS, etc } 669 670 sent_bodyct: cint; { byte count in stream is for body } 671 bytes_sent: clong; { body byte count, for easy access } 672 mtime: time_t; { Time the resource was last modified } 673 674 { HTTP/1.1 connection-level features } 675 676 chunked: cint; { sending chunked transfer-coding } 677 byterange: cint; { number of byte ranges } 678 boundary: PChar; { multipart/byteranges boundary } 679 range: PChar; { The Range: header } 680 clength: clong; { The "real" content length } 681 682 remaining: clong; { bytes left to read } 683 read_length: clong; { bytes that have been read } 684 read_body: cint; { how the request body should be read } 685 read_chunked: cint; { reading chunked transfer-coding } 686 expecting_100: cuint; { is client waiting for a 100 response? } 687 688 { MIME header environments, in and out. Also, an array containing 689 * environment variables to be passed to subprocesses, so people can 690 * write modules to add to that environment. 691 * 692 * The difference between headers_out and err_headers_out is that the 693 * latter are printed even on error, and persist across internal redirects 694 * (so the headers printed for ErrorDocument handlers will have them). 695 * 696 * The 'notes' table is for notes from one module to another, with no 697 * other set purpose in mind... 698 } 699 700 headers_in: PTable; 701 headers_out: PTable; 702 err_headers_out: PTable; 703 subprocess_env: PTable; 704 notes: PTable; 705 706 { content_type, handler, content_encoding, content_language, and all 707 * content_languages MUST be lowercased strings. They may be pointers 708 * to static strings; they should not be modified in place. 709 } 710 content_type: PChar; { Break these out --- we dispatch on 'em } 711 handler: PChar; { What we *really* dispatch on } 712 713 content_encoding: PChar; 714 content_language: PChar; { for back-compat. only -- do not use } 715 content_languages: Parray_header; { array of (char*) } 716 717 vlist_validator: PChar; { variant list validator (if negotiated) } 718 719 no_cache: cint; 720 no_local_copy: cint; 721 722 { What object is being requested (either directly, or via include 723 * or content-negotiation mapping). 724 } 725 726 unparsed_uri: PChar; { the uri without any parsing performed } 727 uri: PChar; { the path portion of the URI } 728 filename: PChar; { filename if found, otherwise NULL } 729 path_info: PChar; 730 args: PChar; { QUERY_ARGS, if any } 731 finfo: Integer;//stat; { ST_MODE set to zero if no such file } 732 parsed_uri: uri_components; { components of uri, dismantled } 733 734 { Various other config info which may change with .htaccess files 735 * These are config vectors, with one void* pointer for each module 736 * (the thing pointed to being the module's business). 737 } 738 739 per_dir_config: Pointer; { Options set in config files, etc. } 740 request_config: Pointer; { Notes on *this* request } 741 742{ 743 * a linked list of the configuration directives in the .htaccess files 744 * accessed by this request. 745 * N.B. always add to the head of the list, _never_ to the end. 746 * that way, a sub request's list can (temporarily) point to a parent's list 747 } 748 htaccess: Phtaccess_result; 749 750 { On systems with case insensitive file systems (Windows, OS/2, etc.), 751 * r->filename is case canonicalized (folded to either lower or upper 752 * case, depending on the specific system) to accomodate file access 753 * checking. case_preserved_filename is the same as r->filename 754 * except case is preserved. There is at least one instance where Apache 755 * needs access to the case preserved filename: Java class files published 756 * with WebDAV need to preserve filename case to make the Java compiler 757 * happy. 758 } 759 case_preserved_filename: PChar; 760 761{$ifdef CHARSET_EBCDIC} 762 { We don't want subrequests to modify our current conversion flags. 763 * These flags save the state of the conversion flags when subrequests 764 * are run. 765 } 766 struct { 767 unsigned conv_in:1; { convert ASCII->EBCDIC when read()ing? } 768 unsigned conv_out:1; { convert EBCDIC->ASCII when write()ing? } 769 } ebcdic; 770{$endif} 771 772{ Things placed at the end of the record to avoid breaking binary 773 * compatibility. It would be nice to remember to reorder the entire 774 * record to improve 64bit alignment the next time we need to break 775 * binary compatibility for some other reason. 776 } 777 end; 778 779 780{ Things which are per connection 781 } 782 783 sockaddr_in = record end; 784 785 conn_rec = record 786 787 pool: Pap_pool; 788 server: Pserver_rec; 789 base_server: Pserver_rec; { Physical vhost this conn come in on } 790 vhost_lookup_data: Pointer; { used by http_vhost.c } 791 792 { Information about the connection itself } 793 794 child_num: cint; { The number of the child handling conn_rec } 795 client: PBUFF; { Connection to the guy } 796 797 { Who is the client? } 798 799 local_addr: sockaddr_in; { local address } 800 remote_addr: sockaddr_in; { remote address } 801 remote_ip: PChar; { Client's IP address } 802 remote_host: PChar; { Client's DNS name, if known. 803 * NULL if DNS hasn't been checked, 804 * "" if it has and no address was found. 805 * N.B. Only access this though 806 * get_remote_host() } 807 remote_logname: PChar; { Only ever set if doing rfc1413 lookups. 808 * N.B. Only access this through 809 * get_remote_logname() } 810 user: PChar; { If an authentication check was made, 811 * this gets set to the user name. We assume 812 * that there's only one user per connection(!) 813 } 814 ap_auth_type: PChar; { Ditto. } 815 816// unsigned aborted:1; { Are we still talking? } 817// signed int keepalive:2; { Are we using HTTP Keep-Alive? 818// * -1 fatal error, 0 undecided, 1 yes } 819// unsigned keptalive:1; { Did we use HTTP Keep-Alive? } 820// signed int double_reverse:2;{ have we done double-reverse DNS? 821// * -1 yes/failure, 0 not yet, 1 yes/success } 822 keepalives: cint; { How many times have we used it? } 823 local_ip: PChar; { server IP address } 824 local_host: PChar; { used for ap_get_server_name when 825 * UseCanonicalName is set to DNS 826 * (ignores setting of HostnameLookups) } 827 end; 828 829{ Per-vhost config... } 830 831{ The address 255.255.255.255, when used as a virtualhost address, 832 * will become the "default" server when the ip doesn't match other vhosts. 833 } 834 835 { Moved up } 836 837 Pserver_addr_rec = ^server_addr_rec; 838 839 in_addr = record end; 840 841 server_addr_rec = record 842 next: Pserver_addr_rec; 843 host_addr: in_addr; { The bound address, for this server } 844 host_port: cushort; { The bound port, for this server } 845 virthost: PChar; { The name given in <VirtualHost> } 846 end; 847 848 server_rec = record 849 850 next: Pserver_rec; 851 852 { description of where the definition came from } 853 defn_name: PChar; 854 defn_line_number: cuint; 855 856 { Full locations of server config info } 857 858 srm_confname: PChar; 859 access_confname: PChar; 860 861 { Contact information } 862 863 server_admin: PChar; 864 server_hostname: PChar; 865 port: cushort; { for redirects, etc. } 866 867 { Log files --- note that transfer log is now in the modules... } 868 869 error_fname: PChar; 870 error_log: Pointer; //FILE * 871 loglevel: cint; 872 873 { Module-specific configuration for server, and defaults... } 874 875 is_virtual: cint; { true if this is the virtual server } 876 module_config: Pointer; { Config vector containing pointers to 877 * modules' per-server config structures. 878 } 879 lookup_defaults: Pointer; { MIME type info, etc., before we start 880 * checking per-directory info. 881 } 882 { Transaction handling } 883 884 addrs: Pserver_addr_rec; 885 timeout: cint; { Timeout, in seconds, before we give up } 886 keep_alive_timeout: cint; { Seconds we'll wait for another request } 887 keep_alive_max: cint; { Maximum requests per connection } 888 keep_alive: cint; { Use persistent connections? } 889 send_buffer_size: cint; { size of TCP send buffer (in bytes) } 890 891 path: PChar; { Pathname for ServerPath } 892 pathlen: cint; { Length of path } 893 894 names: Parray_header; { Normal names for ServerAlias servers } 895 wild_names: Parray_header; { Wildcarded names for ServerAlias servers } 896 897 server_uid: uid_t; { effective user id when calling exec wrapper } 898 server_gid: gid_t; { effective group id when calling exec wrapper } 899 900 limit_req_line: cint; { limit on size of the HTTP request line } 901 limit_req_fieldsize: cint; { limit on size of any request header field } 902 limit_req_fields: cint; { limit on number of request header fields } 903 end; 904 905 { These are more like real hosts than virtual hosts } 906 907 listen_rec = record 908 next: Plisten_rec; 909 local_addr: sockaddr_in; { local IP address and port } 910 fd: cint; 911 used: cint; { Only used during restart } 912 { more stuff here, like which protocol is bound to the port } 913 end; 914 915 tm = record end; 916 917 Ptm = ^tm; 918 919{ Prototypes for utilities... util.c. 920 } 921 922//extern void ap_util_init(void); 923 924{ Time } 925{extern API_VAR_EXPORT const char ap_month_snames[12][4]; 926extern API_VAR_EXPORT const char ap_day_snames[7][4];} 927 928function ap_get_gmtoff(tz: Pcint): Ptm; 929 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 930 931function ap_get_time: PChar; 932 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 933 934function ap_field_noparam(p: Ppool; const intype: PChar): PChar; 935 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 936 937function ap_ht_time(p: Ppool; t: time_t; const fmt: PChar; gmt: cint): PChar; 938 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 939 940function ap_gm_timestr_822(p: Ppool; t: time_t): PChar; 941 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 942 943{ String handling. The *_nc variants allow you to use non-const char **s as 944 arguments (unfortunately C won't automatically convert a char ** to a const 945 char **) } 946 947function ap_getword(p: Ppool; const line: PPChar; stop: Char): PChar; 948 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 949 950function ap_getword_nc(p: Ppool; line: PPChar; stop: Char): PChar; 951 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 952 953function ap_getword_white(p: Ppool; const line: PPChar): PChar; 954 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 955 956function ap_getword_white_nc(p: Ppool; line: PPChar): PChar; 957 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 958 959function ap_getword_nulls(p: Ppool; const line: PPChar; stop: Char): PChar; 960 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 961 962function ap_getword_nulls_nc(p: Ppool; line: PPChar; stop: Char): PChar; 963 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 964 965function ap_getword_conf(p: Ppool; const line: PPChar): PChar; 966 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 967 968function ap_getword_conf_nc(p: Ppool; line: PPChar): PChar; 969 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 970 971 972function ap_size_list_item(const field: PPChar; len: Pcint): PChar; 973 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 974 975function ap_get_list_item(p: Ppool; const field: PPChar): PChar; 976 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 977 978function ap_find_list_item(p: Ppool; const line, tok: PChar): cint; 979 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 980 981 982function ap_get_token(p: Ppool; const accept_line: PPChar; accept_white: cint): PChar; 983 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 984 985function ap_find_token(p: Ppool; const line, tok: PChar): cint; 986 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 987 988function ap_find_last_token(p: Ppool; const line, tok: PChar): cint; 989 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 990 991 992function ap_unescape_url(url: PChar): cint; 993 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 994 995procedure ap_no2slash(name: PChar); 996 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 997 998procedure ap_getparents(name: PChar); 999 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1000 1001function ap_escape_path_segment(p: Ppool; const s: PChar): PChar; 1002 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1003 1004function ap_os_escape_path(p: Ppool; const path: PChar; partial: cint): PChar; 1005 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1006 1007//#define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1) 1008 1009function ap_escape_html(p: Ppool; const s: PChar): PChar; 1010 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1011 1012{API_EXPORT(char *) ap_construct_server(pool *p, const char *hostname, 1013 unsigned port, const request_rec *r); 1014API_EXPORT(char *) ap_escape_logitem(pool *p, const char *str); 1015API_EXPORT(size_t) ap_escape_errorlog_item(char *dest, const char *source, 1016 size_t buflen); 1017API_EXPORT(char *) ap_escape_shell_cmd(pool *p, const char *s); 1018 1019API_EXPORT(int) ap_count_dirs(const char *path); 1020API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n); 1021API_EXPORT(char *) ap_make_dirstr_parent(pool *p, const char *s);} 1022{ deprecated. The previous two routines are preferred. } 1023{API_EXPORT(char *) ap_make_dirstr(pool *a, const char *s, int n); 1024API_EXPORT(char *) ap_make_full_path(pool *a, const char *dir, const char *f); 1025 1026API_EXPORT(int) ap_is_matchexp(const char *str); 1027API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp); 1028API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp); 1029API_EXPORT(char *) ap_stripprefix(const char *bigstring, const char *prefix); 1030API_EXPORT(char *) ap_strcasestr(const char *s1, const char *s2); 1031API_EXPORT(char *) ap_pbase64decode(pool *p, const char *bufcoded); 1032API_EXPORT(char *) ap_pbase64encode(pool *p, char *string); 1033API_EXPORT(char *) ap_uudecode(pool *p, const char *bufcoded); 1034API_EXPORT(char *) ap_uuencode(pool *p, char *string); } 1035 1036{$if defined(OS2) or defined(WINDOWS)} 1037//API_EXPORT(char *) ap_double_quotes(pool *p, const char *str); 1038//API_EXPORT(char *) ap_caret_escape_args(pool *p, const char *str); 1039{$endif} 1040 1041{$ifdef OS2} 1042void os2pathname(char *path); 1043{$endif} 1044 1045{API_EXPORT(int) ap_regexec(const regex_t *preg, const char *string, 1046 size_t nmatch, regmatch_t pmatch[], int eflags); 1047API_EXPORT(size_t) ap_regerror(int errcode, const regex_t *preg, 1048 char *errbuf, size_t errbuf_size); 1049API_EXPORT(char *) ap_pregsub(pool *p, const char *input, const char *source, 1050 size_t nmatch, regmatch_t pmatch[]); 1051 1052API_EXPORT(void) ap_content_type_tolower(char *); 1053API_EXPORT(void) ap_str_tolower(char *); 1054API_EXPORT(int) ap_ind(const char *, char);} { Sigh... } 1055{API_EXPORT(int) ap_rind(const char *, char); 1056 1057API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring); 1058API_EXPORT(void) ap_remove_spaces(char *dest, char *src);} 1059 1060{ Common structure for reading of config files / passwd files etc. } 1061type 1062 1063 Pconfigfile_t = ^configfile_t; 1064 1065 getch_t = function (param: Pointer): cint; 1066 1067 getstr_t = function (buf: Pointer; bufsiz: size_t; param: Pointer): Pointer; 1068 1069 close_t = function (param: Pointer): cint; 1070 1071 configfile_t = record 1072 getch: getch_t; { a getc()-like function } 1073 getstr: getstr_t; { a fgets()-like function } 1074 close: close_t; { a close hander function } 1075 param: Pointer; { the argument passed to getch/getstr/close } 1076 name: PChar; { the filename / description } 1077 line_number: cuint; { current line number, starting at 1 } 1078 end; 1079 1080{ Open a configfile_t as FILE, return open configfile_t struct pointer } 1081//API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name); 1082 1083{ Allocate a configfile_t handle with user defined functions and params } 1084//API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool *p, const char *descr, 1085// void *param, 1086// int( *getc_func)(void*), 1087// void *( *gets_func) (void *buf, size_t bufsiz, void *param), 1088// int( *close_func)(void *param)); 1089 1090{ Read one line from open configfile_t, strip LF, increase line number } 1091//API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp); 1092 1093{ Read one char from open configfile_t, increase line number upon LF } 1094//API_EXPORT(int) ap_cfg_getc(configfile_t *cfp); 1095 1096{ Detach from open configfile_t, calling the close handler } 1097//API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp); 1098 1099{$ifdef NEED_STRERROR} 1100//char *strerror(int err); 1101{$endif} 1102 1103{ Misc system hackery } 1104 1105function ap_uname2id(const name: PChar): uid_t; 1106 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1107 1108function ap_gname2id(const name: PChar): gid_t; 1109 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1110 1111function ap_is_directory(const name: PChar): cint; 1112 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1113 1114function ap_is_rdirectory(const name: PChar): cint; 1115 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1116 1117function ap_can_exec(const stat: Pointer): cint; 1118 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1119 1120procedure ap_chdir_file(const file_: PChar); 1121 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1122 1123{$ifndef HAVE_CANONICAL_FILENAME} 1124{ 1125 * We can't define these in os.h because of dependence on pool pointer. 1126 } 1127{#define ap_os_canonical_filename(p,f) (f) 1128#define ap_os_case_canonical_filename(p,f) (f) 1129#define ap_os_systemcase_filename(p,f) (f)} 1130{$else} 1131//API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file); 1132{$ifdef WINDOWS} 1133//API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); 1134//API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile); 1135{$else}{$ifdef OS2} 1136//API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); 1137//API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile); 1138{$else}{$ifdef NETWARE} 1139//API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); 1140//#define ap_os_systemcase_filename(p,f) ap_os_case_canonical_filename(p,f) 1141{$else} 1142//#define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f) 1143//#define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f) 1144{$endif} 1145{$endif} 1146{$endif} 1147{$endif} 1148 1149{$ifdef CHARSET_EBCDIC} 1150//API_EXPORT(int) ap_checkconv(struct request_rec *r); { for downloads } 1151//API_EXPORT(int) ap_checkconv_in(struct request_rec *r); { for uploads } 1152{$endif} {#ifdef CHARSET_EBCDIC} 1153 1154{API_EXPORT(char *) ap_get_local_host(pool *); 1155API_EXPORT(unsigned long) ap_get_virthost_addr(char *hostname, unsigned short *port); 1156 1157extern API_VAR_EXPORT time_t ap_restart_time;} 1158 1159{ 1160 * Apache tries to keep all of its long term filehandles (such as log files, 1161 * and sockets) above this number. This is to workaround problems in many 1162 * third party libraries that are compiled with a small FD_SETSIZE. There 1163 * should be no reason to lower this, because it's only advisory. If a file 1164 * can't be allocated above this number then it will remain in the "slack" 1165 * area. 1166 * 1167 * Only the low slack line is used by default. If HIGH_SLACK_LINE is defined 1168 * then an attempt is also made to keep all non-FILE * files above the high 1169 * slack line. This is to work around a Solaris C library limitation, where it 1170 * uses an unsigned char to store the file descriptor. 1171 } 1172 1173const 1174 LOW_SLACK_LINE = 15; 1175 1176 HIGH_SLACK_LINE = 255; 1177 1178{ 1179 * The ap_slack() function takes a fd, and tries to move it above the indicated 1180 * line. It returns an fd which may or may not have moved above the line, and 1181 * never fails. If the high line was requested and it fails it will also try 1182 * the low line. 1183 } 1184{#ifdef NO_SLACK 1185#define ap_slack(fd,line) (fd) 1186#else 1187int ap_slack(int fd, int line); 1188const 1189 AP_SLACK_LOW = 1; 1190 AP_SLACK_HIGH = 2; 1191#endif 1192 1193API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr);} 1194 1195{ 1196 * Redefine assert() to something more useful for an Apache... 1197 } 1198{API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) 1199 __attribute__((noreturn)); 1200#define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))} 1201 1202{ The optimized timeout code only works if we're not MULTITHREAD and we're 1203 * also not using a scoreboard file 1204 } 1205{#if !defined (MULTITHREAD) && (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD)) 1206#define OPTIMIZE_TIMEOUTS 1207#endif} 1208 1209{ A set of flags which indicate places where the server should raise(SIGSTOP). 1210 * This is useful for debugging, because you can then attach to that process 1211 * with gdb and continue. This is important in cases where one_process 1212 * debugging isn't possible. 1213 } 1214 SIGSTOP_DETACH = 1; 1215 SIGSTOP_MAKE_CHILD = 2; 1216 SIGSTOP_SPAWN_CHILD = 4; 1217 SIGSTOP_PIPED_LOG_SPAWN = 8; 1218 SIGSTOP_CGI_CHILD = 16; 1219 1220{#ifdef DEBUG_SIGSTOP 1221extern int raise_sigstop_flags; 1222#define RAISE_SIGSTOP(x) do begin 1223 if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\ 1224 end while (0) 1225#else 1226#define RAISE_SIGSTOP(x) 1227#endif 1228 1229API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r);} 1230 1231 { strtoul does not exist on sunos4. } 1232 1233// strtoul = strtoul_is_not_a_portable_function_use_strtol_instead 1234 1235{$ifdef AP_ENABLE_EXCEPTION_HOOK} 1236{ The exception hook allows a module to run from the server's signal 1237 * handler, and perform tasks such as logging the current request or 1238 * getting a backtrace or performing other diagnostic functions. All 1239 * operating system requirements for running in a signal handler must 1240 * be respected, or the process may not exit properly. 1241 * 1242 * AP_ENABLE_EXCEPTION_HOOK is already defined for platforms that have 1243 * been tested. It likely will work on other platforms. In order to 1244 * test, define AP_ENABLE_EXCEPTION_HOOK at configure time. 1245 } 1246type 1247 ap_exception_info_t = record 1248 sig: cint; 1249 pid: pid_t; 1250 end; 1251 1252 Pap_exception_info_t = ^ap_exception_info_t; 1253 1254{ Register a function to be called after a fatal exception (on *X systems, a 1255 * "synchronous signal" such as SIGSEGV, SIGILL, etc.). 1256 * 1257 * Returns 0 on success, non-zero on failure. 1258 * If EnableExceptionHook directive is not set to "on", this function will 1259 * report failure and no such hooks will be called. 1260 } 1261 fn_afeh_t = procedure (param: Pap_exception_info_t); 1262 1263function ap_add_fatal_exception_hook(fn: fn_afeh_t): cint; 1264 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; 1265 1266{$endif} { AP_ENABLE_EXCEPTION_HOOK } 1267