httpd.inc 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806
  1. {
  2. * @file httpd.h
  3. * @brief HTTP Daemon routines
  4. }
  5. { XXX - We need to push more stuff to other .h files, or even .c files, to
  6. * make this file smaller
  7. }
  8. // Headers in which EVERYONE has an interest...
  9. {$include ap_config.inc}
  10. {$include ap_mmn.inc}
  11. {$include ap_release.inc}
  12. {#include "apr_general.h"}
  13. {#include "apr_time.h"
  14. #include "apr_network_io.h"}
  15. {$ifdef windows}
  16. {$include apr\apr_buckets.inc}
  17. {$else}
  18. {$include apr/apr_buckets.inc}
  19. {$endif}
  20. {#include "os.h"}
  21. {$include ap_regex.inc}
  22. // Note: util_uri.h is also included, see below
  23. { ----------------------------- config dir ------------------------------ }
  24. { Define this to be the default server home dir. Most things later in this
  25. * file with a relative pathname will have this added.
  26. }
  27. const
  28. {$ifdef OS2}
  29. { Set default for OS/2 file system }
  30. HTTPD_ROOT = '/os2httpd';
  31. {$else}{$ifdef WINDOWS}
  32. { Set default for Windows file system }
  33. HTTPD_ROOT = '/apache';
  34. {$else}{$ifdef BEOS}
  35. { Set the default for BeOS }
  36. HTTPD_ROOT = '/boot/home/apache';
  37. {$else}{$ifdef NETWARE}
  38. { Set the default for NetWare }
  39. HTTPD_ROOT = '/apache';
  40. {$else}
  41. { Set for all other OSes }
  42. HTTPD_ROOT = '/usr/local/apache';
  43. {$endif}
  44. {$endif}
  45. {$endif}
  46. {$endif}
  47. {
  48. * --------- You shouldn't have to edit anything below this line ----------
  49. *
  50. * Any modifications to any defaults not defined above should be done in the
  51. * respective configuration file.
  52. *
  53. }
  54. const
  55. { Default location of documents. Can be overridden by the DocumentRoot
  56. * directive.
  57. }
  58. DOCUMENT_LOCATION = HTTPD_ROOT + '/htdocs';
  59. // Maximum number of dynamically loaded modules
  60. DYNAMIC_MODULE_LIMIT = 128;
  61. // Default administrator's address
  62. DEFAULT_ADMIN = '[no address given]';
  63. // The name of the log files
  64. {$if defined(OS2) or defined(WINDOWS)}
  65. DEFAULT_ERRORLOG = 'logs/error.log';
  66. {$else}
  67. DEFAULT_ERRORLOG = 'logs/error_log';
  68. {$endif}
  69. { Define this to be what your per-directory security files are called }
  70. DEFAULT_ACCESS_FNAME = '.htaccess';
  71. { The name of the server config file }
  72. SERVER_CONFIG_FILE = 'conf/httpd.conf';
  73. { The default path for CGI scripts if none is currently set }
  74. DEFAULT_PATH = '/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin';
  75. { The path to the suExec wrapper, can be overridden in Configuration }
  76. SUEXEC_BIN = HTTPD_ROOT + '/bin/suexec';
  77. { The timeout for waiting for messages }
  78. DEFAULT_TIMEOUT = 300 ;
  79. { The timeout for waiting for keepalive timeout until next request }
  80. DEFAULT_KEEPALIVE_TIMEOUT = 15;
  81. { The number of requests to entertain per connection }
  82. DEFAULT_KEEPALIVE = 100;
  83. { Limits on the size of various request items. These limits primarily
  84. * exist to prevent simple denial-of-service attacks on a server based
  85. * on misuse of the protocol. The recommended values will depend on the
  86. * nature of the server resources -- CGI scripts and database backends
  87. * might require large values, but most servers could get by with much
  88. * smaller limits than we use below. The request message body size can
  89. * be limited by the per-dir config directive LimitRequestBody.
  90. *
  91. * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE
  92. * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190.
  93. * These two limits can be lowered (but not raised) by the server config
  94. * directives LimitRequestLine and LimitRequestFieldsize, respectively.
  95. *
  96. * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by
  97. * the server config directive LimitRequestFields.
  98. }
  99. DEFAULT_LIMIT_REQUEST_LINE = 8190;
  100. DEFAULT_LIMIT_REQUEST_FIELDSIZE = 8190;
  101. DEFAULT_LIMIT_REQUEST_FIELDS = 100;
  102. {
  103. * The default default character set name to add if AddDefaultCharset is
  104. * enabled. Overridden with AddDefaultCharsetName.
  105. }
  106. DEFAULT_ADD_DEFAULT_CHARSET_NAME = 'iso-8859-1';
  107. { default HTTP Server protocol }
  108. AP_SERVER_PROTOCOL = 'HTTP/1.1';
  109. { ------------------ stuff that modules are allowed to look at ----------- }
  110. AP_DEFAULT_INDEX = 'index.html';
  111. {
  112. * Define this to be what type you'd like returned for files with unknown
  113. * suffixes.
  114. * @warning MUST be all lower case.
  115. }
  116. DEFAULT_CONTENT_TYPE = 'text/plain';
  117. { The name of the MIME types file }
  118. AP_TYPES_CONFIG_FILE = 'conf/mime.types';
  119. {
  120. * Define the HTML doctype strings centrally.
  121. }
  122. { HTML 2.0 Doctype }
  123. DOCTYPE_HTML_2_0 = '<!DOCTYPE HTML PUBLIC "-//IETF//' +
  124. 'DTD HTML 2.0//EN">' + LineEnding;
  125. { HTML 3.2 Doctype }
  126. DOCTYPE_HTML_3_2 = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
  127. 'DTD HTML 3.2 Final//EN">' + LineEnding;
  128. { HTML 4.0 Strict Doctype }
  129. DOCTYPE_HTML_4_0S = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
  130. 'DTD HTML 4.0//EN"' + LineEnding +
  131. '"http://www.w3.org/TR/REC-html40/strict.dtd">' + LineEnding;
  132. { HTML 4.0 Transitional Doctype }
  133. DOCTYPE_HTML_4_0T = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
  134. 'DTD HTML 4.0 Transitional//EN"' + LineEnding +
  135. '"http://www.w3.org/TR/REC-html40/loose.dtd">' + LineEnding;
  136. { HTML 4.0 Frameset Doctype }
  137. DOCTYPE_HTML_4_0F = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
  138. 'DTD HTML 4.0 Frameset//EN"' + LineEnding +
  139. '"http://www.w3.org/TR/REC-html40/frameset.dtd">' + LineEnding;
  140. { XHTML 1.0 Strict Doctype }
  141. DOCTYPE_XHTML_1_0S = '<!DOCTYPE html PUBLIC "-//W3C//' +
  142. 'DTD XHTML 1.0 Strict//EN"' + LineEnding +
  143. '"http://www.w3.org/TR/xhtml1/DTD/' +
  144. 'xhtml1-strict.dtd\">' + LineEnding;
  145. { XHTML 1.0 Transitional Doctype }
  146. DOCTYPE_XHTML_1_0T = '<!DOCTYPE html PUBLIC "-//W3C//' +
  147. 'DTD XHTML 1.0 Transitional//EN"' + LineEnding +
  148. '"http://www.w3.org/TR/xhtml1/DTD/' +
  149. 'xhtml1-transitional.dtd">' + LineEnding;
  150. { XHTML 1.0 Frameset Doctype }
  151. DOCTYPE_XHTML_1_0F = '<!DOCTYPE html PUBLIC "-//W3C//' +
  152. 'DTD XHTML 1.0 Frameset//EN"' + LineEnding +
  153. '"http://www.w3.org/TR/xhtml1/DTD/' +
  154. 'xhtml1-frameset.dtd">' + LineEnding;
  155. { Internal representation for a HTTP protocol number, e.g., HTTP/1.1 }
  156. function HTTP_VERSION(major, minor: Integer): Integer;
  157. { Major part of HTTP protocol }
  158. function HTTP_VERSION_MAJOR(number: Integer): Integer;
  159. { Minor part of HTTP protocol }
  160. function HTTP_VERSION_MINOR(number: Integer): Integer;
  161. { -------------- Port number for server running standalone --------------- }
  162. const
  163. { default HTTP Port }
  164. DEFAULT_HTTP_PORT = 80;
  165. { default HTTPS Port }
  166. DEFAULT_HTTPS_PORT = 443;
  167. {
  168. * Check whether @a port is the default port for the request @a r.
  169. * @param port The port number
  170. * @param r The request
  171. * @see #ap_default_port
  172. }
  173. //#define ap_is_default_port(port,r) ((port) == ap_default_port(r))
  174. {
  175. * Get the default port for a request (which depends on the scheme).
  176. * @param r The request
  177. }
  178. //#define ap_default_port(r) ap_run_default_port(r)
  179. {
  180. * Get the scheme for a request.
  181. * @param r The request
  182. * @bug This should be called ap_http_scheme!
  183. }
  184. //#define ap_http_scheme(r) ap_run_http_scheme(r)
  185. { The default string lengths }
  186. // MAX_STRING_LEN = HUGE_STRING_LEN;
  187. HUGE_STRING_LEN = 8192;
  188. { The size of the server's internal read-write buffers }
  189. AP_IOBUFSIZE = 8192;
  190. { The max number of regex captures that can be expanded by ap_pregsub }
  191. AP_MAX_REG_MATCH = 10;
  192. {
  193. * APR_HAS_LARGE_FILES introduces the problem of spliting sendfile into
  194. * mutiple buckets, no greater than MAX(apr_size_t), and more granular
  195. * than that in case the brigade code/filters attempt to read it directly.
  196. * ### 16mb is an invention, no idea if it is reasonable.
  197. }
  198. AP_MAX_SENDFILE = 16777216; { 2^24 }
  199. {
  200. * Special Apache error codes. These are basically used
  201. * in http_main.c so we can keep track of various errors.
  202. *
  203. }
  204. { a normal exit }
  205. APEXIT_OK = $0;
  206. { A fatal error arising during the server's init sequence }
  207. APEXIT_INIT = $2;
  208. { The child died during its init sequence }
  209. APEXIT_CHILDINIT = $3;
  210. {
  211. * The child exited due to a resource shortage.
  212. * The parent should limit the rate of forking until
  213. * the situation is resolved.
  214. }
  215. APEXIT_CHILDSICK = $7;
  216. {
  217. * A fatal error, resulting in the whole server aborting.
  218. * If a child exits with this error, the parent process
  219. * considers this a server-wide fatal error and aborts.
  220. }
  221. APEXIT_CHILDFATAL = $f;
  222. {
  223. * Stuff marked #AP_DECLARE is part of the API, and intended for use
  224. * by modules. Its purpose is to allow us to add attributes that
  225. * particular platforms or compilers require to every exported function.
  226. }
  227. // define AP_DECLARE(type) type
  228. {
  229. * Stuff marked #AP_DECLARE_NONSTD is part of the API, and intended for
  230. * use by modules. The difference between #AP_DECLARE and
  231. * #AP_DECLARE_NONSTD is that the latter is required for any functions
  232. * which use varargs or are used via indirect function call. This
  233. * is to accomodate the two calling conventions in windows dlls.
  234. }
  235. //# define AP_DECLARE_NONSTD(type) type
  236. {$define AP_DECLARE_DATA}
  237. //# define AP_MODULE_DECLARE(type) type
  238. //# define AP_MODULE_DECLARE_NONSTD(type) type
  239. {$define AP_MODULE_DECLARE_DATA}
  240. {
  241. * @internal
  242. * modules should not used functions marked AP_CORE_DECLARE
  243. }
  244. // AP_CORE_DECLARE = AP_DECLARE;
  245. {
  246. * @internal
  247. * modules should not used functions marked AP_CORE_DECLARE_NONSTD
  248. }
  249. // AP_CORE_DECLARE_NONSTD = AP_DECLARE_NONSTD;
  250. {
  251. * The numeric version information is broken out into fields within this
  252. * structure.
  253. }
  254. type
  255. ap_version_t = record
  256. major: Integer; {< major number }
  257. minor: Integer; {< minor number }
  258. patch: Integer; {< patch number }
  259. add_string: PChar; {< additional string like "-dev" }
  260. end;
  261. Pap_version_t = ^ap_version_t;
  262. {
  263. * Return httpd's version information in a numeric form.
  264. *
  265. * @param version Pointer to a version structure for returning the version
  266. * information.
  267. }
  268. procedure ap_get_server_revision(version: Pap_version_t);
  269. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  270. external LibHTTPD name LibNamePrefix + 'ap_get_server_revision' + LibSuff4;
  271. {**
  272. * Get the server version string, as controlled by the ServerTokens directive
  273. * @return The server version string
  274. * @deprecated @see ap_get_server_banner() and ap_get_server_description()
  275. *}
  276. function ap_get_server_version: PChar;
  277. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  278. external LibHTTPD name LibNamePrefix + 'ap_get_server_version' + LibSuff0;
  279. {**
  280. * Get the server banner in a form suitable for sending over the
  281. * network, with the level of information controlled by the
  282. * ServerTokens directive.
  283. * @return The server banner
  284. *}//added in Apache 2.2.4
  285. function ap_get_server_banner: PChar;
  286. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  287. external LibHTTPD name LibNamePrefix + 'ap_get_server_banner' + LibSuff0;
  288. {**
  289. * Get the server description in a form suitable for local displays,
  290. * status reports, or logging. This includes the detailed server
  291. * version and information about some modules. It is not affected
  292. * by the ServerTokens directive.
  293. * @return The server description
  294. *}//added in Apache 2.2.4
  295. function ap_get_server_description: PChar;
  296. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  297. external LibHTTPD name LibNamePrefix + 'ap_get_server_description' + LibSuff0;
  298. {
  299. * Add a component to the version string
  300. * @param pconf The pool to allocate the component from
  301. * @param component The string to add
  302. }
  303. procedure ap_add_version_component(pconf: Papr_pool_t; const component: PChar);
  304. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  305. external LibHTTPD name LibNamePrefix + 'ap_add_version_component' + LibSuff8;
  306. {
  307. * Get the date a time that the server was built
  308. * @return The server build time string
  309. }
  310. function ap_get_server_built: PChar;
  311. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  312. external LibHTTPD name LibNamePrefix + 'ap_get_server_built' + LibSuff0;
  313. const
  314. DECLINED = -1; {< Module declines to handle }
  315. DONE = -2; {< Module has served the response completely
  316. * - it's safe to die() with no more output
  317. }
  318. OK = 0; {< Module has handled this stage. }
  319. {
  320. * @defgroup HTTP_Status HTTP Status Codes
  321. * @
  322. * The size of the static array in http_protocol.c for storing
  323. * all of the potential response status-lines (a sparse table).
  324. * A future version should dynamically generate the apr_table_t at startup.
  325. }
  326. RESPONSE_CODES = 57;
  327. HTTP_CONTINUE = 100;
  328. HTTP_SWITCHING_PROTOCOLS = 101;
  329. HTTP_PROCESSING = 102;
  330. HTTP_OK = 200;
  331. HTTP_CREATED = 201;
  332. HTTP_ACCEPTED = 202;
  333. HTTP_NON_AUTHORITATIVE = 203;
  334. HTTP_NO_CONTENT = 204;
  335. HTTP_RESET_CONTENT = 205;
  336. HTTP_PARTIAL_CONTENT = 206;
  337. HTTP_MULTI_STATUS = 207;
  338. HTTP_MULTIPLE_CHOICES = 300;
  339. HTTP_MOVED_PERMANENTLY = 301;
  340. HTTP_MOVED_TEMPORARILY = 302;
  341. HTTP_SEE_OTHER = 303;
  342. HTTP_NOT_MODIFIED = 304;
  343. HTTP_USE_PROXY = 305;
  344. HTTP_TEMPORARY_REDIRECT = 307;
  345. HTTP_BAD_REQUEST = 400;
  346. HTTP_UNAUTHORIZED = 401;
  347. HTTP_PAYMENT_REQUIRED = 402;
  348. HTTP_FORBIDDEN = 403;
  349. HTTP_NOT_FOUND = 404;
  350. HTTP_METHOD_NOT_ALLOWED = 405;
  351. HTTP_NOT_ACCEPTABLE = 406;
  352. HTTP_PROXY_AUTHENTICATION_REQUIRED = 407;
  353. HTTP_REQUEST_TIME_OUT = 408;
  354. HTTP_CONFLICT = 409;
  355. HTTP_GONE = 410;
  356. HTTP_LENGTH_REQUIRED = 411;
  357. HTTP_PRECONDITION_FAILED = 412;
  358. HTTP_REQUEST_ENTITY_TOO_LARGE = 413;
  359. HTTP_REQUEST_URI_TOO_LARGE = 414;
  360. HTTP_UNSUPPORTED_MEDIA_TYPE = 415;
  361. HTTP_RANGE_NOT_SATISFIABLE = 416;
  362. HTTP_EXPECTATION_FAILED = 417;
  363. HTTP_UNPROCESSABLE_ENTITY = 422;
  364. HTTP_LOCKED = 423;
  365. HTTP_FAILED_DEPENDENCY = 424;
  366. HTTP_UPGRADE_REQUIRED = 426;
  367. HTTP_INTERNAL_SERVER_ERROR = 500;
  368. HTTP_NOT_IMPLEMENTED = 501;
  369. HTTP_BAD_GATEWAY = 502;
  370. HTTP_SERVICE_UNAVAILABLE = 503;
  371. HTTP_GATEWAY_TIME_OUT = 504;
  372. HTTP_VERSION_NOT_SUPPORTED = 505;
  373. HTTP_VARIANT_ALSO_VARIES = 506;
  374. _INSUFFICIENT_STORAGE = 507;
  375. HTTP_NOT_EXTENDED = 510;
  376. { is the status code informational }
  377. //#define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200))
  378. { is the status code OK ?}
  379. //#define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300))
  380. { is the status code a redirect }
  381. //#define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400))
  382. { is the status code a error (client or server) }
  383. //#define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600))
  384. { is the status code a client error }
  385. //#define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
  386. { is the status code a server error }
  387. //#define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
  388. { should the status code drop the connection }
  389. {#define ap_status_drops_connection(x) \
  390. (((x) == HTTP_BAD_REQUEST) || \
  391. ((x) == HTTP_REQUEST_TIME_OUT) || \
  392. ((x) == HTTP_LENGTH_REQUIRED) || \
  393. ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
  394. ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
  395. ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
  396. ((x) == HTTP_SERVICE_UNAVAILABLE) || \
  397. ((x) == HTTP_NOT_IMPLEMENTED))}
  398. {
  399. * @defgroup Methods List of Methods recognized by the server
  400. * @
  401. * Methods recognized (but not necessarily handled) by the server.
  402. * These constants are used in bit shifting masks of size int, so it is
  403. * unsafe to have more methods than bits in an int. HEAD == M_GET.
  404. * This list must be tracked by the list in http_protocol.c in routine
  405. * ap_method_name_of().
  406. }
  407. const
  408. M_GET = 0; // RFC 2616: HTTP
  409. M_PUT = 1; // :
  410. M_POST = 2;
  411. M_DELETE = 3;
  412. M_CONNECT = 4;
  413. M_OPTIONS = 5;
  414. M_TRACE = 6; // RFC 2616: HTTP }
  415. M_PATCH = 7; // no rfc(!) ### remove this one? }
  416. M_PROPFIND = 8; // RFC 2518: WebDAV }
  417. M_PROPPATCH = 9; // : }
  418. M_MKCOL = 10;
  419. M_COPY = 11;
  420. M_MOVE = 12;
  421. M_LOCK = 13;
  422. M_UNLOCK = 14; // RFC 2518: WebDAV }
  423. M_VERSION_CONTROL = 15; // RFC 3253: WebDAV Versioning }
  424. M_CHECKOUT = 16; // : }
  425. M_UNCHECKOUT = 17;
  426. M_CHECKIN = 18;
  427. M_UPDATE = 19;
  428. M_LABEL = 20;
  429. M_REPORT = 21;
  430. M_MKWORKSPACE = 22;
  431. M_MKACTIVITY = 23;
  432. M_BASELINE_CONTROL = 24;
  433. M_MERGE = 25;
  434. M_INVALID = 26; // RFC 3253: WebDAV Versioning }
  435. {
  436. * METHODS needs to be equal to the number of bits
  437. * we are using for limit masks.
  438. }
  439. METHODS = 64;
  440. {
  441. * The method mask bit to shift for anding with a bitmask.
  442. }
  443. AP_METHOD_BIT = apr_int64_t(1);
  444. {
  445. * Structure for handling HTTP methods. Methods known to the server are
  446. * accessed via a bitmask shortcut; extension methods are handled by
  447. * an array.
  448. }
  449. type
  450. ap_method_list_t = record
  451. { The bitmask used for known methods }
  452. method_mask: apr_int64_t;
  453. { the array used for extension methods }
  454. // method_list: ^apr_array_header_t;
  455. end;
  456. {
  457. * @defgroup module_magic Module Magic mime types
  458. * @
  459. }
  460. { Magic for mod_cgi[d] }
  461. const
  462. CGI_MAGIC_TYPE = 'application/x-httpd-cgi';
  463. { Magic for mod_include }
  464. INCLUDES_MAGIC_TYPE = 'text/x-server-parsed-html';
  465. { Magic for mod_include }
  466. INCLUDES_MAGIC_TYPE3 = 'text/x-server-parsed-html3';
  467. { Magic for mod_dir }
  468. DIR_MAGIC_TYPE = 'httpd/unix-directory';
  469. { Just in case your linefeed isn't the one the other end is expecting. }
  470. { linefeed }
  471. LF = 10;
  472. { carrige return }
  473. CR = 13;
  474. { carrige return /Line Feed Combo }
  475. CRLF = #015#012;
  476. {
  477. * @defgroup values_request_rec_body Possible values for request_rec.read_body
  478. * @
  479. * Possible values for request_rec.read_body (set by handling module):
  480. }
  481. { Send 413 error if message has any body }
  482. REQUEST_NO_BODY = 0;
  483. { Send 411 error if body without Content-Length }
  484. REQUEST_CHUNKED_ERROR = 1;
  485. { If chunked, remove the chunks for me. }
  486. REQUEST_CHUNKED_DECHUNK = 2;
  487. {
  488. * @defgroup values_request_rec_used_path_info Possible values for request_rec.used_path_info
  489. * @
  490. * Possible values for request_rec.used_path_info:
  491. }
  492. { Accept the path_info from the request }
  493. AP_REQ_ACCEPT_PATH_INFO = 0;
  494. { Return a 404 error if path_info was given }
  495. AP_REQ_REJECT_PATH_INFO = 1;
  496. { Module may chose to use the given path_info }
  497. AP_REQ_DEFAULT_PATH_INFO = 2;
  498. { @}
  499. {
  500. * Things which may vary per file-lookup WITHIN a request ---
  501. * e.g., state of MIME config. Basically, the name of an object, info
  502. * about the object, and any other info we may ahve which may need to
  503. * change as we go poking around looking for it (e.g., overridden by
  504. * .htaccess files).
  505. *
  506. * Note how the default state of almost all these things is properly
  507. * zero, so that allocating it with pcalloc does the right thing without
  508. * a whole lot of hairy initialization... so long as we are willing to
  509. * make the (fairly) portable assumption that the bit pattern of a NULL
  510. * pointer is, in fact, zero.
  511. }
  512. {
  513. * This represents the result of calling htaccess; these are cached for
  514. * each request.
  515. }
  516. type
  517. Phtaccess_result = ^htaccess_result;
  518. htaccess_result = record
  519. { the directory to which this applies }
  520. dir: PChar;
  521. { the overrides allowed for the .htaccess file }
  522. override_: Integer;
  523. { the configuration directives }
  524. htaccess: Pap_conf_vector_t;
  525. { the next one, or NULL if no more; N.B. never change this }
  526. next: Phtaccess_result;
  527. end;
  528. { The following four types define a hierarchy of activities, so that
  529. * given a request_rec r you can write r->connection->server->process
  530. * to get to the process_rec. While this reduces substantially the
  531. * number of arguments that various hooks require beware that in
  532. * threaded versions of the server you must consider multiplexing
  533. * issues. }
  534. { ### would be nice to not include this from httpd.h ... }
  535. { This comes after we have defined the request_rec type }
  536. //#include "apr_uri.h"
  537. type
  538. { Forward declarations of pointer to record types}
  539. Pconn_rec = ^conn_rec;
  540. Prequest_rec = ^request_rec;
  541. Pserver_rec = ^server_rec;
  542. PPserver_rec = ^Pserver_rec;
  543. Pserver_addr_rec = ^server_addr_rec;
  544. Pprocess_rec = ^process_rec;
  545. { A structure that represents one process }
  546. process_rec = record
  547. { Global pool. Cleared upon normal exit }
  548. pool: Papr_pool_t;
  549. { Configuration pool. Cleared upon restart }
  550. pconf: Papr_pool_t;
  551. { Number of command line arguments passed to the program }
  552. argc: Integer;
  553. { The command line arguments }
  554. argv: PChar;
  555. { The program name used to execute the program }
  556. short_name: PChar;
  557. end;
  558. { A structure that represents the current request }
  559. request_rec = record
  560. { The pool associated with the request }
  561. pool: Papr_pool_t;
  562. { The connection to the client }
  563. connection: Pconn_rec;
  564. { The virtual host for this request }
  565. server: Pserver_rec;
  566. { Pointer to the redirected request if this is an external redirect }
  567. next: Prequest_rec;
  568. { Pointer to the previous request if this is an internal redirect }
  569. prev: Prequest_rec;
  570. { Pointer to the main request if this is a sub-request
  571. * (see http_request.h) }
  572. main: Prequest_rec;
  573. { Info about the request itself... we begin with stuff that only
  574. * protocol.c should ever touch...
  575. }
  576. { First line of request }
  577. the_request: PChar;
  578. { HTTP/0.9, "simple" request (e.g. GET /foo\n w/no headers) }
  579. assbackwards: Integer;
  580. { A proxy request (calculated during post_read_request/translate_name)
  581. * possible values PROXYREQ_NONE, PROXYREQ_PROXY, PROXYREQ_REVERSE,
  582. * PROXYREQ_RESPONSE
  583. }
  584. proxyreq: Integer;
  585. { HEAD request, as opposed to GET }
  586. header_only: Integer;
  587. { Protocol string, as given to us, or HTTP/0.9 }
  588. protocol: PChar;
  589. { Protocol version number of protocol; 1.1 = 1001 }
  590. proto_num: Integer;
  591. { Host, as set by full URI or Host: }
  592. hostname: PChar;
  593. { Time when the request started }
  594. request_time: apr_time_t;
  595. { Status line, if set by script }
  596. status_line: PChar;
  597. { Status line }
  598. status: Integer;
  599. { Request method, two ways; also, protocol, etc.. Outside of protocol.c,
  600. * look, but don't touch.
  601. }
  602. { Request method (eg. GET, HEAD, POST, etc.) }
  603. method: PChar;
  604. { M_GET, M_POST, etc. }
  605. method_number: Integer;
  606. {
  607. * 'allowed' is a bitvector of the allowed methods.
  608. *
  609. * A handler must ensure that the request method is one that
  610. * it is capable of handling. Generally modules should DECLINE
  611. * any request methods they do not handle. Prior to aborting the
  612. * handler like this the handler should set r->allowed to the list
  613. * of methods that it is willing to handle. This bitvector is used
  614. * to construct the "Allow:" header required for OPTIONS requests,
  615. * and HTTP_METHOD_NOT_ALLOWED and HTTP_NOT_IMPLEMENTED status codes.
  616. *
  617. * Since the default_handler deals with OPTIONS, all modules can
  618. * usually decline to deal with OPTIONS. TRACE is always allowed,
  619. * modules don't need to set it explicitly.
  620. *
  621. * Since the default_handler will always handle a GET, a
  622. * module which does *not* implement GET should probably return
  623. * HTTP_METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET
  624. * handler can't be installed by mod_actions.
  625. }
  626. allowed: apr_int64_t;
  627. { Array of extension methods }
  628. allowed_xmethods: Papr_array_header_t;
  629. { List of allowed methods }
  630. allowed_methods: Pap_method_list_t;
  631. { byte count in stream is for body }
  632. sent_bodyct: apr_off_t;
  633. { body byte count, for easy access }
  634. bytes_sent: apr_off_t;
  635. { Last modified time of the requested resource }
  636. mtime: apr_time_t;
  637. { HTTP/1.1 connection-level features }
  638. { sending chunked transfer-coding }
  639. chunked: Integer;
  640. { The Range: header }
  641. range: PChar;
  642. { The "real" content length }
  643. clength: apr_off_t;
  644. { Remaining bytes left to read from the request body }
  645. remaining: apr_off_t;
  646. { Number of bytes that have been read from the request body }
  647. read_length: apr_off_t;
  648. { Method for reading the request body
  649. * (eg. REQUEST_CHUNKED_ERROR, REQUEST_NO_BODY,
  650. * REQUEST_CHUNKED_DECHUNK, etc...) }
  651. read_body: Integer;
  652. { reading chunked transfer-coding }
  653. read_chunked: Integer;
  654. { is client waiting for a 100 response? }
  655. expecting_100: Cardinal;
  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' apr_table_t is for notes from one module to another, with no
  665. * other set purpose in mind...
  666. }
  667. { MIME header environment from the request }
  668. headers_in: Papr_table_t;
  669. { MIME header environment for the response }
  670. headers_out: Papr_table_t;
  671. { MIME header environment for the response, printed even on errors and
  672. * persist across internal redirects }
  673. err_headers_out: Papr_table_t;
  674. { Array of environment variables to be used for sub processes }
  675. subprocess_env: Papr_table_t;
  676. { Notes from one module to another }
  677. notes: Papr_table_t;
  678. { content_type, handler, content_encoding, and all content_languages
  679. * MUST be lowercased strings. They may be pointers to static strings;
  680. * they should not be modified in place.
  681. }
  682. { The content-type for the current request }
  683. content_type: PChar; // Break these out --- we dispatch on 'em
  684. { The handler string that we use to call a handler function }
  685. handler: PChar; // What we *really* dispatch on
  686. { How to encode the data }
  687. content_encoding: PChar;
  688. { Array of strings representing the content languages }
  689. content_languages: Papr_array_header_t;
  690. { variant list validator (if negotiated) }
  691. vlist_validator: PChar;
  692. { If an authentication check was made, this gets set to the user name. }
  693. user: PChar;
  694. { If an authentication check was made, this gets set to the auth type. }
  695. ap_auth_type: PChar;
  696. { This response can not be cached }
  697. no_cache: Integer;
  698. { There is no local copy of this response }
  699. no_local_copy: Integer;
  700. { What object is being requested (either directly, or via include
  701. * or content-negotiation mapping).
  702. }
  703. { The URI without any parsing performed }
  704. unparsed_uri: PChar;
  705. { The path portion of the URI }
  706. uri: PChar;
  707. { The filename on disk corresponding to this response }
  708. filename: PChar;
  709. { XXX: What does this mean? Please define "canonicalize" -aaron }
  710. { The true filename, we canonicalize r->filename if these don't match }
  711. canonical_filename: PChar;
  712. { The PATH_INFO extracted from this request }
  713. path_info: PChar;
  714. { The QUERY_ARGS extracted from this request }
  715. args: PChar;
  716. { finfo.protection (st_mode) set to zero if no such file }
  717. finfo: apr_finfo_t;
  718. { A struct containing the components of URI }
  719. parsed_uri: apr_uri_t;
  720. {
  721. * Flag for the handler to accept or reject path_info on
  722. * the current request. All modules should respect the
  723. * AP_REQ_ACCEPT_PATH_INFO and AP_REQ_REJECT_PATH_INFO
  724. * values, while AP_REQ_DEFAULT_PATH_INFO indicates they
  725. * may follow existing conventions. This is set to the
  726. * user's preference upon HOOK_VERY_FIRST of the fixups.
  727. }
  728. used_path_info: Integer;
  729. { Various other config info which may change with .htaccess files
  730. * These are config vectors, with one void* pointer for each module
  731. * (the thing pointed to being the module's business).
  732. }
  733. { Options set in config files, etc.}
  734. per_dir_config: Pap_conf_vector_t;
  735. { Notes on *this* request }
  736. request_config: Pap_conf_vector_t;
  737. {
  738. * A linked list of the .htaccess configuration directives
  739. * accessed by this request.
  740. * N.B. always add to the head of the list, _never_ to the end.
  741. * that way, a sub request's list can (temporarily) point to a parent's list
  742. }
  743. htaccess: Phtaccess_result;
  744. { A list of output filters to be used for this request }
  745. output_filters: Pap_filter_t;
  746. { A list of input filters to be used for this request }
  747. input_filters: Pap_filter_t;
  748. { A list of protocol level output filters to be used for this
  749. * request }
  750. proto_output_filters: Pap_filter_t;
  751. { A list of protocol level input filters to be used for this
  752. * request }
  753. proto_input_filters: Pap_filter_t;
  754. { A flag to determine if the eos bucket has been sent yet }
  755. eos_sent: Integer;
  756. { Things placed at the end of the record to avoid breaking binary
  757. * compatibility. It would be nice to remember to reorder the entire
  758. * record to improve 64bit alignment the next time we need to break
  759. * binary compatibility for some other reason.
  760. }
  761. end;
  762. {
  763. * @defgroup ProxyReq Proxy request types
  764. *
  765. * Possible values of request_rec->proxyreq. A request could be normal,
  766. * proxied or reverse proxied. Normally proxied and reverse proxied are
  767. * grouped together as just "proxied", but sometimes it's necessary to
  768. * tell the difference between the two, such as for authentication.
  769. }
  770. ap_conn_keepalive_e = (AP_CONN_UNKNOWN, AP_CONN_CLOSE, AP_CONN_KEEPALIVE);
  771. Pconn_state_t = ^conn_state_t;
  772. { Structure to store things which are per connection }
  773. conn_rec = record
  774. { Pool associated with this connection }
  775. pool: Papr_pool_t;
  776. { Physical vhost this conn came in on }
  777. base_server: Pserver_rec;
  778. { used by http_vhost.c }
  779. vhost_lookup_data: Pointer;
  780. { Information about the connection itself }
  781. { local address }
  782. local_addr: Papr_sockaddr_t;
  783. { remote address }
  784. remote_addr: Papr_sockaddr_t;
  785. { Client's IP address }
  786. remote_ip: PChar;
  787. { Client's DNS name, if known. NULL if DNS hasn't been checked,
  788. * "" if it has and no address was found. N.B. Only access this though
  789. * get_remote_host() }
  790. remote_host: PChar;
  791. { Only ever set if doing rfc1413 lookups. N.B. Only access this through
  792. * get_remote_logname() }
  793. remote_logname: PChar;
  794. {** Are we still talking? *}
  795. //unsigned aborted:1;
  796. flags1: Cardinal;
  797. {** Are we going to keep the connection alive for another request?
  798. * @see ap_conn_keepalive_e *}
  799. //ap_conn_keepalive_e keepalive;
  800. keepalive: ap_conn_keepalive_e;
  801. {** have we done double-reverse DNS? -1 yes/failure, 0 not yet,
  802. * 1 yes/success *}
  803. //signed int double_reverse:2;
  804. flags2: Cardinal;
  805. { How many times have we used it? }
  806. keepalives: Integer;
  807. { server IP address }
  808. local_ip: PChar;
  809. { used for ap_get_server_name when UseCanonicalName is set to DNS
  810. * (ignores setting of HostnameLookups) }
  811. local_host: PChar;
  812. { ID of this connection; unique at any point in time }
  813. id: clong;
  814. { Config vector containing pointers to connections per-server
  815. * config structures. }
  816. conn_config: Pap_conf_vector_t;
  817. { Notes on *this* connection: send note from one module to
  818. * another. must remain valid for all requests on this conn }
  819. notes: Papr_table_t;
  820. { A list of input filters to be used for this connection }
  821. input_filters: Pap_filter_t;
  822. { A list of output filters to be used for this connection }
  823. output_filters: Pap_filter_t;
  824. { handle to scoreboard information for this connection }
  825. sbh: Pointer;
  826. { The bucket allocator to use for all bucket/brigade creations }
  827. bucket_alloc: Papr_bucket_alloc_t;
  828. { The current state of this connection }
  829. cs: Pconn_state_t;
  830. { Is there data pending in the input filters? }
  831. data_in_input_filters: cint;
  832. {** Are there any filters that clogg/buffer the input stream, breaking
  833. * the event mpm.
  834. *}//added in Apache 2.2.7
  835. clogging_input_filters: cint;
  836. end;
  837. {
  838. * Enumeration of connection states
  839. }
  840. conn_state_e = (
  841. CONN_STATE_CHECK_REQUEST_LINE_READABLE,
  842. CONN_STATE_READ_REQUEST_LINE,
  843. CONN_STATE_LINGER
  844. );
  845. {
  846. * @brief A structure to contain connection state information
  847. }
  848. APR_RING_ENTRY_conn_state_t = record
  849. next: Pconn_state_t;
  850. prev: Pconn_state_t;
  851. end;
  852. conn_state_t = record
  853. { APR_RING of expiration timeouts }
  854. timeout_list: APR_RING_ENTRY_conn_state_t;
  855. { the expiration time of the next keepalive timeout }
  856. expiration_time: apr_time_t;
  857. { Current state of the connection }
  858. state: conn_state_e;
  859. { connection record this struct refers to }
  860. c: Pconn_rec;
  861. { memory pool to allocate from }
  862. p: Papr_pool_t;
  863. { bucket allocator }
  864. bucket_alloc: Papr_bucket_alloc_t;
  865. { poll file decriptor information }
  866. pfd: apr_pollfd_t;
  867. end;
  868. { Per-vhost config... }
  869. { A structure to be used for Per-vhost config }
  870. server_addr_rec = record
  871. { The next server in the list }
  872. next: Pserver_addr_rec;
  873. { The bound address, for this server }
  874. host_addr: Papr_sockaddr_t;
  875. { The bound port, for this server }
  876. host_port: apr_port_t;
  877. { The name given in <VirtualHost> }
  878. virthost: PChar;
  879. end;
  880. { A structure to store information for each virtual server }
  881. server_rec = record
  882. { The process this server is running in }
  883. process: Pprocess_rec;
  884. { The next server in the list }
  885. next: Pserver_rec;
  886. { The name of the server }
  887. defn_name: PChar;
  888. { The line of the config file that the server was defined on }
  889. defn_line_number: Cardinal;
  890. { Contact information }
  891. { The admin's contact information }
  892. server_admin: PChar;
  893. { The server hostname }
  894. server_hostname: PChar;
  895. { for redirects, etc. }
  896. port: apr_port_t;
  897. { Log files --- note that transfer log is now in the modules... }
  898. { The name of the error log }
  899. error_fname: PChar;
  900. { A file descriptor that references the error log }
  901. error_log: Papr_file_t;
  902. { The log level for this server }
  903. loglevel: Integer;
  904. { Module-specific configuration for server, and defaults... }
  905. { true if this is the virtual server }
  906. is_virtual: Integer;
  907. { Config vector containing pointers to modules' per-server config
  908. * structures. }
  909. module_config: Pap_conf_vector_t;
  910. { MIME type info, etc., before we start checking per-directory info }
  911. lookup_defaults: Pap_conf_vector_t;
  912. { Transaction handling }
  913. { I haven't got a clue }
  914. addrs: Pserver_addr_rec;
  915. { Timeout, as an apr interval, before we give up }
  916. timeout: apr_interval_time_t;
  917. { The apr interval we will wait for another request }
  918. keep_alive_timeout: apr_interval_time_t;
  919. { Maximum requests per connection }
  920. keep_alive_max: Integer;
  921. { Use persistent connections? }
  922. keep_alive: Integer;
  923. { Pathname for ServerPath }
  924. path: PChar;
  925. { Length of path }
  926. pathlen: Integer;
  927. { Normal names for ServerAlias servers }
  928. names: Papr_array_header_t;
  929. { Wildcarded names for ServerAlias servers }
  930. wild_names: Papr_array_header_t;
  931. { limit on size of the HTTP request line }
  932. limit_req_line: Integer;
  933. { limit on size of any request header field }
  934. limit_req_fieldsize: Integer;
  935. { limit on number of request header fields }
  936. limit_req_fields: Integer;
  937. { The server request scheme for redirect responses }
  938. server_scheme: PChar;
  939. end;
  940. type
  941. core_output_filter_ctx = record
  942. b: Papr_bucket_brigade;
  943. deferred_write_pool: Papr_pool_t; { subpool of c->pool used for resources
  944. * which may outlive the request }
  945. end;
  946. core_filter_ctx = record
  947. b: Papr_bucket_brigade;
  948. tmpbb: Papr_bucket_brigade;
  949. end; // core_ctx_t
  950. core_ctx_t = core_filter_ctx;
  951. Pcore_ctx_t = ^core_ctx_t;
  952. type
  953. core_net_rec = record
  954. { Connection to the client }
  955. client_socket: Papr_socket_t;
  956. { connection record }
  957. c: Pconn_rec;
  958. out_ctx: Pcore_output_filter_ctx_t;
  959. in_ctx: Pcore_ctx_t;
  960. end; // core_net_rec;
  961. Pcore_net_rec = ^core_net_rec;
  962. {
  963. The constants are on the bottom because the structures need to be on the same type block
  964. }
  965. const
  966. PROXYREQ_NONE = 0; {< No proxy }
  967. PROXYREQ_PROXY = 1; {< Standard proxy }
  968. PROXYREQ_REVERSE = 2; {< Reverse proxy }
  969. PROXYREQ_RESPONSE = 3; {< Origin response }
  970. {
  971. * The address 255.255.255.255, when used as a virtualhost address,
  972. * will become the "default" server when the ip doesn't match other vhosts.
  973. }
  974. const DEFAULT_VHOST_ADDR = $ffffffff;//ul
  975. {
  976. * Examine a field value (such as a media-/content-type) string and return
  977. * it sans any parameters; e.g., strip off any ';charset=foo' and the like.
  978. * @param p Pool to allocate memory from
  979. * @param intype The field to examine
  980. * @return A copy of the field minus any parameters
  981. }
  982. function ap_field_noparam(p: Papr_pool_t; const intype: PChar): PChar;
  983. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  984. external LibHTTPD name LibNamePrefix + 'ap_field_noparam' + LibSuff8;
  985. {
  986. * Convert a time from an integer into a string in a specified format
  987. * @param p The pool to allocate memory from
  988. * @param t The time to convert
  989. * @param fmt The format to use for the conversion
  990. * @param gmt Convert the time for GMT?
  991. * @return The string that represents the specified time
  992. }
  993. function ap_ht_time(p: Papr_pool_t; t: apr_time_t; const fmt: PChar; gmt: Integer): PChar;
  994. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  995. external LibHTTPD name LibNamePrefix + 'ap_ht_time' + LibSuff20;
  996. { String handling. The *_nc variants allow you to use non-const char **s as
  997. arguments (unfortunately C won't automatically convert a char ** to a const
  998. char **) }
  999. {
  1000. * Get the characters until the first occurance of a specified character
  1001. * @param p The pool to allocate memory from
  1002. * @param line The string to get the characters from
  1003. * @param stop The character to stop at
  1004. * @return A copy of the characters up to the first stop character
  1005. }
  1006. function ap_getword(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
  1007. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1008. external LibHTTPD name LibNamePrefix + 'ap_getword' + LibSuff12;
  1009. {
  1010. * Get the characters until the first occurance of a specified character
  1011. * @param p The pool to allocate memory from
  1012. * @param line The string to get the characters from
  1013. * @param stop The character to stop at
  1014. * @return A copy of the characters up to the first stop character
  1015. * @note This is the same as ap_getword(), except it doesn't use const char **.
  1016. }
  1017. function ap_getword_nc(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
  1018. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1019. external LibHTTPD name LibNamePrefix + 'ap_getword_nc' + LibSuff12;
  1020. {
  1021. * Get the first word from a given string. A word is defined as all characters
  1022. * up to the first whitespace.
  1023. * @param p The pool to allocate memory from
  1024. * @param line The string to traverse
  1025. * @return The first word in the line
  1026. }
  1027. function ap_getword_white(p: Papr_pool_t; const line: PPChar): PChar;
  1028. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1029. external LibHTTPD name LibNamePrefix + 'ap_getword_white' + LibSuff8;
  1030. {
  1031. * Get the first word from a given string. A word is defined as all characters
  1032. * up to the first whitespace.
  1033. * @param p The pool to allocate memory from
  1034. * @param line The string to traverse
  1035. * @return The first word in the line
  1036. * @note The same as ap_getword_white(), except it doesn't use const char **.
  1037. }
  1038. function ap_getword_white_nc(p: Papr_pool_t; const line: PPChar): PChar;
  1039. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1040. external LibHTTPD name LibNamePrefix + 'ap_getword_white_nc' + LibSuff8;
  1041. {
  1042. * Get all characters from the first occurance of @a stop to the first '\0'
  1043. * @param p The pool to allocate memory from
  1044. * @param line The line to traverse
  1045. * @param stop The character to start at
  1046. * @return A copy of all caracters after the first occurance of the specified
  1047. * character
  1048. }
  1049. function ap_getword_nulls(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
  1050. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1051. external LibHTTPD name LibNamePrefix + 'ap_getword_nulls' + LibSuff12;
  1052. {
  1053. * Get all characters from the first occurance of @a stop to the first '\0'
  1054. * @param p The pool to allocate memory from
  1055. * @param line The line to traverse
  1056. * @param stop The character to start at
  1057. * @return A copy of all caracters after the first occurance of the specified
  1058. * character
  1059. * @note The same as ap_getword_nulls(), except it doesn't use const char **.
  1060. }
  1061. function ap_getword_nulls_nc(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
  1062. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1063. external LibHTTPD name LibNamePrefix + 'ap_getword_nulls_nc' + LibSuff12;
  1064. {
  1065. * Get the second word in the string paying attention to quoting
  1066. * @param p The pool to allocate from
  1067. * @param line The line to traverse
  1068. * @return A copy of the string
  1069. }
  1070. function ap_getword_conf(p: Papr_pool_t; const line: PPChar): PChar;
  1071. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1072. external LibHTTPD name LibNamePrefix + 'ap_getword_conf' + LibSuff8;
  1073. {
  1074. * Get the second word in the string paying attention to quoting
  1075. * @param p The pool to allocate from
  1076. * @param line The line to traverse
  1077. * @return A copy of the string
  1078. * @note The same as ap_getword_conf(), except it doesn't use const char **.
  1079. }
  1080. function ap_getword_conf_nc(p: Papr_pool_t; const line: PPChar): PChar;
  1081. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1082. external LibHTTPD name LibNamePrefix + 'ap_getword_conf_nc' + LibSuff8;
  1083. {
  1084. * Check a string for any $ENV environment variable construct and replace
  1085. * each them by the value of that environment variable, if it exists. If the
  1086. * environment value does not exist, leave the $ENV construct alone; it
  1087. * means something else.
  1088. * @param p The pool to allocate from
  1089. * @param word The string to check
  1090. * @return The string with the replaced environment variables
  1091. }
  1092. function ap_resolve_env(p: Papr_pool_t; const word_: PChar; accept_white: Integer): PChar;
  1093. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1094. external LibHTTPD name LibNamePrefix + 'ap_resolve_env' + LibSuff8;
  1095. {
  1096. * Size an HTTP header field list item, as separated by a comma.
  1097. * @param field The field to size
  1098. * @param len The length of the field
  1099. * @return The return value is a pointer to the beginning of the non-empty
  1100. * list item within the original string (or NULL if there is none) and the
  1101. * address of field is shifted to the next non-comma, non-whitespace
  1102. * character. len is the length of the item excluding any beginning whitespace.
  1103. }
  1104. function ap_size_list_item(const field: PPChar; len: Integer): PChar;
  1105. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1106. external LibHTTPD name LibNamePrefix + 'ap_size_list_item' + LibSuff8;
  1107. {
  1108. * Retrieve an HTTP header field list item, as separated by a comma,
  1109. * while stripping insignificant whitespace and lowercasing anything not in
  1110. * a quoted string or comment.
  1111. * @param p The pool to allocate from
  1112. * @param field The field to retrieve
  1113. * @return The return value is a new string containing the converted list
  1114. * item (or NULL if none) and the address pointed to by field is
  1115. * shifted to the next non-comma, non-whitespace.
  1116. }
  1117. function ap_get_list_item(p: Papr_pool_t; const field: PPChar): PChar;
  1118. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1119. external LibHTTPD name LibNamePrefix + 'ap_get_list_item' + LibSuff8;
  1120. {
  1121. * Find an item in canonical form (lowercase, no extra spaces) within
  1122. * an HTTP field value list.
  1123. * @param p The pool to allocate from
  1124. * @param line The field value list to search
  1125. * @param tok The token to search for
  1126. * @return 1 if found, 0 if not found.
  1127. }
  1128. function ap_find_list_item(p: Papr_pool_t; const line, tok: PChar): Integer;
  1129. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1130. external LibHTTPD name LibNamePrefix + 'ap_find_list_item' + LibSuff12;
  1131. {
  1132. * Retrieve a token, spacing over it and returning a pointer to
  1133. * the first non-white byte afterwards. Note that these tokens
  1134. * are delimited by semis and commas and can also be delimited
  1135. * by whitespace at the caller's option.
  1136. * @param p The pool to allocate from
  1137. * @param accept_line The line to retrieve the token from
  1138. * @param accept_white Is it delimited by whitespace
  1139. * @return the first non-white byte after the token
  1140. }
  1141. function ap_get_token(p: Papr_pool_t; const accept_line: PPChar; accept_white: Integer): PChar;
  1142. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1143. external LibHTTPD name LibNamePrefix + 'ap_get_token' + LibSuff12;
  1144. {
  1145. * Find http tokens, see the definition of token from RFC2068
  1146. * @param p The pool to allocate from
  1147. * @param line The line to find the token
  1148. * @param tok The token to find
  1149. * @return 1 if the token is found, 0 otherwise
  1150. }
  1151. function ap_find_token(p: Papr_pool_t; const line, tok: PChar): Integer;
  1152. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1153. external LibHTTPD name LibNamePrefix + 'ap_find_token' + LibSuff12;
  1154. {
  1155. * find http tokens from the end of the line
  1156. * @param p The pool to allocate from
  1157. * @param line The line to find the token
  1158. * @param tok The token to find
  1159. * @return 1 if the token is found, 0 otherwise
  1160. }
  1161. function ap_find_last_token(p: Papr_pool_t; const line, tok: PChar): Integer;
  1162. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1163. external LibHTTPD name LibNamePrefix + 'ap_find_last_token' + LibSuff12;
  1164. {
  1165. * Check for an Absolute URI syntax
  1166. * @param u The string to check
  1167. * @return 1 if URI, 0 otherwise
  1168. }
  1169. function ap_is_url(const u: PChar): Integer;
  1170. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1171. external LibHTTPD name LibNamePrefix + 'ap_is_url' + LibSuff4;
  1172. {
  1173. * Unescape a URL
  1174. * @param url The url to unescape
  1175. * @return 0 on success, non-zero otherwise
  1176. }
  1177. function ap_unescape_url(url: PChar): Integer;
  1178. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1179. external LibHTTPD name LibNamePrefix + 'ap_unescape_url' + LibSuff4;
  1180. {
  1181. * Unescape a URL, but leaving %2f (slashes) escaped
  1182. * @param url The url to unescape
  1183. * @return 0 on success, non-zero otherwise
  1184. }
  1185. function ap_unescape_url_keep2f(url: PChar): Integer;
  1186. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1187. external LibHTTPD name LibNamePrefix + 'ap_unescape_url_keep2f' + LibSuff4;
  1188. {
  1189. * Convert all double slashes to single slashes
  1190. * @param name The string to convert
  1191. }
  1192. procedure ap_no2slash(name: PChar);
  1193. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1194. external LibHTTPD name LibNamePrefix + 'ap_no2slash' + LibSuff4;
  1195. {
  1196. * Remove all ./ and xx/../ substrings from a file name. Also remove
  1197. * any leading ../ or /../ substrings.
  1198. * @param name the file name to parse
  1199. }
  1200. procedure ap_getparents(name: PChar);
  1201. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1202. external LibHTTPD name LibNamePrefix + 'ap_getparents' + LibSuff4;
  1203. {
  1204. * Escape a path segment, as defined in RFC 1808
  1205. * @param p The pool to allocate from
  1206. * @param s The path to convert
  1207. * @return The converted URL
  1208. }
  1209. function ap_escape_path_segment(p: Papr_pool_t; const s: PChar): PChar;
  1210. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1211. external LibHTTPD name LibNamePrefix + 'ap_escape_path_segment' + LibSuff8;
  1212. {
  1213. * convert an OS path to a URL in an OS dependant way.
  1214. * @param p The pool to allocate from
  1215. * @param path The path to convert
  1216. * @param partial if set, assume that the path will be appended to something
  1217. * with a '/' in it (and thus does not prefix "./")
  1218. * @return The converted URL
  1219. }
  1220. function ap_os_escape_path(p: Papr_pool_t; const path: PChar; partial: Integer): PChar;
  1221. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1222. external LibHTTPD name LibNamePrefix + 'ap_os_escape_path' + LibSuff12;
  1223. { @see ap_os_escape_path }
  1224. function ap_escape_uri(p: Papr_pool_t; const path: PChar): PChar;
  1225. {
  1226. * Escape an html string
  1227. * @param p The pool to allocate from
  1228. * @param s The html to escape
  1229. * @return The escaped string
  1230. }
  1231. function ap_escape_html(p: Papr_pool_t; const s: PChar): PChar;
  1232. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1233. external LibHTTPD name LibNamePrefix + 'ap_escape_html' + LibSuff8;
  1234. {
  1235. * Escape a string for logging
  1236. * @param p The pool to allocate from
  1237. * @param str The string to escape
  1238. * @return The escaped string
  1239. }
  1240. function ap_escape_logitem(p: Papr_pool_t; const str: PChar): PChar;
  1241. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1242. external LibHTTPD name LibNamePrefix + 'ap_escape_logitem' + LibSuff8;
  1243. {
  1244. * Escape a string for logging into the error log (without a pool)
  1245. * @param dest The buffer to write to
  1246. * @param source The string to escape
  1247. * @param buflen The buffer size for the escaped string (including \0)
  1248. * @return The len of the escaped string (always < maxlen)
  1249. }
  1250. function ap_escape_errorlog_item(dest, source: PChar;
  1251. buflen: apr_size_t): apr_size_t;
  1252. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1253. external LibHTTPD name LibNamePrefix + 'ap_escape_errorlog_item' + LibSuff12;
  1254. {
  1255. * Construct a full hostname
  1256. * @param p The pool to allocate from
  1257. * @param hostname The hostname of the server
  1258. * @param port The port the server is running on
  1259. * @param r The current request
  1260. * @return The server's hostname
  1261. }
  1262. function ap_construct_server(p: Papr_pool_t; const hostname: PChar;
  1263. port: Papr_port_t; const r: Prequest_rec): PChar;
  1264. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1265. external LibHTTPD name LibNamePrefix + 'ap_construct_server' + LibSuff16;
  1266. {
  1267. * Escape a shell command
  1268. * @param p The pool to allocate from
  1269. * @param s The command to escape
  1270. * @return The escaped shell command
  1271. }
  1272. function ap_escape_shell_cmd(p: Papr_pool_t; const s: PChar): PChar;
  1273. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1274. external LibHTTPD name LibNamePrefix + 'ap_escape_shell_cmd' + LibSuff8;
  1275. {
  1276. * Count the number of directories in a path
  1277. * @param path The path to count
  1278. * @return The number of directories
  1279. }
  1280. function ap_count_dirs(const path: PChar): Integer;
  1281. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1282. external LibHTTPD name LibNamePrefix + 'ap_count_dirs' + LibSuff4;
  1283. {
  1284. * Copy at most @a n leading directories of @a s into @a d. @a d
  1285. * should be at least as large as @a s plus 1 extra byte
  1286. *
  1287. * @param d The location to copy to
  1288. * @param s The location to copy from
  1289. * @param n The number of directories to copy
  1290. * @return value is the ever useful pointer to the trailing \0 of d
  1291. * @note on platforms with drive letters, n = 0 returns the "/" root,
  1292. * whereas n = 1 returns the "d:/" root. On all other platforms, n = 0
  1293. * returns the empty string. }
  1294. function ap_make_dirstr_prefix(const d, s: PChar; n: Integer): PChar;
  1295. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1296. external LibHTTPD name LibNamePrefix + 'ap_make_dirstr_prefix' + LibSuff12;
  1297. {
  1298. * Return the parent directory name (including trailing /) of the file
  1299. * @a s
  1300. * @param p The pool to allocate from
  1301. * @param s The file to get the parent of
  1302. * @return A copy of the file's parent directory
  1303. }
  1304. function ap_make_dirstr_parent(p: Papr_pool_t; const s: PChar): PChar;
  1305. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1306. external LibHTTPD name LibNamePrefix + 'ap_make_dirstr_parent' + LibSuff8;
  1307. {
  1308. * Given a directory and filename, create a single path from them. This
  1309. * function is smart enough to ensure that there is a sinlge '/' between the
  1310. * directory and file names
  1311. * @param a The pool to allocate from
  1312. * @param dir The directory name
  1313. * @param f The filename
  1314. * @return A copy of the full path
  1315. * @tip Never consider using this function if you are dealing with filesystem
  1316. * names that need to remain canonical, unless you are merging an apr_dir_read
  1317. * path and returned filename. Otherwise, the result is not canonical.
  1318. }
  1319. function ap_make_full_path(a: Papr_pool_t; const dir, f: PChar): PChar;
  1320. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1321. external LibHTTPD name LibNamePrefix + 'ap_make_full_path' + LibSuff12;
  1322. {
  1323. * Test if the given path has an an absolute path.
  1324. * @param p The pool to allocate from
  1325. * @param dir The directory name
  1326. * @tip The converse is not necessarily true, some OS's (Win32/OS2/Netware) have
  1327. * multiple forms of absolute paths. This only reports if the path is absolute
  1328. * in a canonical sense.
  1329. }
  1330. function ap_os_is_path_absolute(p: Papr_pool_t; const dir: PChar): Integer;
  1331. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1332. external LibHTTPD name LibNamePrefix + 'ap_os_is_path_absolute' + LibSuff8;
  1333. {
  1334. * Does the provided string contain wildcard characters? This is useful
  1335. * for determining if the string should be passed to strcmp_match or to strcmp.
  1336. * The only wildcard characters recognized are '?' and '*'
  1337. * @param str The string to check
  1338. * @return 1 if the string has wildcards, 0 otherwise
  1339. }
  1340. function ap_is_matchexp(const str: PChar): Integer;
  1341. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1342. external LibHTTPD name LibNamePrefix + 'ap_is_matchexp' + LibSuff4;
  1343. {
  1344. * Determine if a string matches a patterm containing the wildcards '?' or '*'
  1345. * @param str The string to check
  1346. * @param expected The pattern to match against
  1347. * @return 1 if the two strings match, 0 otherwise
  1348. }
  1349. function ap_strcmp_match(const str, expected: PChar): Integer;
  1350. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1351. external LibHTTPD name LibNamePrefix + 'ap_strcmp_match' + LibSuff8;
  1352. {
  1353. * Determine if a string matches a patterm containing the wildcards '?' or '*',
  1354. * ignoring case
  1355. * @param str The string to check
  1356. * @param expected The pattern to match against
  1357. * @return 1 if the two strings match, 0 otherwise
  1358. }
  1359. function ap_strcasecmp_match(const str, expected: PChar): Integer;
  1360. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1361. external LibHTTPD name LibNamePrefix + 'ap_strcasecmp_match' + LibSuff8;
  1362. {
  1363. * Find the first occurrence of the substring s2 in s1, regardless of case
  1364. * @param s1 The string to search
  1365. * @param s2 The substring to search for
  1366. * @return A pointer to the beginning of the substring
  1367. * @remark See apr_strmatch() for a faster alternative
  1368. }
  1369. function ap_strcasestr(const s1, s2: PChar): PChar;
  1370. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1371. external LibHTTPD name LibNamePrefix + 'ap_strcasestr' + LibSuff8;
  1372. {
  1373. * Return a pointer to the location inside of bigstring immediately after prefix
  1374. * @param bigstring The input string
  1375. * @param prefix The prefix to strip away
  1376. * @return A pointer relative to bigstring after prefix
  1377. }
  1378. function ap_stripprefix(const bigstring, prefix: PChar): PChar;
  1379. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1380. external LibHTTPD name LibNamePrefix + 'ap_stripprefix' + LibSuff8;
  1381. {
  1382. * Decode a base64 encoded string into memory allocated from a pool
  1383. * @param p The pool to allocate from
  1384. * @param bufcoded The encoded string
  1385. * @return The decoded string
  1386. }
  1387. function ap_pbase64decode(p: Papr_pool_t; const bufcoded: PChar): PChar;
  1388. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1389. external LibHTTPD name LibNamePrefix + 'ap_pbase64decode' + LibSuff8;
  1390. {
  1391. * Encode a string into memory allocated from a pool in base 64 format
  1392. * @param p The pool to allocate from
  1393. * @param strin The plaintext string
  1394. * @return The encoded string
  1395. }
  1396. function ap_pbase64encode(p: Papr_pool_t; string_: PChar): PChar;
  1397. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1398. external LibHTTPD name LibNamePrefix + 'ap_pbase64encode' + LibSuff8;
  1399. {
  1400. * Compile a regular expression to be used later
  1401. * @param p The pool to allocate from
  1402. * @param pattern the regular expression to compile
  1403. * @param cflags The bitwise or of one or more of the following:
  1404. * @li #REG_EXTENDED - Use POSIX extended Regular Expressions
  1405. * @li #REG_ICASE - Ignore case
  1406. * @li #REG_NOSUB - Support for substring addressing of matches
  1407. * not required
  1408. * @li #REG_NEWLINE - Match-any-character operators don't match new-line
  1409. * @return The compiled regular expression
  1410. }
  1411. function ap_pregcomp(p: Papr_pool_t; const pattern: PChar; cflags: Integer): Pap_regex_t;
  1412. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1413. external LibHTTPD name LibNamePrefix + 'ap_pregcomp' + LibSuff12;
  1414. {
  1415. * Free the memory associated with a compiled regular expression
  1416. * @param p The pool the regex was allocated from
  1417. * @param reg The regular expression to free
  1418. }
  1419. procedure ap_pregfree(p: Papr_pool_t; reg: Pap_regex_t);
  1420. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1421. external LibHTTPD name LibNamePrefix + 'ap_pregfree' + LibSuff8;
  1422. {
  1423. * After performing a successful regex match, you may use this function to
  1424. * perform a series of string substitutions based on subexpressions that were
  1425. * matched during the call to ap_regexec
  1426. * @param p The pool to allocate from
  1427. * @param input An arbitrary string containing $1 through $9. These are
  1428. * replaced with the corresponding matched sub-expressions
  1429. * @param source The string that was originally matched to the regex
  1430. * @param nmatch the nmatch returned from ap_pregex
  1431. * @param pmatch the pmatch array returned from ap_pregex
  1432. }
  1433. function ap_pregsub(p: Papr_pool_t; const input, source: PChar;
  1434. nmatch: size_t; pmatch: array of ap_regmatch_t): PChar;
  1435. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1436. external LibHTTPD name LibNamePrefix + 'ap_pregsub' + LibSuff20;
  1437. {
  1438. * We want to downcase the type/subtype for comparison purposes
  1439. * but nothing else because ;parameter=foo values are case sensitive.
  1440. * @param s The content-type to convert to lowercase
  1441. }
  1442. procedure ap_content_type_tolower(s: PChar);
  1443. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1444. external LibHTTPD name LibNamePrefix + 'ap_content_type_tolower' + LibSuff4;
  1445. {
  1446. * convert a string to all lowercase
  1447. * @param s The string to convert to lowercase
  1448. }
  1449. procedure ap_str_tolower(s: PChar);
  1450. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1451. external LibHTTPD name LibNamePrefix + 'ap_str_tolower' + LibSuff4;
  1452. {
  1453. * Search a string from left to right for the first occurrence of a
  1454. * specific character
  1455. * @param str The string to search
  1456. * @param c The character to search for
  1457. * @return The index of the first occurrence of c in str
  1458. }
  1459. function ap_ind(str: PChar; c: Char): Integer;
  1460. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1461. external LibHTTPD name LibNamePrefix + 'ap_ind' + LibSuff8;
  1462. {
  1463. * Search a string from right to left for the first occurrence of a
  1464. * specific character
  1465. * @param str The string to search
  1466. * @param c The character to search for
  1467. * @return The index of the first occurrence of c in str
  1468. }
  1469. function ap_rind(str: PChar; c: Char): Integer;
  1470. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1471. external LibHTTPD name LibNamePrefix + 'ap_rind' + LibSuff8;
  1472. {
  1473. * Given a string, replace any bare " with \" .
  1474. * @param p The pool to allocate memory from
  1475. * @param instring The string to search for "
  1476. * @return A copy of the string with escaped quotes
  1477. }
  1478. function ap_escape_quotes(p: Papr_pool_t; const instring: PChar): PChar;
  1479. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1480. external LibHTTPD name LibNamePrefix + 'ap_escape_quotes' + LibSuff8;
  1481. {
  1482. * Given a string, append the PID deliminated by delim.
  1483. * Usually used to create a pid-appended filepath name
  1484. * (eg: /a/b/foo -> /a/b/foo.6726). A function, and not
  1485. * a macro, to avoid unistd.h dependency
  1486. * @param p The pool to allocate memory from
  1487. * @param string The string to append the PID to
  1488. * @param delim The string to use to deliminate the string from the PID
  1489. * @return A copy of the string with the PID appended
  1490. }
  1491. function ap_append_pid(p: Papr_pool_t; const string_, delim: PChar): PChar;
  1492. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1493. external LibHTTPD name LibNamePrefix + 'ap_append_pid' + LibSuff12;
  1494. { Misc system hackery }
  1495. {
  1496. * Given the name of an object in the file system determine if it is a directory
  1497. * @param p The pool to allocate from
  1498. * @param name The name of the object to check
  1499. * @return 1 if it is a directory, 0 otherwise
  1500. }
  1501. function ap_is_rdirectory(p: Papr_pool_t; const name: PChar): Integer;
  1502. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1503. external LibHTTPD name LibNamePrefix + 'ap_is_rdirectory' + LibSuff8;
  1504. {
  1505. * Given the name of an object in the file system determine if it is a directory - this version is symlink aware
  1506. * @param p The pool to allocate from
  1507. * @param name The name of the object to check
  1508. * @return 1 if it is a directory, 0 otherwise
  1509. }
  1510. function ap_is_directory(p: Papr_pool_t; const name: PChar): Integer;
  1511. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1512. external LibHTTPD name LibNamePrefix + 'ap_is_directory' + LibSuff8;
  1513. {#ifdef _OSD_POSIX
  1514. extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
  1515. #endif} { _OSD_POSIX }
  1516. {
  1517. * Determine the local host name for the current machine
  1518. * @param p The pool to allocate from
  1519. * @return A copy of the local host name
  1520. }
  1521. //char *ap_get_local_host(apr_pool_t *p);
  1522. {
  1523. * Log an assertion to the error log
  1524. * @param szExp The assertion that failed
  1525. * @param szFile The file the assertion is in
  1526. * @param nLine The line the assertion is defined on
  1527. }
  1528. procedure ap_log_assert(szExp, szFile: PChar; nLine: Integer);
  1529. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1530. external LibHTTPD name LibNamePrefix + 'ap_log_assert' + LibSuff12;
  1531. { @internal }
  1532. //#define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
  1533. {
  1534. * Redefine assert() to something more useful for an Apache...
  1535. *
  1536. * Use ap_assert() if the condition should always be checked.
  1537. * Use AP_DEBUG_ASSERT() if the condition should only be checked when AP_DEBUG
  1538. * is defined.
  1539. }
  1540. {#ifdef AP_DEBUG
  1541. #define AP_DEBUG_ASSERT(exp) ap_assert(exp)
  1542. #else
  1543. #define AP_DEBUG_ASSERT(exp) ((void)0)
  1544. #endif}
  1545. {
  1546. * @defgroup stopsignal flags which indicate places where the sever should stop for debugging.
  1547. * @
  1548. * A set of flags which indicate places where the server should raise(SIGSTOP).
  1549. * This is useful for debugging, because you can then attach to that process
  1550. * with gdb and continue. This is important in cases where one_process
  1551. * debugging isn't possible.
  1552. }
  1553. { stop on a Detach }
  1554. // SIGSTOP_DETACH = 1;
  1555. { stop making a child process }
  1556. // SIGSTOP_MAKE_CHILD = 2;
  1557. { stop spawning a child process }
  1558. // SIGSTOP_SPAWN_CHILD = 4;
  1559. { stop spawning a child process with a piped log }
  1560. // SIGSTOP_PIPED_LOG_SPAWN = 8;
  1561. { stop spawning a CGI child process }
  1562. // SIGSTOP_CGI_CHILD = 16;
  1563. { Macro to get GDB started }
  1564. {#ifdef DEBUG_SIGSTOP
  1565. extern int raise_sigstop_flags;
  1566. #define RAISE_SIGSTOP(x) do begin
  1567. if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
  1568. end while (0)
  1569. #else
  1570. #define RAISE_SIGSTOP(x)
  1571. #endif }
  1572. {
  1573. * Get HTML describing the address and (optionally) admin of the server.
  1574. * @param prefix Text which is prepended to the return value
  1575. * @param r The request_rec
  1576. * @return HTML describing the server, allocated in @a r's pool.
  1577. }
  1578. function ap_psignature(prefix: PChar; r: Prequest_rec): PChar;
  1579. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1580. external LibHTTPD name LibNamePrefix + 'ap_psignature' + LibSuff8;
  1581. {const
  1582. AP_NORESTART = APR_OS_START_USEERR + 1;}