cryptlib  3.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
file.h
Go to the documentation of this file.
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 * OS/2 *
61 * *
62 ****************************************************************************/
63 
64 #elif defined( __OS2__ )
65 
66 #define INCL_DOSFILEMGR /* DosQueryPathInfo(),DosSetFileSize(),DosSetPathInfo */
67 #define INCL_DOSMISC /* DosQuerySysInfo() */
68 #include <os2.h> /* FILESTATUS */
69 #include <io.h>
70 #include <errno.h> /* Needed for access() check */
71 
72 /****************************************************************************
73 * *
74 * ThreadX (via FileX) *
75 * *
76 ****************************************************************************/
77 
78 #elif defined( __FileX__ )
79 
80 #include <fx_api.h>
81 
82 /****************************************************************************
83 * *
84 * uITRON *
85 * *
86 ****************************************************************************/
87 
88 #elif defined( __ITRON__ )
89 
90 /* uITRON has a file API (ITRON/FILE) derived from the BTRON persistent
91  object store interface, but the only documentationm for this is for BTRON
92  and it's only available in Japanese. Because of the inability to obtain
93  either documentation or an implementation to code against, anyone with
94  access to the required documentation/implementation will need to fill in
95  the required headers and functions here */
96 
97 #error You need to set up the ITRON/FILE headers and interface in str_file.c
98 
99 /****************************************************************************
100 * *
101 * Unix/Unix-like Systems *
102 * *
103 ****************************************************************************/
104 
105 #elif defined( __BEOS__ ) || defined( __ECOS__ ) || defined( __MVS__ ) || \
106  defined( __RTEMS__ ) || defined( __SYMBIAN32__ ) || \
107  defined( __TANDEM_NSK__ ) || defined( __TANDEM_OSS__ ) || \
108  defined( __UNIX__ )
109 
110 #if defined( __TANDEM_NSK__ ) || defined( __TANDEM_OSS__ )
111  /* Needed for lstat() in sys/lstat.h */
112  #define _XOPEN_SOURCE_EXTENDED 1
113 #endif /* Tandem */
114 #include <errno.h>
115 #include <fcntl.h>
116 #include <sys/types.h>
117 #if !( defined( __ECOS__ ) || defined( __TANDEM_NSK__ ) || \
118  defined( __TANDEM_OSS__ ) )
119  #include <sys/file.h>
120 #endif /* Tandem */
121 #include <sys/stat.h>
122 #if !( defined( __APPLE__ ) || defined( __BEOS__ ) || \
123  defined( __bsdi__ ) || defined( _CRAY ) || \
124  defined( __CYGWIN__ ) || defined( __FreeBSD__ ) || \
125  defined( __hpux ) || defined( __linux__ ) || \
126  defined( _M_XENIX ) || defined( __MVS__ ) || \
127  defined( __NetBSD__ ) || defined( __OpenBSD__ ) || \
128  defined( __QNX__ ) || ( defined( sun ) && OSVERSION == 4 ) || \
129  defined ( __SYMBIAN32__ ) || defined( __TANDEM_NSK__ ) || \
130  defined( __TANDEM_OSS__ ) || defined( USE_EMBEDDED_OS ) )
131  #include <sys/mode.h>
132 #endif /* Vaguely non-SYSV-ish systems */
133 #include <unistd.h>
134 #if defined( _AIX ) || defined( __alpha__ ) || defined( __BEOS__ ) || \
135  defined( __bsdi__ ) || defined( _CRAY ) || defined( __FreeBSD__ ) || \
136  defined( __linux__ ) || defined( _MPRAS ) || defined( __MVS__ ) || \
137  defined( _M_XENIX ) || defined( __NetBSD__ ) || \
138  defined( __OpenBSD__ ) || defined( __osf__ ) || defined( __QNX__ ) || \
139  defined( __SCO_VERSION__ ) || defined( sun ) || \
140  defined( __TANDEM_NSK__ ) || defined( __TANDEM_OSS__ )
141  #include <utime.h> /* It's a SYSV thing... */
142 #endif /* SYSV Unixen */
143 #if defined( __APPLE__ ) || defined( __linux__ )
144  #include <sys/time.h> /* For futimes() */
145 #endif /* OS X || Linux */
146 #ifdef __CYGWIN__
147  #include <sys/utime.h>
148 #endif /* __CYGWIN__ */
149 
150 /* By default we try and use flock()-locking, if this isn't available we
151  fall back to fcntl() locking (see the long comment further on). Actually
152  Slowaris does have flock() but there are lots of warnings in the manpage
153  about using it only on BSD platforms and it requires the BSD libraries to
154  work. SunOS did support it without any problems, it's only the SVR4
155  Slowaris that breaks it - the Solaris flock() is really just a
156  compatibility hack around fcntl() locking, even up to the very latest
157  versions (Solaris 10), and there are various weird side-effects and
158  problems that make it too dangerous to use. In addition UnixWare
159  (== SCO) supports something called flockfile() but this only provides
160  thread-level locking that isn't useful */
161 
162 #if defined( _AIX ) || defined( __BEOS__ ) || defined( __CYGWIN__ ) || \
163  defined( __hpux ) || defined( _MPRAS ) || defined( __MVS__ ) || \
164  defined( _M_XENIX ) || defined( __SCO_VERSION__ ) || \
165  ( defined( sun ) && ( OSVERSION >= 5 ) ) || \
166  defined( __TANDEM_NSK__ ) || defined( __TANDEM_OSS__ )
167  #define USE_FCNTL_LOCKING
168 #endif /* Some older SYSV-ish systems */
169 
170 /* Older versions of SCO didn't have ftruncate() but did have the equivalent
171  function chsize() */
172 
173 #if ( defined( _M_XENIX ) && ( OSVERSION == 3 ) )
174  #define ftruncate( a, b ) chsize( a, b )
175 #endif /* SCO */
176 
177 /* Some versions of Cygwin don't define the locking constants */
178 
179 #if defined( __CYGWIN__ ) && !defined( LOCK_SH )
180  #define LOCK_SH 1
181  #define LOCK_EX 2
182  #define LOCK_NB 4
183  #define LOCK_UN 8
184 #endif /* Cygwin */
185 
186 /****************************************************************************
187 * *
188 * VxWorks *
189 * *
190 ****************************************************************************/
191 
192 #elif defined( __VXWORKS__ )
193 
194 #include <ioLib.h>
195 #include <errno.h>
196 #include <ioctl.h>
197 #include <vwModNum.h>
198 
199 /****************************************************************************
200 * *
201 * Xilinx XMK *
202 * *
203 ****************************************************************************/
204 
205 #elif defined( __XMK__ )
206 
207 #include <xilmfs.h>
208 
209 #endif /* OS-specific includes and defines */
210 
211 #endif /* _STRFILE_DEFINED */