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