GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

cpl_minizip_unzip.h
1 /* Modified version by Even Rouault. :
2 - Addition of cpl_unzGetCurrentFileZStreamPos
3 - Decoration of symbol names unz* -> cpl_unz*
4 - Undef EXPORT so that we are sure the symbols are not exported
5 - Add support for ZIP64
6
7 * Copyright (c) 2008, Even Rouault <even dot rouault at mines-paris dot org>
8
9 Original licence available in port/LICENCE_minizip
10 */
11
12 /* unzip.h -- IO for uncompress .zip files using zlib
13 Version 1.01e, February 12th, 2005
14
15 Copyright (C) 1998-2005 Gilles Vollant
16
17 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
18 WinZip, InfoZip tools and compatible.
19
20 Multi volume ZipFile (span) are not supported.
21 Encryption compatible with pkzip 2.04g only supported
22 Old compressions used by old PKZip 1.x are not supported
23
24
25 I WAIT FEEDBACK at mail info@winimage.com
26 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
27
28 Condition of use and distribution are the same than zlib :
29
30 This software is provided 'as-is', without any express or implied
31 warranty. In no event will the authors be held liable for any damages
32 arising from the use of this software.
33
34 Permission is granted to anyone to use this software for any purpose,
35 including commercial applications, and to alter it and redistribute it
36 freely, subject to the following restrictions:
37
38 1. The origin of this software must not be misrepresented; you must not
39 claim that you wrote the original software. If you use this software
40 in a product, an acknowledgment in the product documentation would be
41 appreciated but is not required.
42 2. Altered source versions must be plainly marked as such, and must not be
43 misrepresented as being the original software.
44 3. This notice may not be removed or altered from any source distribution.
45
46
47 */
48
49 /* for more info about .ZIP format, see
50 http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
51 http://www.info-zip.org/pub/infozip/doc/
52 PkWare has also a specification at :
53 ftp://ftp.pkware.com/probdesc.zip
54 */
55
56 #ifndef CPL_MINIZIP_UNZIP_H_INCLUDED
57 #define CPL_MINIZIP_UNZIP_H_INCLUDED
58
59 #include "cpl_vsi.h"
60 #define uLong64 vsi_l_offset
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66 #ifndef _ZLIB_H
67 #include <zlib.h>
68 #endif
69
70 #ifndef CPL_MINIZIP_IOAPI_H_INCLUDED
71 #include "cpl_minizip_ioapi.h"
72 #endif
73
74 /* GDAL addition */
75 #define NOUNCRYPT
76 #undef ZEXPORT
77 #define ZEXPORT
78
79 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
80 /* like the STRICT of WIN32, we define a pointer that cannot be converted
81 from (void*) without cast */
82 typedef struct TagunzFile__ { int unused; } unzFile__;
83 typedef unzFile__ *unzFile;
84 #else
85 typedef voidp unzFile;
86 #endif
87
88
89 #define UNZ_OK (0)
90 #define UNZ_END_OF_LIST_OF_FILE (-100)
91 #define UNZ_ERRNO (Z_ERRNO)
92 #define UNZ_EOF (0)
93 #define UNZ_PARAMERROR (-102)
94 #define UNZ_BADZIPFILE (-103)
95 #define UNZ_INTERNALERROR (-104)
96 #define UNZ_CRCERROR (-105)
97
98 /* tm_unz contain date/time info */
99 typedef struct tm_unz_s
100 {
101 uInt tm_sec; /* seconds after the minute - [0,59] */
102 uInt tm_min; /* minutes after the hour - [0,59] */
103 uInt tm_hour; /* hours since midnight - [0,23] */
104 uInt tm_mday; /* day of the month - [1,31] */
105 uInt tm_mon; /* months since January - [0,11] */
106 uInt tm_year; /* years - [1980..2044] */
107 } tm_unz;
108
109 /* unz_global_info structure contain global data about the ZIPfile
110 These data comes from the end of central dir */
111 typedef struct unz_global_info_s
112 {
113 uLong64 number_entry; /* total number of entries in
114 the central dir on this disk */
115 uLong size_comment; /* size of the global comment of the zipfile */
116 } unz_global_info;
117
118
119 /* unz_file_info contain information about a file in the zipfile */
120 typedef struct unz_file_info_s
121 {
122 uLong version; /* version made by 2 bytes */
123 uLong version_needed; /* version needed to extract 2 bytes */
124 uLong flag; /* general purpose bit flag 2 bytes */
125 uLong compression_method; /* compression method 2 bytes */
126 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
127 uLong crc; /* crc-32 4 bytes */
128 uLong64 compressed_size; /* compressed size 4 bytes */
129 uLong64 uncompressed_size; /* uncompressed size 4 bytes */
130 uLong size_filename; /* filename length 2 bytes */
131 uLong size_file_extra; /* extra field length 2 bytes */
132 uLong size_file_comment; /* file comment length 2 bytes */
133
134 uLong disk_num_start; /* disk number start 2 bytes */
135 uLong internal_fa; /* internal file attributes 2 bytes */
136 uLong external_fa; /* external file attributes 4 bytes */
137
138 tm_unz tmu_date;
139 } unz_file_info;
140
141 extern int ZEXPORT cpl_unzStringFileNameCompare (const char* fileName1,
142 const char* fileName2,
143 int iCaseSensitivity);
144 /*
145 Compare two filename (fileName1,fileName2).
146 If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp)
147 If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi
148 or strcasecmp)
149 If iCaseSenisivity = 0, case sensitivity is default of your operating system
150 (like 1 on Unix, 2 on Windows)
151 */
152
153
154 extern unzFile ZEXPORT cpl_unzOpen (const char *path);
155 /*
156 Open a Zip file. path contain the full pathname (by example,
157 on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
158 "zlib/zlib113.zip".
159 If the zipfile cannot be opened (file don't exist or in not valid), the
160 return value is NULL.
161 Else, the return value is a unzFile Handle, usable with other function
162 of this unzip package.
163 */
164
165 extern unzFile ZEXPORT cpl_unzOpen2 (const char *path,
166 zlib_filefunc_def* pzlib_filefunc_def);
167 /*
168 Open a Zip file, like unzOpen, but provide a set of file low level API
169 for read/write the zip file (see ioapi.h)
170 */
171
172 extern int ZEXPORT cpl_unzClose (unzFile file);
173 /*
174 Close a ZipFile opened with unzipOpen.
175 If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
176 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
177 return UNZ_OK if there is no problem. */
178
179 extern int ZEXPORT cpl_unzGetGlobalInfo (unzFile file,
180 unz_global_info *pglobal_info);
181 /*
182 Write info about the ZipFile in the *pglobal_info structure.
183 No preparation of the structure is needed
184 return UNZ_OK if there is no problem. */
185
186
187 extern int ZEXPORT cpl_unzGetGlobalComment (unzFile file,
188 char *szComment,
189 uLong uSizeBuf);
190 /*
191 Get the global comment string of the ZipFile, in the szComment buffer.
192 uSizeBuf is the size of the szComment buffer.
193 return the number of byte copied or an error code <0
194 */
195
196
197 /***************************************************************************/
198 /* Unzip package allow you browse the directory of the zipfile */
199
200 extern int ZEXPORT cpl_unzGoToFirstFile (unzFile file);
201 /*
202 Set the current file of the zipfile to the first file.
203 return UNZ_OK if there is no problem
204 */
205
206 extern int ZEXPORT cpl_unzGoToNextFile (unzFile file);
207 /*
208 Set the current file of the zipfile to the next file.
209 return UNZ_OK if there is no problem
210 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
211 */
212
213 extern int ZEXPORT cpl_unzLocateFile (unzFile file,
214 const char *szFileName,
215 int iCaseSensitivity);
216 /*
217 Try locate the file szFileName in the zipfile.
218 For the iCaseSensitivity signification, see unzStringFileNameCompare
219
220 return value :
221 UNZ_OK if the file is found. It becomes the current file.
222 UNZ_END_OF_LIST_OF_FILE if the file is not found
223 */
224
225
226 /* ****************************************** */
227 /* Ryan supplied functions */
228 /* unz_file_info contain information about a file in the zipfile */
229 typedef struct unz_file_pos_s
230 {
231 uLong64 pos_in_zip_directory; /* offset in zip file directory */
232 uLong64 num_of_file; /* # of file */
233 } unz_file_pos;
234
235 extern int ZEXPORT cpl_unzGetFilePos(
236 unzFile file,
237 unz_file_pos* file_pos);
238
239 extern int ZEXPORT cpl_unzGoToFilePos(
240 unzFile file,
241 unz_file_pos* file_pos);
242
243 /* ****************************************** */
244
245 extern int ZEXPORT cpl_unzGetCurrentFileInfo (unzFile file,
246 unz_file_info *pfile_info,
247 char *szFileName,
248 uLong fileNameBufferSize,
249 void *extraField,
250 uLong extraFieldBufferSize,
251 char *szComment,
252 uLong commentBufferSize);
253 /*
254 Get Info about the current file
255 if pfile_info!=NULL, the *pfile_info structure will contain some info about
256 the current file
257 if szFileName!=NULL, the filename string will be copied in szFileName
258 (fileNameBufferSize is the size of the buffer)
259 if extraField!=NULL, the extra field information will be copied in extraField
260 (extraFieldBufferSize is the size of the buffer).
261 This is the Central-header version of the extra field
262 if szComment!=NULL, the comment string of the file will be copied in szComment
263 (commentBufferSize is the size of the buffer)
264 */
265
266
269 extern uLong64 ZEXPORT cpl_unzGetCurrentFileZStreamPos (unzFile file);
270
274 /***************************************************************************/
275 /* for reading the content of the current zipfile, you can open it, read data
276 from it, and close it (you can close it before reading all the file)
277 */
278
279 extern int ZEXPORT cpl_unzOpenCurrentFile (unzFile file);
280 /*
281 Open for reading data the current file in the zipfile.
282 If there is no error, the return value is UNZ_OK.
283 */
284
285 extern int ZEXPORT cpl_unzOpenCurrentFilePassword (unzFile file,
286 const char* password);
287 /*
288 Open for reading data the current file in the zipfile.
289 password is a crypting password
290 If there is no error, the return value is UNZ_OK.
291 */
292
293 extern int ZEXPORT cpl_unzOpenCurrentFile2 (unzFile file,
294 int* method,
295 int* level,
296 int raw);
297 /*
298 Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
299 if raw==1
300 *method will receive method of compression, *level will receive level of
301 compression
302 note : you can set level parameter as NULL (if you did not want known level,
303 but you CANNOT set method parameter as NULL
304 */
305
306 extern int ZEXPORT cpl_unzOpenCurrentFile3 (unzFile file,
307 int* method,
308 int* level,
309 int raw,
310 const char* password);
311 /*
312 Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
313 if raw==1
314 *method will receive method of compression, *level will receive level of
315 compression
316 note : you can set level parameter as NULL (if you did not want known level,
317 but you CANNOT set method parameter as NULL
318 */
319
320
321 extern int ZEXPORT cpl_unzCloseCurrentFile (unzFile file);
322 /*
323 Close the file in zip opened with unzOpenCurrentFile
324 Return UNZ_CRCERROR if all the file was read but the CRC is not good
325 */
326
327 extern int ZEXPORT cpl_unzReadCurrentFile (unzFile file,
328 voidp buf,
329 unsigned len);
330 /*
331 Read bytes from the current file (opened by unzOpenCurrentFile)
332 buf contain buffer where data must be copied
333 len the size of buf.
334
335 return the number of byte copied if some bytes are copied
336 return 0 if the end of file was reached
337 return <0 with error code if there is an error
338 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
339 */
340
341 extern z_off_t ZEXPORT cpl_unztell (unzFile file);
342 /*
343 Give the current position in uncompressed data
344 */
345
346 extern int ZEXPORT cpl_unzeof (unzFile file);
347 /*
348 return 1 if the end of file was reached, 0 elsewhere
349 */
350
351 extern int ZEXPORT cpl_unzGetLocalExtrafield (unzFile file,
352 voidp buf,
353 unsigned len);
354 /*
355 Read extra field from the current file (opened by unzOpenCurrentFile)
356 This is the local-header version of the extra field (sometimes, there is
357 more info in the local-header version than in the central-header)
358
359 if buf==NULL, it return the size of the local extra field
360
361 if buf!=NULL, len is the size of the buffer, the extra header is copied in
362 buf.
363 the return value is the number of bytes copied in buf, or (if <0)
364 the error code
365 */
366
367 /***************************************************************************/
368
369 /* Get the current file offset */
370 extern uLong64 ZEXPORT cpl_unzGetOffset (unzFile file);
371
372 /* Set the current file offset */
373 extern int ZEXPORT cpl_unzSetOffset (unzFile file, uLong64 pos);
374
375
376
377 #ifdef __cplusplus
378 }
379 #endif
380
381 #endif /* CPL_MINIZIP_UNZIP_H_INCLUDED */
cpl_vsi.h
Standard C Covers.
unz_file_info_s
Definition: cpl_minizip_unzip.h:120
zlib_filefunc_def_s
Definition: cpl_minizip_ioapi.h:56
tm_unz_s
Definition: cpl_minizip_unzip.h:99
unz_file_pos_s
Definition: cpl_minizip_unzip.h:229
unz_global_info_s
Definition: cpl_minizip_unzip.h:111

Generated for GDAL by 1.8.8.