httpd.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. unit httpd;
  23. {$ifdef fpc}
  24. {$mode delphi}{$H+}
  25. {$endif}
  26. {$IFNDEF FPC}
  27. {$DEFINE WINDOWS}
  28. {$ENDIF}
  29. {$IFDEF WIN32}
  30. {$DEFINE WINDOWS}
  31. {$ENDIF}
  32. {$ifdef Unix}
  33. {$PACKRECORDS C}
  34. {$endif}
  35. {$define Apache2_2}
  36. interface
  37. uses
  38. {$ifdef WINDOWS}
  39. Windows,
  40. {$ELSE}
  41. UnixType,
  42. {$ENDIF}
  43. apr, aprutil, ctypes;
  44. const
  45. {$ifndef fpc}
  46. LineEnding = #13#10;
  47. {$endif}
  48. {$IFDEF WINDOWS}
  49. LibHTTPD = 'libhttpd.dll';
  50. {$ELSE}
  51. LibHTTPD = '';
  52. {$ENDIF}
  53. { Declarations moved here to be on top of all declarations }
  54. { configuration vector structure }
  55. type
  56. ap_conf_vector_t = record end;
  57. Pap_conf_vector_t = ^ap_conf_vector_t;
  58. PPap_conf_vector_t = ^Pap_conf_vector_t;
  59. {
  60. Main httpd header files
  61. Note: There are more include files other then these, because some include files
  62. include more files.
  63. }
  64. {$include ap_provider.inc}
  65. {$include util_cfgtree.inc}
  66. {$include httpd.inc}
  67. {$include http_config.inc}
  68. {$include http_core.inc}
  69. {$include http_log.inc}
  70. {$include http_main.inc}
  71. {$include http_protocol.inc}
  72. {$include http_request.inc}
  73. {$include http_connection.inc}
  74. {$include http_vhost.inc}
  75. {$include util_script.inc}
  76. {$include util_time.inc}
  77. {$include util_md5.inc}
  78. {$include ap_mpm.inc}
  79. implementation
  80. {
  81. Macros transformed into functions in the translation
  82. }
  83. { from httpd.inc }
  84. { Internal representation for a HTTP protocol number, e.g., HTTP/1.1 }
  85. function HTTP_VERSION(major, minor: Integer): Integer;
  86. begin
  87. Result := (1000*(major)+(minor));
  88. end;
  89. { Major part of HTTP protocol }
  90. function HTTP_VERSION_MAJOR(number: Integer): Integer;
  91. begin
  92. Result := number div 1000;
  93. end;
  94. { Minor part of HTTP protocol }
  95. function HTTP_VERSION_MINOR(number: Integer): Integer;
  96. begin
  97. Result := number mod 1000;
  98. end;
  99. function ap_escape_uri(p: Papr_pool_t; const path: PChar): PChar;
  100. begin
  101. Result := ap_os_escape_path(p, path, 1);
  102. end;
  103. { from http_config.inc }
  104. { Use this in all standard modules }
  105. procedure STANDARD20_MODULE_STUFF(var mod_: module);
  106. begin
  107. mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
  108. mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
  109. mod_.module_index := -1;
  110. // mod_.name: PChar;
  111. mod_.dynamic_load_handle := nil;
  112. mod_.next := nil;
  113. mod_.magic := MODULE_MAGIC_COOKIE;
  114. mod_.rewrite_args := nil;
  115. end;
  116. { Use this only in MPMs }
  117. procedure MPM20_MODULE_STUFF(var mod_: module);
  118. begin
  119. mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
  120. mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
  121. mod_.module_index := -1;
  122. // mod_.name: PChar;
  123. mod_.dynamic_load_handle := nil;
  124. mod_.next := nil;
  125. mod_.magic := MODULE_MAGIC_COOKIE;
  126. end;
  127. function ap_get_module_config(v: Pap_conf_vector_t; m: Pmodule): Pap_conf_vector_t;
  128. begin
  129. Result := Pointer(Integer(v) + m^.module_index);
  130. end;
  131. procedure ap_set_module_config(v: Pap_conf_vector_t; m: Pmodule; val: Pap_conf_vector_t);
  132. var
  133. P: PPointer;
  134. begin
  135. P := PPointer(Integer(v) + m^.module_index);
  136. P^ := val;
  137. end;
  138. end.