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