File indexing completed on 2025-01-26 04:24:56
0001 /* zip.h -- IO on .zip files using zlib 0002 Version 1.1, February 14h, 2010 0003 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 0004 0005 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) 0006 0007 Modifications for Zip64 support 0008 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 0009 0010 For more info read MiniZip_info.txt 0011 0012 --------------------------------------------------------------------------- 0013 0014 Condition of use and distribution are the same than zlib : 0015 0016 This software is provided 'as-is', without any express or implied 0017 warranty. In no event will the authors be held liable for any damages 0018 arising from the use of this software. 0019 0020 Permission is granted to anyone to use this software for any purpose, 0021 including commercial applications, and to alter it and redistribute it 0022 freely, subject to the following restrictions: 0023 0024 1. The origin of this software must not be misrepresented; you must not 0025 claim that you wrote the original software. If you use this software 0026 in a product, an acknowledgment in the product documentation would be 0027 appreciated but is not required. 0028 2. Altered source versions must be plainly marked as such, and must not be 0029 misrepresented as being the original software. 0030 3. This notice may not be removed or altered from any source distribution. 0031 0032 --------------------------------------------------------------------------- 0033 0034 Changes 0035 0036 See header of zip.h 0037 0038 --------------------------------------------------------------------------- 0039 0040 As per the requirement above, this file is plainly marked as modified 0041 by Sergey A. Tachenov. Most modifications include the I/O API redesign 0042 to support QIODevice interface. Some improvements and small fixes were also made. 0043 0044 */ 0045 0046 #ifndef _zip12_H 0047 #define _zip12_H 0048 0049 #ifdef __cplusplus 0050 extern "C" { 0051 #endif 0052 0053 //#define HAVE_BZIP2 0054 0055 #ifndef _ZLIB_H 0056 #include "zlib.h" 0057 #endif 0058 0059 #ifndef _ZLIBIOAPI_H 0060 #include "ioapi.h" 0061 #endif 0062 0063 #ifdef HAVE_BZIP2 0064 #include "bzlib.h" 0065 #endif 0066 0067 #define Z_BZIP2ED 12 0068 0069 #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) 0070 /* like the STRICT of WIN32, we define a pointer that cannot be converted 0071 from (void*) without cast */ 0072 typedef struct TagzipFile__ { int unused; } zipFile__; 0073 typedef zipFile__ *zipFile; 0074 #else 0075 typedef voidp zipFile; 0076 #endif 0077 0078 #define ZIP_OK (0) 0079 #define ZIP_EOF (0) 0080 #define ZIP_ERRNO (Z_ERRNO) 0081 #define ZIP_PARAMERROR (-102) 0082 #define ZIP_BADZIPFILE (-103) 0083 #define ZIP_INTERNALERROR (-104) 0084 0085 #define ZIP_WRITE_DATA_DESCRIPTOR 0x8u 0086 #define ZIP_AUTO_CLOSE 0x1u 0087 #define ZIP_SEQUENTIAL 0x2u 0088 #define ZIP_DEFAULT_FLAGS (ZIP_AUTO_CLOSE | ZIP_WRITE_DATA_DESCRIPTOR) 0089 0090 #ifndef DEF_MEM_LEVEL 0091 # if MAX_MEM_LEVEL >= 8 0092 # define DEF_MEM_LEVEL 8 0093 # else 0094 # define DEF_MEM_LEVEL MAX_MEM_LEVEL 0095 # endif 0096 #endif 0097 /* default memLevel */ 0098 0099 /* tm_zip contain date/time info */ 0100 typedef struct tm_zip_s 0101 { 0102 uInt tm_sec; /* seconds after the minute - [0,59] */ 0103 uInt tm_min; /* minutes after the hour - [0,59] */ 0104 uInt tm_hour; /* hours since midnight - [0,23] */ 0105 uInt tm_mday; /* day of the month - [1,31] */ 0106 uInt tm_mon; /* months since January - [0,11] */ 0107 uInt tm_year; /* years - [1980..2044] */ 0108 } tm_zip; 0109 0110 typedef struct 0111 { 0112 tm_zip tmz_date; /* date in understandable format */ 0113 uLong dosDate; /* if dos_date == 0, tmu_date is used */ 0114 /* uLong flag; */ /* general purpose bit flag 2 bytes */ 0115 0116 uLong internal_fa; /* internal file attributes 2 bytes */ 0117 uLong external_fa; /* external file attributes 4 bytes */ 0118 } zip_fileinfo; 0119 0120 typedef const char* zipcharpc; 0121 0122 0123 #define APPEND_STATUS_CREATE (0) 0124 #define APPEND_STATUS_CREATEAFTER (1) 0125 #define APPEND_STATUS_ADDINZIP (2) 0126 0127 extern zipFile ZEXPORT zipOpen OF((voidpf file, int append)); 0128 extern zipFile ZEXPORT zipOpen64 OF((voidpf file, int append)); 0129 /* 0130 Create a zipfile. 0131 the file argument depends on the API used, for QuaZIP it's a QIODevice 0132 pointer. 0133 if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip 0134 will be created at the end of the file. 0135 (useful if the file contain a self extractor code) 0136 if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will 0137 add files in existing zip (be sure you don't add file that doesn't exist) 0138 If the zipfile cannot be opened, the return value is NULL. 0139 Else, the return value is a zipFile Handle, usable with other function 0140 of this zip package. 0141 */ 0142 0143 /* Note : there is no delete function into a zipfile. 0144 If you want delete file into a zipfile, you must open a zipfile, and create another 0145 Of couse, you can use RAW reading and writing to copy the file you did not want delte 0146 */ 0147 0148 extern zipFile ZEXPORT zipOpen2 OF((voidpf file, 0149 int append, 0150 zipcharpc* globalcomment, 0151 zlib_filefunc_def* pzlib_filefunc_def)); 0152 0153 extern zipFile ZEXPORT zipOpen2_64 OF((voidpf file, 0154 int append, 0155 zipcharpc* globalcomment, 0156 zlib_filefunc64_def* pzlib_filefunc_def)); 0157 0158 /* 0159 * Exported by Sergey A. Tachenov to suit the needs of QuaZIP. 0160 * Note that this function MAY change signature in order to 0161 * provide new QuaZIP features. You have been warned! 0162 * */ 0163 extern zipFile ZEXPORT zipOpen3 (voidpf file, 0164 int append, 0165 zipcharpc* globalcomment, 0166 zlib_filefunc64_32_def* pzlib_filefunc64_32_def, 0167 unsigned flags); 0168 0169 extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, 0170 const char* filename, 0171 const zip_fileinfo* zipfi, 0172 const void* extrafield_local, 0173 uInt size_extrafield_local, 0174 const void* extrafield_global, 0175 uInt size_extrafield_global, 0176 const char* comment, 0177 int method, 0178 int level)); 0179 0180 extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, 0181 const char* filename, 0182 const zip_fileinfo* zipfi, 0183 const void* extrafield_local, 0184 uInt size_extrafield_local, 0185 const void* extrafield_global, 0186 uInt size_extrafield_global, 0187 const char* comment, 0188 int method, 0189 int level, 0190 int zip64)); 0191 0192 /* 0193 Open a file in the ZIP for writing. 0194 filename : the filename in zip (if NULL, '-' without quote will be used 0195 *zipfi contain supplemental information 0196 if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local 0197 contains the extrafield data the the local header 0198 if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global 0199 contains the extrafield data the the local header 0200 if comment != NULL, comment contain the comment string 0201 method contain the compression method (0 for store, Z_DEFLATED for deflate) 0202 level contain the level of compression (can be Z_DEFAULT_COMPRESSION) 0203 zip64 is set to 1 if a zip64 extended information block should be added to the local file header. 0204 this MUST be '1' if the uncompressed size is >= 0xffffffff. 0205 0206 */ 0207 0208 0209 extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, 0210 const char* filename, 0211 const zip_fileinfo* zipfi, 0212 const void* extrafield_local, 0213 uInt size_extrafield_local, 0214 const void* extrafield_global, 0215 uInt size_extrafield_global, 0216 const char* comment, 0217 int method, 0218 int level, 0219 int raw)); 0220 0221 0222 extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, 0223 const char* filename, 0224 const zip_fileinfo* zipfi, 0225 const void* extrafield_local, 0226 uInt size_extrafield_local, 0227 const void* extrafield_global, 0228 uInt size_extrafield_global, 0229 const char* comment, 0230 int method, 0231 int level, 0232 int raw, 0233 int zip64)); 0234 /* 0235 Same than zipOpenNewFileInZip, except if raw=1, we write raw file 0236 */ 0237 0238 extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, 0239 const char* filename, 0240 const zip_fileinfo* zipfi, 0241 const void* extrafield_local, 0242 uInt size_extrafield_local, 0243 const void* extrafield_global, 0244 uInt size_extrafield_global, 0245 const char* comment, 0246 int method, 0247 int level, 0248 int raw, 0249 int windowBits, 0250 int memLevel, 0251 int strategy, 0252 const char* password, 0253 uLong crcForCrypting)); 0254 0255 extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, 0256 const char* filename, 0257 const zip_fileinfo* zipfi, 0258 const void* extrafield_local, 0259 uInt size_extrafield_local, 0260 const void* extrafield_global, 0261 uInt size_extrafield_global, 0262 const char* comment, 0263 int method, 0264 int level, 0265 int raw, 0266 int windowBits, 0267 int memLevel, 0268 int strategy, 0269 const char* password, 0270 uLong crcForCrypting, 0271 int zip64 0272 )); 0273 0274 /* 0275 Same than zipOpenNewFileInZip2, except 0276 windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 0277 password : crypting password (NULL for no crypting) 0278 crcForCrypting : crc of file to compress (needed for crypting) 0279 */ 0280 0281 extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, 0282 const char* filename, 0283 const zip_fileinfo* zipfi, 0284 const void* extrafield_local, 0285 uInt size_extrafield_local, 0286 const void* extrafield_global, 0287 uInt size_extrafield_global, 0288 const char* comment, 0289 int method, 0290 int level, 0291 int raw, 0292 int windowBits, 0293 int memLevel, 0294 int strategy, 0295 const char* password, 0296 uLong crcForCrypting, 0297 uLong versionMadeBy, 0298 uLong flagBase 0299 )); 0300 0301 0302 extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, 0303 const char* filename, 0304 const zip_fileinfo* zipfi, 0305 const void* extrafield_local, 0306 uInt size_extrafield_local, 0307 const void* extrafield_global, 0308 uInt size_extrafield_global, 0309 const char* comment, 0310 int method, 0311 int level, 0312 int raw, 0313 int windowBits, 0314 int memLevel, 0315 int strategy, 0316 const char* password, 0317 uLong crcForCrypting, 0318 uLong versionMadeBy, 0319 uLong flagBase, 0320 int zip64 0321 )); 0322 /* 0323 Same than zipOpenNewFileInZip4, except 0324 versionMadeBy : value for Version made by field 0325 flag : value for flag field (compression level info will be added) 0326 */ 0327 0328 0329 extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, 0330 const void* buf, 0331 unsigned len)); 0332 /* 0333 Write data in the zipfile 0334 */ 0335 0336 extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); 0337 /* 0338 Close the current file in the zipfile 0339 */ 0340 0341 extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, 0342 uLong uncompressed_size, 0343 uLong crc32)); 0344 0345 extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, 0346 ZPOS64_T uncompressed_size, 0347 uLong crc32)); 0348 0349 /* 0350 Close the current file in the zipfile, for file opened with 0351 parameter raw=1 in zipOpenNewFileInZip2 0352 uncompressed_size and crc32 are value for the uncompressed size 0353 */ 0354 0355 extern int ZEXPORT zipClose OF((zipFile file, 0356 const char* global_comment)); 0357 /* 0358 Close the zipfile 0359 */ 0360 0361 0362 extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader)); 0363 /* 0364 zipRemoveExtraInfoBlock - Added by Mathias Svensson 0365 0366 Remove extra information block from a extra information data for the local file header or central directory header 0367 0368 It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode. 0369 0370 0x0001 is the signature header for the ZIP64 extra information blocks 0371 0372 usage. 0373 Remove ZIP64 Extra information from a central director extra field data 0374 zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001); 0375 0376 Remove ZIP64 Extra information from a Local File Header extra field data 0377 zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001); 0378 */ 0379 0380 /* 0381 Added by Sergey A. Tachenov to tweak zipping behaviour. 0382 */ 0383 extern int ZEXPORT zipSetFlags(zipFile file, unsigned flags); 0384 extern int ZEXPORT zipClearFlags(zipFile file, unsigned flags); 0385 0386 #ifdef __cplusplus 0387 } 0388 #endif 0389 0390 #endif /* _zip64_H */