httpd.inc 61 KB

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