Home | History | Annotate | Line # | Download | only in minizip
zip.h revision 1.1.1.3.8.1
      1      1.1.1.2  christos /* zip.h -- IO on .zip files using zlib
      2      1.1.1.2  christos    Version 1.1, February 14h, 2010
      3      1.1.1.2  christos    part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
      4          1.1  christos 
      5      1.1.1.2  christos          Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
      6          1.1  christos 
      7      1.1.1.2  christos          Modifications for Zip64 support
      8      1.1.1.2  christos          Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
      9          1.1  christos 
     10      1.1.1.2  christos          For more info read MiniZip_info.txt
     11          1.1  christos 
     12      1.1.1.2  christos          ---------------------------------------------------------------------------
     13          1.1  christos 
     14          1.1  christos    Condition of use and distribution are the same than zlib :
     15          1.1  christos 
     16          1.1  christos   This software is provided 'as-is', without any express or implied
     17          1.1  christos   warranty.  In no event will the authors be held liable for any damages
     18          1.1  christos   arising from the use of this software.
     19          1.1  christos 
     20          1.1  christos   Permission is granted to anyone to use this software for any purpose,
     21          1.1  christos   including commercial applications, and to alter it and redistribute it
     22          1.1  christos   freely, subject to the following restrictions:
     23          1.1  christos 
     24          1.1  christos   1. The origin of this software must not be misrepresented; you must not
     25          1.1  christos      claim that you wrote the original software. If you use this software
     26          1.1  christos      in a product, an acknowledgment in the product documentation would be
     27          1.1  christos      appreciated but is not required.
     28          1.1  christos   2. Altered source versions must be plainly marked as such, and must not be
     29          1.1  christos      misrepresented as being the original software.
     30          1.1  christos   3. This notice may not be removed or altered from any source distribution.
     31          1.1  christos 
     32      1.1.1.2  christos         ---------------------------------------------------------------------------
     33          1.1  christos 
     34      1.1.1.2  christos         Changes
     35      1.1.1.2  christos 
     36      1.1.1.2  christos         See header of zip.h
     37          1.1  christos 
     38          1.1  christos */
     39          1.1  christos 
     40      1.1.1.2  christos #ifndef _zip12_H
     41      1.1.1.2  christos #define _zip12_H
     42          1.1  christos 
     43          1.1  christos #ifdef __cplusplus
     44          1.1  christos extern "C" {
     45          1.1  christos #endif
     46          1.1  christos 
     47      1.1.1.2  christos //#define HAVE_BZIP2
     48      1.1.1.2  christos 
     49          1.1  christos #ifndef _ZLIB_H
     50          1.1  christos #include "zlib.h"
     51          1.1  christos #endif
     52          1.1  christos 
     53          1.1  christos #ifndef _ZLIBIOAPI_H
     54          1.1  christos #include "ioapi.h"
     55          1.1  christos #endif
     56          1.1  christos 
     57      1.1.1.2  christos #ifdef HAVE_BZIP2
     58      1.1.1.2  christos #include "bzlib.h"
     59      1.1.1.2  christos #endif
     60      1.1.1.2  christos 
     61      1.1.1.2  christos #define Z_BZIP2ED 12
     62      1.1.1.2  christos 
     63          1.1  christos #if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
     64          1.1  christos /* like the STRICT of WIN32, we define a pointer that cannot be converted
     65          1.1  christos     from (void*) without cast */
     66          1.1  christos typedef struct TagzipFile__ { int unused; } zipFile__;
     67          1.1  christos typedef zipFile__ *zipFile;
     68          1.1  christos #else
     69          1.1  christos typedef voidp zipFile;
     70          1.1  christos #endif
     71          1.1  christos 
     72          1.1  christos #define ZIP_OK                          (0)
     73          1.1  christos #define ZIP_EOF                         (0)
     74          1.1  christos #define ZIP_ERRNO                       (Z_ERRNO)
     75          1.1  christos #define ZIP_PARAMERROR                  (-102)
     76          1.1  christos #define ZIP_BADZIPFILE                  (-103)
     77          1.1  christos #define ZIP_INTERNALERROR               (-104)
     78          1.1  christos 
     79          1.1  christos #ifndef DEF_MEM_LEVEL
     80          1.1  christos #  if MAX_MEM_LEVEL >= 8
     81          1.1  christos #    define DEF_MEM_LEVEL 8
     82          1.1  christos #  else
     83          1.1  christos #    define DEF_MEM_LEVEL  MAX_MEM_LEVEL
     84          1.1  christos #  endif
     85          1.1  christos #endif
     86          1.1  christos /* default memLevel */
     87          1.1  christos 
     88          1.1  christos /* tm_zip contain date/time info */
     89          1.1  christos typedef struct tm_zip_s
     90          1.1  christos {
     91      1.1.1.3  christos     int tm_sec;             /* seconds after the minute - [0,59] */
     92      1.1.1.3  christos     int tm_min;             /* minutes after the hour - [0,59] */
     93      1.1.1.3  christos     int tm_hour;            /* hours since midnight - [0,23] */
     94      1.1.1.3  christos     int tm_mday;            /* day of the month - [1,31] */
     95      1.1.1.3  christos     int tm_mon;             /* months since January - [0,11] */
     96      1.1.1.3  christos     int tm_year;            /* years - [1980..2044] */
     97          1.1  christos } tm_zip;
     98          1.1  christos 
     99          1.1  christos typedef struct
    100          1.1  christos {
    101          1.1  christos     tm_zip      tmz_date;       /* date in understandable format           */
    102          1.1  christos     uLong       dosDate;       /* if dos_date == 0, tmu_date is used      */
    103          1.1  christos /*    uLong       flag;        */   /* general purpose bit flag        2 bytes */
    104          1.1  christos 
    105          1.1  christos     uLong       internal_fa;    /* internal file attributes        2 bytes */
    106          1.1  christos     uLong       external_fa;    /* external file attributes        4 bytes */
    107          1.1  christos } zip_fileinfo;
    108          1.1  christos 
    109          1.1  christos typedef const char* zipcharpc;
    110          1.1  christos 
    111          1.1  christos 
    112          1.1  christos #define APPEND_STATUS_CREATE        (0)
    113          1.1  christos #define APPEND_STATUS_CREATEAFTER   (1)
    114          1.1  christos #define APPEND_STATUS_ADDINZIP      (2)
    115          1.1  christos 
    116  1.1.1.3.8.1  perseant extern zipFile ZEXPORT zipOpen(const char *pathname, int append);
    117  1.1.1.3.8.1  perseant extern zipFile ZEXPORT zipOpen64(const void *pathname, int append);
    118          1.1  christos /*
    119          1.1  christos   Create a zipfile.
    120          1.1  christos      pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
    121          1.1  christos        an Unix computer "zlib/zlib113.zip".
    122          1.1  christos      if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
    123          1.1  christos        will be created at the end of the file.
    124          1.1  christos          (useful if the file contain a self extractor code)
    125          1.1  christos      if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
    126          1.1  christos        add files in existing zip (be sure you don't add file that doesn't exist)
    127          1.1  christos      If the zipfile cannot be opened, the return value is NULL.
    128          1.1  christos      Else, the return value is a zipFile Handle, usable with other function
    129          1.1  christos        of this zip package.
    130          1.1  christos */
    131          1.1  christos 
    132          1.1  christos /* Note : there is no delete function into a zipfile.
    133          1.1  christos    If you want delete file into a zipfile, you must open a zipfile, and create another
    134  1.1.1.3.8.1  perseant    Of course, you can use RAW reading and writing to copy the file you did not want delete
    135          1.1  christos */
    136          1.1  christos 
    137  1.1.1.3.8.1  perseant extern zipFile ZEXPORT zipOpen2(const char *pathname,
    138  1.1.1.3.8.1  perseant                                 int append,
    139  1.1.1.3.8.1  perseant                                 zipcharpc* globalcomment,
    140  1.1.1.3.8.1  perseant                                 zlib_filefunc_def* pzlib_filefunc_def);
    141          1.1  christos 
    142  1.1.1.3.8.1  perseant extern zipFile ZEXPORT zipOpen2_64(const void *pathname,
    143      1.1.1.2  christos                                    int append,
    144      1.1.1.2  christos                                    zipcharpc* globalcomment,
    145  1.1.1.3.8.1  perseant                                    zlib_filefunc64_def* pzlib_filefunc_def);
    146      1.1.1.2  christos 
    147  1.1.1.3.8.1  perseant extern zipFile ZEXPORT zipOpen3(const void *pathname,
    148  1.1.1.3.8.1  perseant                                 int append,
    149  1.1.1.3.8.1  perseant                                 zipcharpc* globalcomment,
    150  1.1.1.3.8.1  perseant                                 zlib_filefunc64_32_def* pzlib_filefunc64_32_def);
    151  1.1.1.3.8.1  perseant 
    152  1.1.1.3.8.1  perseant extern int ZEXPORT zipOpenNewFileInZip(zipFile file,
    153  1.1.1.3.8.1  perseant                                        const char* filename,
    154  1.1.1.3.8.1  perseant                                        const zip_fileinfo* zipfi,
    155  1.1.1.3.8.1  perseant                                        const void* extrafield_local,
    156  1.1.1.3.8.1  perseant                                        uInt size_extrafield_local,
    157  1.1.1.3.8.1  perseant                                        const void* extrafield_global,
    158  1.1.1.3.8.1  perseant                                        uInt size_extrafield_global,
    159  1.1.1.3.8.1  perseant                                        const char* comment,
    160  1.1.1.3.8.1  perseant                                        int method,
    161  1.1.1.3.8.1  perseant                                        int level);
    162  1.1.1.3.8.1  perseant 
    163  1.1.1.3.8.1  perseant extern int ZEXPORT zipOpenNewFileInZip64(zipFile file,
    164  1.1.1.3.8.1  perseant                                          const char* filename,
    165  1.1.1.3.8.1  perseant                                          const zip_fileinfo* zipfi,
    166  1.1.1.3.8.1  perseant                                          const void* extrafield_local,
    167  1.1.1.3.8.1  perseant                                          uInt size_extrafield_local,
    168  1.1.1.3.8.1  perseant                                          const void* extrafield_global,
    169  1.1.1.3.8.1  perseant                                          uInt size_extrafield_global,
    170  1.1.1.3.8.1  perseant                                          const char* comment,
    171  1.1.1.3.8.1  perseant                                          int method,
    172  1.1.1.3.8.1  perseant                                          int level,
    173  1.1.1.3.8.1  perseant                                          int zip64);
    174      1.1.1.2  christos 
    175          1.1  christos /*
    176          1.1  christos   Open a file in the ZIP for writing.
    177          1.1  christos   filename : the filename in zip (if NULL, '-' without quote will be used
    178          1.1  christos   *zipfi contain supplemental information
    179          1.1  christos   if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
    180  1.1.1.3.8.1  perseant     contains the extrafield data for the local header
    181          1.1  christos   if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
    182  1.1.1.3.8.1  perseant     contains the extrafield data for the global header
    183          1.1  christos   if comment != NULL, comment contain the comment string
    184          1.1  christos   method contain the compression method (0 for store, Z_DEFLATED for deflate)
    185          1.1  christos   level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
    186      1.1.1.2  christos   zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
    187      1.1.1.2  christos                     this MUST be '1' if the uncompressed size is >= 0xffffffff.
    188      1.1.1.2  christos 
    189          1.1  christos */
    190          1.1  christos 
    191          1.1  christos 
    192  1.1.1.3.8.1  perseant extern int ZEXPORT zipOpenNewFileInZip2(zipFile file,
    193  1.1.1.3.8.1  perseant                                         const char* filename,
    194  1.1.1.3.8.1  perseant                                         const zip_fileinfo* zipfi,
    195  1.1.1.3.8.1  perseant                                         const void* extrafield_local,
    196  1.1.1.3.8.1  perseant                                         uInt size_extrafield_local,
    197  1.1.1.3.8.1  perseant                                         const void* extrafield_global,
    198  1.1.1.3.8.1  perseant                                         uInt size_extrafield_global,
    199  1.1.1.3.8.1  perseant                                         const char* comment,
    200  1.1.1.3.8.1  perseant                                         int method,
    201  1.1.1.3.8.1  perseant                                         int level,
    202  1.1.1.3.8.1  perseant                                         int raw);
    203  1.1.1.3.8.1  perseant 
    204  1.1.1.3.8.1  perseant 
    205  1.1.1.3.8.1  perseant extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file,
    206  1.1.1.3.8.1  perseant                                            const char* filename,
    207  1.1.1.3.8.1  perseant                                            const zip_fileinfo* zipfi,
    208  1.1.1.3.8.1  perseant                                            const void* extrafield_local,
    209  1.1.1.3.8.1  perseant                                            uInt size_extrafield_local,
    210  1.1.1.3.8.1  perseant                                            const void* extrafield_global,
    211  1.1.1.3.8.1  perseant                                            uInt size_extrafield_global,
    212  1.1.1.3.8.1  perseant                                            const char* comment,
    213  1.1.1.3.8.1  perseant                                            int method,
    214  1.1.1.3.8.1  perseant                                            int level,
    215  1.1.1.3.8.1  perseant                                            int raw,
    216  1.1.1.3.8.1  perseant                                            int zip64);
    217          1.1  christos /*
    218          1.1  christos   Same than zipOpenNewFileInZip, except if raw=1, we write raw file
    219          1.1  christos  */
    220          1.1  christos 
    221  1.1.1.3.8.1  perseant extern int ZEXPORT zipOpenNewFileInZip3(zipFile file,
    222  1.1.1.3.8.1  perseant                                         const char* filename,
    223  1.1.1.3.8.1  perseant                                         const zip_fileinfo* zipfi,
    224  1.1.1.3.8.1  perseant                                         const void* extrafield_local,
    225  1.1.1.3.8.1  perseant                                         uInt size_extrafield_local,
    226  1.1.1.3.8.1  perseant                                         const void* extrafield_global,
    227  1.1.1.3.8.1  perseant                                         uInt size_extrafield_global,
    228  1.1.1.3.8.1  perseant                                         const char* comment,
    229  1.1.1.3.8.1  perseant                                         int method,
    230  1.1.1.3.8.1  perseant                                         int level,
    231  1.1.1.3.8.1  perseant                                         int raw,
    232  1.1.1.3.8.1  perseant                                         int windowBits,
    233  1.1.1.3.8.1  perseant                                         int memLevel,
    234  1.1.1.3.8.1  perseant                                         int strategy,
    235  1.1.1.3.8.1  perseant                                         const char* password,
    236  1.1.1.3.8.1  perseant                                         uLong crcForCrypting);
    237  1.1.1.3.8.1  perseant 
    238  1.1.1.3.8.1  perseant extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file,
    239  1.1.1.3.8.1  perseant                                            const char* filename,
    240  1.1.1.3.8.1  perseant                                            const zip_fileinfo* zipfi,
    241  1.1.1.3.8.1  perseant                                            const void* extrafield_local,
    242  1.1.1.3.8.1  perseant                                            uInt size_extrafield_local,
    243  1.1.1.3.8.1  perseant                                            const void* extrafield_global,
    244  1.1.1.3.8.1  perseant                                            uInt size_extrafield_global,
    245  1.1.1.3.8.1  perseant                                            const char* comment,
    246  1.1.1.3.8.1  perseant                                            int method,
    247  1.1.1.3.8.1  perseant                                            int level,
    248  1.1.1.3.8.1  perseant                                            int raw,
    249  1.1.1.3.8.1  perseant                                            int windowBits,
    250  1.1.1.3.8.1  perseant                                            int memLevel,
    251  1.1.1.3.8.1  perseant                                            int strategy,
    252  1.1.1.3.8.1  perseant                                            const char* password,
    253  1.1.1.3.8.1  perseant                                            uLong crcForCrypting,
    254  1.1.1.3.8.1  perseant                                            int zip64);
    255          1.1  christos 
    256          1.1  christos /*
    257          1.1  christos   Same than zipOpenNewFileInZip2, except
    258          1.1  christos     windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
    259          1.1  christos     password : crypting password (NULL for no crypting)
    260      1.1.1.2  christos     crcForCrypting : crc of file to compress (needed for crypting)
    261      1.1.1.2  christos  */
    262      1.1.1.2  christos 
    263  1.1.1.3.8.1  perseant extern int ZEXPORT zipOpenNewFileInZip4(zipFile file,
    264  1.1.1.3.8.1  perseant                                         const char* filename,
    265  1.1.1.3.8.1  perseant                                         const zip_fileinfo* zipfi,
    266  1.1.1.3.8.1  perseant                                         const void* extrafield_local,
    267  1.1.1.3.8.1  perseant                                         uInt size_extrafield_local,
    268  1.1.1.3.8.1  perseant                                         const void* extrafield_global,
    269  1.1.1.3.8.1  perseant                                         uInt size_extrafield_global,
    270  1.1.1.3.8.1  perseant                                         const char* comment,
    271  1.1.1.3.8.1  perseant                                         int method,
    272  1.1.1.3.8.1  perseant                                         int level,
    273  1.1.1.3.8.1  perseant                                         int raw,
    274  1.1.1.3.8.1  perseant                                         int windowBits,
    275  1.1.1.3.8.1  perseant                                         int memLevel,
    276  1.1.1.3.8.1  perseant                                         int strategy,
    277  1.1.1.3.8.1  perseant                                         const char* password,
    278  1.1.1.3.8.1  perseant                                         uLong crcForCrypting,
    279  1.1.1.3.8.1  perseant                                         uLong versionMadeBy,
    280  1.1.1.3.8.1  perseant                                         uLong flagBase);
    281  1.1.1.3.8.1  perseant 
    282  1.1.1.3.8.1  perseant 
    283  1.1.1.3.8.1  perseant extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file,
    284  1.1.1.3.8.1  perseant                                            const char* filename,
    285  1.1.1.3.8.1  perseant                                            const zip_fileinfo* zipfi,
    286  1.1.1.3.8.1  perseant                                            const void* extrafield_local,
    287  1.1.1.3.8.1  perseant                                            uInt size_extrafield_local,
    288  1.1.1.3.8.1  perseant                                            const void* extrafield_global,
    289  1.1.1.3.8.1  perseant                                            uInt size_extrafield_global,
    290  1.1.1.3.8.1  perseant                                            const char* comment,
    291  1.1.1.3.8.1  perseant                                            int method,
    292  1.1.1.3.8.1  perseant                                            int level,
    293  1.1.1.3.8.1  perseant                                            int raw,
    294  1.1.1.3.8.1  perseant                                            int windowBits,
    295  1.1.1.3.8.1  perseant                                            int memLevel,
    296  1.1.1.3.8.1  perseant                                            int strategy,
    297  1.1.1.3.8.1  perseant                                            const char* password,
    298  1.1.1.3.8.1  perseant                                            uLong crcForCrypting,
    299  1.1.1.3.8.1  perseant                                            uLong versionMadeBy,
    300  1.1.1.3.8.1  perseant                                            uLong flagBase,
    301  1.1.1.3.8.1  perseant                                            int zip64);
    302      1.1.1.2  christos /*
    303      1.1.1.2  christos   Same than zipOpenNewFileInZip4, except
    304      1.1.1.2  christos     versionMadeBy : value for Version made by field
    305      1.1.1.2  christos     flag : value for flag field (compression level info will be added)
    306          1.1  christos  */
    307          1.1  christos 
    308          1.1  christos 
    309  1.1.1.3.8.1  perseant extern int ZEXPORT zipWriteInFileInZip(zipFile file,
    310  1.1.1.3.8.1  perseant                                        const void* buf,
    311  1.1.1.3.8.1  perseant                                        unsigned len);
    312          1.1  christos /*
    313          1.1  christos   Write data in the zipfile
    314          1.1  christos */
    315          1.1  christos 
    316  1.1.1.3.8.1  perseant extern int ZEXPORT zipCloseFileInZip(zipFile file);
    317          1.1  christos /*
    318          1.1  christos   Close the current file in the zipfile
    319          1.1  christos */
    320          1.1  christos 
    321  1.1.1.3.8.1  perseant extern int ZEXPORT zipCloseFileInZipRaw(zipFile file,
    322  1.1.1.3.8.1  perseant                                         uLong uncompressed_size,
    323  1.1.1.3.8.1  perseant                                         uLong crc32);
    324  1.1.1.3.8.1  perseant 
    325  1.1.1.3.8.1  perseant extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file,
    326  1.1.1.3.8.1  perseant                                           ZPOS64_T uncompressed_size,
    327  1.1.1.3.8.1  perseant                                           uLong crc32);
    328      1.1.1.2  christos 
    329          1.1  christos /*
    330      1.1.1.2  christos   Close the current file in the zipfile, for file opened with
    331          1.1  christos     parameter raw=1 in zipOpenNewFileInZip2
    332          1.1  christos   uncompressed_size and crc32 are value for the uncompressed size
    333          1.1  christos */
    334          1.1  christos 
    335  1.1.1.3.8.1  perseant extern int ZEXPORT zipClose(zipFile file,
    336  1.1.1.3.8.1  perseant                             const char* global_comment);
    337          1.1  christos /*
    338          1.1  christos   Close the zipfile
    339          1.1  christos */
    340          1.1  christos 
    341      1.1.1.2  christos 
    342  1.1.1.3.8.1  perseant extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader);
    343      1.1.1.2  christos /*
    344      1.1.1.2  christos   zipRemoveExtraInfoBlock -  Added by Mathias Svensson
    345      1.1.1.2  christos 
    346      1.1.1.2  christos   Remove extra information block from a extra information data for the local file header or central directory header
    347      1.1.1.2  christos 
    348      1.1.1.2  christos   It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.
    349      1.1.1.2  christos 
    350      1.1.1.2  christos   0x0001 is the signature header for the ZIP64 extra information blocks
    351      1.1.1.2  christos 
    352      1.1.1.2  christos   usage.
    353      1.1.1.2  christos                         Remove ZIP64 Extra information from a central director extra field data
    354      1.1.1.2  christos               zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);
    355      1.1.1.2  christos 
    356      1.1.1.2  christos                         Remove ZIP64 Extra information from a Local File Header extra field data
    357      1.1.1.2  christos         zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);
    358      1.1.1.2  christos */
    359      1.1.1.2  christos 
    360          1.1  christos #ifdef __cplusplus
    361          1.1  christos }
    362          1.1  christos #endif
    363          1.1  christos 
    364      1.1.1.2  christos #endif /* _zip64_H */
    365