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