httpd.pas 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. {
  2. httpd.pas
  3. Copyright (C) 2006 Felipe Monteiro de Carvalho
  4. This unit is a pascal binding for the Apache 2.0.58 headers.
  5. The headers were released under the following copyright:
  6. }
  7. { Licensed to the Apache Software Foundation (ASF) under one or more
  8. * contributor license agreements. See the NOTICE file distributed with
  9. * this work for additional information regarding copyright ownership.
  10. * The ASF licenses this file to You under the Apache License, Version 2.0
  11. * (the "License"); you may not use this file except in compliance with
  12. * the License. You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. }
  22. {$IFNDEF FPC_DOTTEDUNITS}
  23. unit httpd;
  24. {$ENDIF FPC_DOTTEDUNITS}
  25. {$ifdef fpc}
  26. {$mode delphi}
  27. {$H-}
  28. {$modeswitch unicodestrings-}
  29. {$endif}
  30. {$IFNDEF FPC}
  31. {$DEFINE WINDOWS}
  32. {$ENDIF}
  33. {$IFDEF WIN32}
  34. {$DEFINE WINDOWS}
  35. {$ENDIF}
  36. {$ifdef Unix}
  37. {$PACKRECORDS C}
  38. {$endif}
  39. {$define Apache2_2}
  40. interface
  41. {$IFDEF FPC_DOTTEDUNITS}
  42. uses
  43. {$ifdef Windows}
  44. WinApi.Windows,
  45. {$ELSE}
  46. UnixApi.Types,
  47. {$ENDIF}
  48. Api.Httpd22.Apr, Api.Httpd22.Aprutil, System.CTypes;
  49. {$ELSE FPC_DOTTEDUNITS}
  50. uses
  51. {$ifdef WINDOWS}
  52. Windows,
  53. {$ELSE}
  54. UnixType,
  55. {$ENDIF}
  56. apr, aprutil, ctypes;
  57. {$ENDIF FPC_DOTTEDUNITS}
  58. const
  59. {$ifndef fpc}
  60. LineEnding = #13#10;
  61. {$endif}
  62. {$IFDEF WINDOWS}
  63. LibHTTPD = 'libhttpd.dll';
  64. {$ELSE}
  65. LibHTTPD = '';
  66. {$ENDIF}
  67. { Declarations moved here to be on top of all declarations }
  68. { configuration vector structure }
  69. type
  70. ap_conf_vector_t = record end;
  71. Pap_conf_vector_t = ^ap_conf_vector_t;
  72. PPap_conf_vector_t = ^Pap_conf_vector_t;
  73. {
  74. Main httpd header files
  75. Note: There are more include files other then these, because some include files
  76. include more files.
  77. }
  78. {$include ap_provider.inc}
  79. {$include util_cfgtree.inc}
  80. {$include httpd.inc}
  81. {$include http_config.inc}
  82. {$include http_core.inc}
  83. {$include http_log.inc}
  84. {$include http_main.inc}
  85. {$include http_protocol.inc}
  86. {$include http_request.inc}
  87. {$include http_connection.inc}
  88. {$include http_vhost.inc}
  89. {$include util_script.inc}
  90. {$include util_time.inc}
  91. {$include util_md5.inc}
  92. {$include ap_mpm.inc}
  93. implementation
  94. {
  95. Macros transformed into functions in the translation
  96. }
  97. { from httpd.inc }
  98. { Internal representation for a HTTP protocol number, e.g., HTTP/1.1 }
  99. function HTTP_VERSION(major, minor: Integer): Integer;
  100. begin
  101. Result := (1000*(major)+(minor));
  102. end;
  103. { Major part of HTTP protocol }
  104. function HTTP_VERSION_MAJOR(number: Integer): Integer;
  105. begin
  106. Result := number div 1000;
  107. end;
  108. { Minor part of HTTP protocol }
  109. function HTTP_VERSION_MINOR(number: Integer): Integer;
  110. begin
  111. Result := number mod 1000;
  112. end;
  113. function ap_escape_uri(p: Papr_pool_t; const path: PAnsiChar): PAnsiChar;
  114. begin
  115. Result := ap_os_escape_path(p, path, 1);
  116. end;
  117. { from http_config.inc }
  118. { Use this in all standard modules }
  119. procedure STANDARD20_MODULE_STUFF(var mod_: module);
  120. begin
  121. mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
  122. mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
  123. mod_.module_index := -1;
  124. // mod_.name: PAnsiChar;
  125. mod_.dynamic_load_handle := nil;
  126. mod_.next := nil;
  127. mod_.magic := MODULE_MAGIC_COOKIE;
  128. mod_.rewrite_args := nil;
  129. end;
  130. { Use this only in MPMs }
  131. procedure MPM20_MODULE_STUFF(var mod_: module);
  132. begin
  133. mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
  134. mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
  135. mod_.module_index := -1;
  136. // mod_.name: PAnsiChar;
  137. mod_.dynamic_load_handle := nil;
  138. mod_.next := nil;
  139. mod_.magic := MODULE_MAGIC_COOKIE;
  140. end;
  141. function ap_get_module_config(v: Pap_conf_vector_t; m: Pmodule): Pap_conf_vector_t;
  142. begin
  143. Result := Pointer(Integer(v) + m^.module_index);
  144. end;
  145. procedure ap_set_module_config(v: Pap_conf_vector_t; m: Pmodule; val: Pap_conf_vector_t);
  146. var
  147. P: PPointer;
  148. begin
  149. P := PPointer(Integer(v) + m^.module_index);
  150. P^ := val;
  151. end;
  152. end.