Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
86 #define APR_FOPEN_SPARSE 0x08000
90 #define APR_FOPEN_ROTATING 0x10000
92 #define APR_FOPEN_MANUAL_ROTATE 0x20000
94 #define APR_FOPEN_NONBLOCK 0x40000
99 /* backcompat */
100 #define APR_READ APR_FOPEN_READ
101 #define APR_WRITE APR_FOPEN_WRITE
102 #define APR_CREATE APR_FOPEN_CREATE
103 #define APR_APPEND APR_FOPEN_APPEND
104 #define APR_TRUNCATE APR_FOPEN_TRUNCATE
105 #define APR_BINARY APR_FOPEN_BINARY
106 #define APR_EXCL APR_FOPEN_EXCL
107 #define APR_BUFFERED APR_FOPEN_BUFFERED
108 #define APR_DELONCLOSE APR_FOPEN_DELONCLOSE
109 #define APR_XTHREAD APR_FOPEN_XTHREAD
110 #define APR_SHARELOCK APR_FOPEN_SHARELOCK
111 #define APR_FILE_NOCLEANUP APR_FOPEN_NOCLEANUP
112 #define APR_SENDFILE_ENABLED APR_FOPEN_SENDFILE_ENABLED
113 #define APR_LARGEFILE APR_FOPEN_LARGEFILE
150 /* flags for apr_file_seek */
151 
152 #define APR_SET SEEK_SET
153 
154 #define APR_CUR SEEK_CUR
155 
156 #define APR_END SEEK_END
157 
164 /* flags for apr_file_attrs_set */
165 #define APR_FILE_ATTR_READONLY 0x01
166 #define APR_FILE_ATTR_EXECUTABLE 0x02
167 #define APR_FILE_ATTR_HIDDEN 0x04
174 #if defined(DOXYGEN)
175 #define APR_MAX_IOVEC_SIZE 1024
177 #elif defined(IOV_MAX)
178 #define APR_MAX_IOVEC_SIZE IOV_MAX
179 #elif defined(MAX_IOVEC)
180 #define APR_MAX_IOVEC_SIZE MAX_IOVEC
181 #else
182 #define APR_MAX_IOVEC_SIZE 1024
183 #endif
184 
188 
190 typedef int apr_seek_where_t;
191 
195 typedef struct apr_file_t apr_file_t;
196 
197 /* File lock types/flags */
203 #define APR_FLOCK_SHARED 1
209 #define APR_FLOCK_EXCLUSIVE 2
214 #define APR_FLOCK_TYPEMASK 0x000F
215 #define APR_FLOCK_NONBLOCK 0x0010
259 APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **newf, const char *fname,
260  apr_int32_t flag, apr_fileperms_t perm,
261  apr_pool_t *pool);
262 
268 
277 
287 APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path,
288  const char *to_path,
289  apr_pool_t *pool);
290 
297 APR_DECLARE(apr_status_t) apr_file_link(const char *from_path,
298  const char *to_path);
299 
312 APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path,
313  const char *to_path,
314  apr_fileperms_t perms,
315  apr_pool_t *pool);
316 
328 APR_DECLARE(apr_status_t) apr_file_append(const char *from_path,
329  const char *to_path,
330  apr_fileperms_t perms,
331  apr_pool_t *pool);
332 
339 
356  apr_pool_t *pool);
357 
366  apr_pool_t *pool);
367 
376  apr_pool_t *pool);
377 
397  apr_pool_t *pool);
398 
417  apr_int32_t flags,
418  apr_pool_t *pool);
419 
438  apr_int32_t flags,
439  apr_pool_t *pool);
440 
458 APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf,
459  apr_size_t *nbytes);
460 
476 APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf,
477  apr_size_t *nbytes);
478 
495  const struct iovec *vec,
496  apr_size_t nvec, apr_size_t *nbytes);
497 
519  apr_size_t nbytes,
520  apr_size_t *bytes_read);
521 
543  const void *buf,
544  apr_size_t nbytes,
545  apr_size_t *bytes_written);
546 
547 
562  const struct iovec *vec,
563  apr_size_t nvec,
564  apr_size_t *nbytes);
571 
577 APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile);
578 
585 
594 APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len,
595  apr_file_t *thefile);
596 
602 APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile);
603 
613 
619 
625 
631 
640  apr_file_t *old_file,
641  apr_pool_t *p);
642 
652  apr_file_t *old_file,
653  apr_pool_t *p);
654 
667  apr_file_t *old_file,
668  apr_pool_t *p);
669 
682  char * buffer,
684 
690 
703  apr_seek_where_t where,
704  apr_off_t *offset);
705 
720  apr_file_t **out,
721  apr_pool_t *pool);
722 
744  apr_file_t **out,
746  apr_pool_t *pool);
747 
770  apr_file_t **out,
771  apr_int32_t blocking,
772  apr_pool_t *pool_in,
773  apr_pool_t *pool_out);
774 
781 APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename,
782  apr_fileperms_t perm,
783  apr_pool_t *pool);
784 
792 
800  apr_interval_time_t timeout);
801 
813 APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type);
814 
820 
828 APR_DECLARE(apr_status_t) apr_file_name_get(const char **new_path,
829  apr_file_t *thefile);
830 
837 APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key,
838  apr_file_t *file);
839 
848  const char *key,
849  apr_status_t (*cleanup)(void *));
850 
859  const char *format, ...)
860  __attribute__((format(printf,2,3)));
861 
875  apr_fileperms_t perms);
876 
893 APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname,
894  apr_fileattrs_t attributes,
895  apr_fileattrs_t attr_mask,
896  apr_pool_t *pool);
897 
906 APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname,
907  apr_time_t mtime,
908  apr_pool_t *pool);
909 
916 APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm,
917  apr_pool_t *pool);
918 
927  apr_fileperms_t perm,
928  apr_pool_t *pool);
929 
937 APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *pool);
938 
946  apr_int32_t wanted,
947  apr_file_t *thefile);
948 
949 
957 
964 
969 
975 
980 
999  apr_int32_t flags, apr_pool_t *p);
1000 
1001 
1011 APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir,
1012  apr_pool_t *p);
1013 
1014 
1017 
1021 #ifdef __cplusplus
1022 }
1023 #endif
1024 
1025 #endif /* ! APR_FILE_IO_H */
apr_status_t apr_file_flush(apr_file_t *thefile)
enum apr_file_t::@15 blocking
size_t apr_size_t
Definition: apr.h:375
apr_status_t apr_file_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t *pool)
apr_status_t apr_file_open_flags_stdout(apr_file_t **thefile, apr_int32_t flags, apr_pool_t *pool)
apr_status_t apr_file_lock(apr_file_t *thefile, int type)
apr_status_t apr_file_copy(const char *from_path, const char *to_path, apr_fileperms_t perms, apr_pool_t *pool)
char * fname
Definition: apr_arch_file_io.h:110
apr_status_t apr_file_name_get(const char **new_path, apr_file_t *thefile)
apr_status_t apr_file_pipe_wait(apr_file_t *thepipe, apr_wait_type_t direction)
Definition: apr_arch_file_io.h:107
apr_status_t apr_file_remove(const char *path, apr_pool_t *pool)
apr_status_t apr_file_mtime_set(const char *fname, apr_time_t mtime, apr_pool_t *pool)
apr_status_t apr_file_eof(apr_file_t *fptr)
apr_status_t __attribute__((nonnull(1)))
APR File Information.
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:556
apr_status_t apr_temp_dir_get(const char **temp_dir, apr_pool_t *p)
APR_POOL_DECLARE_ACCESSOR(file)
apr_status_t apr_dir_remove(const char *path, apr_pool_t *pool)
apr_status_t apr_file_open_flags_stderr(apr_file_t **thefile, apr_int32_t flags, apr_pool_t *pool)
apr_status_t apr_file_sync(apr_file_t *thefile)
apr_status_t apr_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted, apr_file_t *thefile)
APR File Handle Inheritance Helpers.
apr_finfo_t * finfo
Definition: apr_arch_file_io.h:170
#define APR_DECLARE_NONSTD(x)
Definition: macros.h:7
apr_status_t apr_file_read_full(apr_file_t *thefile, void *buf, apr_size_t nbytes, apr_size_t *bytes_read)
apr_int32_t apr_file_flags_get(apr_file_t *f)
apr_status_t apr_file_read(apr_file_t *thefile, void *buf, apr_size_t *nbytes)
apr_status_t apr_file_datasync(apr_file_t *thefile)
apr_status_t apr_file_unlock(apr_file_t *thefile)
apr_status_t apr_file_puts(const char *str, apr_file_t *thefile)
apr_status_t apr_file_setaside(apr_file_t **new_file, apr_file_t *old_file, apr_pool_t *p)
apr_int64_t apr_interval_time_t
Definition: apr_time.h:55
apr_status_t apr_file_rotating_manual_check(apr_file_t *thefile, apr_time_t time)
apr_status_t apr_file_write_full(apr_file_t *thefile, const void *buf, apr_size_t nbytes, apr_size_t *bytes_written)
apr_status_t apr_file_dup2(apr_file_t *new_file, apr_file_t *old_file, apr_pool_t *p)
apr_status_t apr_file_open_flags_stdin(apr_file_t **thefile, apr_int32_t flags, apr_pool_t *pool)
apr_status_t apr_file_append(const char *from_path, const char *to_path, apr_fileperms_t perms, apr_pool_t *pool)
apr_status_t apr_dir_make(const char *path, apr_fileperms_t perm, apr_pool_t *pool)
apr_int64_t apr_time_t
Definition: apr_time.h:45
APR memory allocation.
apr_status_t apr_file_namedpipe_create(const char *filename, apr_fileperms_t perm, apr_pool_t *pool)
apr_status_t apr_file_trunc(apr_file_t *fp, apr_off_t offset)
apr_status_t apr_file_open_stderr(apr_file_t **thefile, apr_pool_t *pool)
apr_int32_t apr_fileperms_t
Definition: apr_file_info.h:125
apr_status_t apr_file_gets(char *str, int len, apr_file_t *thefile)
apr_status_t apr_file_open_stdout(apr_file_t **thefile, apr_pool_t *pool)
int direction
Definition: apr_arch_file_io.h:127
apr_status_t apr_file_data_set(apr_file_t *file, void *data, const char *key, apr_status_t(*cleanup)(void *))
APR Error Codes.
apr_status_t apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *pool)
char * buffer
Definition: apr_arch_file_io.h:123
int apr_file_printf(apr_file_t *fptr, const char *format,...) __attribute__((format(printf
unsigned int apr_uint32_t
Definition: apr.h:334
APR Platform Definitions.
apr_status_t apr_file_pipe_timeout_get(apr_file_t *thepipe, apr_interval_time_t *timeout)
apr_status_t apr_file_mktemp(apr_file_t **fp, char *templ, apr_int32_t flags, apr_pool_t *p)
apr_wait_type_t
Definition: apr_general.h:71
apr_status_t apr_file_dup(apr_file_t **new_file, apr_file_t *old_file, apr_pool_t *p)
apr_status_t apr_file_seek(apr_file_t *thefile, apr_seek_where_t where, apr_off_t *offset)
apr_status_t apr_file_pipe_create_ex(apr_file_t **in, apr_file_t **out, apr_int32_t blocking, apr_pool_t *pool)
APR_DECLARE_INHERIT_SET(file)
apr_uint32_t apr_fileattrs_t
Definition: apr_file_io.h:208
apr_interval_time_t timeout
Definition: apr_arch_file_io.h:114
apr_status_t apr_file_writev(apr_file_t *thefile, const struct iovec *vec, apr_size_t nvec, apr_size_t *nbytes)
apr_pool_t * p
apr_status_t apr_file_pipe_timeout_set(apr_file_t *thepipe, apr_interval_time_t timeout)
apr_status_t apr_file_data_get(void **data, const char *key, apr_file_t *file)
apr_size_t bufsize
Definition: apr_arch_file_io.h:125
#define APR_DECLARE(x)
Definition: macros.h:6
apr_status_t apr_file_close(apr_file_t *file)
apr_status_t apr_file_rotating_check(apr_file_t *thefile)
dav_buffer const char * str
Definition: mod_dav.h:465
apr_status_t apr_file_rename(const char *from_path, const char *to_path, apr_pool_t *pool)
apr_status_t apr_file_getc(char *ch, apr_file_t *thefile)
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
int apr_status_t
Definition: apr_errno.h:44
int apr_status_t apr_file_perms_set(const char *fname, apr_fileperms_t perms)
apr_status_t apr_dir_make_recursive(const char *path, apr_fileperms_t perm, apr_pool_t *pool)
apr_status_t apr_file_pipe_create_pools(apr_file_t **in, apr_file_t **out, apr_int32_t blocking, apr_pool_t *pool_in, apr_pool_t *pool_out)
APR Time Library.
apr_size_t apr_file_buffer_size_get(apr_file_t *thefile)
dav_resource int dav_locktoken dav_response int flags
Definition: mod_dav.h:1350
apr_status_t apr_file_writev_full(apr_file_t *thefile, const struct iovec *vec, apr_size_t nvec, apr_size_t *nbytes)
apr_status_t apr_file_ungetc(char ch, apr_file_t *thefile)
apr_status_t apr_file_attrs_set(const char *fname, apr_fileattrs_t attributes, apr_fileattrs_t attr_mask, apr_pool_t *pool)
off_t apr_off_t
Definition: apr.h:377
Definition: apr_file_info.h:174
apr_status_t apr_file_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes)
APR_DECLARE_INHERIT_UNSET(file)
int apr_seek_where_t
Definition: apr_file_io.h:211
apr_status_t apr_file_putc(char ch, apr_file_t *thefile)
apr_status_t apr_file_link(const char *from_path, const char *to_path)
int apr_int32_t
Definition: apr.h:333
apr_status_t apr_file_buffer_set(apr_file_t *thefile, char *buffer, apr_size_t bufsize)