apr  1.7.0
About: APR (Apache Portable Runtime) project offers software libraries that provide a predictable and consistent interface to underlying platform-specific implementations (APR core library).
  Fossies Dox: apr-1.7.0.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

apr_file_io.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. 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 #ifndef APR_FILE_IO_H
18 #define APR_FILE_IO_H
19 
25 #include "apr.h"
26 #include "apr_pools.h"
27 #include "apr_time.h"
28 #include "apr_errno.h"
29 #include "apr_file_info.h"
30 #include "apr_inherit.h"
31 
32 #define APR_WANT_STDIO
33 #define APR_WANT_IOVEC
34 #include "apr_want.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39 
51 /* Note to implementors: Values in the range 0x00100000--0x80000000
52  are reserved for platform-specific values. */
53 
54 #define APR_FOPEN_READ 0x00001
55 #define APR_FOPEN_WRITE 0x00002
56 #define APR_FOPEN_CREATE 0x00004
57 #define APR_FOPEN_APPEND 0x00008
58 #define APR_FOPEN_TRUNCATE 0x00010
60 #define APR_FOPEN_BINARY 0x00020
63 #define APR_FOPEN_EXCL 0x00040
65 #define APR_FOPEN_BUFFERED 0x00080
66 #define APR_FOPEN_DELONCLOSE 0x00100
67 #define APR_FOPEN_XTHREAD 0x00200
70 #define APR_FOPEN_SHARELOCK 0x00400
74 #define APR_FOPEN_NOCLEANUP 0x00800
79 #define APR_FOPEN_SENDFILE_ENABLED 0x01000
82 #define APR_FOPEN_LARGEFILE 0x04000
85 #define APR_FOPEN_SPARSE 0x08000
88 #define APR_FOPEN_NONBLOCK 0x40000
92 /* backcompat */
93 #define APR_READ APR_FOPEN_READ
94 #define APR_WRITE APR_FOPEN_WRITE
95 #define APR_CREATE APR_FOPEN_CREATE
96 #define APR_APPEND APR_FOPEN_APPEND
97 #define APR_TRUNCATE APR_FOPEN_TRUNCATE
98 #define APR_BINARY APR_FOPEN_BINARY
99 #define APR_EXCL APR_FOPEN_EXCL
100 #define APR_BUFFERED APR_FOPEN_BUFFERED
101 #define APR_DELONCLOSE APR_FOPEN_DELONCLOSE
102 #define APR_XTHREAD APR_FOPEN_XTHREAD
103 #define APR_SHARELOCK APR_FOPEN_SHARELOCK
104 #define APR_FILE_NOCLEANUP APR_FOPEN_NOCLEANUP
105 #define APR_SENDFILE_ENABLED APR_FOPEN_SENDFILE_ENABLED
106 #define APR_LARGEFILE APR_FOPEN_LARGEFILE
143 /* flags for apr_file_seek */
144 
145 #define APR_SET SEEK_SET
146 
147 #define APR_CUR SEEK_CUR
148 
149 #define APR_END SEEK_END
150 
157 /* flags for apr_file_attrs_set */
158 #define APR_FILE_ATTR_READONLY 0x01
159 #define APR_FILE_ATTR_EXECUTABLE 0x02
160 #define APR_FILE_ATTR_HIDDEN 0x04
167 #if defined(DOXYGEN)
168 #define APR_MAX_IOVEC_SIZE 1024
170 #elif defined(IOV_MAX)
171 #define APR_MAX_IOVEC_SIZE IOV_MAX
172 #elif defined(MAX_IOVEC)
173 #define APR_MAX_IOVEC_SIZE MAX_IOVEC
174 #else
175 #define APR_MAX_IOVEC_SIZE 1024
176 #endif
177 
180 typedef apr_uint32_t apr_fileattrs_t;
181 
183 typedef int apr_seek_where_t;
184 
188 typedef struct apr_file_t apr_file_t;
189 
190 /* File lock types/flags */
196 #define APR_FLOCK_SHARED 1
202 #define APR_FLOCK_EXCLUSIVE 2
207 #define APR_FLOCK_TYPEMASK 0x000F
208 #define APR_FLOCK_NONBLOCK 0x0010
250 APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **newf, const char *fname,
251  apr_int32_t flag, apr_fileperms_t perm,
252  apr_pool_t *pool);
253 
258 APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file);
259 
267 APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool);
268 
278 APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path,
279  const char *to_path,
280  apr_pool_t *pool);
281 
288 APR_DECLARE(apr_status_t) apr_file_link(const char *from_path,
289  const char *to_path);
290 
303 APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path,
304  const char *to_path,
306  apr_pool_t *pool);
307 
323 APR_DECLARE(apr_status_t) apr_file_append(const char *from_path,
324  const char *to_path,
326  apr_pool_t *pool);
327 
333 APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr);
334 
350 APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile,
351  apr_pool_t *pool);
352 
360 APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile,
361  apr_pool_t *pool);
362 
370 APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile,
371  apr_pool_t *pool);
372 
390 APR_DECLARE(apr_status_t) apr_file_open_flags_stderr(apr_file_t **thefile,
391  apr_int32_t flags,
392  apr_pool_t *pool);
393 
411 APR_DECLARE(apr_status_t) apr_file_open_flags_stdout(apr_file_t **thefile,
412  apr_int32_t flags,
413  apr_pool_t *pool);
414 
432 APR_DECLARE(apr_status_t) apr_file_open_flags_stdin(apr_file_t **thefile,
433  apr_int32_t flags,
434  apr_pool_t *pool);
435 
453 APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf,
454  apr_size_t *nbytes);
455 
471 APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf,
472  apr_size_t *nbytes);
473 
489 APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile,
490  const struct iovec *vec,
491  apr_size_t nvec, apr_size_t *nbytes);
492 
513 APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, void *buf,
514  apr_size_t nbytes,
515  apr_size_t *bytes_read);
516 
537 APR_DECLARE(apr_status_t) apr_file_write_full(apr_file_t *thefile,
538  const void *buf,
539  apr_size_t nbytes,
540  apr_size_t *bytes_written);
541 
542 
556 APR_DECLARE(apr_status_t) apr_file_writev_full(apr_file_t *thefile,
557  const struct iovec *vec,
558  apr_size_t nvec,
559  apr_size_t *nbytes);
565 APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile);
566 
572 APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile);
573 
579 APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile);
580 
589 APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len,
591 
597 APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile);
598 
603 APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile);
604 
609 APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile);
610 
615 APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile);
616 
624 APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file,
626  apr_pool_t *p);
627 
636 APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file,
638  apr_pool_t *p);
639 
651 APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file,
653  apr_pool_t *p);
654 
666 APR_DECLARE(apr_status_t) apr_file_buffer_set(apr_file_t *thefile,
667  char * buffer,
668  apr_size_t bufsize);
669 
674 APR_DECLARE(apr_size_t) apr_file_buffer_size_get(apr_file_t *thefile);
675 
687 APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile,
689  apr_off_t *offset);
690 
704 APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in,
705  apr_file_t **out,
706  apr_pool_t *pool);
707 
728 APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in,
729  apr_file_t **out,
730  apr_int32_t blocking,
731  apr_pool_t *pool);
732 
754 APR_DECLARE(apr_status_t) apr_file_pipe_create_pools(apr_file_t **in,
755  apr_file_t **out,
756  apr_int32_t blocking,
759 
766 APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename,
768  apr_pool_t *pool);
769 
775 APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe,
777 
784 APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe,
786 
799 
805 
813 APR_DECLARE(apr_status_t) apr_file_name_get(const char **new_path,
815 
822 APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key,
823  apr_file_t *file);
824 
832 APR_DECLARE(apr_status_t) apr_file_data_set(apr_file_t *file, void *data,
833  const char *key,
834  apr_status_t (*cleanup)(void *));
835 
843 APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr,
844  const char *format, ...)
845  __attribute__((format(printf,2,3)));
846 
859 APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname,
861 
878 APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname,
881  apr_pool_t *pool);
882 
891 APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname,
893  apr_pool_t *pool);
894 
902  apr_pool_t *pool);
903 
913  apr_pool_t *pool);
914 
923 
930 APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo,
931  apr_int32_t wanted,
933 
934 
942 
948 APR_DECLARE(apr_int32_t) apr_file_flags_get(apr_file_t *f);
949 
954 
960 
965 
983 APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *templ,
984  apr_int32_t flags, apr_pool_t *p);
985 
986 
996 APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir,
997  apr_pool_t *p);
998 
1001 #ifdef __cplusplus
1002 }
1003 #endif
1004 
1005 #endif /* ! APR_FILE_IO_H */
cleanup
void const char apr_status_t(* cleanup)(void *))
Definition: apr_file_io.h:863
pool
const char apr_int32_t apr_fileperms_t apr_pool_t * pool
Definition: apr_file_io.h:279
APR_DECLARE_NONSTD
APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr
Definition: readwrite.c:353
len
int len
Definition: apr_file_io.h:618
apr_file_lock
apr_status_t apr_file_lock(apr_file_t *thefile, int type)
Definition: flock.c:21
apr_errno.h
APR Error Codes.
data
void * data
Definition: apr_file_io.h:861
bytes_written
const void apr_size_t apr_size_t * bytes_written
Definition: apr_file_io.h:567
APR_DECLARE_INHERIT_UNSET
#define APR_DECLARE_INHERIT_UNSET(type)
Definition: apr_inherit.h:47
buf
void * buf
Definition: apr_file_io.h:482
pool_out
apr_file_t apr_int32_t apr_pool_t apr_pool_t * pool_out
Definition: apr_file_io.h:784
str
char ** str
Definition: apr_cstr.h:125
apr_seek_where_t
int apr_seek_where_t
Definition: apr_file_io.h:203
apr_fileperms_t
apr_int32_t apr_fileperms_t
Definition: apr_file_info.h:125
apr_file_trunc
apr_status_t apr_file_trunc(apr_file_t *fp, apr_off_t offset)
Definition: seek.c:99
timeout
IN ULONG IN INT timeout
Definition: apr_arch_misc.h:477
perm
const char apr_int32_t apr_fileperms_t perm
Definition: apr_file_io.h:279
blocking
apr_file_t apr_int32_t blocking
Definition: apr_file_io.h:758
to_path
const char * to_path
Definition: apr_file_io.h:308
nvec
const struct iovec apr_size_t nvec
Definition: apr_file_io.h:519
apr_file_unlock
apr_status_t apr_file_unlock(apr_file_t *thefile)
Definition: flock.c:33
p
apr_file_t apr_pool_t * p
Definition: apr_file_io.h:654
offset
apr_seek_where_t apr_off_t * offset
Definition: apr_file_io.h:717
attributes
apr_fileattrs_t attributes
Definition: apr_file_io.h:908
old_file
apr_file_t * old_file
Definition: apr_file_io.h:654
apr_time.h
APR Time Library.
filename
apr_size_t const char * filename
Definition: apr_shm.h:71
thefile
apr_file_t * thefile
Definition: apr_file_io.h:594
buffer
char * buffer
Definition: apr_file_io.h:696
format
const char * format
Definition: apr_file_io.h:873
perms
const char apr_fileperms_t perms
Definition: apr_file_io.h:333
vec
const struct iovec * vec
Definition: apr_file_io.h:519
flag
const char apr_int32_t flag
Definition: apr_file_io.h:279
apr_dir_make
apr_status_t apr_dir_make(const char *path, apr_fileperms_t perm, apr_pool_t *pool)
Definition: dir.c:297
apr_interval_time_t
apr_int64_t apr_interval_time_t
Definition: apr_time.h:55
apr_finfo_t
Definition: apr_file_info.h:174
apr_file_info.h
APR File Information.
flags
apr_int32_t flags
Definition: apr_file_io.h:420
APR_DECLARE
APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **newf
Definition: apr_atomic.c:21
apr_file_t::finfo
apr_finfo_t * finfo
Definition: apr_arch_file_io.h:171
path
const char * path
Definition: apr_escape.h:187
where
apr_seek_where_t where
Definition: apr_file_io.h:717
mtime
apr_time_t mtime
Definition: apr_file_io.h:921
wanted
apr_int32_t wanted
Definition: apr_file_io.h:960
out
apr_file_t ** out
Definition: apr_file_io.h:734
apr_file_t
Definition: apr_arch_file_io.h:97
pool_in
apr_file_t apr_int32_t apr_pool_t * pool_in
Definition: apr_file_io.h:784
apr_pool_t
Definition: apr_pools.c:577
in
apr_int32_t in
Definition: apr_thread_proc.h:427
fname
const char * fname
Definition: apr_file_io.h:279
templ
char * templ
Definition: apr_file_io.h:1012
apr_time_t
apr_int64_t apr_time_t
Definition: apr_time.h:45
apr_dir_remove
apr_status_t apr_dir_remove(const char *path, apr_pool_t *pool)
Definition: dir.c:343
type
int type
Definition: apr_file_io.h:827
APR_DECLARE_INHERIT_SET
#define APR_DECLARE_INHERIT_SET(type)
Definition: apr_inherit.h:35
apr_status_t
int apr_status_t
Definition: apr_errno.h:44
apr_dir_make_recursive
apr_status_t apr_dir_make_recursive(const char *path, apr_fileperms_t perm, apr_pool_t *pool)
Definition: dir_make_recurse.c:63
bytes_read
void apr_size_t apr_size_t * bytes_read
Definition: apr_file_io.h:542
bufsize
char apr_size_t bufsize
Definition: apr_file_io.h:696
nbytes
void apr_size_t * nbytes
Definition: apr_file_io.h:482
apr_pools.h
APR memory allocation.
file
const char apr_file_t * file
Definition: apr_file_io.h:851
key
const char * key
Definition: apr_file_io.h:851
APR_POOL_DECLARE_ACCESSOR
#define APR_POOL_DECLARE_ACCESSOR(type)
Definition: apr_pools.h:81
apr_fileattrs_t
apr_uint32_t apr_fileattrs_t
Definition: apr_file_io.h:200
__attribute__
const char __attribute__((format(printf, 2, 3)))
attr_mask
apr_fileattrs_t apr_fileattrs_t attr_mask
Definition: apr_file_io.h:908
apr_inherit.h
APR File Handle Inheritance Helpers.