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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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"
28 #include "apr_thread_mutex.h"
30 /* System headers the file I/O library needs */
34 #if APR_HAVE_SYS_TYPES_H
35 #include <sys/types.h>
43 #if APR_HAVE_STRINGS_H
49 #ifdef HAVE_SYS_STAT_H
61 #if APR_HAVE_SYS_UIO_H
64 #if APR_HAVE_SYS_TIME_H
68 #include <kernel/OS.h>
73 /* prior to BONE/7 fd_set & select were defined in sys/socket.h */
74 # include <sys/socket.h>
76 /* Be moved the fd_set stuff and also the FIONBIO definition... */
77 # include <sys/ioctl.h>
80 /* End System headers */
82 #define APR_FILE_BUFSIZE 4096
91 apr_interval_time_t timeout;
93 enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking;
94 int ungetchar; /* Last char provided by an unget op. (-1 = no char)*/
96 /* Stuff for buffered mode */
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 */
103 struct apr_thread_mutex_t *thlock;
108 #define file_lock(f) do { \
110 apr_thread_mutex_lock((f)->thlock); \
112 #define file_unlock(f) do { \
114 apr_thread_mutex_unlock((f)->thlock); \
117 #define file_lock(f) do {} while (0)
118 #define file_unlock(f) do {} while (0)
125 struct dirent *entry;
128 apr_status_t apr_unix_file_cleanup(void *);
129 apr_status_t apr_unix_child_file_cleanup(void *);
131 mode_t apr_unix_perms2mode(apr_fileperms_t perms);
132 apr_fileperms_t apr_unix_mode2perms(mode_t mode);
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);
139 #endif /* ! FILE_IO_H */