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