1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
{
apr.pas
Copyright (C) 2006 Felipe Monteiro de Carvalho
This unit is a pascal binding for the Apache 2.0.58 headers.
The headers were released under the following copyright:
}
{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
}
unit apr;
interface
{$ifdef fpc}
{$mode delphi}{$H+}
{$endif}
{$IFNDEF FPC}
{$DEFINE WINDOWS}
{$ENDIF}
{$IFDEF WIN32}
{$DEFINE WINDOWS}
{$ENDIF}
{$ifdef Unix}
{$PACKRECORDS C}
{$endif}
uses
{$ifdef WINDOWS}
Windows, winsock,
{$ELSE}
UnixType,
{$ENDIF}
SysUtils, ctypes;
const
{$IFDEF WINDOWS}
LibAPR = 'libapr-1.dll';
{$ELSE}
LibAPR = '';
{$ENDIF}
{$IFDEF WINDOWS}
LibNamePrefix = '_';
LibSuff0 = '@0';
LibSuff4 = '@4';
LibSuff8 = '@8';
LibSuff12 = '@12';
LibSuff16 = '@16';
LibSuff20 = '@20';
LibSuff24 = '@24';
LibSuff28 = '@28';
LibSuff32 = '@32';
{$ELSE}
LibNamePrefix = '';
LibSuff0 = '';
LibSuff4 = '';
LibSuff8 = '';
LibSuff12 = '';
LibSuff16 = '';
LibSuff20 = '';
LibSuff24 = '';
LibSuff28 = '';
LibSuff32 = '';
{$ENDIF}
type
uid_t = Integer;
gid_t = Integer;
time_t = LongInt;
size_t = Integer;
pid_t = Integer;
Ppid_t = ^pid_t;
apr_uint16_t = Word;
apr_uint32_t = Cardinal;
papr_uint32_t = ^apr_uint32_t;
apr_int64_t = Int64;
papr_int64_t = ^apr_int64_t;
apr_uint64_t = Int64;
papr_uint64_t = ^apr_uint64_t;
apr_socklen_t = Integer;
apr_byte_t = Byte;
papr_byte_t = ^apr_byte_t;
apr_uint32_tso_handle_t = cuint;
type
apr_off_t = Int64;
apr_int32_t = Integer;
Papr_int32_t = ^Integer;
apr_size_t = size_t;
Papr_size_t = ^apr_size_t;
apr_int16_t = SmallInt;
Papr_int16_t = ^SmallInt;
// Network structures
sockaddr = record
sa_family: cushort; // address family, AF_xxx
sa_data: array [1..14] of Char; // (NBO) 14 bytes of protocol address
end;
in_addr = record
s_addr: culong; // load with inet_aton()
end;
{$ifndef windows}
va_list = Pointer;
sockaddr_in = record
sin_family: cshort; // e.g. AF_INET
sin_port: cushort; // e.g. htons(3490)
sin_addr: in_addr; // see struct in_addr, below
sin_zero: array [1..8] of Char; // zero this if you want to
end;
{$endif}
in6_addr = record
Case Integer of
1: (u6_addr8: array [1..16] of Byte);
2: (u6_addr16: array [1..8] of Word);
3: (u6_addr32: array [1..4] of Cardinal);
end;
//#define s6_addr in6_u.u6_addr8
//#define s6_addr16 in6_u.u6_addr16
//#define s6_addr32 in6_u.u6_addr32
sockaddr_in6 = record
sin6_family: cushort;
sin6_port: Word;
sin6_flowinfo: Cardinal;
sin6_addr: in6_addr;
sin6_scope_id: Cardinal;
end;
// TEMPORARY
Papr_xml_ns_scope = Pointer;
Pap_method_list_t = Pointer;
Pcore_output_filter_ctx_t = Pointer;
Pap_directive_t = Pointer;
Pap_filter_t = Pointer;
Papr_file_t = Pointer;
Papr_off_t = Pointer;
iovec = record
/// byte count to read/write
iov_len: culong;
/// data to be read/written
iov_base: PChar;
end;
Piovec = ^iovec;
{$include apr_errno.inc}
{$include apr_pools.inc}
{$include apr_general.inc}
{$include apr_dso.inc}
{$include apr_user.inc}
{$include apr_time.inc}
{$include apr_tables.inc}
{$include apr_file_info.inc}
{$include apr_file_io.inc}
{$include apr_strings.inc}
{$include apr_lib.inc}
{$include apr_signal.inc}
{$include apr_network_io.inc}
{$include apr_hash.inc}
{.$include apr_portable.inc}
{.$include ../aprutils/apr_uri.inc}
{$include apr_thread_proc.inc}
{$include apr_version.inc}
{$include apr_poll.inc}
implementation
{
Macros transformed into functions in the translation
}
{ apr_pools.inc }
{$ifndef DOXYGEN}
function apr_pool_create(newpool: PPapr_pool_t; parent: Papr_pool_t): apr_status_t;
begin
Result := apr_pool_create_ex(newpool, parent, nil, nil);
end;
{$endif}
function apr_pool_sub_make(newpool: PPapr_pool_t; parent: Papr_pool_t;
abort_fn: apr_abortfunc_t): apr_status_t;
begin
Result := apr_pool_create_ex(newpool, parent, abort_fn, nil);
end;
{ apr_lib.inc }
function apr_tolower(c: Char): Char;
var
buf: array[0..1] of Char;
begin
buf[0] := c;
buf[1] := #0;
buf := StrLower(@buf[0]);
Result := buf[0];
end;
function apr_toupper(c: Char): Char;
var
buf: array[0..1] of Char;
begin
buf[0] := c;
buf[1] := #0;
buf := StrUpper(@buf[0]);
Result := buf[0];
end;
end.
|