apr.pas 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. {
  2. apr.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. { Copyright 2000-2005 The Apache Software Foundation or its licensors, as
  8. * applicable.
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * 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 apr;
  23. interface
  24. {$ifdef fpc}
  25. {$mode delphi}{$H+}
  26. {$endif}
  27. {$IFNDEF FPC}
  28. {$DEFINE WINDOWS}
  29. {$ENDIF}
  30. {$IFDEF WIN32}
  31. {$DEFINE WINDOWS}
  32. {$ENDIF}
  33. {$ifdef Unix}
  34. {$PACKRECORDS C}
  35. {$endif}
  36. {$define Apache2_0}
  37. uses
  38. {$ifdef WINDOWS}
  39. Windows, winsock,
  40. {$ELSE}
  41. UnixType,
  42. {$ENDIF}
  43. SysUtils, ctypes;
  44. const
  45. {$IFDEF WINDOWS}
  46. LibAPR = 'libapr.dll';
  47. {$ELSE}
  48. LibAPR = '';
  49. {$ENDIF}
  50. {$IFDEF WINDOWS}
  51. LibNamePrefix = '_';
  52. LibSuff0 = '@0';
  53. LibSuff4 = '@4';
  54. LibSuff8 = '@8';
  55. LibSuff12 = '@12';
  56. LibSuff16 = '@16';
  57. LibSuff20 = '@20';
  58. LibSuff24 = '@24';
  59. LibSuff28 = '@28';
  60. LibSuff32 = '@32';
  61. {$ELSE}
  62. LibNamePrefix = '';
  63. LibSuff0 = '';
  64. LibSuff4 = '';
  65. LibSuff8 = '';
  66. LibSuff12 = '';
  67. LibSuff16 = '';
  68. LibSuff20 = '';
  69. LibSuff24 = '';
  70. LibSuff28 = '';
  71. LibSuff32 = '';
  72. {$ENDIF}
  73. type
  74. uid_t = Integer;
  75. gid_t = Integer;
  76. time_t = LongInt;
  77. size_t = Integer;
  78. pid_t = Integer;
  79. Ppid_t = ^pid_t;
  80. apr_uint16_t = Word;
  81. apr_uint32_t = Cardinal;
  82. apr_int64_t = Int64;
  83. apr_uint64_t = Int64;
  84. apr_socklen_t = Integer;
  85. apr_uint32_tso_handle_t = cuint;
  86. type
  87. {$IFDEF WINDOWS}
  88. apr_off_t = Int64;
  89. {$ENDIF}
  90. {$IFDEF UNIX}
  91. {$ifdef CPU64}
  92. apr_off_t = int64;
  93. {$else}
  94. apr_off_t = Integer;
  95. {$endif}
  96. {$ENDIF}
  97. apr_int32_t = Integer;
  98. Papr_int32_t = ^Integer;
  99. apr_size_t = size_t;
  100. Papr_size_t = ^apr_size_t;
  101. apr_int16_t = SmallInt;
  102. Papr_int16_t = ^SmallInt;
  103. // Network structures
  104. sockaddr = record
  105. sa_family: cushort; // address family, AF_xxx
  106. sa_data: array [1..14] of Char; // (NBO) 14 bytes of protocol address
  107. end;
  108. {$ifndef windows}
  109. va_list = Pointer;
  110. in_addr = record
  111. s_addr: culong; // load with inet_aton()
  112. end;
  113. sockaddr_in = record
  114. sin_family: cshort; // e.g. AF_INET
  115. sin_port: cushort; // e.g. htons(3490)
  116. sin_addr: in_addr; // see struct in_addr, below
  117. sin_zero: array [1..8] of Char; // zero this if you want to
  118. end;
  119. {$endif}
  120. in6_addr = record
  121. Case Integer of
  122. 1: (u6_addr8: array [1..16] of Byte);
  123. 2: (u6_addr16: array [1..8] of Word);
  124. 3: (u6_addr32: array [1..4] of Cardinal);
  125. end;
  126. //#define s6_addr in6_u.u6_addr8
  127. //#define s6_addr16 in6_u.u6_addr16
  128. //#define s6_addr32 in6_u.u6_addr32
  129. sockaddr_in6 = record
  130. sin6_family: cushort;
  131. sin6_port: Word;
  132. sin6_flowinfo: Cardinal;
  133. sin6_addr: in6_addr;
  134. sin6_scope_id: Cardinal;
  135. end;
  136. // TEMPORARY
  137. Papr_xml_ns_scope = Pointer;
  138. Pap_method_list_t = Pointer;
  139. Pcore_output_filter_ctx_t = Pointer;
  140. Pap_directive_t = Pointer;
  141. Pap_filter_t = Pointer;
  142. Papr_file_t = Pointer;
  143. Papr_off_t = Pointer;
  144. iovec = record
  145. /// byte count to read/write
  146. iov_len: culong;
  147. /// data to be read/written
  148. iov_base: PChar;
  149. end;
  150. Piovec = ^iovec;
  151. {$include apr_errno.inc}
  152. {$include apr_pools.inc}
  153. {$include apr_general.inc}
  154. {$include apr_dso.inc}
  155. {$include apr_user.inc}
  156. {$include apr_time.inc}
  157. {$include apr_tables.inc}
  158. {$include apr_file_info.inc}
  159. {$include apr_file_io.inc}
  160. {$include apr_strings.inc}
  161. {$include apr_lib.inc}
  162. {$include apr_signal.inc}
  163. {$include apr_network_io.inc}
  164. {.$include apr_portable.inc}
  165. {.$include ../aprutils/apr_uri.inc}
  166. {$include apr_thread_proc.inc}
  167. {$include apr_version.inc}
  168. {$include apr_poll.inc}
  169. implementation
  170. {
  171. Macros transformed into functions in the translation
  172. }
  173. { apr_pools.inc }
  174. {$ifndef DOXYGEN}
  175. function apr_pool_create(newpool: PPapr_pool_t; parent: Papr_pool_t): apr_status_t;
  176. begin
  177. Result := apr_pool_create_ex(newpool, parent, nil, nil);
  178. end;
  179. {$endif}
  180. function apr_pool_sub_make(newpool: PPapr_pool_t; parent: Papr_pool_t;
  181. abort_fn: apr_abortfunc_t): apr_status_t;
  182. begin
  183. Result := apr_pool_create_ex(newpool, parent, abort_fn, nil);
  184. end;
  185. { apr_lib.inc }
  186. function apr_tolower(c: Char): Char;
  187. var
  188. buf: array[0..1] of Char;
  189. begin
  190. buf[0] := c;
  191. buf[1] := #0;
  192. buf := StrLower(@buf[0]);
  193. Result := buf[0];
  194. end;
  195. function apr_toupper(c: Char): Char;
  196. var
  197. buf: array[0..1] of Char;
  198. begin
  199. buf[0] := c;
  200. buf[1] := #0;
  201. buf := StrUpper(@buf[0]);
  202. Result := buf[0];
  203. end;
  204. end.