Oolite
Loading...
Searching...
No Matches
unzip.h
Go to the documentation of this file.
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#ifndef _unz64_H
44#define _unz64_H
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50#ifndef _ZLIB_H
51#include "zlib.h"
52#endif
53
54#ifndef _ZLIBIOAPI_H
55#include "ioapi.h"
56#endif
57
58#ifdef HAVE_BZIP2
59#include "bzlib.h"
60#endif
61
62#define Z_BZIP2ED 12
63
64#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
65/* like the STRICT of WIN32, we define a pointer that cannot be converted
66 from (void*) without cast */
67typedef struct TagunzFile__ {
68 int unused;
69} unzFile__;
70typedef unzFile__* unzFile;
71#else
72typedef voidp unzFile;
73#endif
74
75#define UNZ_OK (0)
76#define UNZ_END_OF_LIST_OF_FILE (-100)
77#define UNZ_ERRNO (Z_ERRNO)
78#define UNZ_EOF (0)
79#define UNZ_PARAMERROR (-102)
80#define UNZ_BADZIPFILE (-103)
81#define UNZ_INTERNALERROR (-104)
82#define UNZ_CRCERROR (-105)
83
84/* tm_unz contain date/time info */
85typedef struct tm_unz_s {
86 uInt tm_sec; /* seconds after the minute - [0,59] */
87 uInt tm_min; /* minutes after the hour - [0,59] */
88 uInt tm_hour; /* hours since midnight - [0,23] */
89 uInt tm_mday; /* day of the month - [1,31] */
90 uInt tm_mon; /* months since January - [0,11] */
91 uInt tm_year; /* years - [1980..2044] */
93
94/* unz_global_info structure contain global data about the ZIPfile
95 These data comes from the end of central dir */
96typedef struct unz_global_info64_s {
97 ZPOS64_T number_entry; /* total number of entries in
98 the central dir on this disk */
99 uLong size_comment; /* size of the global comment of the zipfile */
101
102typedef struct unz_global_info_s {
103 uLong number_entry; /* total number of entries in
104 the central dir on this disk */
105 uLong size_comment; /* size of the global comment of the zipfile */
107
108/* unz_file_info contain information about a file in the zipfile */
109typedef struct unz_file_info64_s {
110 uLong version; /* version made by 2 bytes */
111 uLong version_needed; /* version needed to extract 2 bytes */
112 uLong flag; /* general purpose bit flag 2 bytes */
113 uLong compression_method; /* compression method 2 bytes */
114 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
115 uLong crc; /* crc-32 4 bytes */
116 ZPOS64_T compressed_size; /* compressed size 8 bytes */
117 ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
118 uLong size_filename; /* filename length 2 bytes */
119 uLong size_file_extra; /* extra field length 2 bytes */
120 uLong size_file_comment; /* file comment length 2 bytes */
121
122 uLong disk_num_start; /* disk number start 2 bytes */
123 uLong internal_fa; /* internal file attributes 2 bytes */
124 uLong external_fa; /* external file attributes 4 bytes */
125
128
129typedef struct unz_file_info_s {
130 uLong version; /* version made by 2 bytes */
131 uLong version_needed; /* version needed to extract 2 bytes */
132 uLong flag; /* general purpose bit flag 2 bytes */
133 uLong compression_method; /* compression method 2 bytes */
134 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
135 uLong crc; /* crc-32 4 bytes */
136 uLong compressed_size; /* compressed size 4 bytes */
137 uLong uncompressed_size; /* uncompressed size 4 bytes */
138 uLong size_filename; /* filename length 2 bytes */
139 uLong size_file_extra; /* extra field length 2 bytes */
140 uLong size_file_comment; /* file comment length 2 bytes */
141
142 uLong disk_num_start; /* disk number start 2 bytes */
143 uLong internal_fa; /* internal file attributes 2 bytes */
144 uLong external_fa; /* external file attributes 4 bytes */
145
148
149extern int ZEXPORT unzStringFileNameCompare OF((const char* fileName1,
150 const char* fileName2,
151 int iCaseSensitivity));
152/*
153 Compare two filename (fileName1,fileName2).
154 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
155 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
156 or strcasecmp)
157 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
158 (like 1 on Unix, 2 on Windows)
159*/
160
161extern unzFile ZEXPORT unzOpen OF((const char* path));
162extern unzFile ZEXPORT unzOpen64 OF((const void* path));
163/*
164 Open a Zip file. path contain the full pathname (by example,
165 on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
166 "zlib/zlib113.zip".
167 If the zipfile cannot be opened (file don't exist or in not valid), the
168 return value is NULL.
169 Else, the return value is a unzFile Handle, usable with other function
170 of this unzip package.
171 the "64" function take a const void* pointer, because the path is just the
172 value passed to the open64_file_func callback.
173 Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
174 is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
175 does not describe the reality
176*/
177
178extern unzFile ZEXPORT unzOpen2 OF((const char* path,
179 zlib_filefunc_def* pzlib_filefunc_def));
180/*
181 Open a Zip file, like unzOpen, but provide a set of file low level API
182 for read/write the zip file (see ioapi.h)
183*/
184
185extern unzFile ZEXPORT unzOpen2_64 OF((const void* path,
186 zlib_filefunc64_def* pzlib_filefunc_def));
187/*
188 Open a Zip file, like unz64Open, but provide a set of file low level API
189 for read/write the zip file (see ioapi.h)
190*/
191
192extern int ZEXPORT unzClose OF((unzFile file));
193/*
194 Close a ZipFile opened with unzipOpen.
195 If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
196 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
197 return UNZ_OK if there is no problem. */
198
199extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
200 unz_global_info* pglobal_info));
201
202extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
203 unz_global_info64* pglobal_info));
204/*
205 Write info about the ZipFile in the *pglobal_info structure.
206 No preparation of the structure is needed
207 return UNZ_OK if there is no problem. */
208
209extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
210 char* szComment,
211 uLong uSizeBuf));
212/*
213 Get the global comment string of the ZipFile, in the szComment buffer.
214 uSizeBuf is the size of the szComment buffer.
215 return the number of byte copied or an error code <0
216*/
217
218/***************************************************************************/
219/* Unzip package allow you browse the directory of the zipfile */
220
221extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
222/*
223 Set the current file of the zipfile to the first file.
224 return UNZ_OK if there is no problem
225*/
226
227extern int ZEXPORT unzGoToNextFile OF((unzFile file));
228/*
229 Set the current file of the zipfile to the next file.
230 return UNZ_OK if there is no problem
231 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
232*/
233
234extern int ZEXPORT unzLocateFile OF((unzFile file,
235 const char* szFileName,
236 int iCaseSensitivity));
237/*
238 Try locate the file szFileName in the zipfile.
239 For the iCaseSensitivity signification, see unzStringFileNameCompare
240
241 return value :
242 UNZ_OK if the file is found. It becomes the current file.
243 UNZ_END_OF_LIST_OF_FILE if the file is not found
244*/
245
246/* ****************************************** */
247/* Ryan supplied functions */
248/* unz_file_info contain information about a file in the zipfile */
249typedef struct unz_file_pos_s {
250 uLong pos_in_zip_directory; /* offset in zip file directory */
251 uLong num_of_file; /* # of file */
253
254extern int ZEXPORT unzGetFilePos(
255 unzFile file,
256 unz_file_pos* file_pos);
257
258extern int ZEXPORT unzGoToFilePos(
259 unzFile file,
260 unz_file_pos* file_pos);
261
262typedef struct unz64_file_pos_s {
263 ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
264 ZPOS64_T num_of_file; /* # of file */
266
267extern int ZEXPORT unzGetFilePos64(
268 unzFile file,
269 unz64_file_pos* file_pos);
270
271extern int ZEXPORT unzGoToFilePos64(
272 unzFile file,
273 const unz64_file_pos* file_pos);
274
275/* ****************************************** */
276
277extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
278 unz_file_info64* pfile_info,
279 char* szFileName,
280 uLong fileNameBufferSize,
281 void* extraField,
282 uLong extraFieldBufferSize,
283 char* szComment,
284 uLong commentBufferSize));
285
286extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
287 unz_file_info* pfile_info,
288 char* szFileName,
289 uLong fileNameBufferSize,
290 void* extraField,
291 uLong extraFieldBufferSize,
292 char* szComment,
293 uLong commentBufferSize));
294/*
295 Get Info about the current file
296 if pfile_info!=NULL, the *pfile_info structure will contain somes info about
297 the current file
298 if szFileName!=NULL, the filemane string will be copied in szFileName
299 (fileNameBufferSize is the size of the buffer)
300 if extraField!=NULL, the extra field information will be copied in extraField
301 (extraFieldBufferSize is the size of the buffer).
302 This is the Central-header version of the extra field
303 if szComment!=NULL, the comment string of the file will be copied in szComment
304 (commentBufferSize is the size of the buffer)
305*/
306
308
309extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
310
312
313/***************************************************************************/
314/* for reading the content of the current zipfile, you can open it, read data
315 from it, and close it (you can close it before reading all the file)
316 */
317
318extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
319/*
320 Open for reading data the current file in the zipfile.
321 If there is no error, the return value is UNZ_OK.
322*/
323
324extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
325 const char* password));
326/*
327 Open for reading data the current file in the zipfile.
328 password is a crypting password
329 If there is no error, the return value is UNZ_OK.
330*/
331
332extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
333 int* method,
334 int* level,
335 int raw));
336/*
337 Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
338 if raw==1
339 *method will receive method of compression, *level will receive level of
340 compression
341 note : you can set level parameter as NULL (if you did not want known level,
342 but you CANNOT set method parameter as NULL
343*/
344
345extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
346 int* method,
347 int* level,
348 int raw,
349 const char* password));
350/*
351 Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
352 if raw==1
353 *method will receive method of compression, *level will receive level of
354 compression
355 note : you can set level parameter as NULL (if you did not want known level,
356 but you CANNOT set method parameter as NULL
357*/
358
359extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
360/*
361 Close the file in zip opened with unzOpenCurrentFile
362 Return UNZ_CRCERROR if all the file was read but the CRC is not good
363*/
364
365extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
366 voidp buf,
367 unsigned len));
368/*
369 Read bytes from the current file (opened by unzOpenCurrentFile)
370 buf contain buffer where data must be copied
371 len the size of buf.
372
373 return the number of byte copied if somes bytes are copied
374 return 0 if the end of file was reached
375 return <0 with error code if there is an error
376 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
377*/
378
379extern z_off_t ZEXPORT unztell OF((unzFile file));
380
381extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
382/*
383 Give the current position in uncompressed data
384*/
385
386extern int ZEXPORT unzeof OF((unzFile file));
387/*
388 return 1 if the end of file was reached, 0 elsewhere
389*/
390
391extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
392 voidp buf,
393 unsigned len));
394/*
395 Read extra field from the current file (opened by unzOpenCurrentFile)
396 This is the local-header version of the extra field (sometimes, there is
397 more info in the local-header version than in the central-header)
398
399 if buf==NULL, it return the size of the local extra field
400
401 if buf!=NULL, len is the size of the buffer, the extra header is copied in
402 buf.
403 the return value is the number of bytes copied in buf, or (if <0)
404 the error code
405*/
406
407/***************************************************************************/
408
409/* Get the current file offset */
410extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file);
411extern uLong ZEXPORT unzGetOffset(unzFile file);
412
413/* Set the current file offset */
414extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos);
415extern int ZEXPORT unzSetOffset(unzFile file, uLong pos);
416
417#ifdef __cplusplus
418}
419#endif
420
421#endif /* _unz64_H */
struct zlib_filefunc64_def_s zlib_filefunc64_def
voidpf void * buf
Definition ioapi.h:126
struct zlib_filefunc_def_s zlib_filefunc_def
unsigned long long int ZPOS64_T
Definition ioapi.h:97
mz_ulong uLong
Definition miniz.h:440
unsigned int uInt
Definition miniz.h:439
void * voidp
Definition miniz.h:447
uInt tm_mon
Definition unzip.h:90
uInt tm_mday
Definition unzip.h:89
uInt tm_year
Definition unzip.h:91
uInt tm_sec
Definition unzip.h:86
uInt tm_min
Definition unzip.h:87
uInt tm_hour
Definition unzip.h:88
ZPOS64_T num_of_file
Definition unzip.h:264
ZPOS64_T pos_in_zip_directory
Definition unzip.h:263
uLong size_file_extra
Definition unzip.h:119
uLong internal_fa
Definition unzip.h:123
ZPOS64_T uncompressed_size
Definition unzip.h:117
tm_unz tmu_date
Definition unzip.h:126
uLong size_filename
Definition unzip.h:118
uLong compression_method
Definition unzip.h:113
uLong external_fa
Definition unzip.h:124
uLong version_needed
Definition unzip.h:111
uLong disk_num_start
Definition unzip.h:122
ZPOS64_T compressed_size
Definition unzip.h:116
uLong size_file_comment
Definition unzip.h:120
uLong dosDate
Definition unzip.h:134
uLong version_needed
Definition unzip.h:131
uLong compressed_size
Definition unzip.h:136
uLong size_file_extra
Definition unzip.h:139
uLong version
Definition unzip.h:130
uLong uncompressed_size
Definition unzip.h:137
uLong internal_fa
Definition unzip.h:143
uLong compression_method
Definition unzip.h:133
uLong disk_num_start
Definition unzip.h:142
tm_unz tmu_date
Definition unzip.h:146
uLong external_fa
Definition unzip.h:144
uLong size_filename
Definition unzip.h:138
uLong size_file_comment
Definition unzip.h:140
uLong num_of_file
Definition unzip.h:251
uLong pos_in_zip_directory
Definition unzip.h:250
ZPOS64_T number_entry
Definition unzip.h:97
uLong size_comment
Definition unzip.h:99
uLong size_comment
Definition unzip.h:105
uLong number_entry
Definition unzip.h:103
int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len)
Definition unzip.c:1845
int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char *password)
Definition unzip.c:1563
z_off_t ZEXPORT unztell(unzFile file)
Definition unzip.c:1781
int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity)
Definition unzip.c:1161
int ZEXPORT unzStringFileNameCompare(const char *fileName1, const char *fileName2, int iCaseSensitivity)
Definition unzip.c:379
ZPOS64_T ZEXPORT unztell64(unzFile file)
Definition unzip.c:1796
unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def)
Definition unzip.c:740
unzFile ZEXPORT unzOpen(const char *path)
Definition unzip.c:753
int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
Definition unzip.c:1058
int ZEXPORT unzGoToFirstFile(unzFile file)
Definition unzip.c:1109
int ZEXPORT unzeof(unzFile file)
Definition unzip.c:1815
int ZEXPORT unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw)
Definition unzip.c:1568
int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password)
Definition unzip.c:1393
int ZEXPORT unzOpenCurrentFile(unzFile file)
Definition unzip.c:1558
int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len)
Definition unzip.c:1600
int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info)
Definition unzip.c:787
unzFile ZEXPORT unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc32_def)
Definition unzip.c:729
int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info32)
Definition unzip.c:797
ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file)
Definition unzip.c:1575
unzFile ZEXPORT unzOpen64(const void *path)
Definition unzip.c:758
int ZEXPORT unzCloseCurrentFile(unzFile file)
Definition unzip.c:1893
int ZEXPORT unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
Definition unzip.c:1070
int ZEXPORT unzGoToNextFile(unzFile file)
Definition unzip.c:1130
int ZEXPORT unzGetGlobalComment(unzFile file, char *szComment, uLong uSizeBuf)
Definition unzip.c:1934
int ZEXPORT unzClose(unzFile file)
Definition unzip.c:768
struct tm_unz_s tm_unz
int ZEXPORT unzSetOffset(unzFile file, uLong pos)
Definition unzip.c:2004
uLong ZEXPORT unzGetOffset(unzFile file)
Definition unzip.c:1976
int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos *file_pos)
Definition unzip.c:1250
int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos *file_pos)
Definition unzip.c:1234
ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
Definition unzip.c:1961
int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos)
Definition unzip.c:1263
int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos *file_pos)
Definition unzip.c:1285
struct unz_global_info_s unz_global_info
struct unz_global_info64_s unz_global_info64
int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
Definition unzip.c:1986
struct unz_file_pos_s unz_file_pos
struct unz_file_info_s unz_file_info
int ZEXPORT unzStringFileNameCompare OF((const char *fileName1, const char *fileName2, int iCaseSensitivity))
struct unz_file_info64_s unz_file_info64
struct unz64_file_pos_s unz64_file_pos
voidp unzFile
Definition unzip.h:72