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