source: s10k/CommonLibs/quazip-0.7.2/quazip/unzip.h@ 1166

Last change on this file since 1166 was 1096, checked in by s10k, 7 years ago

Added zlib, quazip, basicxmlsyntaxhighlighter, conditionalsemaphore and linenumberdisplay libraries. zlib and quazip are pre-compiled, but you can compile them yourself, just delete the dll files (or equivalent binary files to your OS)

File size: 17.3 KB
Line 
1/* unzip.h -- IO for uncompress .zip files using zlib
2 Version 1.1, February 14h, 2010
3 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
4
5 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
6
7 Modifications of Unzip for Zip64
8 Copyright (C) 2007-2008 Even Rouault
9
10 Modifications for Zip64 support on both zip and unzip
11 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
12
13 For more info read MiniZip_info.txt
14
15 ---------------------------------------------------------------------------------
16
17 Condition of use and distribution are the same than zlib :
18
19 This software is provided 'as-is', without any express or implied
20 warranty. In no event will the authors be held liable for any damages
21 arising from the use of this software.
22
23 Permission is granted to anyone to use this software for any purpose,
24 including commercial applications, and to alter it and redistribute it
25 freely, subject to the following restrictions:
26
27 1. The origin of this software must not be misrepresented; you must not
28 claim that you wrote the original software. If you use this software
29 in a product, an acknowledgment in the product documentation would be
30 appreciated but is not required.
31 2. Altered source versions must be plainly marked as such, and must not be
32 misrepresented as being the original software.
33 3. This notice may not be removed or altered from any source distribution.
34
35 ---------------------------------------------------------------------------------
36
37 Changes
38
39 See header of unzip64.c
40
41 ---------------------------------------------------------------------------
42
43 As per the requirement above, this file is plainly marked as modified
44 by Sergey A. Tachenov. Most modifications include the I/O API redesign
45 to support QIODevice interface. Some improvements and small fixes were also made.
46*/
47
48#ifndef _unz64_H
49#define _unz64_H
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55#ifndef _ZLIB_H
56#include "zlib.h"
57#endif
58
59#ifndef _ZLIBIOAPI_H
60#include "ioapi.h"
61#endif
62
63#ifdef HAVE_BZIP2
64#include "bzlib.h"
65#endif
66
67#define Z_BZIP2ED 12
68
69#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
70/* like the STRICT of WIN32, we define a pointer that cannot be converted
71 from (void*) without cast */
72typedef struct TagunzFile__ { int unused; } unzFile__;
73typedef unzFile__ *unzFile;
74#else
75typedef voidp unzFile;
76#endif
77
78
79#define UNZ_OK (0)
80#define UNZ_END_OF_LIST_OF_FILE (-100)
81#define UNZ_ERRNO (Z_ERRNO)
82#define UNZ_EOF (0)
83#define UNZ_PARAMERROR (-102)
84#define UNZ_BADZIPFILE (-103)
85#define UNZ_INTERNALERROR (-104)
86#define UNZ_CRCERROR (-105)
87
88#define UNZ_AUTO_CLOSE 0x01u
89#define UNZ_DEFAULT_FLAGS UNZ_AUTO_CLOSE
90
91/* tm_unz contain date/time info */
92typedef struct tm_unz_s
93{
94 uInt tm_sec; /* seconds after the minute - [0,59] */
95 uInt tm_min; /* minutes after the hour - [0,59] */
96 uInt tm_hour; /* hours since midnight - [0,23] */
97 uInt tm_mday; /* day of the month - [1,31] */
98 uInt tm_mon; /* months since January - [0,11] */
99 uInt tm_year; /* years - [1980..2044] */
100} tm_unz;
101
102/* unz_global_info structure contain global data about the ZIPfile
103 These data comes from the end of central dir */
104typedef struct unz_global_info64_s
105{
106 ZPOS64_T number_entry; /* total number of entries in
107 the central dir on this disk */
108 uLong size_comment; /* size of the global comment of the zipfile */
109} unz_global_info64;
110
111typedef struct unz_global_info_s
112{
113 uLong 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/* unz_file_info contain information about a file in the zipfile */
119typedef struct unz_file_info64_s
120{
121 uLong version; /* version made by 2 bytes */
122 uLong version_needed; /* version needed to extract 2 bytes */
123 uLong flag; /* general purpose bit flag 2 bytes */
124 uLong compression_method; /* compression method 2 bytes */
125 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
126 uLong crc; /* crc-32 4 bytes */
127 ZPOS64_T compressed_size; /* compressed size 8 bytes */
128 ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
129 uLong size_filename; /* filename length 2 bytes */
130 uLong size_file_extra; /* extra field length 2 bytes */
131 uLong size_file_comment; /* file comment length 2 bytes */
132
133 uLong disk_num_start; /* disk number start 2 bytes */
134 uLong internal_fa; /* internal file attributes 2 bytes */
135 uLong external_fa; /* external file attributes 4 bytes */
136
137 tm_unz tmu_date;
138} unz_file_info64;
139
140typedef struct unz_file_info_s
141{
142 uLong version; /* version made by 2 bytes */
143 uLong version_needed; /* version needed to extract 2 bytes */
144 uLong flag; /* general purpose bit flag 2 bytes */
145 uLong compression_method; /* compression method 2 bytes */
146 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
147 uLong crc; /* crc-32 4 bytes */
148 uLong compressed_size; /* compressed size 4 bytes */
149 uLong uncompressed_size; /* uncompressed size 4 bytes */
150 uLong size_filename; /* filename length 2 bytes */
151 uLong size_file_extra; /* extra field length 2 bytes */
152 uLong size_file_comment; /* file comment length 2 bytes */
153
154 uLong disk_num_start; /* disk number start 2 bytes */
155 uLong internal_fa; /* internal file attributes 2 bytes */
156 uLong external_fa; /* external file attributes 4 bytes */
157
158 tm_unz tmu_date;
159} unz_file_info;
160
161extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
162 const char* fileName2,
163 int iCaseSensitivity));
164/*
165 Compare two filename (fileName1,fileName2).
166 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
167 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
168 or strcasecmp)
169 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
170 (like 1 on Unix, 2 on Windows)
171*/
172
173
174extern unzFile ZEXPORT unzOpen OF((voidpf file));
175extern unzFile ZEXPORT unzOpen64 OF((voidpf file));
176/*
177 Open a Zip file. path contain the full pathname (by example,
178 on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
179 "zlib/zlib113.zip".
180 If the zipfile cannot be opened (file don't exist or in not valid), the
181 return value is NULL.
182 Else, the return value is a unzFile Handle, usable with other function
183 of this unzip package.
184 the "64" function take a const void* pointer, because the path is just the
185 value passed to the open64_file_func callback.
186 Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
187 is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
188 does not describe the reality
189*/
190
191
192extern unzFile ZEXPORT unzOpen2 OF((voidpf file,
193 zlib_filefunc_def* pzlib_filefunc_def));
194/*
195 Open a Zip file, like unzOpen, but provide a set of file low level API
196 for read/write the zip file (see ioapi.h)
197*/
198
199extern unzFile ZEXPORT unzOpen2_64 OF((voidpf file,
200 zlib_filefunc64_def* pzlib_filefunc_def));
201/*
202 Open a Zip file, like unz64Open, but provide a set of file low level API
203 for read/write the zip file (see ioapi.h)
204*/
205
206
207/*
208 * Exported by Sergey A. Tachenov to implement some QuaZIP features. This
209 * function MAY change signature in order to implement even more features.
210 * You have been warned!
211 * */
212extern unzFile unzOpenInternal (voidpf file,
213 zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
214 int is64bitOpenFunction, unsigned flags);
215
216
217
218extern int ZEXPORT unzClose OF((unzFile file));
219/*
220 Close a ZipFile opened with unzipOpen.
221 If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
222 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
223 return UNZ_OK if there is no problem. */
224
225extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
226 unz_global_info *pglobal_info));
227
228extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
229 unz_global_info64 *pglobal_info));
230/*
231 Write info about the ZipFile in the *pglobal_info structure.
232 No preparation of the structure is needed
233 return UNZ_OK if there is no problem. */
234
235
236extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
237 char *szComment,
238 uLong uSizeBuf));
239/*
240 Get the global comment string of the ZipFile, in the szComment buffer.
241 uSizeBuf is the size of the szComment buffer.
242 return the number of byte copied or an error code <0
243*/
244
245
246/***************************************************************************/
247/* Unzip package allow you browse the directory of the zipfile */
248
249extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
250/*
251 Set the current file of the zipfile to the first file.
252 return UNZ_OK if there is no problem
253*/
254
255extern int ZEXPORT unzGoToNextFile OF((unzFile file));
256/*
257 Set the current file of the zipfile to the next file.
258 return UNZ_OK if there is no problem
259 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
260*/
261
262extern int ZEXPORT unzLocateFile OF((unzFile file,
263 const char *szFileName,
264 int iCaseSensitivity));
265/*
266 Try locate the file szFileName in the zipfile.
267 For the iCaseSensitivity signification, see unzStringFileNameCompare
268
269 return value :
270 UNZ_OK if the file is found. It becomes the current file.
271 UNZ_END_OF_LIST_OF_FILE if the file is not found
272*/
273
274
275/* ****************************************** */
276/* Ryan supplied functions */
277/* unz_file_info contain information about a file in the zipfile */
278typedef struct unz_file_pos_s
279{
280 uLong pos_in_zip_directory; /* offset in zip file directory */
281 uLong num_of_file; /* # of file */
282} unz_file_pos;
283
284extern int ZEXPORT unzGetFilePos(
285 unzFile file,
286 unz_file_pos* file_pos);
287
288extern int ZEXPORT unzGoToFilePos(
289 unzFile file,
290 unz_file_pos* file_pos);
291
292typedef struct unz64_file_pos_s
293{
294 ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
295 ZPOS64_T num_of_file; /* # of file */
296} unz64_file_pos;
297
298extern int ZEXPORT unzGetFilePos64(
299 unzFile file,
300 unz64_file_pos* file_pos);
301
302extern int ZEXPORT unzGoToFilePos64(
303 unzFile file,
304 const unz64_file_pos* file_pos);
305
306/* ****************************************** */
307
308extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
309 unz_file_info64 *pfile_info,
310 char *szFileName,
311 uLong fileNameBufferSize,
312 void *extraField,
313 uLong extraFieldBufferSize,
314 char *szComment,
315 uLong commentBufferSize));
316
317extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
318 unz_file_info *pfile_info,
319 char *szFileName,
320 uLong fileNameBufferSize,
321 void *extraField,
322 uLong extraFieldBufferSize,
323 char *szComment,
324 uLong commentBufferSize));
325/*
326 Get Info about the current file
327 if pfile_info!=NULL, the *pfile_info structure will contain somes info about
328 the current file
329 if szFileName!=NULL, the filemane string will be copied in szFileName
330 (fileNameBufferSize is the size of the buffer)
331 if extraField!=NULL, the extra field information will be copied in extraField
332 (extraFieldBufferSize is the size of the buffer).
333 This is the Central-header version of the extra field
334 if szComment!=NULL, the comment string of the file will be copied in szComment
335 (commentBufferSize is the size of the buffer)
336*/
337
338
339/** Addition for GDAL : START */
340
341extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
342
343/** Addition for GDAL : END */
344
345
346/***************************************************************************/
347/* for reading the content of the current zipfile, you can open it, read data
348 from it, and close it (you can close it before reading all the file)
349 */
350
351extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
352/*
353 Open for reading data the current file in the zipfile.
354 If there is no error, the return value is UNZ_OK.
355*/
356
357extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
358 const char* password));
359/*
360 Open for reading data the current file in the zipfile.
361 password is a crypting password
362 If there is no error, the return value is UNZ_OK.
363*/
364
365extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
366 int* method,
367 int* level,
368 int raw));
369/*
370 Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
371 if raw==1
372 *method will receive method of compression, *level will receive level of
373 compression
374 note : you can set level parameter as NULL (if you did not want known level,
375 but you CANNOT set method parameter as NULL
376*/
377
378extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
379 int* method,
380 int* level,
381 int raw,
382 const char* password));
383/*
384 Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
385 if raw==1
386 *method will receive method of compression, *level will receive level of
387 compression
388 note : you can set level parameter as NULL (if you did not want known level,
389 but you CANNOT set method parameter as NULL
390*/
391
392
393extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
394/*
395 Close the file in zip opened with unzOpenCurrentFile
396 Return UNZ_CRCERROR if all the file was read but the CRC is not good
397*/
398
399extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
400 voidp buf,
401 unsigned len));
402/*
403 Read bytes from the current file (opened by unzOpenCurrentFile)
404 buf contain buffer where data must be copied
405 len the size of buf.
406
407 return the number of byte copied if somes bytes are copied
408 return 0 if the end of file was reached
409 return <0 with error code if there is an error
410 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
411*/
412
413extern z_off_t ZEXPORT unztell OF((unzFile file));
414
415extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
416/*
417 Give the current position in uncompressed data
418*/
419
420extern int ZEXPORT unzeof OF((unzFile file));
421/*
422 return 1 if the end of file was reached, 0 elsewhere
423*/
424
425extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
426 voidp buf,
427 unsigned len));
428/*
429 Read extra field from the current file (opened by unzOpenCurrentFile)
430 This is the local-header version of the extra field (sometimes, there is
431 more info in the local-header version than in the central-header)
432
433 if buf==NULL, it return the size of the local extra field
434
435 if buf!=NULL, len is the size of the buffer, the extra header is copied in
436 buf.
437 the return value is the number of bytes copied in buf, or (if <0)
438 the error code
439*/
440
441/***************************************************************************/
442
443/* Get the current file offset */
444extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
445extern uLong ZEXPORT unzGetOffset (unzFile file);
446
447/* Set the current file offset */
448extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
449extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
450
451extern int ZEXPORT unzSetFlags(unzFile file, unsigned flags);
452extern int ZEXPORT unzClearFlags(unzFile file, unsigned flags);
453
454#ifdef __cplusplus
455}
456#endif
457
458#endif /* _unz64_H */
Note: See TracBrowser for help on using the repository browser.