2
0

httpd.inc 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783
  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
  273. * @return The server version string
  274. }
  275. function ap_get_server_version: PChar;
  276. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  277. external LibHTTPD name LibNamePrefix + 'ap_get_server_version' + LibSuff0;
  278. {
  279. * Add a component to the version string
  280. * @param pconf The pool to allocate the component from
  281. * @param component The string to add
  282. }
  283. procedure ap_add_version_component(pconf: Papr_pool_t; const component: PChar);
  284. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  285. external LibHTTPD name LibNamePrefix + 'ap_add_version_component' + LibSuff8;
  286. {
  287. * Get the date a time that the server was built
  288. * @return The server build time string
  289. }
  290. function ap_get_server_built: PChar;
  291. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  292. external LibHTTPD name LibNamePrefix + 'ap_get_server_built' + LibSuff0;
  293. const
  294. DECLINED = -1; {< Module declines to handle }
  295. DONE = -2; {< Module has served the response completely
  296. * - it's safe to die() with no more output
  297. }
  298. OK = 0; {< Module has handled this stage. }
  299. {
  300. * @defgroup HTTP_Status HTTP Status Codes
  301. * @
  302. * The size of the static array in http_protocol.c for storing
  303. * all of the potential response status-lines (a sparse table).
  304. * A future version should dynamically generate the apr_table_t at startup.
  305. }
  306. RESPONSE_CODES = 57;
  307. HTTP_CONTINUE = 100;
  308. HTTP_SWITCHING_PROTOCOLS = 101;
  309. HTTP_PROCESSING = 102;
  310. HTTP_OK = 200;
  311. HTTP_CREATED = 201;
  312. HTTP_ACCEPTED = 202;
  313. HTTP_NON_AUTHORITATIVE = 203;
  314. HTTP_NO_CONTENT = 204;
  315. HTTP_RESET_CONTENT = 205;
  316. HTTP_PARTIAL_CONTENT = 206;
  317. HTTP_MULTI_STATUS = 207;
  318. HTTP_MULTIPLE_CHOICES = 300;
  319. HTTP_MOVED_PERMANENTLY = 301;
  320. HTTP_MOVED_TEMPORARILY = 302;
  321. HTTP_SEE_OTHER = 303;
  322. HTTP_NOT_MODIFIED = 304;
  323. HTTP_USE_PROXY = 305;
  324. HTTP_TEMPORARY_REDIRECT = 307;
  325. HTTP_BAD_REQUEST = 400;
  326. HTTP_UNAUTHORIZED = 401;
  327. HTTP_PAYMENT_REQUIRED = 402;
  328. HTTP_FORBIDDEN = 403;
  329. HTTP_NOT_FOUND = 404;
  330. HTTP_METHOD_NOT_ALLOWED = 405;
  331. HTTP_NOT_ACCEPTABLE = 406;
  332. HTTP_PROXY_AUTHENTICATION_REQUIRED = 407;
  333. HTTP_REQUEST_TIME_OUT = 408;
  334. HTTP_CONFLICT = 409;
  335. HTTP_GONE = 410;
  336. HTTP_LENGTH_REQUIRED = 411;
  337. HTTP_PRECONDITION_FAILED = 412;
  338. HTTP_REQUEST_ENTITY_TOO_LARGE = 413;
  339. HTTP_REQUEST_URI_TOO_LARGE = 414;
  340. HTTP_UNSUPPORTED_MEDIA_TYPE = 415;
  341. HTTP_RANGE_NOT_SATISFIABLE = 416;
  342. HTTP_EXPECTATION_FAILED = 417;
  343. HTTP_UNPROCESSABLE_ENTITY = 422;
  344. HTTP_LOCKED = 423;
  345. HTTP_FAILED_DEPENDENCY = 424;
  346. HTTP_UPGRADE_REQUIRED = 426;
  347. HTTP_INTERNAL_SERVER_ERROR = 500;
  348. HTTP_NOT_IMPLEMENTED = 501;
  349. HTTP_BAD_GATEWAY = 502;
  350. HTTP_SERVICE_UNAVAILABLE = 503;
  351. HTTP_GATEWAY_TIME_OUT = 504;
  352. HTTP_VERSION_NOT_SUPPORTED = 505;
  353. HTTP_VARIANT_ALSO_VARIES = 506;
  354. _INSUFFICIENT_STORAGE = 507;
  355. HTTP_NOT_EXTENDED = 510;
  356. { is the status code informational }
  357. //#define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200))
  358. { is the status code OK ?}
  359. //#define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300))
  360. { is the status code a redirect }
  361. //#define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400))
  362. { is the status code a error (client or server) }
  363. //#define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600))
  364. { is the status code a client error }
  365. //#define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
  366. { is the status code a server error }
  367. //#define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
  368. { should the status code drop the connection }
  369. {#define ap_status_drops_connection(x) \
  370. (((x) == HTTP_BAD_REQUEST) || \
  371. ((x) == HTTP_REQUEST_TIME_OUT) || \
  372. ((x) == HTTP_LENGTH_REQUIRED) || \
  373. ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
  374. ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
  375. ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
  376. ((x) == HTTP_SERVICE_UNAVAILABLE) || \
  377. ((x) == HTTP_NOT_IMPLEMENTED))}
  378. {
  379. * @defgroup Methods List of Methods recognized by the server
  380. * @
  381. * Methods recognized (but not necessarily handled) by the server.
  382. * These constants are used in bit shifting masks of size int, so it is
  383. * unsafe to have more methods than bits in an int. HEAD == M_GET.
  384. * This list must be tracked by the list in http_protocol.c in routine
  385. * ap_method_name_of().
  386. }
  387. const
  388. M_GET = 0; // RFC 2616: HTTP
  389. M_PUT = 1; // :
  390. M_POST = 2;
  391. M_DELETE = 3;
  392. M_CONNECT = 4;
  393. M_OPTIONS = 5;
  394. M_TRACE = 6; // RFC 2616: HTTP }
  395. M_PATCH = 7; // no rfc(!) ### remove this one? }
  396. M_PROPFIND = 8; // RFC 2518: WebDAV }
  397. M_PROPPATCH = 9; // : }
  398. M_MKCOL = 10;
  399. M_COPY = 11;
  400. M_MOVE = 12;
  401. M_LOCK = 13;
  402. M_UNLOCK = 14; // RFC 2518: WebDAV }
  403. M_VERSION_CONTROL = 15; // RFC 3253: WebDAV Versioning }
  404. M_CHECKOUT = 16; // : }
  405. M_UNCHECKOUT = 17;
  406. M_CHECKIN = 18;
  407. M_UPDATE = 19;
  408. M_LABEL = 20;
  409. M_REPORT = 21;
  410. M_MKWORKSPACE = 22;
  411. M_MKACTIVITY = 23;
  412. M_BASELINE_CONTROL = 24;
  413. M_MERGE = 25;
  414. M_INVALID = 26; // RFC 3253: WebDAV Versioning }
  415. {
  416. * METHODS needs to be equal to the number of bits
  417. * we are using for limit masks.
  418. }
  419. METHODS = 64;
  420. {
  421. * The method mask bit to shift for anding with a bitmask.
  422. }
  423. AP_METHOD_BIT = apr_int64_t(1);
  424. {
  425. * Structure for handling HTTP methods. Methods known to the server are
  426. * accessed via a bitmask shortcut; extension methods are handled by
  427. * an array.
  428. }
  429. type
  430. ap_method_list_t = record
  431. { The bitmask used for known methods }
  432. method_mask: apr_int64_t;
  433. { the array used for extension methods }
  434. // method_list: ^apr_array_header_t;
  435. end;
  436. {
  437. * @defgroup module_magic Module Magic mime types
  438. * @
  439. }
  440. { Magic for mod_cgi[d] }
  441. const
  442. CGI_MAGIC_TYPE = 'application/x-httpd-cgi';
  443. { Magic for mod_include }
  444. INCLUDES_MAGIC_TYPE = 'text/x-server-parsed-html';
  445. { Magic for mod_include }
  446. INCLUDES_MAGIC_TYPE3 = 'text/x-server-parsed-html3';
  447. { Magic for mod_dir }
  448. DIR_MAGIC_TYPE = 'httpd/unix-directory';
  449. { Just in case your linefeed isn't the one the other end is expecting. }
  450. { linefeed }
  451. LF = 10;
  452. { carrige return }
  453. CR = 13;
  454. { carrige return /Line Feed Combo }
  455. CRLF = #015#012;
  456. {
  457. * @defgroup values_request_rec_body Possible values for request_rec.read_body
  458. * @
  459. * Possible values for request_rec.read_body (set by handling module):
  460. }
  461. { Send 413 error if message has any body }
  462. REQUEST_NO_BODY = 0;
  463. { Send 411 error if body without Content-Length }
  464. REQUEST_CHUNKED_ERROR = 1;
  465. { If chunked, remove the chunks for me. }
  466. REQUEST_CHUNKED_DECHUNK = 2;
  467. {
  468. * @defgroup values_request_rec_used_path_info Possible values for request_rec.used_path_info
  469. * @
  470. * Possible values for request_rec.used_path_info:
  471. }
  472. { Accept the path_info from the request }
  473. AP_REQ_ACCEPT_PATH_INFO = 0;
  474. { Return a 404 error if path_info was given }
  475. AP_REQ_REJECT_PATH_INFO = 1;
  476. { Module may chose to use the given path_info }
  477. AP_REQ_DEFAULT_PATH_INFO = 2;
  478. { @}
  479. {
  480. * Things which may vary per file-lookup WITHIN a request ---
  481. * e.g., state of MIME config. Basically, the name of an object, info
  482. * about the object, and any other info we may ahve which may need to
  483. * change as we go poking around looking for it (e.g., overridden by
  484. * .htaccess files).
  485. *
  486. * Note how the default state of almost all these things is properly
  487. * zero, so that allocating it with pcalloc does the right thing without
  488. * a whole lot of hairy initialization... so long as we are willing to
  489. * make the (fairly) portable assumption that the bit pattern of a NULL
  490. * pointer is, in fact, zero.
  491. }
  492. {
  493. * This represents the result of calling htaccess; these are cached for
  494. * each request.
  495. }
  496. type
  497. Phtaccess_result = ^htaccess_result;
  498. htaccess_result = record
  499. { the directory to which this applies }
  500. dir: PChar;
  501. { the overrides allowed for the .htaccess file }
  502. override_: Integer;
  503. { the configuration directives }
  504. htaccess: Pap_conf_vector_t;
  505. { the next one, or NULL if no more; N.B. never change this }
  506. next: Phtaccess_result;
  507. end;
  508. { The following four types define a hierarchy of activities, so that
  509. * given a request_rec r you can write r->connection->server->process
  510. * to get to the process_rec. While this reduces substantially the
  511. * number of arguments that various hooks require beware that in
  512. * threaded versions of the server you must consider multiplexing
  513. * issues. }
  514. { ### would be nice to not include this from httpd.h ... }
  515. { This comes after we have defined the request_rec type }
  516. //#include "apr_uri.h"
  517. type
  518. { Forward declarations of pointer to record types}
  519. Pconn_rec = ^conn_rec;
  520. Prequest_rec = ^request_rec;
  521. Pserver_rec = ^server_rec;
  522. PPserver_rec = ^Pserver_rec;
  523. Pserver_addr_rec = ^server_addr_rec;
  524. Pprocess_rec = ^process_rec;
  525. { A structure that represents one process }
  526. process_rec = record
  527. { Global pool. Cleared upon normal exit }
  528. pool: Papr_pool_t;
  529. { Configuration pool. Cleared upon restart }
  530. pconf: Papr_pool_t;
  531. { Number of command line arguments passed to the program }
  532. argc: Integer;
  533. { The command line arguments }
  534. argv: PChar;
  535. { The program name used to execute the program }
  536. short_name: PChar;
  537. end;
  538. { A structure that represents the current request }
  539. request_rec = record
  540. { The pool associated with the request }
  541. pool: Papr_pool_t;
  542. { The connection to the client }
  543. connection: Pconn_rec;
  544. { The virtual host for this request }
  545. server: Pserver_rec;
  546. { Pointer to the redirected request if this is an external redirect }
  547. next: Prequest_rec;
  548. { Pointer to the previous request if this is an internal redirect }
  549. prev: Prequest_rec;
  550. { Pointer to the main request if this is a sub-request
  551. * (see http_request.h) }
  552. main: Prequest_rec;
  553. { Info about the request itself... we begin with stuff that only
  554. * protocol.c should ever touch...
  555. }
  556. { First line of request }
  557. the_request: PChar;
  558. { HTTP/0.9, "simple" request (e.g. GET /foo\n w/no headers) }
  559. assbackwards: Integer;
  560. { A proxy request (calculated during post_read_request/translate_name)
  561. * possible values PROXYREQ_NONE, PROXYREQ_PROXY, PROXYREQ_REVERSE,
  562. * PROXYREQ_RESPONSE
  563. }
  564. proxyreq: Integer;
  565. { HEAD request, as opposed to GET }
  566. header_only: Integer;
  567. { Protocol string, as given to us, or HTTP/0.9 }
  568. protocol: PChar;
  569. { Protocol version number of protocol; 1.1 = 1001 }
  570. proto_num: Integer;
  571. { Host, as set by full URI or Host: }
  572. hostname: PChar;
  573. { Time when the request started }
  574. request_time: apr_time_t;
  575. { Status line, if set by script }
  576. status_line: PChar;
  577. { Status line }
  578. status: Integer;
  579. { Request method, two ways; also, protocol, etc.. Outside of protocol.c,
  580. * look, but don't touch.
  581. }
  582. { Request method (eg. GET, HEAD, POST, etc.) }
  583. method: PChar;
  584. { M_GET, M_POST, etc. }
  585. method_number: Integer;
  586. {
  587. * 'allowed' is a bitvector of the allowed methods.
  588. *
  589. * A handler must ensure that the request method is one that
  590. * it is capable of handling. Generally modules should DECLINE
  591. * any request methods they do not handle. Prior to aborting the
  592. * handler like this the handler should set r->allowed to the list
  593. * of methods that it is willing to handle. This bitvector is used
  594. * to construct the "Allow:" header required for OPTIONS requests,
  595. * and HTTP_METHOD_NOT_ALLOWED and HTTP_NOT_IMPLEMENTED status codes.
  596. *
  597. * Since the default_handler deals with OPTIONS, all modules can
  598. * usually decline to deal with OPTIONS. TRACE is always allowed,
  599. * modules don't need to set it explicitly.
  600. *
  601. * Since the default_handler will always handle a GET, a
  602. * module which does *not* implement GET should probably return
  603. * HTTP_METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET
  604. * handler can't be installed by mod_actions.
  605. }
  606. allowed: apr_int64_t;
  607. { Array of extension methods }
  608. allowed_xmethods: Papr_array_header_t;
  609. { List of allowed methods }
  610. allowed_methods: Pap_method_list_t;
  611. { byte count in stream is for body }
  612. sent_bodyct: apr_off_t;
  613. { body byte count, for easy access }
  614. bytes_sent: apr_off_t;
  615. { Last modified time of the requested resource }
  616. mtime: apr_time_t;
  617. { HTTP/1.1 connection-level features }
  618. { sending chunked transfer-coding }
  619. chunked: Integer;
  620. { The Range: header }
  621. range: PChar;
  622. { The "real" content length }
  623. clength: apr_off_t;
  624. { Remaining bytes left to read from the request body }
  625. remaining: apr_off_t;
  626. { Number of bytes that have been read from the request body }
  627. read_length: apr_off_t;
  628. { Method for reading the request body
  629. * (eg. REQUEST_CHUNKED_ERROR, REQUEST_NO_BODY,
  630. * REQUEST_CHUNKED_DECHUNK, etc...) }
  631. read_body: Integer;
  632. { reading chunked transfer-coding }
  633. read_chunked: Integer;
  634. { is client waiting for a 100 response? }
  635. expecting_100: Cardinal;
  636. { MIME header environments, in and out. Also, an array containing
  637. * environment variables to be passed to subprocesses, so people can
  638. * write modules to add to that environment.
  639. *
  640. * The difference between headers_out and err_headers_out is that the
  641. * latter are printed even on error, and persist across internal redirects
  642. * (so the headers printed for ErrorDocument handlers will have them).
  643. *
  644. * The 'notes' apr_table_t is for notes from one module to another, with no
  645. * other set purpose in mind...
  646. }
  647. { MIME header environment from the request }
  648. headers_in: Papr_table_t;
  649. { MIME header environment for the response }
  650. headers_out: Papr_table_t;
  651. { MIME header environment for the response, printed even on errors and
  652. * persist across internal redirects }
  653. err_headers_out: Papr_table_t;
  654. { Array of environment variables to be used for sub processes }
  655. subprocess_env: Papr_table_t;
  656. { Notes from one module to another }
  657. notes: Papr_table_t;
  658. { content_type, handler, content_encoding, and all content_languages
  659. * MUST be lowercased strings. They may be pointers to static strings;
  660. * they should not be modified in place.
  661. }
  662. { The content-type for the current request }
  663. content_type: PChar; // Break these out --- we dispatch on 'em
  664. { The handler string that we use to call a handler function }
  665. handler: PChar; // What we *really* dispatch on
  666. { How to encode the data }
  667. content_encoding: PChar;
  668. { Array of strings representing the content languages }
  669. content_languages: Papr_array_header_t;
  670. { variant list validator (if negotiated) }
  671. vlist_validator: PChar;
  672. { If an authentication check was made, this gets set to the user name. }
  673. user: PChar;
  674. { If an authentication check was made, this gets set to the auth type. }
  675. ap_auth_type: PChar;
  676. { This response can not be cached }
  677. no_cache: Integer;
  678. { There is no local copy of this response }
  679. no_local_copy: Integer;
  680. { What object is being requested (either directly, or via include
  681. * or content-negotiation mapping).
  682. }
  683. { The URI without any parsing performed }
  684. unparsed_uri: PChar;
  685. { The path portion of the URI }
  686. uri: PChar;
  687. { The filename on disk corresponding to this response }
  688. filename: PChar;
  689. { XXX: What does this mean? Please define "canonicalize" -aaron }
  690. { The true filename, we canonicalize r->filename if these don't match }
  691. canonical_filename: PChar;
  692. { The PATH_INFO extracted from this request }
  693. path_info: PChar;
  694. { The QUERY_ARGS extracted from this request }
  695. args: PChar;
  696. { finfo.protection (st_mode) set to zero if no such file }
  697. finfo: apr_finfo_t;
  698. { A struct containing the components of URI }
  699. parsed_uri: apr_uri_t;
  700. {
  701. * Flag for the handler to accept or reject path_info on
  702. * the current request. All modules should respect the
  703. * AP_REQ_ACCEPT_PATH_INFO and AP_REQ_REJECT_PATH_INFO
  704. * values, while AP_REQ_DEFAULT_PATH_INFO indicates they
  705. * may follow existing conventions. This is set to the
  706. * user's preference upon HOOK_VERY_FIRST of the fixups.
  707. }
  708. used_path_info: Integer;
  709. { Various other config info which may change with .htaccess files
  710. * These are config vectors, with one void* pointer for each module
  711. * (the thing pointed to being the module's business).
  712. }
  713. { Options set in config files, etc.}
  714. per_dir_config: Pap_conf_vector_t;
  715. { Notes on *this* request }
  716. request_config: Pap_conf_vector_t;
  717. {
  718. * A linked list of the .htaccess configuration directives
  719. * accessed by this request.
  720. * N.B. always add to the head of the list, _never_ to the end.
  721. * that way, a sub request's list can (temporarily) point to a parent's list
  722. }
  723. htaccess: Phtaccess_result;
  724. { A list of output filters to be used for this request }
  725. output_filters: Pap_filter_t;
  726. { A list of input filters to be used for this request }
  727. input_filters: Pap_filter_t;
  728. { A list of protocol level output filters to be used for this
  729. * request }
  730. proto_output_filters: Pap_filter_t;
  731. { A list of protocol level input filters to be used for this
  732. * request }
  733. proto_input_filters: Pap_filter_t;
  734. { A flag to determine if the eos bucket has been sent yet }
  735. eos_sent: Integer;
  736. { Things placed at the end of the record to avoid breaking binary
  737. * compatibility. It would be nice to remember to reorder the entire
  738. * record to improve 64bit alignment the next time we need to break
  739. * binary compatibility for some other reason.
  740. }
  741. end;
  742. {
  743. * @defgroup ProxyReq Proxy request types
  744. *
  745. * Possible values of request_rec->proxyreq. A request could be normal,
  746. * proxied or reverse proxied. Normally proxied and reverse proxied are
  747. * grouped together as just "proxied", but sometimes it's necessary to
  748. * tell the difference between the two, such as for authentication.
  749. }
  750. ap_conn_keepalive_e = (AP_CONN_UNKNOWN, AP_CONN_CLOSE, AP_CONN_KEEPALIVE);
  751. Pconn_state_t = ^conn_state_t;
  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: clong;
  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. { The current state of this connection }
  810. cs: Pconn_state_t;
  811. { Is there data pending in the input filters? }
  812. data_in_input_filters: cint;
  813. end;
  814. {
  815. * Enumeration of connection states
  816. }
  817. conn_state_e = (
  818. CONN_STATE_CHECK_REQUEST_LINE_READABLE,
  819. CONN_STATE_READ_REQUEST_LINE,
  820. CONN_STATE_LINGER
  821. );
  822. {
  823. * @brief A structure to contain connection state information
  824. }
  825. APR_RING_ENTRY_conn_state_t = record
  826. next: Pconn_state_t;
  827. prev: Pconn_state_t;
  828. end;
  829. conn_state_t = record
  830. { APR_RING of expiration timeouts }
  831. timeout_list: APR_RING_ENTRY_conn_state_t;
  832. { the expiration time of the next keepalive timeout }
  833. expiration_time: apr_time_t;
  834. { Current state of the connection }
  835. state: conn_state_e;
  836. { connection record this struct refers to }
  837. c: Pconn_rec;
  838. { memory pool to allocate from }
  839. p: Papr_pool_t;
  840. { bucket allocator }
  841. bucket_alloc: Papr_bucket_alloc_t;
  842. { poll file decriptor information }
  843. pfd: apr_pollfd_t;
  844. end;
  845. { Per-vhost config... }
  846. { A structure to be used for Per-vhost config }
  847. server_addr_rec = record
  848. { The next server in the list }
  849. next: Pserver_addr_rec;
  850. { The bound address, for this server }
  851. host_addr: Papr_sockaddr_t;
  852. { The bound port, for this server }
  853. host_port: apr_port_t;
  854. { The name given in <VirtualHost> }
  855. virthost: PChar;
  856. end;
  857. { A structure to store information for each virtual server }
  858. server_rec = record
  859. { The process this server is running in }
  860. process: Pprocess_rec;
  861. { The next server in the list }
  862. next: Pserver_rec;
  863. { The name of the server }
  864. defn_name: PChar;
  865. { The line of the config file that the server was defined on }
  866. defn_line_number: Integer;
  867. { Contact information }
  868. { The admin's contact information }
  869. server_admin: PChar;
  870. { The server hostname }
  871. server_hostname: PChar;
  872. { for redirects, etc. }
  873. port: apr_port_t;
  874. { Log files --- note that transfer log is now in the modules... }
  875. { The name of the error log }
  876. error_fname: PChar;
  877. { A file descriptor that references the error log }
  878. error_log: Papr_file_t;
  879. { The log level for this server }
  880. loglevel: Integer;
  881. { Module-specific configuration for server, and defaults... }
  882. { true if this is the virtual server }
  883. is_virtual: Integer;
  884. { Config vector containing pointers to modules' per-server config
  885. * structures. }
  886. module_config: Pap_conf_vector_t;
  887. { MIME type info, etc., before we start checking per-directory info }
  888. lookup_defaults: Pap_conf_vector_t;
  889. { Transaction handling }
  890. { I haven't got a clue }
  891. addrs: Pserver_addr_rec;
  892. { Timeout, as an apr interval, before we give up }
  893. timeout: apr_interval_time_t;
  894. { The apr interval we will wait for another request }
  895. keep_alive_timeout: apr_interval_time_t;
  896. { Maximum requests per connection }
  897. keep_alive_max: Integer;
  898. { Use persistent connections? }
  899. keep_alive: Integer;
  900. { Pathname for ServerPath }
  901. path: PChar;
  902. { Length of path }
  903. pathlen: Integer;
  904. { Normal names for ServerAlias servers }
  905. names: Papr_array_header_t;
  906. { Wildcarded names for ServerAlias servers }
  907. wild_names: Papr_array_header_t;
  908. { limit on size of the HTTP request line }
  909. limit_req_line: Integer;
  910. { limit on size of any request header field }
  911. limit_req_fieldsize: Integer;
  912. { limit on number of request header fields }
  913. limit_req_fields: Integer;
  914. { The server request scheme for redirect responses }
  915. server_scheme: PChar;
  916. end;
  917. type
  918. core_output_filter_ctx = record
  919. b: Papr_bucket_brigade;
  920. deferred_write_pool: Papr_pool_t; { subpool of c->pool used for resources
  921. * which may outlive the request }
  922. end;
  923. core_filter_ctx = record
  924. b: Papr_bucket_brigade;
  925. tmpbb: Papr_bucket_brigade;
  926. end; // core_ctx_t
  927. core_ctx_t = core_filter_ctx;
  928. Pcore_ctx_t = ^core_ctx_t;
  929. type
  930. core_net_rec = record
  931. { Connection to the client }
  932. client_socket: Papr_socket_t;
  933. { connection record }
  934. c: Pconn_rec;
  935. out_ctx: Pcore_output_filter_ctx_t;
  936. in_ctx: Pcore_ctx_t;
  937. end; // core_net_rec;
  938. Pcore_net_rec = ^core_net_rec;
  939. {
  940. The constants are on the bottom because the structures need to be on the same type block
  941. }
  942. const
  943. PROXYREQ_NONE = 0; {< No proxy }
  944. PROXYREQ_PROXY = 1; {< Standard proxy }
  945. PROXYREQ_REVERSE = 2; {< Reverse proxy }
  946. PROXYREQ_RESPONSE = 3; {< Origin response }
  947. {
  948. * The address 255.255.255.255, when used as a virtualhost address,
  949. * will become the "default" server when the ip doesn't match other vhosts.
  950. }
  951. const DEFAULT_VHOST_ADDR = $ffffffff;//ul
  952. {
  953. * Examine a field value (such as a media-/content-type) string and return
  954. * it sans any parameters; e.g., strip off any ';charset=foo' and the like.
  955. * @param p Pool to allocate memory from
  956. * @param intype The field to examine
  957. * @return A copy of the field minus any parameters
  958. }
  959. function ap_field_noparam(p: Papr_pool_t; const intype: PChar): PChar;
  960. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  961. external LibHTTPD name LibNamePrefix + 'ap_field_noparam' + LibSuff8;
  962. {
  963. * Convert a time from an integer into a string in a specified format
  964. * @param p The pool to allocate memory from
  965. * @param t The time to convert
  966. * @param fmt The format to use for the conversion
  967. * @param gmt Convert the time for GMT?
  968. * @return The string that represents the specified time
  969. }
  970. function ap_ht_time(p: Papr_pool_t; t: apr_time_t; const fmt: PChar; gmt: Integer): PChar;
  971. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  972. external LibHTTPD name LibNamePrefix + 'ap_ht_time' + LibSuff20;
  973. { String handling. The *_nc variants allow you to use non-const char **s as
  974. arguments (unfortunately C won't automatically convert a char ** to a const
  975. char **) }
  976. {
  977. * Get the characters until the first occurance of a specified character
  978. * @param p The pool to allocate memory from
  979. * @param line The string to get the characters from
  980. * @param stop The character to stop at
  981. * @return A copy of the characters up to the first stop character
  982. }
  983. function ap_getword(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
  984. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  985. external LibHTTPD name LibNamePrefix + 'ap_getword' + LibSuff12;
  986. {
  987. * Get the characters until the first occurance of a specified character
  988. * @param p The pool to allocate memory from
  989. * @param line The string to get the characters from
  990. * @param stop The character to stop at
  991. * @return A copy of the characters up to the first stop character
  992. * @note This is the same as ap_getword(), except it doesn't use const char **.
  993. }
  994. function ap_getword_nc(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
  995. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  996. external LibHTTPD name LibNamePrefix + 'ap_getword_nc' + LibSuff12;
  997. {
  998. * Get the first word from a given string. A word is defined as all characters
  999. * up to the first whitespace.
  1000. * @param p The pool to allocate memory from
  1001. * @param line The string to traverse
  1002. * @return The first word in the line
  1003. }
  1004. function ap_getword_white(p: Papr_pool_t; const line: PPChar): PChar;
  1005. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1006. external LibHTTPD name LibNamePrefix + 'ap_getword_white' + LibSuff8;
  1007. {
  1008. * Get the first word from a given string. A word is defined as all characters
  1009. * up to the first whitespace.
  1010. * @param p The pool to allocate memory from
  1011. * @param line The string to traverse
  1012. * @return The first word in the line
  1013. * @note The same as ap_getword_white(), except it doesn't use const char **.
  1014. }
  1015. function ap_getword_white_nc(p: Papr_pool_t; const line: PPChar): PChar;
  1016. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1017. external LibHTTPD name LibNamePrefix + 'ap_getword_white_nc' + LibSuff8;
  1018. {
  1019. * Get all characters from the first occurance of @a stop to the first '\0'
  1020. * @param p The pool to allocate memory from
  1021. * @param line The line to traverse
  1022. * @param stop The character to start at
  1023. * @return A copy of all caracters after the first occurance of the specified
  1024. * character
  1025. }
  1026. function ap_getword_nulls(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
  1027. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1028. external LibHTTPD name LibNamePrefix + 'ap_getword_nulls' + LibSuff12;
  1029. {
  1030. * Get all characters from the first occurance of @a stop to the first '\0'
  1031. * @param p The pool to allocate memory from
  1032. * @param line The line to traverse
  1033. * @param stop The character to start at
  1034. * @return A copy of all caracters after the first occurance of the specified
  1035. * character
  1036. * @note The same as ap_getword_nulls(), except it doesn't use const char **.
  1037. }
  1038. function ap_getword_nulls_nc(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
  1039. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1040. external LibHTTPD name LibNamePrefix + 'ap_getword_nulls_nc' + LibSuff12;
  1041. {
  1042. * Get the second word in the string paying attention to quoting
  1043. * @param p The pool to allocate from
  1044. * @param line The line to traverse
  1045. * @return A copy of the string
  1046. }
  1047. function ap_getword_conf(p: Papr_pool_t; const line: PPChar): PChar;
  1048. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1049. external LibHTTPD name LibNamePrefix + 'ap_getword_conf' + LibSuff8;
  1050. {
  1051. * Get the second word in the string paying attention to quoting
  1052. * @param p The pool to allocate from
  1053. * @param line The line to traverse
  1054. * @return A copy of the string
  1055. * @note The same as ap_getword_conf(), except it doesn't use const char **.
  1056. }
  1057. function ap_getword_conf_nc(p: Papr_pool_t; const line: PPChar): PChar;
  1058. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1059. external LibHTTPD name LibNamePrefix + 'ap_getword_conf_nc' + LibSuff8;
  1060. {
  1061. * Check a string for any $ENV environment variable construct and replace
  1062. * each them by the value of that environment variable, if it exists. If the
  1063. * environment value does not exist, leave the $ENV construct alone; it
  1064. * means something else.
  1065. * @param p The pool to allocate from
  1066. * @param word The string to check
  1067. * @return The string with the replaced environment variables
  1068. }
  1069. function ap_resolve_env(p: Papr_pool_t; const word_: PChar; accept_white: Integer): PChar;
  1070. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1071. external LibHTTPD name LibNamePrefix + 'ap_resolve_env' + LibSuff8;
  1072. {
  1073. * Size an HTTP header field list item, as separated by a comma.
  1074. * @param field The field to size
  1075. * @param len The length of the field
  1076. * @return The return value is a pointer to the beginning of the non-empty
  1077. * list item within the original string (or NULL if there is none) and the
  1078. * address of field is shifted to the next non-comma, non-whitespace
  1079. * character. len is the length of the item excluding any beginning whitespace.
  1080. }
  1081. function ap_size_list_item(const field: PPChar; len: Integer): PChar;
  1082. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1083. external LibHTTPD name LibNamePrefix + 'ap_size_list_item' + LibSuff8;
  1084. {
  1085. * Retrieve an HTTP header field list item, as separated by a comma,
  1086. * while stripping insignificant whitespace and lowercasing anything not in
  1087. * a quoted string or comment.
  1088. * @param p The pool to allocate from
  1089. * @param field The field to retrieve
  1090. * @return The return value is a new string containing the converted list
  1091. * item (or NULL if none) and the address pointed to by field is
  1092. * shifted to the next non-comma, non-whitespace.
  1093. }
  1094. function ap_get_list_item(p: Papr_pool_t; const field: PPChar): PChar;
  1095. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1096. external LibHTTPD name LibNamePrefix + 'ap_get_list_item' + LibSuff8;
  1097. {
  1098. * Find an item in canonical form (lowercase, no extra spaces) within
  1099. * an HTTP field value list.
  1100. * @param p The pool to allocate from
  1101. * @param line The field value list to search
  1102. * @param tok The token to search for
  1103. * @return 1 if found, 0 if not found.
  1104. }
  1105. function ap_find_list_item(p: Papr_pool_t; const line, tok: PChar): Integer;
  1106. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1107. external LibHTTPD name LibNamePrefix + 'ap_find_list_item' + LibSuff12;
  1108. {
  1109. * Retrieve a token, spacing over it and returning a pointer to
  1110. * the first non-white byte afterwards. Note that these tokens
  1111. * are delimited by semis and commas and can also be delimited
  1112. * by whitespace at the caller's option.
  1113. * @param p The pool to allocate from
  1114. * @param accept_line The line to retrieve the token from
  1115. * @param accept_white Is it delimited by whitespace
  1116. * @return the first non-white byte after the token
  1117. }
  1118. function ap_get_token(p: Papr_pool_t; const accept_line: PPChar; accept_white: Integer): PChar;
  1119. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1120. external LibHTTPD name LibNamePrefix + 'ap_get_token' + LibSuff12;
  1121. {
  1122. * Find http tokens, see the definition of token from RFC2068
  1123. * @param p The pool to allocate from
  1124. * @param line The line to find the token
  1125. * @param tok The token to find
  1126. * @return 1 if the token is found, 0 otherwise
  1127. }
  1128. function ap_find_token(p: Papr_pool_t; const line, tok: PChar): Integer;
  1129. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1130. external LibHTTPD name LibNamePrefix + 'ap_find_token' + LibSuff12;
  1131. {
  1132. * find http tokens from the end of the line
  1133. * @param p The pool to allocate from
  1134. * @param line The line to find the token
  1135. * @param tok The token to find
  1136. * @return 1 if the token is found, 0 otherwise
  1137. }
  1138. function ap_find_last_token(p: Papr_pool_t; const line, tok: PChar): Integer;
  1139. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1140. external LibHTTPD name LibNamePrefix + 'ap_find_last_token' + LibSuff12;
  1141. {
  1142. * Check for an Absolute URI syntax
  1143. * @param u The string to check
  1144. * @return 1 if URI, 0 otherwise
  1145. }
  1146. function ap_is_url(const u: PChar): Integer;
  1147. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1148. external LibHTTPD name LibNamePrefix + 'ap_is_url' + LibSuff4;
  1149. {
  1150. * Unescape a URL
  1151. * @param url The url to unescape
  1152. * @return 0 on success, non-zero otherwise
  1153. }
  1154. function ap_unescape_url(url: PChar): Integer;
  1155. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1156. external LibHTTPD name LibNamePrefix + 'ap_unescape_url' + LibSuff4;
  1157. {
  1158. * Unescape a URL, but leaving %2f (slashes) escaped
  1159. * @param url The url to unescape
  1160. * @return 0 on success, non-zero otherwise
  1161. }
  1162. function ap_unescape_url_keep2f(url: PChar): Integer;
  1163. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1164. external LibHTTPD name LibNamePrefix + 'ap_unescape_url_keep2f' + LibSuff4;
  1165. {
  1166. * Convert all double slashes to single slashes
  1167. * @param name The string to convert
  1168. }
  1169. procedure ap_no2slash(name: PChar);
  1170. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1171. external LibHTTPD name LibNamePrefix + 'ap_no2slash' + LibSuff4;
  1172. {
  1173. * Remove all ./ and xx/../ substrings from a file name. Also remove
  1174. * any leading ../ or /../ substrings.
  1175. * @param name the file name to parse
  1176. }
  1177. procedure ap_getparents(name: PChar);
  1178. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1179. external LibHTTPD name LibNamePrefix + 'ap_getparents' + LibSuff4;
  1180. {
  1181. * Escape a path segment, as defined in RFC 1808
  1182. * @param p The pool to allocate from
  1183. * @param s The path to convert
  1184. * @return The converted URL
  1185. }
  1186. function ap_escape_path_segment(p: Papr_pool_t; const s: PChar): PChar;
  1187. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1188. external LibHTTPD name LibNamePrefix + 'ap_escape_path_segment' + LibSuff8;
  1189. {
  1190. * convert an OS path to a URL in an OS dependant way.
  1191. * @param p The pool to allocate from
  1192. * @param path The path to convert
  1193. * @param partial if set, assume that the path will be appended to something
  1194. * with a '/' in it (and thus does not prefix "./")
  1195. * @return The converted URL
  1196. }
  1197. function ap_os_escape_path(p: Papr_pool_t; const path: PChar; partial: Integer): PChar;
  1198. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1199. external LibHTTPD name LibNamePrefix + 'ap_os_escape_path' + LibSuff12;
  1200. { @see ap_os_escape_path }
  1201. function ap_escape_uri(p: Papr_pool_t; const path: PChar): PChar;
  1202. {
  1203. * Escape an html string
  1204. * @param p The pool to allocate from
  1205. * @param s The html to escape
  1206. * @return The escaped string
  1207. }
  1208. function ap_escape_html(p: Papr_pool_t; const s: PChar): PChar;
  1209. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1210. external LibHTTPD name LibNamePrefix + 'ap_escape_html' + LibSuff8;
  1211. {
  1212. * Escape a string for logging
  1213. * @param p The pool to allocate from
  1214. * @param str The string to escape
  1215. * @return The escaped string
  1216. }
  1217. function ap_escape_logitem(p: Papr_pool_t; const str: PChar): PChar;
  1218. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1219. external LibHTTPD name LibNamePrefix + 'ap_escape_logitem' + LibSuff8;
  1220. {
  1221. * Escape a string for logging into the error log (without a pool)
  1222. * @param dest The buffer to write to
  1223. * @param source The string to escape
  1224. * @param buflen The buffer size for the escaped string (including \0)
  1225. * @return The len of the escaped string (always < maxlen)
  1226. }
  1227. function ap_escape_errorlog_item(dest, source: PChar;
  1228. buflen: apr_size_t): apr_size_t;
  1229. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1230. external LibHTTPD name LibNamePrefix + 'ap_escape_errorlog_item' + LibSuff12;
  1231. {
  1232. * Construct a full hostname
  1233. * @param p The pool to allocate from
  1234. * @param hostname The hostname of the server
  1235. * @param port The port the server is running on
  1236. * @param r The current request
  1237. * @return The server's hostname
  1238. }
  1239. function ap_construct_server(p: Papr_pool_t; const hostname: PChar;
  1240. port: Papr_port_t; const r: Prequest_rec): PChar;
  1241. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1242. external LibHTTPD name LibNamePrefix + 'ap_construct_server' + LibSuff16;
  1243. {
  1244. * Escape a shell command
  1245. * @param p The pool to allocate from
  1246. * @param s The command to escape
  1247. * @return The escaped shell command
  1248. }
  1249. function ap_escape_shell_cmd(p: Papr_pool_t; const s: PChar): PChar;
  1250. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1251. external LibHTTPD name LibNamePrefix + 'ap_escape_shell_cmd' + LibSuff8;
  1252. {
  1253. * Count the number of directories in a path
  1254. * @param path The path to count
  1255. * @return The number of directories
  1256. }
  1257. function ap_count_dirs(const path: PChar): Integer;
  1258. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1259. external LibHTTPD name LibNamePrefix + 'ap_count_dirs' + LibSuff4;
  1260. {
  1261. * Copy at most @a n leading directories of @a s into @a d. @a d
  1262. * should be at least as large as @a s plus 1 extra byte
  1263. *
  1264. * @param d The location to copy to
  1265. * @param s The location to copy from
  1266. * @param n The number of directories to copy
  1267. * @return value is the ever useful pointer to the trailing \0 of d
  1268. * @note on platforms with drive letters, n = 0 returns the "/" root,
  1269. * whereas n = 1 returns the "d:/" root. On all other platforms, n = 0
  1270. * returns the empty string. }
  1271. function ap_make_dirstr_prefix(const d, s: PChar; n: Integer): PChar;
  1272. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1273. external LibHTTPD name LibNamePrefix + 'ap_make_dirstr_prefix' + LibSuff12;
  1274. {
  1275. * Return the parent directory name (including trailing /) of the file
  1276. * @a s
  1277. * @param p The pool to allocate from
  1278. * @param s The file to get the parent of
  1279. * @return A copy of the file's parent directory
  1280. }
  1281. function ap_make_dirstr_parent(p: Papr_pool_t; const s: PChar): PChar;
  1282. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1283. external LibHTTPD name LibNamePrefix + 'ap_make_dirstr_parent' + LibSuff8;
  1284. {
  1285. * Given a directory and filename, create a single path from them. This
  1286. * function is smart enough to ensure that there is a sinlge '/' between the
  1287. * directory and file names
  1288. * @param a The pool to allocate from
  1289. * @param dir The directory name
  1290. * @param f The filename
  1291. * @return A copy of the full path
  1292. * @tip Never consider using this function if you are dealing with filesystem
  1293. * names that need to remain canonical, unless you are merging an apr_dir_read
  1294. * path and returned filename. Otherwise, the result is not canonical.
  1295. }
  1296. function ap_make_full_path(a: Papr_pool_t; const dir, f: PChar): PChar;
  1297. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1298. external LibHTTPD name LibNamePrefix + 'ap_make_full_path' + LibSuff12;
  1299. {
  1300. * Test if the given path has an an absolute path.
  1301. * @param p The pool to allocate from
  1302. * @param dir The directory name
  1303. * @tip The converse is not necessarily true, some OS's (Win32/OS2/Netware) have
  1304. * multiple forms of absolute paths. This only reports if the path is absolute
  1305. * in a canonical sense.
  1306. }
  1307. function ap_os_is_path_absolute(p: Papr_pool_t; const dir: PChar): Integer;
  1308. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1309. external LibHTTPD name LibNamePrefix + 'ap_os_is_path_absolute' + LibSuff8;
  1310. {
  1311. * Does the provided string contain wildcard characters? This is useful
  1312. * for determining if the string should be passed to strcmp_match or to strcmp.
  1313. * The only wildcard characters recognized are '?' and '*'
  1314. * @param str The string to check
  1315. * @return 1 if the string has wildcards, 0 otherwise
  1316. }
  1317. function ap_is_matchexp(const str: PChar): Integer;
  1318. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1319. external LibHTTPD name LibNamePrefix + 'ap_is_matchexp' + LibSuff4;
  1320. {
  1321. * Determine if a string matches a patterm containing the wildcards '?' or '*'
  1322. * @param str The string to check
  1323. * @param expected The pattern to match against
  1324. * @return 1 if the two strings match, 0 otherwise
  1325. }
  1326. function ap_strcmp_match(const str, expected: PChar): Integer;
  1327. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1328. external LibHTTPD name LibNamePrefix + 'ap_strcmp_match' + LibSuff8;
  1329. {
  1330. * Determine if a string matches a patterm containing the wildcards '?' or '*',
  1331. * ignoring case
  1332. * @param str The string to check
  1333. * @param expected The pattern to match against
  1334. * @return 1 if the two strings match, 0 otherwise
  1335. }
  1336. function ap_strcasecmp_match(const str, expected: PChar): Integer;
  1337. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1338. external LibHTTPD name LibNamePrefix + 'ap_strcasecmp_match' + LibSuff8;
  1339. {
  1340. * Find the first occurrence of the substring s2 in s1, regardless of case
  1341. * @param s1 The string to search
  1342. * @param s2 The substring to search for
  1343. * @return A pointer to the beginning of the substring
  1344. * @remark See apr_strmatch() for a faster alternative
  1345. }
  1346. function ap_strcasestr(const s1, s2: PChar): PChar;
  1347. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1348. external LibHTTPD name LibNamePrefix + 'ap_strcasestr' + LibSuff8;
  1349. {
  1350. * Return a pointer to the location inside of bigstring immediately after prefix
  1351. * @param bigstring The input string
  1352. * @param prefix The prefix to strip away
  1353. * @return A pointer relative to bigstring after prefix
  1354. }
  1355. function ap_stripprefix(const bigstring, prefix: PChar): PChar;
  1356. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1357. external LibHTTPD name LibNamePrefix + 'ap_stripprefix' + LibSuff8;
  1358. {
  1359. * Decode a base64 encoded string into memory allocated from a pool
  1360. * @param p The pool to allocate from
  1361. * @param bufcoded The encoded string
  1362. * @return The decoded string
  1363. }
  1364. function ap_pbase64decode(p: Papr_pool_t; const bufcoded: PChar): PChar;
  1365. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1366. external LibHTTPD name LibNamePrefix + 'ap_pbase64decode' + LibSuff8;
  1367. {
  1368. * Encode a string into memory allocated from a pool in base 64 format
  1369. * @param p The pool to allocate from
  1370. * @param strin The plaintext string
  1371. * @return The encoded string
  1372. }
  1373. function ap_pbase64encode(p: Papr_pool_t; string_: PChar): PChar;
  1374. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1375. external LibHTTPD name LibNamePrefix + 'ap_pbase64encode' + LibSuff8;
  1376. {
  1377. * Compile a regular expression to be used later
  1378. * @param p The pool to allocate from
  1379. * @param pattern the regular expression to compile
  1380. * @param cflags The bitwise or of one or more of the following:
  1381. * @li #REG_EXTENDED - Use POSIX extended Regular Expressions
  1382. * @li #REG_ICASE - Ignore case
  1383. * @li #REG_NOSUB - Support for substring addressing of matches
  1384. * not required
  1385. * @li #REG_NEWLINE - Match-any-character operators don't match new-line
  1386. * @return The compiled regular expression
  1387. }
  1388. function ap_pregcomp(p: Papr_pool_t; const pattern: PChar; cflags: Integer): Pap_regex_t;
  1389. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1390. external LibHTTPD name LibNamePrefix + 'ap_pregcomp' + LibSuff12;
  1391. {
  1392. * Free the memory associated with a compiled regular expression
  1393. * @param p The pool the regex was allocated from
  1394. * @param reg The regular expression to free
  1395. }
  1396. procedure ap_pregfree(p: Papr_pool_t; reg: Pap_regex_t);
  1397. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1398. external LibHTTPD name LibNamePrefix + 'ap_pregfree' + LibSuff8;
  1399. {
  1400. * After performing a successful regex match, you may use this function to
  1401. * perform a series of string substitutions based on subexpressions that were
  1402. * matched during the call to ap_regexec
  1403. * @param p The pool to allocate from
  1404. * @param input An arbitrary string containing $1 through $9. These are
  1405. * replaced with the corresponding matched sub-expressions
  1406. * @param source The string that was originally matched to the regex
  1407. * @param nmatch the nmatch returned from ap_pregex
  1408. * @param pmatch the pmatch array returned from ap_pregex
  1409. }
  1410. function ap_pregsub(p: Papr_pool_t; const input, source: PChar;
  1411. nmatch: size_t; pmatch: array of ap_regmatch_t): PChar;
  1412. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1413. external LibHTTPD name LibNamePrefix + 'ap_pregsub' + LibSuff20;
  1414. {
  1415. * We want to downcase the type/subtype for comparison purposes
  1416. * but nothing else because ;parameter=foo values are case sensitive.
  1417. * @param s The content-type to convert to lowercase
  1418. }
  1419. procedure ap_content_type_tolower(s: PChar);
  1420. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1421. external LibHTTPD name LibNamePrefix + 'ap_content_type_tolower' + LibSuff4;
  1422. {
  1423. * convert a string to all lowercase
  1424. * @param s The string to convert to lowercase
  1425. }
  1426. procedure ap_str_tolower(s: PChar);
  1427. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1428. external LibHTTPD name LibNamePrefix + 'ap_str_tolower' + LibSuff4;
  1429. {
  1430. * Search a string from left to right 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_ind(str: PChar; c: Char): Integer;
  1437. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1438. external LibHTTPD name LibNamePrefix + 'ap_ind' + LibSuff8;
  1439. {
  1440. * Search a string from right to left for the first occurrence of a
  1441. * specific character
  1442. * @param str The string to search
  1443. * @param c The character to search for
  1444. * @return The index of the first occurrence of c in str
  1445. }
  1446. function ap_rind(str: PChar; c: Char): Integer;
  1447. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1448. external LibHTTPD name LibNamePrefix + 'ap_rind' + LibSuff8;
  1449. {
  1450. * Given a string, replace any bare " with \" .
  1451. * @param p The pool to allocate memory from
  1452. * @param instring The string to search for "
  1453. * @return A copy of the string with escaped quotes
  1454. }
  1455. function ap_escape_quotes(p: Papr_pool_t; const instring: PChar): PChar;
  1456. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1457. external LibHTTPD name LibNamePrefix + 'ap_escape_quotes' + LibSuff8;
  1458. {
  1459. * Given a string, append the PID deliminated by delim.
  1460. * Usually used to create a pid-appended filepath name
  1461. * (eg: /a/b/foo -> /a/b/foo.6726). A function, and not
  1462. * a macro, to avoid unistd.h dependency
  1463. * @param p The pool to allocate memory from
  1464. * @param string The string to append the PID to
  1465. * @param delim The string to use to deliminate the string from the PID
  1466. * @return A copy of the string with the PID appended
  1467. }
  1468. function ap_append_pid(p: Papr_pool_t; const string_, delim: PChar): PChar;
  1469. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1470. external LibHTTPD name LibNamePrefix + 'ap_append_pid' + LibSuff12;
  1471. { Misc system hackery }
  1472. {
  1473. * Given the name of an object in the file system determine if it is a directory
  1474. * @param p The pool to allocate from
  1475. * @param name The name of the object to check
  1476. * @return 1 if it is a directory, 0 otherwise
  1477. }
  1478. function ap_is_rdirectory(p: Papr_pool_t; const name: PChar): Integer;
  1479. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1480. external LibHTTPD name LibNamePrefix + 'ap_is_rdirectory' + LibSuff8;
  1481. {
  1482. * Given the name of an object in the file system determine if it is a directory - this version is symlink aware
  1483. * @param p The pool to allocate from
  1484. * @param name The name of the object to check
  1485. * @return 1 if it is a directory, 0 otherwise
  1486. }
  1487. function ap_is_directory(p: Papr_pool_t; const name: PChar): Integer;
  1488. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1489. external LibHTTPD name LibNamePrefix + 'ap_is_directory' + LibSuff8;
  1490. {#ifdef _OSD_POSIX
  1491. extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
  1492. #endif} { _OSD_POSIX }
  1493. {
  1494. * Determine the local host name for the current machine
  1495. * @param p The pool to allocate from
  1496. * @return A copy of the local host name
  1497. }
  1498. //char *ap_get_local_host(apr_pool_t *p);
  1499. {
  1500. * Log an assertion to the error log
  1501. * @param szExp The assertion that failed
  1502. * @param szFile The file the assertion is in
  1503. * @param nLine The line the assertion is defined on
  1504. }
  1505. procedure ap_log_assert(szExp, szFile: PChar; nLine: Integer);
  1506. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1507. external LibHTTPD name LibNamePrefix + 'ap_log_assert' + LibSuff12;
  1508. { @internal }
  1509. //#define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
  1510. {
  1511. * Redefine assert() to something more useful for an Apache...
  1512. *
  1513. * Use ap_assert() if the condition should always be checked.
  1514. * Use AP_DEBUG_ASSERT() if the condition should only be checked when AP_DEBUG
  1515. * is defined.
  1516. }
  1517. {#ifdef AP_DEBUG
  1518. #define AP_DEBUG_ASSERT(exp) ap_assert(exp)
  1519. #else
  1520. #define AP_DEBUG_ASSERT(exp) ((void)0)
  1521. #endif}
  1522. {
  1523. * @defgroup stopsignal flags which indicate places where the sever should stop for debugging.
  1524. * @
  1525. * A set of flags which indicate places where the server should raise(SIGSTOP).
  1526. * This is useful for debugging, because you can then attach to that process
  1527. * with gdb and continue. This is important in cases where one_process
  1528. * debugging isn't possible.
  1529. }
  1530. { stop on a Detach }
  1531. // SIGSTOP_DETACH = 1;
  1532. { stop making a child process }
  1533. // SIGSTOP_MAKE_CHILD = 2;
  1534. { stop spawning a child process }
  1535. // SIGSTOP_SPAWN_CHILD = 4;
  1536. { stop spawning a child process with a piped log }
  1537. // SIGSTOP_PIPED_LOG_SPAWN = 8;
  1538. { stop spawning a CGI child process }
  1539. // SIGSTOP_CGI_CHILD = 16;
  1540. { Macro to get GDB started }
  1541. {#ifdef DEBUG_SIGSTOP
  1542. extern int raise_sigstop_flags;
  1543. #define RAISE_SIGSTOP(x) do begin
  1544. if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
  1545. end while (0)
  1546. #else
  1547. #define RAISE_SIGSTOP(x)
  1548. #endif }
  1549. {
  1550. * Get HTML describing the address and (optionally) admin of the server.
  1551. * @param prefix Text which is prepended to the return value
  1552. * @param r The request_rec
  1553. * @return HTML describing the server, allocated in @a r's pool.
  1554. }
  1555. function ap_psignature(prefix: PChar; r: Prequest_rec): PChar;
  1556. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  1557. external LibHTTPD name LibNamePrefix + 'ap_psignature' + LibSuff8;
  1558. {const
  1559. AP_NORESTART = APR_OS_START_USEERR + 1;}