svn-gvsig-desktop / tags / v10_RC2c / libraries / libjni-gdal / include / cpl_vsi.h @ 8745
History | View | Annotate | Download (10.4 KB)
1 | 716 | igbrotru | /******************************************************************************
|
---|---|---|---|
2 | * Copyright (c) 1998, Frank Warmerdam
|
||
3 | *
|
||
4 | * Permission is hereby granted, free of charge, to any person obtaining a
|
||
5 | * copy of this software and associated documentation files (the "Software"),
|
||
6 | * to deal in the Software without restriction, including without limitation
|
||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||
8 | * and/or sell copies of the Software, and to permit persons to whom the
|
||
9 | * Software is furnished to do so, subject to the following conditions:
|
||
10 | *
|
||
11 | * The above copyright notice and this permission notice shall be included
|
||
12 | * in all copies or substantial portions of the Software.
|
||
13 | *
|
||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||
15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||
20 | * DEALINGS IN THE SOFTWARE.
|
||
21 | ******************************************************************************
|
||
22 | *
|
||
23 | * cpl_vsi.h
|
||
24 | *
|
||
25 | * Include file defining the Virtual System Interface (VSI) functions. This
|
||
26 | * should normally be included by all translators using VSI functions for
|
||
27 | * accessing system services. It is also used by the GDAL core, and can be
|
||
28 | * used by higher level applications which adhere to VSI use.
|
||
29 | *
|
||
30 | * Most VSI functions are direct analogs of Posix C library functions.
|
||
31 | * VSI exists to allow ``hooking'' these functions to provide application
|
||
32 | * specific checking, io redirection and so on.
|
||
33 | *
|
||
34 | * $Log$
|
||
35 | 7847 | nacho | * Revision 1.2.10.1 2006-10-04 06:55:46 nacho
|
36 | 716 | igbrotru | * *** empty log message ***
|
37 | *
|
||
38 | 7847 | nacho | * Revision 1.3 2006/10/03 07:05:18 nacho
|
39 | * *** empty log message ***
|
||
40 | *
|
||
41 | * Revision 1.1 2006/07/18 16:21:00 nacho
|
||
42 | * *** empty log message ***
|
||
43 | *
|
||
44 | * Revision 1.1 2006/06/29 16:23:27 nacho
|
||
45 | * *** empty log message ***
|
||
46 | *
|
||
47 | * Revision 1.2 2006/01/09 12:50:13 nacho
|
||
48 | * *** empty log message ***
|
||
49 | *
|
||
50 | 3540 | nacho | * Revision 1.1 2005/07/27 08:22:55 igbrotru
|
51 | * *** empty log message ***
|
||
52 | *
|
||
53 | * Revision 1.1 2004/12/28 14:06:59 igbrotru
|
||
54 | * *** empty log message ***
|
||
55 | *
|
||
56 | 716 | igbrotru | * Revision 1.1 2004/10/28 12:08:47 igbrotru
|
57 | * *** empty log message ***
|
||
58 | *
|
||
59 | * Revision 1.1 2004/09/27 08:27:48 igbrotru
|
||
60 | * *** empty log message ***
|
||
61 | *
|
||
62 | * Revision 1.1 2004/09/08 12:39:04 igbrotru
|
||
63 | * *** empty log message ***
|
||
64 | *
|
||
65 | * Revision 1.18 2003/09/10 19:44:36 warmerda
|
||
66 | * added VSIStrerrno()
|
||
67 | *
|
||
68 | * Revision 1.17 2003/09/08 08:11:40 dron
|
||
69 | * Added VSIGMTime() and VSILocalTime().
|
||
70 | *
|
||
71 | * Revision 1.16 2003/05/27 20:44:40 warmerda
|
||
72 | * added VSI io debugging macros
|
||
73 | *
|
||
74 | * Revision 1.15 2002/06/17 14:10:14 warmerda
|
||
75 | * no stat64 on Win32
|
||
76 | *
|
||
77 | * Revision 1.14 2002/06/17 14:00:16 warmerda
|
||
78 | * segregate VSIStatL() and VSIStatBufL.
|
||
79 | *
|
||
80 | * Revision 1.13 2002/06/15 02:13:13 aubin
|
||
81 | * remove debug test for 64bit compile
|
||
82 | *
|
||
83 | * Revision 1.12 2002/06/15 00:07:23 aubin
|
||
84 | * mods to enable 64bit file i/o
|
||
85 | *
|
||
86 | * Revision 1.11 2001/04/30 18:19:06 warmerda
|
||
87 | * avoid stat on macos_pre10
|
||
88 | *
|
||
89 | * Revision 1.10 2001/01/19 21:16:41 warmerda
|
||
90 | * expanded tabs
|
||
91 | *
|
||
92 | * Revision 1.9 2001/01/03 17:41:44 warmerda
|
||
93 | * added #define for VSIFFlushL
|
||
94 | *
|
||
95 | * Revision 1.8 2001/01/03 16:17:50 warmerda
|
||
96 | * added large file API
|
||
97 | *
|
||
98 | * Revision 1.7 2000/12/14 18:29:48 warmerda
|
||
99 | * added VSIMkdir
|
||
100 | *
|
||
101 | * Revision 1.6 2000/01/25 03:11:03 warmerda
|
||
102 | * added unlink and mkdir
|
||
103 | *
|
||
104 | * Revision 1.5 1999/05/23 02:43:57 warmerda
|
||
105 | * Added documentation block.
|
||
106 | *
|
||
107 | * Revision 1.4 1999/02/25 04:48:11 danmo
|
||
108 | * Added VSIStat() macros specific to _WIN32 (for MSVC++)
|
||
109 | *
|
||
110 | * Revision 1.3 1999/01/28 18:31:25 warmerda
|
||
111 | * Test on _WIN32 rather than WIN32. It seems to be more reliably defined.
|
||
112 | *
|
||
113 | * Revision 1.2 1998/12/04 21:42:57 danmo
|
||
114 | * Added #ifndef WIN32 arounf #include <unistd.h>
|
||
115 | *
|
||
116 | * Revision 1.1 1998/12/03 18:26:02 warmerda
|
||
117 | * New
|
||
118 | *
|
||
119 | */
|
||
120 | |||
121 | #ifndef CPL_VSI_H_INCLUDED
|
||
122 | #define CPL_VSI_H_INCLUDED
|
||
123 | |||
124 | #include "cpl_port.h" |
||
125 | /**
|
||
126 | * \file cpl_vsi.h
|
||
127 | *
|
||
128 | * Standard C Covers
|
||
129 | *
|
||
130 | * The VSI functions are intended to be hookable aliases for Standard C
|
||
131 | * I/O, memory allocation and other system functions. They are intended
|
||
132 | * to allow virtualization of disk I/O so that non file data sources
|
||
133 | * can be made to appear as files, and so that additional error trapping
|
||
134 | * and reporting can be interested. The memory access API is aliased
|
||
135 | * so that special application memory management services can be used.
|
||
136 | *
|
||
137 | * Is is intended that each of these functions retains exactly the same
|
||
138 | * calling pattern as the original Standard C functions they relate to.
|
||
139 | * This means we don't have to provide custom documentation, and also means
|
||
140 | * that the default implementation is very simple.
|
||
141 | */
|
||
142 | |||
143 | |||
144 | /* -------------------------------------------------------------------- */
|
||
145 | /* We need access to ``struct stat''. */
|
||
146 | /* -------------------------------------------------------------------- */
|
||
147 | #ifndef _WIN32
|
||
148 | # include <unistd.h> |
||
149 | #endif
|
||
150 | #if !defined(macos_pre10)
|
||
151 | # include <sys/stat.h> |
||
152 | #endif
|
||
153 | |||
154 | CPL_C_START |
||
155 | |||
156 | /* ==================================================================== */
|
||
157 | /* stdio file access functions. */
|
||
158 | /* ==================================================================== */
|
||
159 | |||
160 | FILE CPL_DLL * VSIFOpen( const char *, const char * ); |
||
161 | int CPL_DLL VSIFClose( FILE * );
|
||
162 | int CPL_DLL VSIFSeek( FILE *, long, int ); |
||
163 | long CPL_DLL VSIFTell( FILE * );
|
||
164 | void CPL_DLL VSIRewind( FILE * );
|
||
165 | void CPL_DLL VSIFFlush( FILE * );
|
||
166 | |||
167 | size_t CPL_DLL VSIFRead( void *, size_t, size_t, FILE * );
|
||
168 | size_t CPL_DLL VSIFWrite( void *, size_t, size_t, FILE * );
|
||
169 | char CPL_DLL *VSIFGets( char *, int, FILE * ); |
||
170 | int CPL_DLL VSIFPuts( const char *, FILE * ); |
||
171 | int CPL_DLL VSIFPrintf( FILE *, const char *, ... ); |
||
172 | |||
173 | int CPL_DLL VSIFGetc( FILE * );
|
||
174 | int CPL_DLL VSIFPutc( int, FILE * ); |
||
175 | int CPL_DLL VSIUngetc( int, FILE * ); |
||
176 | int CPL_DLL VSIFEof( FILE * );
|
||
177 | |||
178 | /* ==================================================================== */
|
||
179 | /* VSIStat() related. */
|
||
180 | /* ==================================================================== */
|
||
181 | |||
182 | typedef struct stat VSIStatBuf; |
||
183 | int CPL_DLL VSIStat( const char *, VSIStatBuf * ); |
||
184 | |||
185 | #ifdef _WIN32
|
||
186 | # define VSI_ISLNK(x) ( 0 ) /* N/A on Windows */ |
||
187 | # define VSI_ISREG(x) ((x) & S_IFREG)
|
||
188 | # define VSI_ISDIR(x) ((x) & S_IFDIR)
|
||
189 | # define VSI_ISCHR(x) ((x) & S_IFCHR)
|
||
190 | # define VSI_ISBLK(x) ( 0 ) /* N/A on Windows */ |
||
191 | #else
|
||
192 | # define VSI_ISLNK(x) S_ISLNK(x)
|
||
193 | # define VSI_ISREG(x) S_ISREG(x)
|
||
194 | # define VSI_ISDIR(x) S_ISDIR(x)
|
||
195 | # define VSI_ISCHR(x) S_ISCHR(x)
|
||
196 | # define VSI_ISBLK(x) S_ISBLK(x)
|
||
197 | #endif
|
||
198 | |||
199 | /* ==================================================================== */
|
||
200 | /* 64bit stdio file access functions. If we have a big size */
|
||
201 | /* defined, then provide protypes for the large file API, */
|
||
202 | /* otherwise redefine to use the regular api. */
|
||
203 | /* ==================================================================== */
|
||
204 | #ifdef VSI_LARGE_API_SUPPORTED
|
||
205 | |||
206 | typedef GUIntBig vsi_l_offset;
|
||
207 | |||
208 | FILE CPL_DLL * VSIFOpenL( const char *, const char * ); |
||
209 | int CPL_DLL VSIFCloseL( FILE * );
|
||
210 | int CPL_DLL VSIFSeekL( FILE *, vsi_l_offset, int ); |
||
211 | vsi_l_offset CPL_DLL VSIFTellL( FILE * ); |
||
212 | void CPL_DLL VSIRewindL( FILE * );
|
||
213 | size_t CPL_DLL VSIFReadL( void *, size_t, size_t, FILE * );
|
||
214 | size_t CPL_DLL VSIFWriteL( void *, size_t, size_t, FILE * );
|
||
215 | int CPL_DLL VSIFEofL( FILE * );
|
||
216 | void CPL_DLL VSIFFlushL( FILE * );
|
||
217 | |||
218 | #ifndef WIN32
|
||
219 | typedef struct stat64 VSIStatBufL; |
||
220 | int CPL_DLL VSIStatL( const char *, VSIStatBufL * ); |
||
221 | #else
|
||
222 | #define VSIStatBufL VSIStatBuf
|
||
223 | #define VSIStatL VSIStat
|
||
224 | #endif
|
||
225 | |||
226 | #else
|
||
227 | |||
228 | typedef long vsi_l_offset; |
||
229 | |||
230 | #define vsi_l_offset long |
||
231 | |||
232 | #define VSIFOpenL VSIFOpen
|
||
233 | #define VSIFCloseL VSIFClose
|
||
234 | #define VSIFSeekL VSIFSeek
|
||
235 | #define VSIFTellL VSIFTell
|
||
236 | #define VSIFRewindL VSIFRewind
|
||
237 | #define VSIFReadL VSIFRead
|
||
238 | #define VSIFWriteL VSIFWrite
|
||
239 | #define VSIFEofL VSIFEof
|
||
240 | #define VSIFFlushL VSIFFlush
|
||
241 | #define VSIStatBufL VSIStatBuf
|
||
242 | #define VSIStatL VSIStat
|
||
243 | |||
244 | #endif
|
||
245 | |||
246 | /* ==================================================================== */
|
||
247 | /* Memory allocation */
|
||
248 | /* ==================================================================== */
|
||
249 | |||
250 | void CPL_DLL *VSICalloc( size_t, size_t );
|
||
251 | void CPL_DLL *VSIMalloc( size_t );
|
||
252 | void CPL_DLL VSIFree( void * ); |
||
253 | void CPL_DLL *VSIRealloc( void *, size_t ); |
||
254 | char CPL_DLL *VSIStrdup( const char * ); |
||
255 | |||
256 | /* ==================================================================== */
|
||
257 | /* Other... */
|
||
258 | /* ==================================================================== */
|
||
259 | |||
260 | int CPL_DLL VSIMkdir( const char * pathname, long mode ); |
||
261 | int CPL_DLL VSIRmdir( const char * pathname ); |
||
262 | int CPL_DLL VSIUnlink( const char * pathname ); |
||
263 | char CPL_DLL *VSIStrerror( int ); |
||
264 | |||
265 | /* ==================================================================== */
|
||
266 | /* Time quering. */
|
||
267 | /* ==================================================================== */
|
||
268 | |||
269 | unsigned long CPL_DLL VSITime( unsigned long * ); |
||
270 | const char CPL_DLL *VSICTime( unsigned long ); |
||
271 | struct tm CPL_DLL *VSIGMTime( const time_t *pnTime, |
||
272 | struct tm *poBrokenTime );
|
||
273 | struct tm CPL_DLL *VSILocalTime( const time_t *pnTime, |
||
274 | struct tm *poBrokenTime );
|
||
275 | |||
276 | /* -------------------------------------------------------------------- */
|
||
277 | /* the following can be turned on for detailed logging of */
|
||
278 | /* almost all IO calls. */
|
||
279 | /* -------------------------------------------------------------------- */
|
||
280 | #ifdef VSI_DEBUG
|
||
281 | |||
282 | #ifndef DEBUG
|
||
283 | # define DEBUG
|
||
284 | #endif
|
||
285 | |||
286 | #include "cpl_error.h" |
||
287 | |||
288 | #define VSIDebug4(f,a1,a2,a3,a4) CPLDebug( "VSI", f, a1, a2, a3, a4 ); |
||
289 | #define VSIDebug3( f, a1, a2, a3 ) CPLDebug( "VSI", f, a1, a2, a3 ); |
||
290 | #define VSIDebug2( f, a1, a2 ) CPLDebug( "VSI", f, a1, a2 ); |
||
291 | #define VSIDebug1( f, a1 ) CPLDebug( "VSI", f, a1 ); |
||
292 | #else
|
||
293 | #define VSIDebug4( f, a1, a2, a3, a4 ) {}
|
||
294 | #define VSIDebug3( f, a1, a2, a3 ) {}
|
||
295 | #define VSIDebug2( f, a1, a2 ) {}
|
||
296 | #define VSIDebug1( f, a1 ) {}
|
||
297 | #endif
|
||
298 | |||
299 | CPL_C_END |
||
300 | |||
301 | #endif /* ndef CPL_VSI_H_INCLUDED */ |