annotate src/zlib-1.2.8/contrib/minizip/zip.h @ 155:54abead6ecce

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