/packages/httpd13/src/httpd.inc

https://github.com/slibre/freepascal · Pascal · 1267 lines · 438 code · 245 blank · 584 comment · 0 complexity · 93e1faf221c3824af4d8d324c233a8a6 MD5 · raw file

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