ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
zip.h
Go to the documentation of this file.
1 /* zip.h -- IO on .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 for Zip64 support
10  Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
11 
12  For more info read MiniZip_info.txt
13 
14  ---------------------------------------------------------------------------
15 
16  Condition of use and distribution are the same than zlib :
17 
18  This software is provided 'as-is', without any express or implied
19  warranty. In no event will the authors be held liable for any damages
20  arising from the use of this software.
21 
22  Permission is granted to anyone to use this software for any purpose,
23  including commercial applications, and to alter it and redistribute it
24  freely, subject to the following restrictions:
25 
26  1. The origin of this software must not be misrepresented; you must not
27  claim that you wrote the original software. If you use this software
28  in a product, an acknowledgment in the product documentation would be
29  appreciated but is not required.
30  2. Altered source versions must be plainly marked as such, and must not be
31  misrepresented as being the original software.
32  3. This notice may not be removed or altered from any source distribution.
33 
34  ---------------------------------------------------------------------------
35 
36  Changes
37 
38  See header of zip.h
39 
40  ---------------------------------------------------------------------------
41 
42  As per the requirement above, this file is plainly marked as modified
43  by Sergey A. Tachenov. Most modifications include the I/O API redesign
44  to support QIODevice interface. Some improvements and small fixes were also
45  made.
46 
47 */
48 
49 #ifndef _zip12_H
50 #define _zip12_H
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 // #define HAVE_BZIP2
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(STRICTZIP) || defined(STRICTZIPUNZIP)
73 /* like the STRICT of WIN32, we define a pointer that cannot be converted
74  from (void*) without cast */
75 typedef struct TagzipFile__ {
76  int unused;
77 } zipFile__;
78 typedef zipFile__* zipFile;
79 #else
80 typedef voidp zipFile;
81 #endif
82 
83 #define ZIP_OK (0)
84 #define ZIP_EOF (0)
85 #define ZIP_ERRNO (Z_ERRNO)
86 #define ZIP_PARAMERROR (-102)
87 #define ZIP_BADZIPFILE (-103)
88 #define ZIP_INTERNALERROR (-104)
89 
90 #define ZIP_WRITE_DATA_DESCRIPTOR 0x8u
91 #define ZIP_AUTO_CLOSE 0x1u
92 #define ZIP_SEQUENTIAL 0x2u
93 #define ZIP_DEFAULT_FLAGS (ZIP_AUTO_CLOSE | ZIP_WRITE_DATA_DESCRIPTOR)
94 
95 #ifndef DEF_MEM_LEVEL
96 #if MAX_MEM_LEVEL >= 8
97 #define DEF_MEM_LEVEL 8
98 #else
99 #define DEF_MEM_LEVEL MAX_MEM_LEVEL
100 #endif
101 #endif
102 /* default memLevel */
103 
104 /* tm_zip contain date/time info */
105 typedef struct tm_zip_s {
106  uInt tm_sec; /* seconds after the minute - [0,59] */
107  uInt tm_min; /* minutes after the hour - [0,59] */
108  uInt tm_hour; /* hours since midnight - [0,23] */
109  uInt tm_mday; /* day of the month - [1,31] */
110  uInt tm_mon; /* months since January - [0,11] */
111  uInt tm_year; /* years - [1980..2044] */
113 
114 typedef struct {
115  tm_zip tmz_date; /* date in understandable format */
116  uLong dosDate; /* if dos_date == 0, tmu_date is used */
117  /* uLong flag; */ /* general purpose bit flag 2 bytes
118  */
119 
120  uLong internal_fa; /* internal file attributes 2 bytes */
121  uLong external_fa; /* external file attributes 4 bytes */
122 } zip_fileinfo;
123 
124 typedef const char* zipcharpc;
125 
126 #define APPEND_STATUS_CREATE (0)
127 #define APPEND_STATUS_CREATEAFTER (1)
128 #define APPEND_STATUS_ADDINZIP (2)
129 
130 extern zipFile ZEXPORT zipOpen OF((voidpf file, int append));
131 extern zipFile ZEXPORT zipOpen64 OF((voidpf file, int append));
132 /*
133  Create a zipfile.
134  the file argument depends on the API used, for QuaZIP it's a QIODevice
135  pointer.
136  if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
137  will be created at the end of the file.
138  (useful if the file contain a self extractor code)
139  if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
140  add files in existing zip (be sure you don't add file that doesn't exist)
141  If the zipfile cannot be opened, the return value is NULL.
142  Else, the return value is a zipFile Handle, usable with other function
143  of this zip package.
144 */
145 
146 /* Note : there is no delete function into a zipfile.
147  If you want delete file into a zipfile, you must open a zipfile, and create
148  another Of couse, you can use RAW reading and writing to copy the file you
149  did not want delte
150 */
151 
152 extern zipFile ZEXPORT zipOpen2 OF((voidpf file,
153  int append,
154  zipcharpc* globalcomment,
155  zlib_filefunc_def* pzlib_filefunc_def));
156 
157 extern zipFile ZEXPORT zipOpen2_64
158  OF((voidpf file,
159  int append,
160  zipcharpc* globalcomment,
161  zlib_filefunc64_def* pzlib_filefunc_def));
162 
163 /*
164  * Exported by Sergey A. Tachenov to suit the needs of QuaZIP.
165  * Note that this function MAY change signature in order to
166  * provide new QuaZIP features. You have been warned!
167  * */
168 extern zipFile ZEXPORT zipOpen3(voidpf file,
169  int append,
170  zipcharpc* globalcomment,
171  zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
172  unsigned flags);
173 
174 extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
175  const char* filename,
176  const zip_fileinfo* zipfi,
177  const void* extrafield_local,
178  uInt size_extrafield_local,
179  const void* extrafield_global,
180  uInt size_extrafield_global,
181  const char* comment,
182  int method,
183  int level));
184 
185 extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
186  const char* filename,
187  const zip_fileinfo* zipfi,
188  const void* extrafield_local,
189  uInt size_extrafield_local,
190  const void* extrafield_global,
191  uInt size_extrafield_global,
192  const char* comment,
193  int method,
194  int level,
195  int zip64));
196 
197 /*
198  Open a file in the ZIP for writing.
199  filename : the filename in zip (if NULL, '-' without quote will be used
200  *zipfi contain supplemental information
201  if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
202  contains the extrafield data the the local header
203  if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
204  contains the extrafield data the the local header
205  if comment != NULL, comment contain the comment string
206  method contain the compression method (0 for store, Z_DEFLATED for deflate)
207  level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
208  zip64 is set to 1 if a zip64 extended information block should be added to the
209  local file header. this MUST be '1' if the uncompressed size is >= 0xffffffff.
210 
211 */
212 
213 extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
214  const char* filename,
215  const zip_fileinfo* zipfi,
216  const void* extrafield_local,
217  uInt size_extrafield_local,
218  const void* extrafield_global,
219  uInt size_extrafield_global,
220  const char* comment,
221  int method,
222  int level,
223  int raw));
224 
225 extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,
226  const char* filename,
227  const zip_fileinfo* zipfi,
228  const void* extrafield_local,
229  uInt size_extrafield_local,
230  const void* extrafield_global,
231  uInt size_extrafield_global,
232  const char* comment,
233  int method,
234  int level,
235  int raw,
236  int zip64));
237 /*
238  Same than zipOpenNewFileInZip, except if raw=1, we write raw file
239  */
240 
241 extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
242  const char* filename,
243  const zip_fileinfo* zipfi,
244  const void* extrafield_local,
245  uInt size_extrafield_local,
246  const void* extrafield_global,
247  uInt size_extrafield_global,
248  const char* comment,
249  int method,
250  int level,
251  int raw,
252  int windowBits,
253  int memLevel,
254  int strategy,
255  const char* password,
256  uLong crcForCrypting));
257 
258 extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
259  const char* filename,
260  const zip_fileinfo* zipfi,
261  const void* extrafield_local,
262  uInt size_extrafield_local,
263  const void* extrafield_global,
264  uInt size_extrafield_global,
265  const char* comment,
266  int method,
267  int level,
268  int raw,
269  int windowBits,
270  int memLevel,
271  int strategy,
272  const char* password,
273  uLong crcForCrypting,
274  int zip64));
275 
276 /*
277  Same than zipOpenNewFileInZip2, except
278  windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
279  password : crypting password (NULL for no crypting)
280  crcForCrypting : crc of file to compress (needed for crypting)
281  */
282 
283 extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
284  const char* filename,
285  const zip_fileinfo* zipfi,
286  const void* extrafield_local,
287  uInt size_extrafield_local,
288  const void* extrafield_global,
289  uInt size_extrafield_global,
290  const char* comment,
291  int method,
292  int level,
293  int raw,
294  int windowBits,
295  int memLevel,
296  int strategy,
297  const char* password,
298  uLong crcForCrypting,
299  uLong versionMadeBy,
300  uLong flagBase));
301 
302 extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
303  const char* filename,
304  const zip_fileinfo* zipfi,
305  const void* extrafield_local,
306  uInt size_extrafield_local,
307  const void* extrafield_global,
308  uInt size_extrafield_global,
309  const char* comment,
310  int method,
311  int level,
312  int raw,
313  int windowBits,
314  int memLevel,
315  int strategy,
316  const char* password,
317  uLong crcForCrypting,
318  uLong versionMadeBy,
319  uLong flagBase,
320  int zip64));
321 /*
322  Same than zipOpenNewFileInZip4, except
323  versionMadeBy : value for Version made by field
324  flag : value for flag field (compression level info will be added)
325  */
326 
327 extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
328  const void* buf,
329  unsigned len));
330 /*
331  Write data in the zipfile
332 */
333 
334 extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
335 /*
336  Close the current file in the zipfile
337 */
338 
339 extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
340  uLong uncompressed_size,
341  uLong crc32));
342 
343 extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
344  ZPOS64_T uncompressed_size,
345  uLong crc32));
346 
347 /*
348  Close the current file in the zipfile, for file opened with
349  parameter raw=1 in zipOpenNewFileInZip2
350  uncompressed_size and crc32 are value for the uncompressed size
351 */
352 
353 extern int ZEXPORT zipClose OF((zipFile file, const char* global_comment));
354 /*
355  Close the zipfile
356 */
357 
358 extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData,
359  int* dataLen,
360  short sHeader));
361 /*
362  zipRemoveExtraInfoBlock - Added by Mathias Svensson
363 
364  Remove extra information block from a extra information data for the local
365  file header or central directory header
366 
367  It is needed to remove ZIP64 extra information blocks when before data is
368  written if using RAW mode.
369 
370  0x0001 is the signature header for the ZIP64 extra information blocks
371 
372  usage.
373  Remove ZIP64 Extra information from a central director
374  extra field data zipRemoveExtraInfoBlock(pCenDirExtraFieldData,
375  &nCenDirExtraFieldDataLen, 0x0001);
376 
377  Remove ZIP64 Extra information from a Local File Header
378  extra field data zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData,
379  &nLocalHeaderExtraFieldDataLen, 0x0001);
380 */
381 
382 /*
383  Added by Sergey A. Tachenov to tweak zipping behaviour.
384 */
385 extern int ZEXPORT zipSetFlags(zipFile file, unsigned flags);
386 extern int ZEXPORT zipClearFlags(zipFile file, unsigned flags);
387 
388 #ifdef __cplusplus
389 }
390 #endif
391 
392 #endif /* _zip64_H */
std::string filename
#define OF
Definition: ioapi.h:107
unsigned long long int ZPOS64_T
Definition: ioapi.h:97
Definition: zip.h:105
uInt tm_hour
Definition: zip.h:108
uInt tm_min
Definition: zip.h:107
uInt tm_year
Definition: zip.h:111
uInt tm_sec
Definition: zip.h:106
uInt tm_mon
Definition: zip.h:110
uInt tm_mday
Definition: zip.h:109
uLong dosDate
Definition: zip.h:116
uLong internal_fa
Definition: zip.h:120
uLong external_fa
Definition: zip.h:121
tm_zip tmz_date
Definition: zip.h:115
int ZEXPORT zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level)
Definition: zip.c:1390
int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int zip64)
Definition: zip.c:1377
int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase)
Definition: zip.c:1305
zipFile ZEXPORT zipOpen(voidpf file, int append)
Definition: zip.c:967
int ZEXPORT zipRemoveExtraInfoBlock(char *pData, int *dataLen, short sHeader)
Definition: zip.c:2013
int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32)
Definition: zip.c:1548
int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32)
Definition: zip.c:1543
int ZEXPORT zipClose(zipFile file, const char *global_comment)
Definition: zip.c:1936
int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64)
Definition: zip.c:1077
zipFile ZEXPORT zipOpen2(voidpf file, int append, zipcharpc *globalcomment, zlib_filefunc_def *pzlib_filefunc32_def)
Definition: zip.c:939
int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting)
Definition: zip.c:1321
zipFile ZEXPORT zipOpen64(voidpf file, int append)
Definition: zip.c:972
int ZEXPORT zipWriteInFileInZip(zipFile file, const void *buf, unsigned int len)
Definition: zip.c:1442
int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int zip64)
Definition: zip.c:1364
int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, int zip64)
Definition: zip.c:1336
int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw)
Definition: zip.c:1351
int ZEXPORT zipCloseFileInZip(zipFile file)
Definition: zip.c:1804
zipFile ZEXPORT zipOpen2_64(voidpf file, int append, zipcharpc *globalcomment, zlib_filefunc64_def *pzlib_filefunc_def)
Definition: zip.c:951
struct tm_zip_s tm_zip
const char * zipcharpc
Definition: zip.h:124
int ZEXPORT zipSetFlags(zipFile file, unsigned flags)
Definition: zip.c:2071
zipFile ZEXPORT zipOpen3(voidpf file, int append, zipcharpc *globalcomment, zlib_filefunc64_32_def *pzlib_filefunc64_32_def, unsigned flags)
Definition: zip.c:862
int ZEXPORT zipClearFlags(zipFile file, unsigned flags)
Definition: zip.c:2085
voidp zipFile
Definition: zip.h:80