~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/packages/base/httpd/httpd-2.0/apr/apr_file_io.inc

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 }
 
16
 
 
17
{
 
18
 * @file apr_file_io.h
 
19
 * @brief APR File I/O Handling
 
20
 }
 
21
 
 
22
{#include "apr.h"
 
23
#include "apr_pools.h"
 
24
#include "apr_time.h"
 
25
#include "apr_errno.h"}
 
26
{.$include apr_file_info.inc}
 
27
{#include "apr_inherit.h"}
 
28
 
 
29
//#define APR_WANT_STDIO          {< for SEEK_* }
 
30
//#define APR_WANT_IOVEC          {< for apr_file_writev }
 
31
//#include "apr_want.h"
 
32
 
 
33
{
 
34
 * @defgroup apr_file_io File I/O Handling Functions
 
35
 * @ingroup APR 
 
36
 }
 
37
 
 
38
{
 
39
 * @defgroup apr_file_open_flags File Open Flags/Routines
 
40
 }
 
41
 
 
42
{ Note to implementors: Values in the range 0x00100000--0x80000000
 
43
   are reserved for platform-specific values. }
 
44
 
 
45
const
 
46
  APR_READ =      $00001;     {< Open the file for reading }
 
47
  APR_WRITE =     $00002;     {< Open the file for writing }
 
48
  APR_CREATE =    $00004;     {< Create the file if not there }
 
49
  APR_APPEND =    $00008;     {< Append to the end of the file }
 
50
  APR_TRUNCATE =  $00010;     {< Open the file and truncate to 0 length }
 
51
  APR_BINARY =    $00020;     {< Open the file in binary mode }
 
52
  APR_EXCL =      $00040;     {< Open should fail if APR_CREATE and file
 
53
                                        exists. }
 
54
  APR_BUFFERED =  $00080;     {< Open the file for buffered I/O }
 
55
  APR_DELONCLOSE =$00100;     {< Delete the file after close }
 
56
  APR_XTHREAD =   $00200;     {< Platform dependent tag to open the file
 
57
                                        for use across multiple threads }
 
58
  APR_SHARELOCK = $00400;     {< Platform dependent support for higher
 
59
                                        level locked read/write access to support
 
60
                                        writes across process/machines }
 
61
  APR_FILE_NOCLEANUP =$00800; {< Do not register a cleanup when the file
 
62
                                        is opened }
 
63
  APR_SENDFILE_ENABLED =$01000; {< Advisory flag that this file should
 
64
                                          support apr_sendfile operation }
 
65
  APR_LARGEFILE =  $04000;    {< Platform dependent flag to enable large file
 
66
                                        support; WARNING see below. }
 
67
 
 
68
{ @warning The APR_LARGEFILE flag only has effect on some platforms
 
69
 * where sizeof(apr_off_t) == 4.  Where implemented, it allows opening
 
70
 * and writing to a file which exceeds the size which can be
 
71
 * represented by apr_off_t (2 gigabytes).  When a file's size does
 
72
 * exceed 2Gb, apr_file_info_get() will fail with an error on the
 
73
 * descriptor, likewise apr_stat()/apr_lstat() will fail on the
 
74
 * filename.  apr_dir_read() will fail with APR_INCOMPLETE on a
 
75
 * directory entry for a large file depending on the particular
 
76
 * APR_FINFO_* flags.  Generally, it is not recommended to use this
 
77
 * flag. }
 
78
 
 
79
{
 
80
 * @defgroup apr_file_seek_flags File Seek Flags
 
81
 }
 
82
 
 
83
{
 
84
 * @defgroup apr_file_attrs_set_flags File Attribute Flags
 
85
 }
 
86
 
 
87
{ flags for apr_file_attrs_set }
 
88
  APR_FILE_ATTR_READONLY =  $01;          {< File is read-only }
 
89
  APR_FILE_ATTR_EXECUTABLE =$02;          {< File is executable }
 
90
  APR_FILE_ATTR_HIDDEN =    $04;          {< File is hidden }
 
91
 
 
92
{ File attributes }
 
93
type
 
94
  apr_fileattrs_t = apr_uint32_t;
 
95
 
 
96
{ should be same as whence type in lseek, POSIX defines this as int }
 
97
  apr_seek_where_t = Integer;
 
98
 
 
99
{
 
100
 * Structure for referencing files.
 
101
 }
 
102
  apr_file_t = record end;
 
103
//  Papr_file_t = ^apr_file_t;
 
104
  PPapr_file_t = ^Papr_file_t;
 
105
 
 
106
{ File lock types/flags }
 
107
{
 
108
 * @defgroup apr_file_lock_types File Lock Types
 
109
 }
 
110
 
 
111
const
 
112
  APR_FLOCK_SHARED =       1;       {< Shared lock. More than one process
 
113
                                           or thread can hold a shared lock
 
114
                                           at any given time. Essentially,
 
115
                                           this is a "read lock", preventing
 
116
                                           writers from establishing an
 
117
                                           exclusive lock. }
 
118
  APR_FLOCK_EXCLUSIVE =    2;       {< Exclusive lock. Only one process
 
119
                                           may hold an exclusive lock at any
 
120
                                           given time. This is analogous to
 
121
                                           a "write lock". }
 
122
 
 
123
  APR_FLOCK_TYPEMASK =     $000F;  {< mask to extract lock type }
 
124
  APR_FLOCK_NONBLOCK =     $0010;  {< do not block while acquiring the
 
125
                                           file lock }
 
126
{
 
127
 * Open the specified file.
 
128
 * @param newf The opened file descriptor.
 
129
 * @param fname The full path to the file (using / on all systems)
 
130
 * @param flag Or'ed value of:
 
131
 * <PRE>
 
132
 *         APR_READ              open for reading
 
133
 *         APR_WRITE             open for writing
 
134
 *         APR_CREATE            create the file if not there
 
135
 *         APR_APPEND            file ptr is set to end prior to all writes
 
136
 *         APR_TRUNCATE          set length to zero if file exists
 
137
 *         APR_BINARY            not a text file (This flag is ignored on 
 
138
 *                               UNIX because it has no meaning)
 
139
 *         APR_BUFFERED          buffer the data.  Default is non-buffered
 
140
 *         APR_EXCL              return error if APR_CREATE and file exists
 
141
 *         APR_DELONCLOSE        delete the file after closing.
 
142
 *         APR_XTHREAD           Platform dependent tag to open the file
 
143
 *                               for use across multiple threads
 
144
 *         APR_SHARELOCK         Platform dependent support for higher
 
145
 *                               level locked read/write access to support
 
146
 *                               writes across process/machines
 
147
 *         APR_FILE_NOCLEANUP    Do not register a cleanup with the pool 
 
148
 *                               passed in on the <EM>cont</EM> argument (see below).
 
149
 *                               The apr_os_file_t handle in apr_file_t will not
 
150
 *                               be closed when the pool is destroyed.
 
151
 *         APR_SENDFILE_ENABLED  Open with appropriate platform semantics
 
152
 *                               for sendfile operations.  Advisory only,
 
153
 *                               apr_sendfile does not check this flag.
 
154
 * </PRE>
 
155
 * @param perm Access permissions for file.
 
156
 * @param pool The pool to use.
 
157
 * @remark If perm is APR_OS_DEFAULT and the file is being created, appropriate 
 
158
 *      default permissions will be used.  *arg1 must point to a valid file_t, 
 
159
 *      or NULL (in which case it will be allocated)
 
160
 }
 
161
function apr_file_open(newf: PPapr_file_t; const fname: PChar;
 
162
 flag: apr_int32_t; perm: apr_fileperms_t;
 
163
 pool: Papr_pool_t): apr_status_t;
 
164
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
165
 external LibAPR name LibNamePrefix + 'apr_file_open' + LibSuff20;
 
166
 
 
167
{
 
168
 * Close the specified file.
 
169
 * @param file The file descriptor to close.
 
170
 }
 
171
function apr_file_close(file_: Papr_file_t): apr_status_t;
 
172
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
173
 external LibAPR name LibNamePrefix + 'apr_file_close' + LibSuff4;
 
174
 
 
175
{
 
176
 * delete the specified file.
 
177
 * @param path The full path to the file (using / on all systems)
 
178
 * @param cont The pool to use.
 
179
 * @remark If the file is open, it won't be removed until all instances are closed.
 
180
 }
 
181
function apr_file_remove(const path: PChar; cont: Papr_pool_t): apr_status_t;
 
182
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
183
 external LibAPR name LibNamePrefix + 'apr_file_remove' + LibSuff8;
 
184
 
 
185
{
 
186
 * rename the specified file.
 
187
 * @param from_path The full path to the original file (using / on all systems)
 
188
 * @param to_path The full path to the new file (using / on all systems)
 
189
 * @param pool The pool to use.
 
190
 * @warning If a file exists at the new location, then it will be overwritten.  
 
191
 *      Moving files or directories across devices may not be possible.
 
192
 }
 
193
function apr_file_rename(const from_path, to_path: PChar; pool: Papr_pool_t): apr_status_t;
 
194
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
195
 external LibAPR name LibNamePrefix + 'apr_file_rename' + LibSuff12;
 
196
 
 
197
{
 
198
 * copy the specified file to another file.
 
199
 * @param from_path The full path to the original file (using / on all systems)
 
200
 * @param to_path The full path to the new file (using / on all systems)
 
201
 * @param perms Access permissions for the new file if it is created.
 
202
 *     In place of the usual or'd combination of file permissions, the
 
203
 *     value APR_FILE_SOURCE_PERMS may be given, in which case the source
 
204
 *     file's permissions are copied.
 
205
 * @param pool The pool to use.
 
206
 * @remark The new file does not need to exist, it will be created if required.
 
207
 * @warning If the new file already exists, its contents will be overwritten.
 
208
 }
 
209
function apr_file_copy(const from_path, to_path: PChar;
 
210
 perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
 
211
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
212
 external LibAPR name LibNamePrefix + 'apr_file_copy' + LibSuff16;
 
213
 
 
214
{
 
215
 * append the specified file to another file.
 
216
 * @param from_path The full path to the source file (using / on all systems)
 
217
 * @param to_path The full path to the destination file (using / on all systems)
 
218
 * @param perms Access permissions for the destination file if it is created.
 
219
 *     In place of the usual or'd combination of file permissions, the
 
220
 *     value APR_FILE_SOURCE_PERMS may be given, in which case the source
 
221
 *     file's permissions are copied.
 
222
 * @param pool The pool to use.
 
223
 * @remark The new file does not need to exist, it will be created if required.
 
224
 }
 
225
function apr_file_append(const from_path, to_path: PChar;
 
226
 perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
 
227
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
228
 external LibAPR name LibNamePrefix + 'apr_file_append' + LibSuff16;
 
229
 
 
230
{
 
231
 * Are we at the end of the file
 
232
 * @param fptr The apr file we are testing.
 
233
 * @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise.
 
234
 }
 
235
function apr_file_eof(fptr: Papr_file_t): apr_status_t;
 
236
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
237
 external LibAPR name LibNamePrefix + 'apr_file_eof' + LibSuff4;
 
238
 
 
239
{
 
240
 * open standard error as an apr file pointer.
 
241
 * @param thefile The apr file to use as stderr.
 
242
 * @param cont The pool to allocate the file out of.
 
243
 * 
 
244
 * @remark The only reason that the apr_file_open_std* functions exist
 
245
 * is that you may not always have a stderr/out/in on Windows.  This
 
246
 * is generally a problem with newer versions of Windows and services.
 
247
 * 
 
248
 * The other problem is that the C library functions generally work
 
249
 * differently on Windows and Unix.  So, by using apr_file_open_std*
 
250
 * functions, you can get a handle to an APR struct that works with
 
251
 * the APR functions which are supposed to work identically on all
 
252
 * platforms.
 
253
 }
 
254
function apr_file_open_stderr(thefile: PPapr_file_t;
 
255
 cont: Papr_pool_t): apr_status_t;
 
256
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
257
 external LibAPR name LibNamePrefix + 'apr_file_open_stderr' + LibSuff8;
 
258
 
 
259
{
 
260
 * open standard output as an apr file pointer.
 
261
 * @param thefile The apr file to use as stdout.
 
262
 * @param cont The pool to allocate the file out of.
 
263
 * 
 
264
 * @remark The only reason that the apr_file_open_std* functions exist
 
265
 * is that you may not always have a stderr/out/in on Windows.  This
 
266
 * is generally a problem with newer versions of Windows and services.
 
267
 * 
 
268
 * The other problem is that the C library functions generally work
 
269
 * differently on Windows and Unix.  So, by using apr_file_open_std*
 
270
 * functions, you can get a handle to an APR struct that works with
 
271
 * the APR functions which are supposed to work identically on all
 
272
 * platforms.
 
273
 }
 
274
function apr_file_open_stdout(thefile: PPapr_file_t;
 
275
 cont: Papr_pool_t): apr_status_t;
 
276
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
277
 external LibAPR name LibNamePrefix + 'apr_file_open_stdout' + LibSuff8;
 
278
 
 
279
{
 
280
 * open standard input as an apr file pointer.
 
281
 * @param thefile The apr file to use as stdin.
 
282
 * @param cont The pool to allocate the file out of.
 
283
 * 
 
284
 * @remark The only reason that the apr_file_open_std* functions exist
 
285
 * is that you may not always have a stderr/out/in on Windows.  This
 
286
 * is generally a problem with newer versions of Windows and services.
 
287
 * 
 
288
 * The other problem is that the C library functions generally work
 
289
 * differently on Windows and Unix.  So, by using apr_file_open_std*
 
290
 * functions, you can get a handle to an APR struct that works with
 
291
 * the APR functions which are supposed to work identically on all
 
292
 * platforms.
 
293
 }
 
294
function apr_file_open_stdin(thefile: PPapr_file_t;
 
295
 cont: Papr_pool_t): apr_status_t;
 
296
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
297
 external LibAPR name LibNamePrefix + 'apr_file_open_stdin' + LibSuff8;
 
298
 
 
299
{
 
300
 * Read data from the specified file.
 
301
 * @param thefile The file descriptor to read from.
 
302
 * @param buf The buffer to store the data to.
 
303
 * @param nbytes On entry, the number of bytes to read; on exit, the number of bytes read.
 
304
 * @remark apr_file_read will read up to the specified number of bytes, but 
 
305
 *         never more.  If there isn't enough data to fill that number of 
 
306
 *         bytes, all of the available data is read.  The third argument is 
 
307
 *         modified to reflect the number of bytes read.  If a char was put 
 
308
 *         back into the stream via ungetc, it will be the first character 
 
309
 *         returned. 
 
310
 *
 
311
 *         It is not possible for both bytes to be read and an APR_EOF or other 
 
312
 *         error to be returned.
 
313
 *
 
314
 *         APR_EINTR is never returned.
 
315
 }
 
316
function apr_file_read(thefile: Papr_file_t; buf: Pointer;
 
317
 nbytes: Papr_size_t): apr_status_t;
 
318
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
319
 external LibAPR name LibNamePrefix + 'apr_file_read' + LibSuff12;
 
320
 
 
321
{
 
322
 * Write data to the specified file.
 
323
 * @param thefile The file descriptor to write to.
 
324
 * @param buf The buffer which contains the data.
 
325
 * @param nbytes On entry, the number of bytes to write; on exit, the number 
 
326
 *               of bytes written.
 
327
 * @remark apr_file_write will write up to the specified number of bytes, but never 
 
328
 *      more.  If the OS cannot write that many bytes, it will write as many 
 
329
 *      as it can.  The third argument is modified to reflect the * number 
 
330
 *      of bytes written. 
 
331
 *
 
332
 *      It is possible for both bytes to be written and an error to be returned.
 
333
 *
 
334
 *      APR_EINTR is never returned.
 
335
 }
 
336
function apr_file_write(thefile: Papr_file_t; buf: Pointer;
 
337
 nbytes: Papr_size_t): apr_status_t;
 
338
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
339
 external LibAPR name LibNamePrefix + 'apr_file_write' + LibSuff12;
 
340
 
 
341
{
 
342
 * Write data from iovec array to the specified file.
 
343
 * @param thefile The file descriptor to write to.
 
344
 * @param vec The array from which to get the data to write to the file.
 
345
 * @param nvec The number of elements in the struct iovec array. This must 
 
346
 *             be smaller than APR_MAX_IOVEC_SIZE.  If it isn't, the function 
 
347
 *             will fail with APR_EINVAL.
 
348
 * @param nbytes The number of bytes written.
 
349
 * @remark It is possible for both bytes to be written and an error to be returned.
 
350
 *      APR_EINTR is never returned.
 
351
 *
 
352
 *      apr_file_writev is available even if the underlying operating system 
 
353
 *
 
354
 *      doesn't provide writev().
 
355
 }
 
356
function apr_file_writev(thefile: Papr_file_t; const vec: Piovec;
 
357
 nvec: apr_size_t; nbytes: Papr_size_t): apr_status_t;
 
358
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
359
 external LibAPR name LibNamePrefix + 'apr_file_writev' + LibSuff16;
 
360
 
 
361
{
 
362
 * Read data from the specified file, ensuring that the buffer is filled
 
363
 * before returning.
 
364
 * @param thefile The file descriptor to read from.
 
365
 * @param buf The buffer to store the data to.
 
366
 * @param nbytes The number of bytes to read.
 
367
 * @param bytes_read If non-NULL, this will contain the number of bytes read.
 
368
 * @remark apr_file_read will read up to the specified number of bytes, but never 
 
369
 *      more.  If there isn't enough data to fill that number of bytes, 
 
370
 *      then the process/thread will block until it is available or EOF 
 
371
 *      is reached.  If a char was put back into the stream via ungetc, 
 
372
 *      it will be the first character returned. 
 
373
 *
 
374
 *      It is possible for both bytes to be read and an error to be 
 
375
 *      returned.  And if *bytes_read is less than nbytes, an
 
376
 *      accompanying error is _always_ returned.
 
377
 *
 
378
 *      APR_EINTR is never returned.
 
379
 }
 
380
function apr_file_read_full(thefile: Papr_file_t; buf: Pointer;
 
381
 nbytes: apr_size_t; bytes_read: Papr_size_t): apr_status_t;
 
382
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
383
 external LibAPR name LibNamePrefix + 'apr_file_read_full' + LibSuff16;
 
384
 
 
385
{
 
386
 * Write data to the specified file, ensuring that all of the data is
 
387
 * written before returning.
 
388
 * @param thefile The file descriptor to write to.
 
389
 * @param buf The buffer which contains the data.
 
390
 * @param nbytes The number of bytes to write.
 
391
 * @param bytes_written If non-NULL, this will contain the number of bytes written.
 
392
 * @remark apr_file_write will write up to the specified number of bytes, but never 
 
393
 *      more.  If the OS cannot write that many bytes, the process/thread 
 
394
 *      will block until they can be written. Exceptional error such as 
 
395
 *      "out of space" or "pipe closed" will terminate with an error.
 
396
 *
 
397
 *      It is possible for both bytes to be written and an error to be 
 
398
 *      returned.  And if *bytes_written is less than nbytes, an
 
399
 *      accompanying error is _always_ returned.
 
400
 *
 
401
 *      APR_EINTR is never returned.
 
402
 }
 
403
function apr_file_write_full(thefile: Papr_file_t; buf: Pointer;
 
404
 nbytes: apr_size_t; bytes_written: Papr_size_t): apr_status_t;
 
405
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
406
 external LibAPR name LibNamePrefix + 'apr_file_write_full' + LibSuff16;
 
407
 
 
408
{
 
409
 * put a character into the specified file.
 
410
 * @param ch The character to write.
 
411
 * @param thefile The file descriptor to write to
 
412
 }
 
413
function apr_file_putc(ch: Char; thefile: Papr_file_t): apr_status_t;
 
414
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
415
 external LibAPR name LibNamePrefix + 'apr_file_putc' + LibSuff8;
 
416
 
 
417
{
 
418
 * get a character from the specified file.
 
419
 * @param ch The character to read into
 
420
 * @param thefile The file descriptor to read from
 
421
 }
 
422
function apr_file_getc(ch: PChar; thefile: Papr_file_t): apr_status_t;
 
423
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
424
 external LibAPR name LibNamePrefix + 'apr_file_getc' + LibSuff8;
 
425
 
 
426
{
 
427
 * put a character back onto a specified stream.
 
428
 * @param ch The character to write.
 
429
 * @param thefile The file descriptor to write to
 
430
 }
 
431
function apr_file_ungetc(ch: Char; thefile: PPapr_file_t): apr_status_t;
 
432
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
433
 external LibAPR name LibNamePrefix + 'apr_file_ungetc' + LibSuff8;
 
434
 
 
435
{
 
436
 * Get a string from a specified file.
 
437
 * @param str The buffer to store the string in. 
 
438
 * @param len The length of the string
 
439
 * @param thefile The file descriptor to read from
 
440
 * @remark The buffer will be '\0'-terminated if any characters are stored.
 
441
 }
 
442
function apr_file_gets(str: PChar; len: Integer;
 
443
 thefile: Papr_file_t): apr_status_t;
 
444
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
445
 external LibAPR name LibNamePrefix + 'apr_file_gets' + LibSuff12;
 
446
 
 
447
{
 
448
 * Put the string into a specified file.
 
449
 * @param str The string to write. 
 
450
 * @param thefile The file descriptor to write to
 
451
 }
 
452
function apr_file_puts(const str: PChar; thefile: Papr_file_t): apr_status_t;
 
453
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
454
 external LibAPR name LibNamePrefix + 'apr_file_puts' + LibSuff8;
 
455
 
 
456
{
 
457
 * Flush the file's buffer.
 
458
 * @param thefile The file descriptor to flush
 
459
 }
 
460
function apr_file_flush(thefile: PPapr_file_t): apr_status_t;
 
461
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
462
 external LibAPR name LibNamePrefix + 'apr_file_flush' + LibSuff4;
 
463
 
 
464
{
 
465
 * duplicate the specified file descriptor.
 
466
 * @param new_file The structure to duplicate into. 
 
467
 * @param old_file The file to duplicate.
 
468
 * @param p The pool to use for the new file.
 
469
 * @remark *new_file must point to a valid apr_file_t, or point to NULL
 
470
 }
 
471
function apr_file_dup(new_file: PPapr_file_t; old_file: PPapr_file_t;
 
472
 p: Papr_pool_t): apr_status_t;
 
473
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
474
 external LibAPR name LibNamePrefix + 'apr_file_dup' + LibSuff12;
 
475
 
 
476
{
 
477
 * duplicate the specified file descriptor and close the original
 
478
 * @param new_file The old file that is to be closed and reused
 
479
 * @param old_file The file to duplicate
 
480
 * @param p        The pool to use for the new file
 
481
 *
 
482
 * @remark new_file MUST point at a valid apr_file_t. It cannot be NULL
 
483
 }
 
484
function apr_file_dup2(new_file: PPapr_file_t; old_file: PPapr_file_t;
 
485
 p: Papr_pool_t): apr_status_t;
 
486
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
487
 external LibAPR name LibNamePrefix + 'apr_file_dup2' + LibSuff12;
 
488
 
 
489
{
 
490
 * move the specified file descriptor to a new pool
 
491
 * @param new_file Pointer in which to return the new apr_file_t
 
492
 * @param old_file The file to move
 
493
 * @param p        The pool to which the descriptor is to be moved
 
494
 * @remark Unlike apr_file_dup2(), this function doesn't do an
 
495
 *         OS dup() operation on the underlying descriptor; it just
 
496
 *         moves the descriptor's apr_file_t wrapper to a new pool.
 
497
 * @remark The new pool need not be an ancestor of old_file's pool.
 
498
 * @remark After calling this function, old_file may not be used
 
499
 }
 
500
function apr_file_setaside(new_file: PPapr_file_t; old_file: PPapr_file_t;
 
501
 p: Papr_pool_t): apr_status_t;
 
502
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
503
 external LibAPR name LibNamePrefix + 'apr_file_setaside' + LibSuff12;
 
504
 
 
505
{
 
506
 * Move the read/write file offset to a specified byte within a file.
 
507
 * @param thefile The file descriptor
 
508
 * @param where How to move the pointer, one of:
 
509
 * <PRE>
 
510
 *            APR_SET  --  set the offset to offset
 
511
 *            APR_CUR  --  add the offset to the current position 
 
512
 *            APR_END  --  add the offset to the current file size 
 
513
 * </PRE>
 
514
 * @param offset The offset to move the pointer to.
 
515
 * @remark The third argument is modified to be the offset the pointer
 
516
          was actually moved to.
 
517
 }
 
518
function apr_file_seek(thefile: Papr_file_t;
 
519
 where: apr_seek_where_t; offset: Papr_off_t): apr_status_t;
 
520
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
521
 external LibAPR name LibNamePrefix + 'apr_file_seek' + LibSuff12;
 
522
 
 
523
{
 
524
 * Create an anonymous pipe.
 
525
 * @param in The file descriptor to use as input to the pipe.
 
526
 * @param out The file descriptor to use as output from the pipe.
 
527
 * @param cont The pool to operate on.
 
528
 }
 
529
function apr_file_pipe_create(in_: PPapr_file_t; out_: PPapr_file_t;
 
530
 cont: Papr_pool_t): apr_status_t;
 
531
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
532
 external LibAPR name LibNamePrefix + 'apr_file_pipe_create' + LibSuff12;
 
533
 
 
534
{
 
535
 * Create a named pipe.
 
536
 * @param filename The filename of the named pipe
 
537
 * @param perm The permissions for the newly created pipe.
 
538
 * @param cont The pool to operate on.
 
539
 }
 
540
function apr_file_namedpipe_create(const filename: PChar;
 
541
 perm: apr_fileperms_t; cont: Papr_pool_t): apr_status_t;
 
542
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
543
 external LibAPR name LibNamePrefix + 'apr_file_namedpipe_create' + LibSuff12;
 
544
 
 
545
{
 
546
 * Get the timeout value for a pipe or manipulate the blocking state.
 
547
 * @param thepipe The pipe we are getting a timeout for.
 
548
 * @param timeout The current timeout value in microseconds. 
 
549
 }
 
550
function apr_file_pipe_timeout_get(thepipe: Papr_file_t;
 
551
 timeout: Papr_interval_time_t): apr_status_t;
 
552
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
553
 external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_get' + LibSuff8;
 
554
 
 
555
{
 
556
 * Set the timeout value for a pipe or manipulate the blocking state.
 
557
 * @param thepipe The pipe we are setting a timeout on.
 
558
 * @param timeout The timeout value in microseconds.  Values < 0 mean wait 
 
559
 *        forever, 0 means do not wait at all.
 
560
 }
 
561
function apr_file_pipe_timeout_set(thepipe: Papr_file_t;
 
562
 timeout: apr_interval_time_t): apr_status_t;
 
563
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
564
 external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_set' + LibSuff12;
 
565
 
 
566
{ file (un)locking functions. }
 
567
 
 
568
{
 
569
 * Establish a lock on the specified, open file. The lock may be advisory
 
570
 * or mandatory, at the discretion of the platform. The lock applies to
 
571
 * the file as a whole, rather than a specific range. Locks are established
 
572
 * on a per-thread/process basis; a second lock by the same thread will not
 
573
 * block.
 
574
 * @param thefile The file to lock.
 
575
 * @param type The type of lock to establish on the file.
 
576
 }
 
577
function apr_file_lock(thefile: Papr_file_t; type_: Integer): apr_status_t;
 
578
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
579
 external LibAPR name LibNamePrefix + 'apr_file_lock' + LibSuff8;
 
580
 
 
581
{
 
582
 * Remove any outstanding locks on the file.
 
583
 * @param thefile The file to unlock.
 
584
 }
 
585
function apr_file_unlock(thefile: Papr_file_t): apr_status_t;
 
586
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
587
 external LibAPR name LibNamePrefix + 'apr_file_unlock' + LibSuff4;
 
588
 
 
589
{accessor and general file_io functions. }
 
590
 
 
591
{
 
592
 * return the file name of the current file.
 
593
 * @param new_path The path of the file.  
 
594
 * @param thefile The currently open file.
 
595
 }
 
596
function apr_file_name_get(const newpath: PPChar; thefile: Papr_file_t): apr_status_t;
 
597
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
598
 external LibAPR name LibNamePrefix + 'apr_file_name_get' + LibSuff8;
 
599
 
 
600
{
 
601
 * Return the data associated with the current file.
 
602
 * @param data The user data associated with the file.  
 
603
 * @param key The key to use for retreiving data associated with this file.
 
604
 * @param file The currently open file.
 
605
 }
 
606
function apr_file_data_get(data: PPointer; const key: PChar;
 
607
 file_: Papr_file_t): apr_status_t;
 
608
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
609
 external LibAPR name LibNamePrefix + 'apr_file_data_get' + LibSuff12;
 
610
 
 
611
{
 
612
 * Set the data associated with the current file.
 
613
 * @param file The currently open file.
 
614
 * @param data The user data to associate with the file.  
 
615
 * @param key The key to use for assocaiteing data with the file.
 
616
 * @param cleanup The cleanup routine to use when the file is destroyed.
 
617
 }
 
618
//function apr_file_data_set(ch: Char; thefile: PPapr_file_t): apr_status_t;
 
619
// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
620
// external LibAPR name LibNamePrefix + 'apr_file_data_set' + LibSuff4;
 
621
//APR_DECLARE(apr_status_t) (apr_file_t *file, void *data,
 
622
//                                           const char *key,
 
623
//                                           apr_status_t (*cleanup)(void *));
 
624
 
 
625
{
 
626
 * Write a string to a file using a printf format.
 
627
 * @param fptr The file to write to.
 
628
 * @param format The format string
 
629
 * @param ... The values to substitute in the format string
 
630
 * @return The number of bytes written
 
631
 }
 
632
function apr_file_printf(fptr: Papr_file_t; const format: PChar;
 
633
 othres: array of const): Integer;
 
634
 cdecl; external LibAPR name 'apr_file_printf';
 
635
 
 
636
{
 
637
 * set the specified file's permission bits.
 
638
 * @param fname The file (name) to apply the permissions to.
 
639
 * @param perms The permission bits to apply to the file.
 
640
 * @warning Some platforms may not be able to apply all of the available 
 
641
 *      permission bits; APR_INCOMPLETE will be returned if some permissions 
 
642
 *      are specified which could not be set.
 
643
 *
 
644
 *      Platforms which do not implement this feature will return APR_ENOTIMPL.
 
645
 }
 
646
function apr_file_perms_set(const fname: PChar;
 
647
 perms: apr_fileperms_t): apr_status_t;
 
648
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
649
 external LibAPR name LibNamePrefix + 'apr_file_perms_set' + LibSuff8;
 
650
 
 
651
{
 
652
 * Set attributes of the specified file.
 
653
 * @param fname The full path to the file (using / on all systems)
 
654
 * @param attributes Or'd combination of
 
655
 * <PRE>
 
656
 *            APR_FILE_ATTR_READONLY   - make the file readonly
 
657
 *            APR_FILE_ATTR_EXECUTABLE - make the file executable
 
658
 *            APR_FILE_ATTR_HIDDEN     - make the file hidden
 
659
 * </PRE>
 
660
 * @param attr_mask Mask of valid bits in attributes.
 
661
 * @param cont the pool to use.
 
662
 * @remark This function should be used in preference to explict manipulation
 
663
 *      of the file permissions, because the operations to provide these
 
664
 *      attributes are platform specific and may involve more than simply
 
665
 *      setting permission bits.
 
666
 * @warning Platforms which do not implement this feature will return
 
667
 *      APR_ENOTIMPL.
 
668
 }
 
669
function apr_file_attrs_set(const fname: PChar;
 
670
 attributes, attr_mask: apr_fileattrs_t;
 
671
 cont: Papr_pool_t): apr_status_t;
 
672
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
673
 external LibAPR name LibNamePrefix + 'apr_file_attrs_set' + LibSuff16;
 
674
 
 
675
{
 
676
 * Set the mtime of the specified file.
 
677
 * @param fname The full path to the file (using / on all systems)
 
678
 * @param mtime The mtime to apply to the file.
 
679
 * @param pool The pool to use.
 
680
 * @warning Platforms which do not implement this feature will return
 
681
 *      APR_ENOTIMPL.
 
682
 }
 
683
function apr_file_mtime_set(const fname: PChar;
 
684
 mtime: apr_time_t; pool: Papr_pool_t): apr_status_t;
 
685
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
686
 external LibAPR name LibNamePrefix + 'apr_file_mtime_set' + LibSuff16;
 
687
 
 
688
{
 
689
 * Create a new directory on the file system.
 
690
 * @param path the path for the directory to be created.  (use / on all systems)
 
691
 * @param perm Permissions for the new direcoty.
 
692
 * @param cont the pool to use.
 
693
 }
 
694
function apr_dir_make(const path: PChar; perm: apr_fileperms_t;
 
695
 cont: Papr_pool_t): apr_status_t;
 
696
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
697
 external LibAPR name LibNamePrefix + 'apr_dir_make' + LibSuff12;
 
698
 
 
699
{ Creates a new directory on the file system, but behaves like
 
700
 * 'mkdir -p'. Creates intermediate directories as required. No error
 
701
 * will be reported if PATH already exists.
 
702
 * @param path the path for the directory to be created.  (use / on all systems)
 
703
 * @param perm Permissions for the new direcoty.
 
704
 * @param pool the pool to use.
 
705
 }
 
706
function apr_dir_make_recursive(const path: PChar;
 
707
 perm: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
 
708
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
709
 external LibAPR name LibNamePrefix + 'apr_dir_make_recursive' + LibSuff12;
 
710
 
 
711
{
 
712
 * Remove directory from the file system.
 
713
 * @param path the path for the directory to be removed.  (use / on all systems)
 
714
 * @param cont the pool to use.
 
715
 }
 
716
function apr_dir_remove(const path: PChar; cont: Papr_pool_t): apr_status_t;
 
717
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
718
 external LibAPR name LibNamePrefix + 'apr_dir_remove' + LibSuff8;
 
719
 
 
720
{
 
721
 * get the specified file's stats.
 
722
 * @param finfo Where to store the information about the file.
 
723
 * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values 
 
724
 * @param thefile The file to get information about.
 
725
 }
 
726
function apr_file_info_get(finfo: Papr_finfo_t;
 
727
 wanted: apr_int32_t; thefile: Papr_file_t): apr_status_t;
 
728
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
729
 external LibAPR name LibNamePrefix + 'apr_file_info_get' + LibSuff12;
 
730
 
 
731
{
 
732
 * Truncate the file's length to the specified offset
 
733
 * @param fp The file to truncate
 
734
 * @param offset The offset to truncate to.
 
735
 }
 
736
function apr_file_trunc(fp: Papr_file_t; offset: apr_off_t): apr_status_t;
 
737
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
738
 external LibAPR name LibNamePrefix + 'apr_file_trunc' + LibSuff12;
 
739
 
 
740
{
 
741
 * Retrieve the flags that were passed into apr_file_open()
 
742
 * when the file was opened.
 
743
 * @return apr_int32_t the flags
 
744
 }
 
745
function apr_file_flags_get(f: Papr_file_t): apr_int32_t;
 
746
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
747
 external LibAPR name LibNamePrefix + 'apr_file_flags_get' + LibSuff4;
 
748
 
 
749
{
 
750
 * Get the pool used by the file.
 
751
 }
 
752
{APR_POOL_DECLARE_ACCESSOR(file);
 
753
}
 
754
{
 
755
 * Set a file to be inherited by child processes.
 
756
 *
 
757
 }
 
758
{APR_DECLARE_INHERIT_SET(file);
 
759
}
 
760
{ @deprecated @see apr_file_inherit_set }
 
761
{APR_DECLARE(void) apr_file_set_inherit(apr_file_t *file);
 
762
}
 
763
{
 
764
 * Unset a file from being inherited by child processes.
 
765
 }
 
766
{APR_DECLARE_INHERIT_UNSET(file);
 
767
}
 
768
{ @deprecated @see apr_file_inherit_unset }
 
769
{APR_DECLARE(void) apr_file_unset_inherit(apr_file_t *file);
 
770
}
 
771
{
 
772
 * Open a temporary file
 
773
 * @param fp The apr file to use as a temporary file.
 
774
 * @param templ The template to use when creating a temp file.
 
775
 * @param flags The flags to open the file with. If this is zero,
 
776
 *              the file is opened with 
 
777
 *              APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE
 
778
 * @param p The pool to allocate the file out of.
 
779
 * @remark   
 
780
 * This function  generates  a unique temporary file name from template.  
 
781
 * The last six characters of template must be XXXXXX and these are replaced 
 
782
 * with a string that makes the filename unique. Since it will  be  modified,
 
783
 * template must not be a string constant, but should be declared as a character
 
784
 * array.  
 
785
 *
 
786
 }
 
787
function apr_file_mktemp(fp: PPapr_file_t; templ: PChar;
 
788
 flags: apr_int32_t; p: Papr_pool_t): apr_status_t;
 
789
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
790
 external LibAPR name LibNamePrefix + 'apr_file_mktemp' + LibSuff16;
 
791
 
 
792
{
 
793
 * Find an existing directory suitable as a temporary storage location.
 
794
 * @param temp_dir The temp directory.
 
795
 * @param p The pool to use for any necessary allocations.
 
796
 * @remark   
 
797
 * This function uses an algorithm to search for a directory that an
 
798
 * an application can use for temporary storage.  Once such a
 
799
 * directory is found, that location is cached by the library.  Thus,
 
800
 * callers only pay the cost of this algorithm once if that one time
 
801
 * is successful.
 
802
 *
 
803
 }
 
804
function apr_temp_dir_get(const temp_dir: PPChar; p: Papr_pool_t): apr_status_t;
 
805
 {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
 
806
 external LibAPR name LibNamePrefix + 'apr_temp_dir_get' + LibSuff8;
 
807