bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / srclib / apr / include / arch / unix / apr_arch_file_io.h
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 FILE_IO_H
18 #define FILE_IO_H
19
20 #include "apr.h"
21 #include "apr_private.h"
22 #include "apr_general.h"
23 #include "apr_tables.h"
24 #include "apr_file_io.h"
25 #include "apr_file_info.h"
26 #include "apr_errno.h"
27 #include "apr_lib.h"
28 #include "apr_thread_mutex.h"
29
30 /* System headers the file I/O library needs */
31 #if APR_HAVE_FCNTL_H
32 #include <fcntl.h>
33 #endif
34 #if APR_HAVE_SYS_TYPES_H
35 #include <sys/types.h>
36 #endif
37 #if APR_HAVE_ERRNO_H
38 #include <errno.h>
39 #endif
40 #if APR_HAVE_STRING_H
41 #include <string.h>
42 #endif
43 #if APR_HAVE_STRINGS_H
44 #include <strings.h>
45 #endif
46 #if APR_HAVE_DIRENT_H
47 #include <dirent.h>
48 #endif
49 #ifdef HAVE_SYS_STAT_H
50 #include <sys/stat.h>
51 #endif
52 #if APR_HAVE_UNISTD_H
53 #include <unistd.h>
54 #endif
55 #if APR_HAVE_STDIO_H
56 #include <stdio.h>
57 #endif
58 #if APR_HAVE_STDLIB_H
59 #include <stdlib.h>
60 #endif
61 #if APR_HAVE_SYS_UIO_H
62 #include <sys/uio.h>
63 #endif
64 #if APR_HAVE_SYS_TIME_H
65 #include <sys/time.h>
66 #endif
67 #ifdef BEOS
68 #include <kernel/OS.h>
69 #endif
70
71 #if BEOS_BONE
72 # ifndef BONE7
73   /* prior to BONE/7 fd_set & select were defined in sys/socket.h */
74 #  include <sys/socket.h>
75 # else
76   /* Be moved the fd_set stuff and also the FIONBIO definition... */
77 #  include <sys/ioctl.h>
78 # endif
79 #endif
80 /* End System headers */
81
82 #define APR_FILE_BUFSIZE 4096
83
84 struct apr_file_t {
85     apr_pool_t *pool;
86     int filedes;
87     char *fname;
88     apr_int32_t flags;
89     int eof_hit;
90     int is_pipe;
91     apr_interval_time_t timeout;
92     int buffered;
93     enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking;
94     int ungetchar;    /* Last char provided by an unget op. (-1 = no char)*/
95
96     /* Stuff for buffered mode */
97     char *buffer;
98     int bufpos;               /* Read/Write position in buffer */
99     unsigned long dataRead;   /* amount of valid data read into buffer */
100     int direction;            /* buffer being used for 0 = read, 1 = write */
101     unsigned long filePtr;    /* position in file of handle */
102 #if APR_HAS_THREADS
103     struct apr_thread_mutex_t *thlock;
104 #endif
105 };
106
107 #if APR_HAS_THREADS
108 #define file_lock(f)   do { \
109                            if ((f)->thlock) \
110                                apr_thread_mutex_lock((f)->thlock); \
111                        } while (0)
112 #define file_unlock(f) do { \
113                            if ((f)->thlock) \
114                                apr_thread_mutex_unlock((f)->thlock); \
115                        } while (0)
116 #else
117 #define file_lock(f)   do {} while (0)
118 #define file_unlock(f) do {} while (0)
119 #endif
120
121 struct apr_dir_t {
122     apr_pool_t *pool;
123     char *dirname;
124     DIR *dirstruct;
125     struct dirent *entry;
126 };
127
128 apr_status_t apr_unix_file_cleanup(void *);
129 apr_status_t apr_unix_child_file_cleanup(void *);
130
131 mode_t apr_unix_perms2mode(apr_fileperms_t perms);
132 apr_fileperms_t apr_unix_mode2perms(mode_t mode);
133
134 apr_status_t apr_file_flush_locked(apr_file_t *thefile);
135 apr_status_t apr_file_info_get_locked(apr_finfo_t *finfo, apr_int32_t wanted,
136                                       apr_file_t *thefile);
137
138
139 #endif  /* ! FILE_IO_H */
140