cannam@128: /* zip.h -- IO on .zip files using zlib cannam@128: Version 1.1, February 14h, 2010 cannam@128: part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) cannam@128: cannam@128: Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) cannam@128: cannam@128: Modifications for Zip64 support cannam@128: Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) cannam@128: cannam@128: For more info read MiniZip_info.txt cannam@128: cannam@128: --------------------------------------------------------------------------- cannam@128: cannam@128: Condition of use and distribution are the same than zlib : cannam@128: cannam@128: This software is provided 'as-is', without any express or implied cannam@128: warranty. In no event will the authors be held liable for any damages cannam@128: arising from the use of this software. cannam@128: cannam@128: Permission is granted to anyone to use this software for any purpose, cannam@128: including commercial applications, and to alter it and redistribute it cannam@128: freely, subject to the following restrictions: cannam@128: cannam@128: 1. The origin of this software must not be misrepresented; you must not cannam@128: claim that you wrote the original software. If you use this software cannam@128: in a product, an acknowledgment in the product documentation would be cannam@128: appreciated but is not required. cannam@128: 2. Altered source versions must be plainly marked as such, and must not be cannam@128: misrepresented as being the original software. cannam@128: 3. This notice may not be removed or altered from any source distribution. cannam@128: cannam@128: --------------------------------------------------------------------------- cannam@128: cannam@128: Changes cannam@128: cannam@128: See header of zip.h cannam@128: cannam@128: */ cannam@128: cannam@128: #ifndef _zip12_H cannam@128: #define _zip12_H cannam@128: cannam@128: #ifdef __cplusplus cannam@128: extern "C" { cannam@128: #endif cannam@128: cannam@128: //#define HAVE_BZIP2 cannam@128: cannam@128: #ifndef _ZLIB_H cannam@128: #include "zlib.h" cannam@128: #endif cannam@128: cannam@128: #ifndef _ZLIBIOAPI_H cannam@128: #include "ioapi.h" cannam@128: #endif cannam@128: cannam@128: #ifdef HAVE_BZIP2 cannam@128: #include "bzlib.h" cannam@128: #endif cannam@128: cannam@128: #define Z_BZIP2ED 12 cannam@128: cannam@128: #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) cannam@128: /* like the STRICT of WIN32, we define a pointer that cannot be converted cannam@128: from (void*) without cast */ cannam@128: typedef struct TagzipFile__ { int unused; } zipFile__; cannam@128: typedef zipFile__ *zipFile; cannam@128: #else cannam@128: typedef voidp zipFile; cannam@128: #endif cannam@128: cannam@128: #define ZIP_OK (0) cannam@128: #define ZIP_EOF (0) cannam@128: #define ZIP_ERRNO (Z_ERRNO) cannam@128: #define ZIP_PARAMERROR (-102) cannam@128: #define ZIP_BADZIPFILE (-103) cannam@128: #define ZIP_INTERNALERROR (-104) cannam@128: cannam@128: #ifndef DEF_MEM_LEVEL cannam@128: # if MAX_MEM_LEVEL >= 8 cannam@128: # define DEF_MEM_LEVEL 8 cannam@128: # else cannam@128: # define DEF_MEM_LEVEL MAX_MEM_LEVEL cannam@128: # endif cannam@128: #endif cannam@128: /* default memLevel */ cannam@128: cannam@128: /* tm_zip contain date/time info */ cannam@128: typedef struct tm_zip_s cannam@128: { cannam@128: uInt tm_sec; /* seconds after the minute - [0,59] */ cannam@128: uInt tm_min; /* minutes after the hour - [0,59] */ cannam@128: uInt tm_hour; /* hours since midnight - [0,23] */ cannam@128: uInt tm_mday; /* day of the month - [1,31] */ cannam@128: uInt tm_mon; /* months since January - [0,11] */ cannam@128: uInt tm_year; /* years - [1980..2044] */ cannam@128: } tm_zip; cannam@128: cannam@128: typedef struct cannam@128: { cannam@128: tm_zip tmz_date; /* date in understandable format */ cannam@128: uLong dosDate; /* if dos_date == 0, tmu_date is used */ cannam@128: /* uLong flag; */ /* general purpose bit flag 2 bytes */ cannam@128: cannam@128: uLong internal_fa; /* internal file attributes 2 bytes */ cannam@128: uLong external_fa; /* external file attributes 4 bytes */ cannam@128: } zip_fileinfo; cannam@128: cannam@128: typedef const char* zipcharpc; cannam@128: cannam@128: cannam@128: #define APPEND_STATUS_CREATE (0) cannam@128: #define APPEND_STATUS_CREATEAFTER (1) cannam@128: #define APPEND_STATUS_ADDINZIP (2) cannam@128: cannam@128: extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); cannam@128: extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); cannam@128: /* cannam@128: Create a zipfile. cannam@128: pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on cannam@128: an Unix computer "zlib/zlib113.zip". cannam@128: if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip cannam@128: will be created at the end of the file. cannam@128: (useful if the file contain a self extractor code) cannam@128: if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will cannam@128: add files in existing zip (be sure you don't add file that doesn't exist) cannam@128: If the zipfile cannot be opened, the return value is NULL. cannam@128: Else, the return value is a zipFile Handle, usable with other function cannam@128: of this zip package. cannam@128: */ cannam@128: cannam@128: /* Note : there is no delete function into a zipfile. cannam@128: If you want delete file into a zipfile, you must open a zipfile, and create another cannam@128: Of couse, you can use RAW reading and writing to copy the file you did not want delte cannam@128: */ cannam@128: cannam@128: extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, cannam@128: int append, cannam@128: zipcharpc* globalcomment, cannam@128: zlib_filefunc_def* pzlib_filefunc_def)); cannam@128: cannam@128: extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, cannam@128: int append, cannam@128: zipcharpc* globalcomment, cannam@128: zlib_filefunc64_def* pzlib_filefunc_def)); cannam@128: cannam@128: extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, cannam@128: const char* filename, cannam@128: const zip_fileinfo* zipfi, cannam@128: const void* extrafield_local, cannam@128: uInt size_extrafield_local, cannam@128: const void* extrafield_global, cannam@128: uInt size_extrafield_global, cannam@128: const char* comment, cannam@128: int method, cannam@128: int level)); cannam@128: cannam@128: extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, cannam@128: const char* filename, cannam@128: const zip_fileinfo* zipfi, cannam@128: const void* extrafield_local, cannam@128: uInt size_extrafield_local, cannam@128: const void* extrafield_global, cannam@128: uInt size_extrafield_global, cannam@128: const char* comment, cannam@128: int method, cannam@128: int level, cannam@128: int zip64)); cannam@128: cannam@128: /* cannam@128: Open a file in the ZIP for writing. cannam@128: filename : the filename in zip (if NULL, '-' without quote will be used cannam@128: *zipfi contain supplemental information cannam@128: if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local cannam@128: contains the extrafield data the the local header cannam@128: if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global cannam@128: contains the extrafield data the the local header cannam@128: if comment != NULL, comment contain the comment string cannam@128: method contain the compression method (0 for store, Z_DEFLATED for deflate) cannam@128: level contain the level of compression (can be Z_DEFAULT_COMPRESSION) cannam@128: zip64 is set to 1 if a zip64 extended information block should be added to the local file header. cannam@128: this MUST be '1' if the uncompressed size is >= 0xffffffff. cannam@128: cannam@128: */ cannam@128: cannam@128: cannam@128: extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, cannam@128: const char* filename, cannam@128: const zip_fileinfo* zipfi, cannam@128: const void* extrafield_local, cannam@128: uInt size_extrafield_local, cannam@128: const void* extrafield_global, cannam@128: uInt size_extrafield_global, cannam@128: const char* comment, cannam@128: int method, cannam@128: int level, cannam@128: int raw)); cannam@128: cannam@128: cannam@128: extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, cannam@128: const char* filename, cannam@128: const zip_fileinfo* zipfi, cannam@128: const void* extrafield_local, cannam@128: uInt size_extrafield_local, cannam@128: const void* extrafield_global, cannam@128: uInt size_extrafield_global, cannam@128: const char* comment, cannam@128: int method, cannam@128: int level, cannam@128: int raw, cannam@128: int zip64)); cannam@128: /* cannam@128: Same than zipOpenNewFileInZip, except if raw=1, we write raw file cannam@128: */ cannam@128: cannam@128: extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, cannam@128: const char* filename, cannam@128: const zip_fileinfo* zipfi, cannam@128: const void* extrafield_local, cannam@128: uInt size_extrafield_local, cannam@128: const void* extrafield_global, cannam@128: uInt size_extrafield_global, cannam@128: const char* comment, cannam@128: int method, cannam@128: int level, cannam@128: int raw, cannam@128: int windowBits, cannam@128: int memLevel, cannam@128: int strategy, cannam@128: const char* password, cannam@128: uLong crcForCrypting)); cannam@128: cannam@128: extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, cannam@128: const char* filename, cannam@128: const zip_fileinfo* zipfi, cannam@128: const void* extrafield_local, cannam@128: uInt size_extrafield_local, cannam@128: const void* extrafield_global, cannam@128: uInt size_extrafield_global, cannam@128: const char* comment, cannam@128: int method, cannam@128: int level, cannam@128: int raw, cannam@128: int windowBits, cannam@128: int memLevel, cannam@128: int strategy, cannam@128: const char* password, cannam@128: uLong crcForCrypting, cannam@128: int zip64 cannam@128: )); cannam@128: cannam@128: /* cannam@128: Same than zipOpenNewFileInZip2, except cannam@128: windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 cannam@128: password : crypting password (NULL for no crypting) cannam@128: crcForCrypting : crc of file to compress (needed for crypting) cannam@128: */ cannam@128: cannam@128: extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, cannam@128: const char* filename, cannam@128: const zip_fileinfo* zipfi, cannam@128: const void* extrafield_local, cannam@128: uInt size_extrafield_local, cannam@128: const void* extrafield_global, cannam@128: uInt size_extrafield_global, cannam@128: const char* comment, cannam@128: int method, cannam@128: int level, cannam@128: int raw, cannam@128: int windowBits, cannam@128: int memLevel, cannam@128: int strategy, cannam@128: const char* password, cannam@128: uLong crcForCrypting, cannam@128: uLong versionMadeBy, cannam@128: uLong flagBase cannam@128: )); cannam@128: cannam@128: cannam@128: extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, cannam@128: const char* filename, cannam@128: const zip_fileinfo* zipfi, cannam@128: const void* extrafield_local, cannam@128: uInt size_extrafield_local, cannam@128: const void* extrafield_global, cannam@128: uInt size_extrafield_global, cannam@128: const char* comment, cannam@128: int method, cannam@128: int level, cannam@128: int raw, cannam@128: int windowBits, cannam@128: int memLevel, cannam@128: int strategy, cannam@128: const char* password, cannam@128: uLong crcForCrypting, cannam@128: uLong versionMadeBy, cannam@128: uLong flagBase, cannam@128: int zip64 cannam@128: )); cannam@128: /* cannam@128: Same than zipOpenNewFileInZip4, except cannam@128: versionMadeBy : value for Version made by field cannam@128: flag : value for flag field (compression level info will be added) cannam@128: */ cannam@128: cannam@128: cannam@128: extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, cannam@128: const void* buf, cannam@128: unsigned len)); cannam@128: /* cannam@128: Write data in the zipfile cannam@128: */ cannam@128: cannam@128: extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); cannam@128: /* cannam@128: Close the current file in the zipfile cannam@128: */ cannam@128: cannam@128: extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, cannam@128: uLong uncompressed_size, cannam@128: uLong crc32)); cannam@128: cannam@128: extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, cannam@128: ZPOS64_T uncompressed_size, cannam@128: uLong crc32)); cannam@128: cannam@128: /* cannam@128: Close the current file in the zipfile, for file opened with cannam@128: parameter raw=1 in zipOpenNewFileInZip2 cannam@128: uncompressed_size and crc32 are value for the uncompressed size cannam@128: */ cannam@128: cannam@128: extern int ZEXPORT zipClose OF((zipFile file, cannam@128: const char* global_comment)); cannam@128: /* cannam@128: Close the zipfile cannam@128: */ cannam@128: cannam@128: cannam@128: extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader)); cannam@128: /* cannam@128: zipRemoveExtraInfoBlock - Added by Mathias Svensson cannam@128: cannam@128: Remove extra information block from a extra information data for the local file header or central directory header cannam@128: cannam@128: It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode. cannam@128: cannam@128: 0x0001 is the signature header for the ZIP64 extra information blocks cannam@128: cannam@128: usage. cannam@128: Remove ZIP64 Extra information from a central director extra field data cannam@128: zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001); cannam@128: cannam@128: Remove ZIP64 Extra information from a Local File Header extra field data cannam@128: zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001); cannam@128: */ cannam@128: cannam@128: #ifdef __cplusplus cannam@128: } cannam@128: #endif cannam@128: cannam@128: #endif /* _zip64_H */