annotate src/zlib-1.2.8/contrib/minizip/zip.h @ 43:5ea0608b923f

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