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