GME  13
apr_file_io.h
Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APR_FILE_IO_H
00018 #define APR_FILE_IO_H
00019 
00025 #include "apr.h"
00026 #include "apr_pools.h"
00027 #include "apr_time.h"
00028 #include "apr_errno.h"
00029 #include "apr_file_info.h"
00030 #include "apr_inherit.h"
00031 
00032 #define APR_WANT_STDIO          
00033 #define APR_WANT_IOVEC          
00034 #include "apr_want.h"
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif /* __cplusplus */
00039 
00051 /* Note to implementors: Values in the range 0x00100000--0x80000000
00052    are reserved for platform-specific values. */
00053 
00054 #define APR_FOPEN_READ       0x00001  
00055 #define APR_FOPEN_WRITE      0x00002  
00056 #define APR_FOPEN_CREATE     0x00004  
00057 #define APR_FOPEN_APPEND     0x00008  
00058 #define APR_FOPEN_TRUNCATE   0x00010  
00060 #define APR_FOPEN_BINARY     0x00020  
00061 #define APR_FOPEN_EXCL       0x00040  
00063 #define APR_FOPEN_BUFFERED   0x00080  
00064 #define APR_FOPEN_DELONCLOSE 0x00100  
00065 #define APR_FOPEN_XTHREAD    0x00200  
00068 #define APR_FOPEN_SHARELOCK  0x00400  
00072 #define APR_FOPEN_NOCLEANUP  0x00800  
00074 #define APR_FOPEN_SENDFILE_ENABLED 0x01000 
00077 #define APR_FOPEN_LARGEFILE   0x04000 
00080 #define APR_FOPEN_SPARSE      0x08000 
00084 /* backcompat */
00085 #define APR_READ             APR_FOPEN_READ       
00086 #define APR_WRITE            APR_FOPEN_WRITE      
00087 #define APR_CREATE           APR_FOPEN_CREATE     
00088 #define APR_APPEND           APR_FOPEN_APPEND     
00089 #define APR_TRUNCATE         APR_FOPEN_TRUNCATE   
00090 #define APR_BINARY           APR_FOPEN_BINARY     
00091 #define APR_EXCL             APR_FOPEN_EXCL       
00092 #define APR_BUFFERED         APR_FOPEN_BUFFERED   
00093 #define APR_DELONCLOSE       APR_FOPEN_DELONCLOSE 
00094 #define APR_XTHREAD          APR_FOPEN_XTHREAD    
00095 #define APR_SHARELOCK        APR_FOPEN_SHARELOCK  
00096 #define APR_FILE_NOCLEANUP   APR_FOPEN_NOCLEANUP  
00097 #define APR_SENDFILE_ENABLED APR_FOPEN_SENDFILE_ENABLED 
00098 #define APR_LARGEFILE        APR_FOPEN_LARGEFILE  
00129 /* flags for apr_file_seek */
00130 
00131 #define APR_SET SEEK_SET
00132 
00133 #define APR_CUR SEEK_CUR
00134 
00135 #define APR_END SEEK_END
00136 
00143 /* flags for apr_file_attrs_set */
00144 #define APR_FILE_ATTR_READONLY   0x01          
00145 #define APR_FILE_ATTR_EXECUTABLE 0x02          
00146 #define APR_FILE_ATTR_HIDDEN     0x04          
00153 #if defined(DOXYGEN)
00154 #define APR_MAX_IOVEC_SIZE 1024                
00156 #elif defined(IOV_MAX)
00157 #define APR_MAX_IOVEC_SIZE IOV_MAX
00158 #elif defined(MAX_IOVEC)
00159 #define APR_MAX_IOVEC_SIZE MAX_IOVEC
00160 #else
00161 #define APR_MAX_IOVEC_SIZE 1024
00162 #endif
00163 
00166 typedef apr_uint32_t apr_fileattrs_t;
00167 
00169 typedef int       apr_seek_where_t;
00170 
00174 typedef struct apr_file_t         apr_file_t;
00175 
00176 /* File lock types/flags */
00182 #define APR_FLOCK_SHARED        1       
00188 #define APR_FLOCK_EXCLUSIVE     2       
00193 #define APR_FLOCK_TYPEMASK      0x000F  
00194 #define APR_FLOCK_NONBLOCK      0x0010  
00235 APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **newf, const char *fname,
00236                                         apr_int32_t flag, apr_fileperms_t perm,
00237                                         apr_pool_t *pool);
00238 
00243 APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file);
00244 
00252 APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *pool);
00253 
00263 APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, 
00264                                           const char *to_path,
00265                                           apr_pool_t *pool);
00266 
00273 APR_DECLARE(apr_status_t) apr_file_link(const char *from_path, 
00274                                           const char *to_path);
00275 
00288 APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path, 
00289                                         const char *to_path,
00290                                         apr_fileperms_t perms,
00291                                         apr_pool_t *pool);
00292 
00304 APR_DECLARE(apr_status_t) apr_file_append(const char *from_path, 
00305                                           const char *to_path,
00306                                           apr_fileperms_t perms,
00307                                           apr_pool_t *pool);
00308 
00314 APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr);
00315 
00331 APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile,
00332                                                apr_pool_t *pool);
00333 
00341 APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile,
00342                                                apr_pool_t *pool);
00343 
00351 APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile,
00352                                               apr_pool_t *pool);
00353 
00365 APR_DECLARE(apr_status_t) apr_file_open_flags_stderr(apr_file_t **thefile,
00366                                                      apr_int32_t flags,
00367                                                      apr_pool_t *pool);
00368 
00380 APR_DECLARE(apr_status_t) apr_file_open_flags_stdout(apr_file_t **thefile,
00381                                                      apr_int32_t flags,
00382                                                      apr_pool_t *pool);
00383 
00395 APR_DECLARE(apr_status_t) apr_file_open_flags_stdin(apr_file_t **thefile,
00396                                                      apr_int32_t flags,
00397                                                      apr_pool_t *pool);
00398 
00416 APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf,
00417                                         apr_size_t *nbytes);
00418 
00434 APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf,
00435                                          apr_size_t *nbytes);
00436 
00452 APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile,
00453                                           const struct iovec *vec,
00454                                           apr_size_t nvec, apr_size_t *nbytes);
00455 
00476 APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, void *buf,
00477                                              apr_size_t nbytes,
00478                                              apr_size_t *bytes_read);
00479 
00500 APR_DECLARE(apr_status_t) apr_file_write_full(apr_file_t *thefile, 
00501                                               const void *buf,
00502                                               apr_size_t nbytes, 
00503                                               apr_size_t *bytes_written);
00504 
00505 
00519 APR_DECLARE(apr_status_t) apr_file_writev_full(apr_file_t *thefile,
00520                                                const struct iovec *vec,
00521                                                apr_size_t nvec,
00522                                                apr_size_t *nbytes);
00528 APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile);
00529 
00535 APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile);
00536 
00542 APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile);
00543 
00552 APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, 
00553                                         apr_file_t *thefile);
00554 
00560 APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile);
00561 
00566 APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile);
00567 
00572 APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile);
00573 
00578 APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile);
00579 
00587 APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file,
00588                                        apr_file_t *old_file,
00589                                        apr_pool_t *p);
00590 
00599 APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file,
00600                                         apr_file_t *old_file,
00601                                         apr_pool_t *p);
00602 
00614 APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file,
00615                                             apr_file_t *old_file,
00616                                             apr_pool_t *p);
00617 
00629 APR_DECLARE(apr_status_t) apr_file_buffer_set(apr_file_t *thefile,
00630                                               char * buffer,
00631                                               apr_size_t bufsize);
00632 
00637 APR_DECLARE(apr_size_t) apr_file_buffer_size_get(apr_file_t *thefile);
00638 
00652 APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, 
00653                                    apr_seek_where_t where,
00654                                    apr_off_t *offset);
00655 
00669 APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, 
00670                                                apr_file_t **out,
00671                                                apr_pool_t *pool);
00672 
00694 APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in, 
00695                                                   apr_file_t **out, 
00696                                                   apr_int32_t blocking, 
00697                                                   apr_pool_t *pool);
00698 
00705 APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, 
00706                                                     apr_fileperms_t perm, 
00707                                                     apr_pool_t *pool);
00708 
00714 APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, 
00715                                                apr_interval_time_t *timeout);
00716 
00723 APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, 
00724                                                   apr_interval_time_t timeout);
00725 
00737 APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type);
00738 
00743 APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile);
00744 
00752 APR_DECLARE(apr_status_t) apr_file_name_get(const char **new_path, 
00753                                             apr_file_t *thefile);
00754     
00761 APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key, 
00762                                             apr_file_t *file);
00763 
00771 APR_DECLARE(apr_status_t) apr_file_data_set(apr_file_t *file, void *data,
00772                                             const char *key,
00773                                             apr_status_t (*cleanup)(void *));
00774 
00782 APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, 
00783                                         const char *format, ...)
00784         __attribute__((format(printf,2,3)));
00785 
00798 APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname,
00799                                              apr_fileperms_t perms);
00800 
00819 APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname,
00820                                              apr_fileattrs_t attributes,
00821                                              apr_fileattrs_t attr_mask,
00822                                              apr_pool_t *pool);
00823 
00832 APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname,
00833                                              apr_time_t mtime,
00834                                              apr_pool_t *pool);
00835 
00842 APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, 
00843                                        apr_pool_t *pool);
00844 
00852 APR_DECLARE(apr_status_t) apr_dir_make_recursive(const char *path,
00853                                                  apr_fileperms_t perm,
00854                                                  apr_pool_t *pool);
00855 
00863 APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *pool);
00864 
00871 APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, 
00872                                             apr_int32_t wanted,
00873                                             apr_file_t *thefile);
00874     
00875 
00882 APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *fp, apr_off_t offset);
00883 
00889 APR_DECLARE(apr_int32_t) apr_file_flags_get(apr_file_t *f);
00890 
00894 APR_POOL_DECLARE_ACCESSOR(file);
00895 
00900 APR_DECLARE_INHERIT_SET(file);
00901 
00905 APR_DECLARE_INHERIT_UNSET(file);
00906 
00923 APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *templ,
00924                                           apr_int32_t flags, apr_pool_t *p);
00925 
00926 
00936 APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir, 
00937                                            apr_pool_t *p);
00938 
00941 #ifdef __cplusplus
00942 }
00943 #endif
00944 
00945 #endif  /* ! APR_FILE_IO_H */