/* 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{90int tm_sec; /* seconds after the minute - [0,59] */91int tm_min; /* minutes after the hour - [0,59] */92int tm_hour; /* hours since midnight - [0,23] */93int tm_mday; /* day of the month - [1,31] */94int tm_mon; /* months since January - [0,11] */95int 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(const char *pathname, int append);116extern zipFile ZEXPORT zipOpen64(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 course, you can use RAW reading and writing to copy the file you did not want delete134*/135136extern zipFile ZEXPORT zipOpen2(const char *pathname,137int append,138zipcharpc* globalcomment,139zlib_filefunc_def* pzlib_filefunc_def);140141extern zipFile ZEXPORT zipOpen2_64(const void *pathname,142int append,143zipcharpc* globalcomment,144zlib_filefunc64_def* pzlib_filefunc_def);145146extern zipFile ZEXPORT zipOpen3(const void *pathname,147int append,148zipcharpc* globalcomment,149zlib_filefunc64_32_def* pzlib_filefunc64_32_def);150151extern int ZEXPORT zipOpenNewFileInZip(zipFile file,152const char* filename,153const zip_fileinfo* zipfi,154const void* extrafield_local,155uInt size_extrafield_local,156const void* extrafield_global,157uInt size_extrafield_global,158const char* comment,159int method,160int level);161162extern int ZEXPORT zipOpenNewFileInZip64(zipFile file,163const char* filename,164const zip_fileinfo* zipfi,165const void* extrafield_local,166uInt size_extrafield_local,167const void* extrafield_global,168uInt size_extrafield_global,169const char* comment,170int method,171int level,172int zip64);173174/*175Open a file in the ZIP for writing.176filename : the filename in zip (if NULL, '-' without quote will be used177*zipfi contain supplemental information178if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local179contains the extrafield data for the local header180if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global181contains the extrafield data for the global header182if comment != NULL, comment contain the comment string183method contain the compression method (0 for store, Z_DEFLATED for deflate)184level contain the level of compression (can be Z_DEFAULT_COMPRESSION)185zip64 is set to 1 if a zip64 extended information block should be added to the local file header.186this MUST be '1' if the uncompressed size is >= 0xffffffff.187188*/189190191extern int ZEXPORT zipOpenNewFileInZip2(zipFile file,192const char* filename,193const zip_fileinfo* zipfi,194const void* extrafield_local,195uInt size_extrafield_local,196const void* extrafield_global,197uInt size_extrafield_global,198const char* comment,199int method,200int level,201int raw);202203204extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file,205const char* filename,206const zip_fileinfo* zipfi,207const void* extrafield_local,208uInt size_extrafield_local,209const void* extrafield_global,210uInt size_extrafield_global,211const char* comment,212int method,213int level,214int raw,215int zip64);216/*217Same than zipOpenNewFileInZip, except if raw=1, we write raw file218*/219220extern int ZEXPORT zipOpenNewFileInZip3(zipFile file,221const char* filename,222const zip_fileinfo* zipfi,223const void* extrafield_local,224uInt size_extrafield_local,225const void* extrafield_global,226uInt size_extrafield_global,227const char* comment,228int method,229int level,230int raw,231int windowBits,232int memLevel,233int strategy,234const char* password,235uLong crcForCrypting);236237extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file,238const char* filename,239const zip_fileinfo* zipfi,240const void* extrafield_local,241uInt size_extrafield_local,242const void* extrafield_global,243uInt size_extrafield_global,244const char* comment,245int method,246int level,247int raw,248int windowBits,249int memLevel,250int strategy,251const char* password,252uLong crcForCrypting,253int zip64);254255/*256Same than zipOpenNewFileInZip2, except257windowBits,memLevel,,strategy : see parameter strategy in deflateInit2258password : crypting password (NULL for no crypting)259crcForCrypting : crc of file to compress (needed for crypting)260*/261262extern int ZEXPORT zipOpenNewFileInZip4(zipFile file,263const char* filename,264const zip_fileinfo* zipfi,265const void* extrafield_local,266uInt size_extrafield_local,267const void* extrafield_global,268uInt size_extrafield_global,269const char* comment,270int method,271int level,272int raw,273int windowBits,274int memLevel,275int strategy,276const char* password,277uLong crcForCrypting,278uLong versionMadeBy,279uLong flagBase);280281282extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file,283const char* filename,284const zip_fileinfo* zipfi,285const void* extrafield_local,286uInt size_extrafield_local,287const void* extrafield_global,288uInt size_extrafield_global,289const char* comment,290int method,291int level,292int raw,293int windowBits,294int memLevel,295int strategy,296const char* password,297uLong crcForCrypting,298uLong versionMadeBy,299uLong flagBase,300int zip64);301/*302Same than zipOpenNewFileInZip4, except303versionMadeBy : value for Version made by field304flag : value for flag field (compression level info will be added)305*/306307308extern int ZEXPORT zipWriteInFileInZip(zipFile file,309const void* buf,310unsigned len);311/*312Write data in the zipfile313*/314315extern int ZEXPORT zipCloseFileInZip(zipFile file);316/*317Close the current file in the zipfile318*/319320extern int ZEXPORT zipCloseFileInZipRaw(zipFile file,321uLong uncompressed_size,322uLong crc32);323324extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file,325ZPOS64_T uncompressed_size,326uLong crc32);327328/*329Close the current file in the zipfile, for file opened with330parameter raw=1 in zipOpenNewFileInZip2331uncompressed_size and crc32 are value for the uncompressed size332*/333334extern int ZEXPORT zipClose(zipFile file,335const char* global_comment);336/*337Close the zipfile338*/339340341extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader);342/*343zipRemoveExtraInfoBlock - Added by Mathias Svensson344345Remove extra information block from a extra information data for the local file header or central directory header346347It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.3483490x0001 is the signature header for the ZIP64 extra information blocks350351usage.352Remove ZIP64 Extra information from a central director extra field data353zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);354355Remove ZIP64 Extra information from a Local File Header extra field data356zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);357*/358359#ifdef __cplusplus360}361#endif362363#endif /* _zip64_H */364365366