/* zip.h -- IO on .zip files using zlib1Version 1.1, February 14h, 20102part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )34Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )56Modifications for Zip64 support7Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )89For more info read MiniZip_info.txt1011---------------------------------------------------------------------------1213Condition of use and distribution are the same than zlib :1415This software is provided 'as-is', without any express or implied16warranty. In no event will the authors be held liable for any damages17arising from the use of this software.1819Permission is granted to anyone to use this software for any purpose,20including commercial applications, and to alter it and redistribute it21freely, subject to the following restrictions:22231. The origin of this software must not be misrepresented; you must not24claim that you wrote the original software. If you use this software25in a product, an acknowledgment in the product documentation would be26appreciated but is not required.272. Altered source versions must be plainly marked as such, and must not be28misrepresented as being the original software.293. This notice may not be removed or altered from any source distribution.3031---------------------------------------------------------------------------3233Changes3435See header of zip.h3637*/3839#ifndef _zip12_H40#define _zip12_H4142#ifdef __cplusplus43extern "C" {44#endif4546//#define HAVE_BZIP24748#ifndef _ZLIB_H49#include "zlib.h"50#endif5152#ifndef _ZLIBIOAPI_H53#include "ioapi.h"54#endif5556#ifdef HAVE_BZIP257#include "bzlib.h"58#endif5960#define Z_BZIP2ED 126162#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)63/* like the STRICT of WIN32, we define a pointer that cannot be converted64from (void*) without cast */65typedef struct TagzipFile__ { int unused; } zipFile__;66typedef zipFile__ *zipFile;67#else68typedef voidp zipFile;69#endif7071#define ZIP_OK (0)72#define ZIP_EOF (0)73#define ZIP_ERRNO (Z_ERRNO)74#define ZIP_PARAMERROR (-102)75#define ZIP_BADZIPFILE (-103)76#define ZIP_INTERNALERROR (-104)7778#ifndef DEF_MEM_LEVEL79# if MAX_MEM_LEVEL >= 880# define DEF_MEM_LEVEL 881# else82# define DEF_MEM_LEVEL MAX_MEM_LEVEL83# endif84#endif85/* default memLevel */8687/* tm_zip contain date/time info */88typedef struct tm_zip_s89{90uInt tm_sec; /* seconds after the minute - [0,59] */91uInt tm_min; /* minutes after the hour - [0,59] */92uInt tm_hour; /* hours since midnight - [0,23] */93uInt tm_mday; /* day of the month - [1,31] */94uInt tm_mon; /* months since January - [0,11] */95uInt tm_year; /* years - [1980..2044] */96} tm_zip;9798typedef struct99{100tm_zip tmz_date; /* date in understandable format */101uLong dosDate; /* if dos_date == 0, tmu_date is used */102/* uLong flag; */ /* general purpose bit flag 2 bytes */103104uLong internal_fa; /* internal file attributes 2 bytes */105uLong external_fa; /* external file attributes 4 bytes */106} zip_fileinfo;107108typedef const char* zipcharpc;109110111#define APPEND_STATUS_CREATE (0)112#define APPEND_STATUS_CREATEAFTER (1)113#define APPEND_STATUS_ADDINZIP (2)114115extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));116extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));117/*118Create a zipfile.119pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on120an Unix computer "zlib/zlib113.zip".121if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip122will be created at the end of the file.123(useful if the file contain a self extractor code)124if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will125add files in existing zip (be sure you don't add file that doesn't exist)126If the zipfile cannot be opened, the return value is NULL.127Else, the return value is a zipFile Handle, usable with other function128of this zip package.129*/130131/* Note : there is no delete function into a zipfile.132If you want delete file into a zipfile, you must open a zipfile, and create another133Of couse, you can use RAW reading and writing to copy the file you did not want delte134*/135136extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,137int append,138zipcharpc* globalcomment,139zlib_filefunc_def* pzlib_filefunc_def));140141extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,142int append,143zipcharpc* globalcomment,144zlib_filefunc64_def* pzlib_filefunc_def));145146extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,147const char* filename,148const zip_fileinfo* zipfi,149const void* extrafield_local,150uInt size_extrafield_local,151const void* extrafield_global,152uInt size_extrafield_global,153const char* comment,154int method,155int level));156157extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,158const char* filename,159const zip_fileinfo* zipfi,160const void* extrafield_local,161uInt size_extrafield_local,162const void* extrafield_global,163uInt size_extrafield_global,164const char* comment,165int method,166int level,167int zip64));168169/*170Open a file in the ZIP for writing.171filename : the filename in zip (if NULL, '-' without quote will be used172*zipfi contain supplemental information173if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local174contains the extrafield data the the local header175if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global176contains the extrafield data the the local header177if comment != NULL, comment contain the comment string178method contain the compression method (0 for store, Z_DEFLATED for deflate)179level contain the level of compression (can be Z_DEFAULT_COMPRESSION)180zip64 is set to 1 if a zip64 extended information block should be added to the local file header.181this MUST be '1' if the uncompressed size is >= 0xffffffff.182183*/184185186extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,187const char* filename,188const zip_fileinfo* zipfi,189const void* extrafield_local,190uInt size_extrafield_local,191const void* extrafield_global,192uInt size_extrafield_global,193const char* comment,194int method,195int level,196int raw));197198199extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,200const char* filename,201const zip_fileinfo* zipfi,202const void* extrafield_local,203uInt size_extrafield_local,204const void* extrafield_global,205uInt size_extrafield_global,206const char* comment,207int method,208int level,209int raw,210int zip64));211/*212Same than zipOpenNewFileInZip, except if raw=1, we write raw file213*/214215extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,216const char* filename,217const zip_fileinfo* zipfi,218const void* extrafield_local,219uInt size_extrafield_local,220const void* extrafield_global,221uInt size_extrafield_global,222const char* comment,223int method,224int level,225int raw,226int windowBits,227int memLevel,228int strategy,229const char* password,230uLong crcForCrypting));231232extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,233const char* filename,234const zip_fileinfo* zipfi,235const void* extrafield_local,236uInt size_extrafield_local,237const void* extrafield_global,238uInt size_extrafield_global,239const char* comment,240int method,241int level,242int raw,243int windowBits,244int memLevel,245int strategy,246const char* password,247uLong crcForCrypting,248int zip64249));250251/*252Same than zipOpenNewFileInZip2, except253windowBits,memLevel,,strategy : see parameter strategy in deflateInit2254password : crypting password (NULL for no crypting)255crcForCrypting : crc of file to compress (needed for crypting)256*/257258extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,259const char* filename,260const zip_fileinfo* zipfi,261const void* extrafield_local,262uInt size_extrafield_local,263const void* extrafield_global,264uInt size_extrafield_global,265const char* comment,266int method,267int level,268int raw,269int windowBits,270int memLevel,271int strategy,272const char* password,273uLong crcForCrypting,274uLong versionMadeBy,275uLong flagBase276));277278279extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,280const char* filename,281const zip_fileinfo* zipfi,282const void* extrafield_local,283uInt size_extrafield_local,284const void* extrafield_global,285uInt size_extrafield_global,286const char* comment,287int method,288int level,289int raw,290int windowBits,291int memLevel,292int strategy,293const char* password,294uLong crcForCrypting,295uLong versionMadeBy,296uLong flagBase,297int zip64298));299/*300Same than zipOpenNewFileInZip4, except301versionMadeBy : value for Version made by field302flag : value for flag field (compression level info will be added)303*/304305306extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,307const void* buf,308unsigned len));309/*310Write data in the zipfile311*/312313extern int ZEXPORT zipCloseFileInZip OF((zipFile file));314/*315Close the current file in the zipfile316*/317318extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,319uLong uncompressed_size,320uLong crc32));321322extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,323ZPOS64_T uncompressed_size,324uLong crc32));325326/*327Close the current file in the zipfile, for file opened with328parameter raw=1 in zipOpenNewFileInZip2329uncompressed_size and crc32 are value for the uncompressed size330*/331332extern int ZEXPORT zipClose OF((zipFile file,333const char* global_comment));334/*335Close the zipfile336*/337338339extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));340/*341zipRemoveExtraInfoBlock - Added by Mathias Svensson342343Remove extra information block from a extra information data for the local file header or central directory header344345It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.3463470x0001 is the signature header for the ZIP64 extra information blocks348349usage.350Remove ZIP64 Extra information from a central director extra field data351zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);352353Remove ZIP64 Extra information from a Local File Header extra field data354zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);355*/356357#ifdef __cplusplus358}359#endif360361#endif /* _zip64_H */362363364