source: Vago/quazip-0.7.2/quazip/zip.h@ 1049

Last change on this file since 1049 was 1049, checked in by s10k, 8 years ago
File size: 16.4 KB
Line 
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
50extern "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 */
72typedef struct TagzipFile__ { int unused; } zipFile__;
73typedef zipFile__ *zipFile;
74#else
75typedef 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_DEFAULT_FLAGS (ZIP_AUTO_CLOSE | ZIP_WRITE_DATA_DESCRIPTOR)
89
90#ifndef DEF_MEM_LEVEL
91# if MAX_MEM_LEVEL >= 8
92# define DEF_MEM_LEVEL 8
93# else
94# define DEF_MEM_LEVEL MAX_MEM_LEVEL
95# endif
96#endif
97/* default memLevel */
98
99/* tm_zip contain date/time info */
100typedef struct tm_zip_s
101{
102 uInt tm_sec; /* seconds after the minute - [0,59] */
103 uInt tm_min; /* minutes after the hour - [0,59] */
104 uInt tm_hour; /* hours since midnight - [0,23] */
105 uInt tm_mday; /* day of the month - [1,31] */
106 uInt tm_mon; /* months since January - [0,11] */
107 uInt tm_year; /* years - [1980..2044] */
108} tm_zip;
109
110typedef struct
111{
112 tm_zip tmz_date; /* date in understandable format */
113 uLong dosDate; /* if dos_date == 0, tmu_date is used */
114/* uLong flag; */ /* general purpose bit flag 2 bytes */
115
116 uLong internal_fa; /* internal file attributes 2 bytes */
117 uLong external_fa; /* external file attributes 4 bytes */
118} zip_fileinfo;
119
120typedef const char* zipcharpc;
121
122
123#define APPEND_STATUS_CREATE (0)
124#define APPEND_STATUS_CREATEAFTER (1)
125#define APPEND_STATUS_ADDINZIP (2)
126
127extern zipFile ZEXPORT zipOpen OF((voidpf file, int append));
128extern zipFile ZEXPORT zipOpen64 OF((voidpf file, int append));
129/*
130 Create a zipfile.
131 the file argument depends on the API used, for QuaZIP it's a QIODevice
132 pointer.
133 if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
134 will be created at the end of the file.
135 (useful if the file contain a self extractor code)
136 if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
137 add files in existing zip (be sure you don't add file that doesn't exist)
138 If the zipfile cannot be opened, the return value is NULL.
139 Else, the return value is a zipFile Handle, usable with other function
140 of this zip package.
141*/
142
143/* Note : there is no delete function into a zipfile.
144 If you want delete file into a zipfile, you must open a zipfile, and create another
145 Of couse, you can use RAW reading and writing to copy the file you did not want delte
146*/
147
148extern zipFile ZEXPORT zipOpen2 OF((voidpf file,
149 int append,
150 zipcharpc* globalcomment,
151 zlib_filefunc_def* pzlib_filefunc_def));
152
153extern zipFile ZEXPORT zipOpen2_64 OF((voidpf file,
154 int append,
155 zipcharpc* globalcomment,
156 zlib_filefunc64_def* pzlib_filefunc_def));
157
158/*
159 * Exported by Sergey A. Tachenov to suit the needs of QuaZIP.
160 * Note that this function MAY change signature in order to
161 * provide new QuaZIP features. You have been warned!
162 * */
163extern zipFile ZEXPORT zipOpen3 (voidpf file,
164 int append,
165 zipcharpc* globalcomment,
166 zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
167 unsigned flags);
168
169extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
170 const char* filename,
171 const zip_fileinfo* zipfi,
172 const void* extrafield_local,
173 uInt size_extrafield_local,
174 const void* extrafield_global,
175 uInt size_extrafield_global,
176 const char* comment,
177 int method,
178 int level));
179
180extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
181 const char* filename,
182 const zip_fileinfo* zipfi,
183 const void* extrafield_local,
184 uInt size_extrafield_local,
185 const void* extrafield_global,
186 uInt size_extrafield_global,
187 const char* comment,
188 int method,
189 int level,
190 int zip64));
191
192/*
193 Open a file in the ZIP for writing.
194 filename : the filename in zip (if NULL, '-' without quote will be used
195 *zipfi contain supplemental information
196 if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
197 contains the extrafield data the the local header
198 if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
199 contains the extrafield data the the local header
200 if comment != NULL, comment contain the comment string
201 method contain the compression method (0 for store, Z_DEFLATED for deflate)
202 level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
203 zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
204 this MUST be '1' if the uncompressed size is >= 0xffffffff.
205
206*/
207
208
209extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
210 const char* filename,
211 const zip_fileinfo* zipfi,
212 const void* extrafield_local,
213 uInt size_extrafield_local,
214 const void* extrafield_global,
215 uInt size_extrafield_global,
216 const char* comment,
217 int method,
218 int level,
219 int raw));
220
221
222extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,
223 const char* filename,
224 const zip_fileinfo* zipfi,
225 const void* extrafield_local,
226 uInt size_extrafield_local,
227 const void* extrafield_global,
228 uInt size_extrafield_global,
229 const char* comment,
230 int method,
231 int level,
232 int raw,
233 int zip64));
234/*
235 Same than zipOpenNewFileInZip, except if raw=1, we write raw file
236 */
237
238extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
239 const char* filename,
240 const zip_fileinfo* zipfi,
241 const void* extrafield_local,
242 uInt size_extrafield_local,
243 const void* extrafield_global,
244 uInt size_extrafield_global,
245 const char* comment,
246 int method,
247 int level,
248 int raw,
249 int windowBits,
250 int memLevel,
251 int strategy,
252 const char* password,
253 uLong crcForCrypting));
254
255extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
256 const char* filename,
257 const zip_fileinfo* zipfi,
258 const void* extrafield_local,
259 uInt size_extrafield_local,
260 const void* extrafield_global,
261 uInt size_extrafield_global,
262 const char* comment,
263 int method,
264 int level,
265 int raw,
266 int windowBits,
267 int memLevel,
268 int strategy,
269 const char* password,
270 uLong crcForCrypting,
271 int zip64
272 ));
273
274/*
275 Same than zipOpenNewFileInZip2, except
276 windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
277 password : crypting password (NULL for no crypting)
278 crcForCrypting : crc of file to compress (needed for crypting)
279 */
280
281extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
282 const char* filename,
283 const zip_fileinfo* zipfi,
284 const void* extrafield_local,
285 uInt size_extrafield_local,
286 const void* extrafield_global,
287 uInt size_extrafield_global,
288 const char* comment,
289 int method,
290 int level,
291 int raw,
292 int windowBits,
293 int memLevel,
294 int strategy,
295 const char* password,
296 uLong crcForCrypting,
297 uLong versionMadeBy,
298 uLong flagBase
299 ));
300
301
302extern 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/*
323 Same than zipOpenNewFileInZip4, except
324 versionMadeBy : value for Version made by field
325 flag : value for flag field (compression level info will be added)
326 */
327
328
329extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
330 const void* buf,
331 unsigned len));
332/*
333 Write data in the zipfile
334*/
335
336extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
337/*
338 Close the current file in the zipfile
339*/
340
341extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
342 uLong uncompressed_size,
343 uLong crc32));
344
345extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
346 ZPOS64_T uncompressed_size,
347 uLong crc32));
348
349/*
350 Close the current file in the zipfile, for file opened with
351 parameter raw=1 in zipOpenNewFileInZip2
352 uncompressed_size and crc32 are value for the uncompressed size
353*/
354
355extern int ZEXPORT zipClose OF((zipFile file,
356 const char* global_comment));
357/*
358 Close the zipfile
359*/
360
361
362extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));
363/*
364 zipRemoveExtraInfoBlock - Added by Mathias Svensson
365
366 Remove extra information block from a extra information data for the local file header or central directory header
367
368 It is needed to remove ZIP64 extra information blocks when before data is 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 extra field data
374 zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);
375
376 Remove ZIP64 Extra information from a Local File Header extra field data
377 zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);
378*/
379
380/*
381 Added by Sergey A. Tachenov to tweak zipping behaviour.
382*/
383extern int ZEXPORT zipSetFlags(zipFile file, unsigned flags);
384extern int ZEXPORT zipClearFlags(zipFile file, unsigned flags);
385
386#ifdef __cplusplus
387}
388#endif
389
390#endif /* _zip64_H */
Note: See TracBrowser for help on using the repository browser.