OLD | NEW |
1 /* zip.h -- IO for compress .zip files using zlib | 1 /* zip.h -- IO on .zip files using zlib |
2 Version 1.01e, February 12th, 2005 | 2 Version 1.1, February 14h, 2010 |
| 3 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html
) |
3 | 4 |
4 Copyright (C) 1998-2005 Gilles Vollant | 5 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.
com/zLibDll/minizip.html ) |
5 | 6 |
6 This unzip package allow creates .ZIP file, compatible with PKZip 2.04g | 7 Modifications for Zip64 support |
7 WinZip, InfoZip tools and compatible. | 8 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) |
8 Multi volume ZipFile (span) are not supported. | |
9 Encryption compatible with pkzip 2.04g only supported | |
10 Old compressions used by old PKZip 1.x are not supported | |
11 | 9 |
12 For uncompress .zip file, look at unzip.h | 10 For more info read MiniZip_info.txt |
13 | 11 |
14 | 12 -----------------------------------------------------------------------
---- |
15 I WAIT FEEDBACK at mail info@winimage.com | |
16 Visit also http://www.winimage.com/zLibDll/unzip.html for evolution | |
17 | 13 |
18 Condition of use and distribution are the same than zlib : | 14 Condition of use and distribution are the same than zlib : |
19 | 15 |
20 This software is provided 'as-is', without any express or implied | 16 This software is provided 'as-is', without any express or implied |
21 warranty. In no event will the authors be held liable for any damages | 17 warranty. In no event will the authors be held liable for any damages |
22 arising from the use of this software. | 18 arising from the use of this software. |
23 | 19 |
24 Permission is granted to anyone to use this software for any purpose, | 20 Permission is granted to anyone to use this software for any purpose, |
25 including commercial applications, and to alter it and redistribute it | 21 including commercial applications, and to alter it and redistribute it |
26 freely, subject to the following restrictions: | 22 freely, subject to the following restrictions: |
27 | 23 |
28 1. The origin of this software must not be misrepresented; you must not | 24 1. The origin of this software must not be misrepresented; you must not |
29 claim that you wrote the original software. If you use this software | 25 claim that you wrote the original software. If you use this software |
30 in a product, an acknowledgment in the product documentation would be | 26 in a product, an acknowledgment in the product documentation would be |
31 appreciated but is not required. | 27 appreciated but is not required. |
32 2. Altered source versions must be plainly marked as such, and must not be | 28 2. Altered source versions must be plainly marked as such, and must not be |
33 misrepresented as being the original software. | 29 misrepresented as being the original software. |
34 3. This notice may not be removed or altered from any source distribution. | 30 3. This notice may not be removed or altered from any source distribution. |
35 | 31 |
| 32 ------------------------------------------------------------------------
--- |
| 33 |
| 34 Changes |
| 35 |
| 36 See header of zip.h |
36 | 37 |
37 */ | 38 */ |
38 | 39 |
39 /* for more info about .ZIP format, see | 40 #ifndef _zip12_H |
40 http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip | 41 #define _zip12_H |
41 http://www.info-zip.org/pub/infozip/doc/ | |
42 PkWare has also a specification at : | |
43 ftp://ftp.pkware.com/probdesc.zip | |
44 */ | |
45 | |
46 #ifndef _zip_H | |
47 #define _zip_H | |
48 | 42 |
49 #ifdef __cplusplus | 43 #ifdef __cplusplus |
50 extern "C" { | 44 extern "C" { |
51 #endif | 45 #endif |
52 | 46 |
| 47 //#define HAVE_BZIP2 |
| 48 |
| 49 #ifndef _ZLIB_H |
53 #if defined(USE_SYSTEM_ZLIB) | 50 #if defined(USE_SYSTEM_ZLIB) |
54 #include <zlib.h> | 51 #include <zlib.h> |
55 #else | 52 #else |
56 #include "third_party/zlib/zlib.h" | 53 #include "third_party/zlib/zlib.h" |
57 #endif | 54 #endif |
| 55 #endif |
58 | 56 |
59 #ifndef _ZLIBIOAPI_H | 57 #ifndef _ZLIBIOAPI_H |
60 #include "ioapi.h" | 58 #include "ioapi.h" |
61 #endif | 59 #endif |
62 | 60 |
| 61 #ifdef HAVE_BZIP2 |
| 62 #include "bzlib.h" |
| 63 #endif |
| 64 |
| 65 #define Z_BZIP2ED 12 |
| 66 |
63 #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) | 67 #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) |
64 /* like the STRICT of WIN32, we define a pointer that cannot be converted | 68 /* like the STRICT of WIN32, we define a pointer that cannot be converted |
65 from (void*) without cast */ | 69 from (void*) without cast */ |
66 typedef struct TagzipFile__ { int unused; } zipFile__; | 70 typedef struct TagzipFile__ { int unused; } zipFile__; |
67 typedef zipFile__ *zipFile; | 71 typedef zipFile__ *zipFile; |
68 #else | 72 #else |
69 typedef voidp zipFile; | 73 typedef voidp zipFile; |
70 #endif | 74 #endif |
71 | 75 |
72 #define ZIP_OK (0) | 76 #define ZIP_OK (0) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } zip_fileinfo; | 111 } zip_fileinfo; |
108 | 112 |
109 typedef const char* zipcharpc; | 113 typedef const char* zipcharpc; |
110 | 114 |
111 | 115 |
112 #define APPEND_STATUS_CREATE (0) | 116 #define APPEND_STATUS_CREATE (0) |
113 #define APPEND_STATUS_CREATEAFTER (1) | 117 #define APPEND_STATUS_CREATEAFTER (1) |
114 #define APPEND_STATUS_ADDINZIP (2) | 118 #define APPEND_STATUS_ADDINZIP (2) |
115 | 119 |
116 extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); | 120 extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); |
| 121 extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); |
117 /* | 122 /* |
118 Create a zipfile. | 123 Create a zipfile. |
119 pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or o
n | 124 pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or o
n |
120 an Unix computer "zlib/zlib113.zip". | 125 an Unix computer "zlib/zlib113.zip". |
121 if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip | 126 if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip |
122 will be created at the end of the file. | 127 will be created at the end of the file. |
123 (useful if the file contain a self extractor code) | 128 (useful if the file contain a self extractor code) |
124 if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will | 129 if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will |
125 add files in existing zip (be sure you don't add file that doesn't exist) | 130 add files in existing zip (be sure you don't add file that doesn't exist) |
126 If the zipfile cannot be opened, the return value is NULL. | 131 If the zipfile cannot be opened, the return value is NULL. |
127 Else, the return value is a zipFile Handle, usable with other function | 132 Else, the return value is a zipFile Handle, usable with other function |
128 of this zip package. | 133 of this zip package. |
129 */ | 134 */ |
130 | 135 |
131 /* Note : there is no delete function into a zipfile. | 136 /* Note : there is no delete function into a zipfile. |
132 If you want delete file into a zipfile, you must open a zipfile, and create a
nother | 137 If you want delete file into a zipfile, you must open a zipfile, and create a
nother |
133 Of couse, you can use RAW reading and writing to copy the file you did not wa
nt delte | 138 Of couse, you can use RAW reading and writing to copy the file you did not wa
nt delte |
134 */ | 139 */ |
135 | 140 |
136 extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, | 141 extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, |
137 int append, | 142 int append, |
138 zipcharpc* globalcomment, | 143 zipcharpc* globalcomment, |
139 zlib_filefunc_def* pzlib_filefunc_def)); | 144 zlib_filefunc_def* pzlib_filefunc_def)); |
140 | 145 |
| 146 extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, |
| 147 int append, |
| 148 zipcharpc* globalcomment, |
| 149 zlib_filefunc64_def* pzlib_filefunc_def)); |
| 150 |
141 extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, | 151 extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, |
142 const char* filename, | 152 const char* filename, |
143 const zip_fileinfo* zipfi, | 153 const zip_fileinfo* zipfi, |
144 const void* extrafield_local, | 154 const void* extrafield_local, |
145 uInt size_extrafield_local, | 155 uInt size_extrafield_local, |
146 const void* extrafield_global, | 156 const void* extrafield_global, |
147 uInt size_extrafield_global, | 157 uInt size_extrafield_global, |
148 const char* comment, | 158 const char* comment, |
149 int method, | 159 int method, |
150 int level)); | 160 int level)); |
| 161 |
| 162 extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, |
| 163 const char* filename, |
| 164 const zip_fileinfo* zipfi, |
| 165 const void* extrafield_local, |
| 166 uInt size_extrafield_local, |
| 167 const void* extrafield_global, |
| 168 uInt size_extrafield_global, |
| 169 const char* comment, |
| 170 int method, |
| 171 int level, |
| 172 int zip64)); |
| 173 |
151 /* | 174 /* |
152 Open a file in the ZIP for writing. | 175 Open a file in the ZIP for writing. |
153 filename : the filename in zip (if NULL, '-' without quote will be used | 176 filename : the filename in zip (if NULL, '-' without quote will be used |
154 *zipfi contain supplemental information | 177 *zipfi contain supplemental information |
155 if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local | 178 if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local |
156 contains the extrafield data the the local header | 179 contains the extrafield data the the local header |
157 if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global | 180 if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global |
158 contains the extrafield data the the local header | 181 contains the extrafield data the the local header |
159 if comment != NULL, comment contain the comment string | 182 if comment != NULL, comment contain the comment string |
160 method contain the compression method (0 for store, Z_DEFLATED for deflate) | 183 method contain the compression method (0 for store, Z_DEFLATED for deflate) |
161 level contain the level of compression (can be Z_DEFAULT_COMPRESSION) | 184 level contain the level of compression (can be Z_DEFAULT_COMPRESSION) |
| 185 zip64 is set to 1 if a zip64 extended information block should be added to the
local file header. |
| 186 this MUST be '1' if the uncompressed size is >= 0xffffffff. |
| 187 |
162 */ | 188 */ |
163 | 189 |
164 | 190 |
165 extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, | 191 extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, |
166 const char* filename, | 192 const char* filename, |
167 const zip_fileinfo* zipfi, | 193 const zip_fileinfo* zipfi, |
168 const void* extrafield_local, | 194 const void* extrafield_local, |
169 uInt size_extrafield_local, | 195 uInt size_extrafield_local, |
170 const void* extrafield_global, | 196 const void* extrafield_global, |
171 uInt size_extrafield_global, | 197 uInt size_extrafield_global, |
172 const char* comment, | 198 const char* comment, |
173 int method, | 199 int method, |
174 int level, | 200 int level, |
175 int raw)); | 201 int raw)); |
176 | 202 |
| 203 |
| 204 extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, |
| 205 const char* filename, |
| 206 const zip_fileinfo* zipfi, |
| 207 const void* extrafield_local, |
| 208 uInt size_extrafield_local, |
| 209 const void* extrafield_global, |
| 210 uInt size_extrafield_global, |
| 211 const char* comment, |
| 212 int method, |
| 213 int level, |
| 214 int raw, |
| 215 int zip64)); |
177 /* | 216 /* |
178 Same than zipOpenNewFileInZip, except if raw=1, we write raw file | 217 Same than zipOpenNewFileInZip, except if raw=1, we write raw file |
179 */ | 218 */ |
180 | 219 |
181 extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, | 220 extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, |
182 const char* filename, | 221 const char* filename, |
183 const zip_fileinfo* zipfi, | 222 const zip_fileinfo* zipfi, |
184 const void* extrafield_local, | 223 const void* extrafield_local, |
185 uInt size_extrafield_local, | 224 uInt size_extrafield_local, |
186 const void* extrafield_global, | 225 const void* extrafield_global, |
187 uInt size_extrafield_global, | 226 uInt size_extrafield_global, |
188 const char* comment, | 227 const char* comment, |
189 int method, | 228 int method, |
190 int level, | 229 int level, |
191 int raw, | 230 int raw, |
192 int windowBits, | 231 int windowBits, |
193 int memLevel, | 232 int memLevel, |
194 int strategy, | 233 int strategy, |
195 const char* password, | 234 const char* password, |
196 uLong crcForCtypting)); | 235 uLong crcForCrypting)); |
| 236 |
| 237 extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, |
| 238 const char* filename, |
| 239 const zip_fileinfo* zipfi, |
| 240 const void* extrafield_local, |
| 241 uInt size_extrafield_local, |
| 242 const void* extrafield_global, |
| 243 uInt size_extrafield_global, |
| 244 const char* comment, |
| 245 int method, |
| 246 int level, |
| 247 int raw, |
| 248 int windowBits, |
| 249 int memLevel, |
| 250 int strategy, |
| 251 const char* password, |
| 252 uLong crcForCrypting, |
| 253 int zip64 |
| 254 )); |
197 | 255 |
198 /* | 256 /* |
199 Same than zipOpenNewFileInZip2, except | 257 Same than zipOpenNewFileInZip2, except |
200 windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 | 258 windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 |
201 password : crypting password (NULL for no crypting) | 259 password : crypting password (NULL for no crypting) |
202 crcForCtypting : crc of file to compress (needed for crypting) | 260 crcForCrypting : crc of file to compress (needed for crypting) |
| 261 */ |
| 262 |
| 263 extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, |
| 264 const char* filename, |
| 265 const zip_fileinfo* zipfi, |
| 266 const void* extrafield_local, |
| 267 uInt size_extrafield_local, |
| 268 const void* extrafield_global, |
| 269 uInt size_extrafield_global, |
| 270 const char* comment, |
| 271 int method, |
| 272 int level, |
| 273 int raw, |
| 274 int windowBits, |
| 275 int memLevel, |
| 276 int strategy, |
| 277 const char* password, |
| 278 uLong crcForCrypting, |
| 279 uLong versionMadeBy, |
| 280 uLong flagBase |
| 281 )); |
| 282 |
| 283 |
| 284 extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, |
| 285 const char* filename, |
| 286 const zip_fileinfo* zipfi, |
| 287 const void* extrafield_local, |
| 288 uInt size_extrafield_local, |
| 289 const void* extrafield_global, |
| 290 uInt size_extrafield_global, |
| 291 const char* comment, |
| 292 int method, |
| 293 int level, |
| 294 int raw, |
| 295 int windowBits, |
| 296 int memLevel, |
| 297 int strategy, |
| 298 const char* password, |
| 299 uLong crcForCrypting, |
| 300 uLong versionMadeBy, |
| 301 uLong flagBase, |
| 302 int zip64 |
| 303 )); |
| 304 /* |
| 305 Same than zipOpenNewFileInZip4, except |
| 306 versionMadeBy : value for Version made by field |
| 307 flag : value for flag field (compression level info will be added) |
203 */ | 308 */ |
204 | 309 |
205 | 310 |
206 extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, | 311 extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, |
207 const void* buf, | 312 const void* buf, |
208 unsigned len)); | 313 unsigned len)); |
209 /* | 314 /* |
210 Write data in the zipfile | 315 Write data in the zipfile |
211 */ | 316 */ |
212 | 317 |
213 extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); | 318 extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); |
214 /* | 319 /* |
215 Close the current file in the zipfile | 320 Close the current file in the zipfile |
216 */ | 321 */ |
217 | 322 |
218 extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, | 323 extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, |
219 uLong uncompressed_size, | 324 uLong uncompressed_size, |
220 uLong crc32)); | 325 uLong crc32)); |
| 326 |
| 327 extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, |
| 328 ZPOS64_T uncompressed_size, |
| 329 uLong crc32)); |
| 330 |
221 /* | 331 /* |
222 Close the current file in the zipfile, for fiel opened with | 332 Close the current file in the zipfile, for file opened with |
223 parameter raw=1 in zipOpenNewFileInZip2 | 333 parameter raw=1 in zipOpenNewFileInZip2 |
224 uncompressed_size and crc32 are value for the uncompressed size | 334 uncompressed_size and crc32 are value for the uncompressed size |
225 */ | 335 */ |
226 | 336 |
227 extern int ZEXPORT zipClose OF((zipFile file, | 337 extern int ZEXPORT zipClose OF((zipFile file, |
228 const char* global_comment)); | 338 const char* global_comment)); |
229 /* | 339 /* |
230 Close the zipfile | 340 Close the zipfile |
231 */ | 341 */ |
232 | 342 |
| 343 |
| 344 extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short
sHeader)); |
| 345 /* |
| 346 zipRemoveExtraInfoBlock - Added by Mathias Svensson |
| 347 |
| 348 Remove extra information block from a extra information data for the local fil
e header or central directory header |
| 349 |
| 350 It is needed to remove ZIP64 extra information blocks when before data is writ
ten if using RAW mode. |
| 351 |
| 352 0x0001 is the signature header for the ZIP64 extra information blocks |
| 353 |
| 354 usage. |
| 355 Remove ZIP64 Extra information from a central director e
xtra field data |
| 356 zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldD
ataLen, 0x0001); |
| 357 |
| 358 Remove ZIP64 Extra information from a Local File Header
extra field data |
| 359 zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFi
eldDataLen, 0x0001); |
| 360 */ |
| 361 |
233 #ifdef __cplusplus | 362 #ifdef __cplusplus |
234 } | 363 } |
235 #endif | 364 #endif |
236 | 365 |
237 #endif /* _zip_H */ | 366 #endif /* _zip64_H */ |
OLD | NEW |