1 /****************************************************************************
2 *																			*
3 *							File Stream I/O Header							*
4 *						Copyright Peter Gutmann 1993-2003					*
5 *																			*
6 ****************************************************************************/
7 
8 #ifndef _STRFILE_DEFINED
9 
10 #define _STRFILE_DEFINED
11 
12 /****************************************************************************
13 *																			*
14 *						 				AMX									*
15 *																			*
16 ****************************************************************************/
17 
18 #if defined( __AMX__ )
19 
20 #include <fjzzz.h>
21 
22 /****************************************************************************
23 *																			*
24 *						 			DOS/Win16								*
25 *																			*
26 ****************************************************************************/
27 
28 #elif defined( __MSDOS16__ ) || defined( __WIN16__ )
29 
30 #include <io.h>
31 #include <errno.h>			/* Needed for access() check */
32 
33 /****************************************************************************
34 *																			*
35 *						 			IBM 4758								*
36 *																			*
37 ****************************************************************************/
38 
39 #elif defined( __IBM4758__ )
40 
41 #include <scc_err.h>
42 #include <scc_int.h>
43 
44 /****************************************************************************
45 *																			*
46 *						 			Macintosh								*
47 *																			*
48 ****************************************************************************/
49 
50 #elif defined( __MAC__ )
51 
52 #include <Script.h>
53 #if defined __MWERKS__
54   #pragma mpwc_relax off
55   #pragma extended_errorcheck on
56 #endif /* __MWERKS__ */
57 
58 /****************************************************************************
59 *																			*
60 *						 			Nucleus									*
61 *																			*
62 ****************************************************************************/
63 
64 #elif defined( __Nucleus__ )
65 
66 #include <pcdisk.h>
67 
68 /****************************************************************************
69 *																			*
70 *						 				OS/2								*
71 *																			*
72 ****************************************************************************/
73 
74 #elif defined( __OS2__ )
75 
76 #define INCL_DOSFILEMGR		/* DosQueryPathInfo(),DosSetFileSize(),DosSetPathInfo */
77 #define INCL_DOSMISC		/* DosQuerySysInfo() */
78 #include <os2.h>			/* FILESTATUS */
79 #include <io.h>
80 #include <errno.h>			/* Needed for access() check */
81 
82 /****************************************************************************
83 *																			*
84 *						 				AMX									*
85 *																			*
86 ****************************************************************************/
87 
88 #elif defined( __SMX__ )
89 
90 #include <smx.h>
91 #include <smxfs.h>
92 
93 /****************************************************************************
94 *																			*
95 *						 		ThreadX (via FileX)							*
96 *																			*
97 ****************************************************************************/
98 
99 #elif defined( __FileX__ )
100 
101 #include <fx_api.h>
102 
103 /****************************************************************************
104 *																			*
105 *						 			TI RTS									*
106 *																			*
107 ****************************************************************************/
108 
109 #elif defined( __TI_COMPILER_VERSION__ )
110 
111 #include <errno.h>
112 
113 /****************************************************************************
114 *																			*
115 *						 			uITRON									*
116 *																			*
117 ****************************************************************************/
118 
119 #elif defined( __ITRON__ )
120 
121 /* uITRON has a file API (ITRON/FILE) derived from the BTRON persistent
122    object store interface, but the only documentationm for this is for BTRON
123    and it's only available in Japanese.  Because of the inability to obtain
124    either documentation or an implementation to code against, anyone with
125    access to the required documentation/implementation will need to fill in
126    the required headers and functions here */
127 
128 #error You need to set up the ITRON/FILE headers and interface in str_file.c
129 
130 /****************************************************************************
131 *																			*
132 *						 		Unix/Unix-like Systems						*
133 *																			*
134 ****************************************************************************/
135 
136 #elif defined( __Android__ ) || defined( __BEOS__ ) || \
137 	  defined( __ECOS__ ) || defined( __iOS__ ) || defined( __MVS__ ) || \
138 	  defined( __RTEMS__ ) || defined( __SYMBIAN32__ ) || \
139 	  defined( __TANDEM_NSK__ ) || defined( __TANDEM_OSS__ ) || \
140 	  defined( __UNIX__ )
141 
142 #if defined( __TANDEM_NSK__ ) || defined( __TANDEM_OSS__ )
143   /* Needed for lstat() in sys/lstat.h */
144   #define _XOPEN_SOURCE_EXTENDED	1
145 #endif /* Tandem */
146 #include <errno.h>
147 #include <fcntl.h>
148 #include <sys/types.h>
149 #if !( defined( __ECOS__ ) || defined( __TANDEM_NSK__ ) || \
150 	   defined( __TANDEM_OSS__ ) )
151   #include <sys/file.h>
152 #endif /* Tandem */
153 #include <sys/stat.h>
154 #if defined( _AIX ) || defined( __alpha__ ) || defined( _MPRAS ) || \
155 	defined( __osf__ ) || defined( __SCO_VERSION__ )
156   #include <sys/mode.h>
157 #endif /* Vaguely SYSV-ish systems */
158 #include <unistd.h>
159 #if defined( _AIX ) || defined( __alpha__ ) || defined( __BEOS__ ) || \
160 	defined( __bsdi__ ) || defined( _CRAY ) || (defined( __FreeBSD__ )||defined(__DragonFly__)) || \
161 	defined( __iOS__ ) || defined( __linux__ ) || defined( _MPRAS ) || \
162 	defined( __MVS__ ) || defined( _M_XENIX ) || defined( __NetBSD__ ) || \
163 	defined( __OpenBSD__ ) || defined( __osf__ ) || defined( __QNX__ ) || \
164 	defined( __SCO_VERSION__ ) || defined( sun ) || \
165 	defined( __TANDEM_NSK__ ) || defined( __TANDEM_OSS__ )
166   #include <utime.h>			/* It's a SYSV thing... */
167 #endif /* SYSV Unixen */
168 #if defined( __APPLE__ ) || defined( __linux__ )
169   #include <sys/time.h>			/* For futimes() */
170 #endif /* OS X || Linux */
171 #ifdef __CYGWIN__
172   #include <sys/utime.h>
173 #endif /* __CYGWIN__ */
174 
175 /* By default we try and use flock()-locking, if this isn't available we
176    fall back to fcntl() locking (see the long comment further on).  Actually
177    Slowaris does have flock() but there are lots of warnings in the manpage
178    about using it only on BSD platforms and it requires the BSD libraries to
179    work.  SunOS did support it without any problems, it's only the SVR4
180    Slowaris that breaks it - the Solaris flock() is really just a
181    compatibility hack around fcntl() locking, even up to the very latest
182    versions (Solaris 10), and there are various weird side-effects and
183    problems that make it too dangerous to use.  In addition UnixWare
184    (== SCO) supports something called flockfile() but this only provides
185    thread-level locking that isn't useful */
186 
187 #if defined( _AIX ) || defined( __BEOS__ ) || defined( __CYGWIN__ ) || \
188 	defined( __hpux ) || defined( _MPRAS ) || defined( __MVS__ ) || \
189 	defined( _M_XENIX ) || defined( __SCO_VERSION__ ) || \
190 	( defined( sun ) && ( OSVERSION >= 5 ) ) || \
191 	defined( __TANDEM_NSK__ ) || defined( __TANDEM_OSS__ )
192   #define USE_FCNTL_LOCKING
193 #endif /* Some older SYSV-ish systems */
194 
195 /* Older versions of SCO didn't have ftruncate() but did have the equivalent
196    function chsize() */
197 
198 #if ( defined( _M_XENIX ) && ( OSVERSION == 3 ) )
199   #define ftruncate( a, b )	chsize( a, b )
200 #endif /* SCO */
201 
202 /* Some versions of Cygwin don't define the locking constants */
203 
204 #if defined( __CYGWIN__ ) && !defined( LOCK_SH )
205   #define LOCK_SH		1
206   #define LOCK_EX		2
207   #define LOCK_NB		4
208   #define LOCK_UN		8
209 #endif /* Cygwin */
210 
211 /****************************************************************************
212 *																			*
213 *						 			VxWorks									*
214 *																			*
215 ****************************************************************************/
216 
217 #elif defined( __VxWorks__ )
218 
219 #include <vxWorks.h>
220 #include <ioLib.h>
221 #include <errno.h>
222 #include <ioctl.h>
223 #include <sys/stat.h>
224 
225 /****************************************************************************
226 *																			*
227 *						 			Xilinx XMK								*
228 *																			*
229 ****************************************************************************/
230 
231 #elif defined( __XMK__ )
232 
233 #include <xilmfs.h>
234 
235 #endif /* OS-specific includes and defines */
236 
237 #endif /* _STRFILE_DEFINED */
238