Home | History | Annotate | Line # | Download | only in minizip
zip.h revision 1.1
      1  1.1  christos /*	$NetBSD: zip.h,v 1.1 2006/01/14 20:11:01 christos Exp $	*/
      2  1.1  christos 
      3  1.1  christos /* zip.h -- IO for compress .zip files using zlib
      4  1.1  christos    Version 1.01e, February 12th, 2005
      5  1.1  christos 
      6  1.1  christos    Copyright (C) 1998-2005 Gilles Vollant
      7  1.1  christos 
      8  1.1  christos    This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
      9  1.1  christos      WinZip, InfoZip tools and compatible.
     10  1.1  christos    Multi volume ZipFile (span) are not supported.
     11  1.1  christos    Encryption compatible with pkzip 2.04g only supported
     12  1.1  christos    Old compressions used by old PKZip 1.x are not supported
     13  1.1  christos 
     14  1.1  christos   For uncompress .zip file, look at unzip.h
     15  1.1  christos 
     16  1.1  christos 
     17  1.1  christos    I WAIT FEEDBACK at mail info (at) winimage.com
     18  1.1  christos    Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
     19  1.1  christos 
     20  1.1  christos    Condition of use and distribution are the same than zlib :
     21  1.1  christos 
     22  1.1  christos   This software is provided 'as-is', without any express or implied
     23  1.1  christos   warranty.  In no event will the authors be held liable for any damages
     24  1.1  christos   arising from the use of this software.
     25  1.1  christos 
     26  1.1  christos   Permission is granted to anyone to use this software for any purpose,
     27  1.1  christos   including commercial applications, and to alter it and redistribute it
     28  1.1  christos   freely, subject to the following restrictions:
     29  1.1  christos 
     30  1.1  christos   1. The origin of this software must not be misrepresented; you must not
     31  1.1  christos      claim that you wrote the original software. If you use this software
     32  1.1  christos      in a product, an acknowledgment in the product documentation would be
     33  1.1  christos      appreciated but is not required.
     34  1.1  christos   2. Altered source versions must be plainly marked as such, and must not be
     35  1.1  christos      misrepresented as being the original software.
     36  1.1  christos   3. This notice may not be removed or altered from any source distribution.
     37  1.1  christos 
     38  1.1  christos 
     39  1.1  christos */
     40  1.1  christos 
     41  1.1  christos /* for more info about .ZIP format, see
     42  1.1  christos       http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
     43  1.1  christos       http://www.info-zip.org/pub/infozip/doc/
     44  1.1  christos    PkWare has also a specification at :
     45  1.1  christos       ftp://ftp.pkware.com/probdesc.zip
     46  1.1  christos */
     47  1.1  christos 
     48  1.1  christos #ifndef _zip_H
     49  1.1  christos #define _zip_H
     50  1.1  christos 
     51  1.1  christos #ifdef __cplusplus
     52  1.1  christos extern "C" {
     53  1.1  christos #endif
     54  1.1  christos 
     55  1.1  christos #ifndef _ZLIB_H
     56  1.1  christos #include "zlib.h"
     57  1.1  christos #endif
     58  1.1  christos 
     59  1.1  christos #ifndef _ZLIBIOAPI_H
     60  1.1  christos #include "ioapi.h"
     61  1.1  christos #endif
     62  1.1  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  christos     uInt tm_sec;            /* seconds after the minute - [0,59] */
     92  1.1  christos     uInt tm_min;            /* minutes after the hour - [0,59] */
     93  1.1  christos     uInt tm_hour;           /* hours since midnight - [0,23] */
     94  1.1  christos     uInt tm_mday;           /* day of the month - [1,31] */
     95  1.1  christos     uInt tm_mon;            /* months since January - [0,11] */
     96  1.1  christos     uInt 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  christos extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
    117  1.1  christos /*
    118  1.1  christos   Create a zipfile.
    119  1.1  christos      pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
    120  1.1  christos        an Unix computer "zlib/zlib113.zip".
    121  1.1  christos      if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
    122  1.1  christos        will be created at the end of the file.
    123  1.1  christos          (useful if the file contain a self extractor code)
    124  1.1  christos      if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
    125  1.1  christos        add files in existing zip (be sure you don't add file that doesn't exist)
    126  1.1  christos      If the zipfile cannot be opened, the return value is NULL.
    127  1.1  christos      Else, the return value is a zipFile Handle, usable with other function
    128  1.1  christos        of this zip package.
    129  1.1  christos */
    130  1.1  christos 
    131  1.1  christos /* Note : there is no delete function into a zipfile.
    132  1.1  christos    If you want delete file into a zipfile, you must open a zipfile, and create another
    133  1.1  christos    Of couse, you can use RAW reading and writing to copy the file you did not want delte
    134  1.1  christos */
    135  1.1  christos 
    136  1.1  christos extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
    137  1.1  christos                                    int append,
    138  1.1  christos                                    zipcharpc* globalcomment,
    139  1.1  christos                                    zlib_filefunc_def* pzlib_filefunc_def));
    140  1.1  christos 
    141  1.1  christos extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
    142  1.1  christos                        const char* filename,
    143  1.1  christos                        const zip_fileinfo* zipfi,
    144  1.1  christos                        const void* extrafield_local,
    145  1.1  christos                        uInt size_extrafield_local,
    146  1.1  christos                        const void* extrafield_global,
    147  1.1  christos                        uInt size_extrafield_global,
    148  1.1  christos                        const char* comment,
    149  1.1  christos                        int method,
    150  1.1  christos                        int level));
    151  1.1  christos /*
    152  1.1  christos   Open a file in the ZIP for writing.
    153  1.1  christos   filename : the filename in zip (if NULL, '-' without quote will be used
    154  1.1  christos   *zipfi contain supplemental information
    155  1.1  christos   if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
    156  1.1  christos     contains the extrafield data the the local header
    157  1.1  christos   if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
    158  1.1  christos     contains the extrafield data the the local header
    159  1.1  christos   if comment != NULL, comment contain the comment string
    160  1.1  christos   method contain the compression method (0 for store, Z_DEFLATED for deflate)
    161  1.1  christos   level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
    162  1.1  christos */
    163  1.1  christos 
    164  1.1  christos 
    165  1.1  christos extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
    166  1.1  christos                                             const char* filename,
    167  1.1  christos                                             const zip_fileinfo* zipfi,
    168  1.1  christos                                             const void* extrafield_local,
    169  1.1  christos                                             uInt size_extrafield_local,
    170  1.1  christos                                             const void* extrafield_global,
    171  1.1  christos                                             uInt size_extrafield_global,
    172  1.1  christos                                             const char* comment,
    173  1.1  christos                                             int method,
    174  1.1  christos                                             int level,
    175  1.1  christos                                             int raw));
    176  1.1  christos 
    177  1.1  christos /*
    178  1.1  christos   Same than zipOpenNewFileInZip, except if raw=1, we write raw file
    179  1.1  christos  */
    180  1.1  christos 
    181  1.1  christos extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
    182  1.1  christos                                             const char* filename,
    183  1.1  christos                                             const zip_fileinfo* zipfi,
    184  1.1  christos                                             const void* extrafield_local,
    185  1.1  christos                                             uInt size_extrafield_local,
    186  1.1  christos                                             const void* extrafield_global,
    187  1.1  christos                                             uInt size_extrafield_global,
    188  1.1  christos                                             const char* comment,
    189  1.1  christos                                             int method,
    190  1.1  christos                                             int level,
    191  1.1  christos                                             int raw,
    192  1.1  christos                                             int windowBits,
    193  1.1  christos                                             int memLevel,
    194  1.1  christos                                             int strategy,
    195  1.1  christos                                             const char* password,
    196  1.1  christos                                             uLong crcForCtypting));
    197  1.1  christos 
    198  1.1  christos /*
    199  1.1  christos   Same than zipOpenNewFileInZip2, except
    200  1.1  christos     windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
    201  1.1  christos     password : crypting password (NULL for no crypting)
    202  1.1  christos     crcForCtypting : crc of file to compress (needed for crypting)
    203  1.1  christos  */
    204  1.1  christos 
    205  1.1  christos 
    206  1.1  christos extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
    207  1.1  christos                        const void* buf,
    208  1.1  christos                        unsigned len));
    209  1.1  christos /*
    210  1.1  christos   Write data in the zipfile
    211  1.1  christos */
    212  1.1  christos 
    213  1.1  christos extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
    214  1.1  christos /*
    215  1.1  christos   Close the current file in the zipfile
    216  1.1  christos */
    217  1.1  christos 
    218  1.1  christos extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
    219  1.1  christos                                             uLong uncompressed_size,
    220  1.1  christos                                             uLong crc32));
    221  1.1  christos /*
    222  1.1  christos   Close the current file in the zipfile, for fiel opened with
    223  1.1  christos     parameter raw=1 in zipOpenNewFileInZip2
    224  1.1  christos   uncompressed_size and crc32 are value for the uncompressed size
    225  1.1  christos */
    226  1.1  christos 
    227  1.1  christos extern int ZEXPORT zipClose OF((zipFile file,
    228  1.1  christos                 const char* global_comment));
    229  1.1  christos /*
    230  1.1  christos   Close the zipfile
    231  1.1  christos */
    232  1.1  christos 
    233  1.1  christos #ifdef __cplusplus
    234  1.1  christos }
    235  1.1  christos #endif
    236  1.1  christos 
    237  1.1  christos #endif /* _zip_H */
    238