- Main Page
- Related Pages
- Classes
- Files

# cpl_minizip_zip.h

    00001 /******************************************************************************
    00002  * $Id: cpl_minizip_zip.h 20794 2010-10-08 16:58:27Z warmerdam $
    00003  *
    00004  * Project:  CPL - Common Portability Library
    00005  * Author:   Frank Warmerdam, warmerdam@pobox.com
    00006  * Purpose:  Adjusted minizip "zip.h" include file for zip services.
    00007  *
    00008  * Modified version by Even Rouault. :
    00009  *   - Decoration of symbol names unz* -> cpl_unz*
    00010  *   - Undef EXPORT so that we are sure the symbols are not exported
    00011  *   - Remove old C style function prototypes
    00012  *   - Added CPL* simplified API at bottom.
    00013  *
    00014  *   Original licence available in port/LICENCE_minizip
    00015  *
    00016  *****************************************************************************/
    00017
    00018 /* zip.h -- IO for compress .zip files using zlib
    00019    Version 1.01e, February 12th, 2005
    00020
    00021    Copyright (C) 1998-2005 Gilles Vollant
    00022
    00023    This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
    00024      WinZip, InfoZip tools and compatible.
    00025    Multi volume ZipFile (span) are not supported.
    00026    Encryption compatible with pkzip 2.04g only supported
    00027    Old compressions used by old PKZip 1.x are not supported
    00028
    00029   For uncompress .zip file, look at unzip.h
    00030
    00031
    00032    I WAIT FEEDBACK at mail info@winimage.com
    00033    Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
    00034
    00035    Condition of use and distribution are the same than zlib :
    00036
    00037   This software is provided 'as-is', without any express or implied
    00038   warranty.  In no event will the authors be held liable for any damages
    00039   arising from the use of this software.
    00040
    00041   Permission is granted to anyone to use this software for any purpose,
    00042   including commercial applications, and to alter it and redistribute it
    00043   freely, subject to the following restrictions:
    00044
    00045   1. The origin of this software must not be misrepresented; you must not
    00046      claim that you wrote the original software. If you use this software
    00047      in a product, an acknowledgment in the product documentation would be
    00048      appreciated but is not required.
    00049   2. Altered source versions must be plainly marked as such, and must not be
    00050      misrepresented as being the original software.
    00051   3. This notice may not be removed or altered from any source distribution.
    00052
    00053
    00054 */
    00055
    00056 /* for more info about .ZIP format, see
    00057       http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
    00058       http://www.info-zip.org/pub/infozip/doc/
    00059    PkWare has also a specification at :
    00060       ftp://ftp.pkware.com/probdesc.zip
    00061 */
    00062
    00063 #ifndef CPL_MINIZIP_ZIP_H_INCLUDED
    00064 #define CPL_MINIZIP_ZIP_H_INCLUDED
    00065
    00066 #include "cpl_vsi.h"
    00067 #define uLong64 vsi_l_offset
    00068
    00069 #ifdef __cplusplus
    00070 extern "C" {
    00071 #endif
    00072
    00073 #ifndef _ZLIB_H
    00074 #include "zlib.h"
    00075 #endif
    00076
    00077 #ifndef CPL_MINIZIP_IOAPI_H_INCLUDED
    00078 #include "cpl_minizip_ioapi.h"
    00079 #endif
    00080
    00081 #define NOCRYPT
    00082 #undef ZEXPORT
    00083 #define ZEXPORT
    00084
    00085 #if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
    00086 /* like the STRICT of WIN32, we define a pointer that cannot be converted
    00087     from (void*) without cast */
    00088 typedef struct TagzipFile__ { int unused; } zipFile__;
    00089 typedef zipFile__ *zipFile;
    00090 #else
    00091 typedef voidp zipFile;
    00092 #endif
    00093
    00094 #define ZIP_OK                          (0)
    00095 #define ZIP_EOF                         (0)
    00096 #define ZIP_ERRNO                       (Z_ERRNO)
    00097 #define ZIP_PARAMERROR                  (-102)
    00098 #define ZIP_BADZIPFILE                  (-103)
    00099 #define ZIP_INTERNALERROR               (-104)
    00100
    00101 #ifndef DEF_MEM_LEVEL
    00102 #  if MAX_MEM_LEVEL >= 8
    00103 #    define DEF_MEM_LEVEL 8
    00104 #  else
    00105 #    define DEF_MEM_LEVEL  MAX_MEM_LEVEL
    00106 #  endif
    00107 #endif
    00108 /* default memLevel */
    00109
    00110 /* tm_zip contain date/time info */
    00111 typedef struct tm_zip_s
    00112 {
    00113     uInt tm_sec;            /* seconds after the minute - [0,59] */
    00114     uInt tm_min;            /* minutes after the hour - [0,59] */
    00115     uInt tm_hour;           /* hours since midnight - [0,23] */
    00116     uInt tm_mday;           /* day of the month - [1,31] */
    00117     uInt tm_mon;            /* months since January - [0,11] */
    00118     uInt tm_year;           /* years - [1980..2044] */
    00119 } tm_zip;
    00120
    00121 typedef struct
    00122 {
    00123     tm_zip      tmz_date;       /* date in understandable format           */
    00124     uLong       dosDate;       /* if dos_date == 0, tmu_date is used      */
    00125 /*    uLong       flag;        */   /* general purpose bit flag        2 bytes */
    00126
    00127     uLong       internal_fa;    /* internal file attributes        2 bytes */
    00128     uLong       external_fa;    /* external file attributes        4 bytes */
    00129 } zip_fileinfo;
    00130
    00131 typedef const char* zipcharpc;
    00132
    00133
    00134 #define APPEND_STATUS_CREATE        (0)
    00135 #define APPEND_STATUS_CREATEAFTER   (1)
    00136 #define APPEND_STATUS_ADDINZIP      (2)
    00137
    00138 extern zipFile ZEXPORT cpl_zipOpen OF((const char *pathname, int append));
    00139 /*
    00140   Create a zipfile.
    00141      pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
    00142        an Unix computer "zlib/zlib113.zip".
    00143      if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
    00144        will be created at the end of the file.
    00145          (useful if the file contain a self extractor code)
    00146      if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
    00147        add files in existing zip (be sure you don't add file that doesn't exist)
    00148      If the zipfile cannot be opened, the return value is NULL.
    00149      Else, the return value is a zipFile Handle, usable with other function
    00150        of this zip package.
    00151 */
    00152
    00153 /* Note : there is no delete function into a zipfile.
    00154    If you want delete file into a zipfile, you must open a zipfile, and create another
    00155    Of couse, you can use RAW reading and writing to copy the file you did not want delte
    00156 */
    00157
    00158 extern zipFile ZEXPORT cpl_zipOpen2 OF((const char *pathname,
    00159                                    int append,
    00160                                    zipcharpc* globalcomment,
    00161                                    zlib_filefunc_def* pzlib_filefunc_def));
    00162
    00163 extern int ZEXPORT cpl_zipOpenNewFileInZip OF((zipFile file,
    00164                        const char* filename,
    00165                        const zip_fileinfo* zipfi,
    00166                        const void* extrafield_local,
    00167                        uInt size_extrafield_local,
    00168                        const void* extrafield_global,
    00169                        uInt size_extrafield_global,
    00170                        const char* comment,
    00171                        int method,
    00172                        int level));
    00173 /*
    00174   Open a file in the ZIP for writing.
    00175   filename : the filename in zip (if NULL, '-' without quote will be used
    00176   *zipfi contain supplemental information
    00177   if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
    00178     contains the extrafield data the the local header
    00179   if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
    00180     contains the extrafield data the the local header
    00181   if comment != NULL, comment contain the comment string
    00182   method contain the compression method (0 for store, Z_DEFLATED for deflate)
    00183   level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
    00184 */
    00185
    00186
    00187 extern int ZEXPORT cpl_zipOpenNewFileInZip2 OF((zipFile file,
    00188                                             const char* filename,
    00189                                             const zip_fileinfo* zipfi,
    00190                                             const void* extrafield_local,
    00191                                             uInt size_extrafield_local,
    00192                                             const void* extrafield_global,
    00193                                             uInt size_extrafield_global,
    00194                                             const char* comment,
    00195                                             int method,
    00196                                             int level,
    00197                                             int raw));
    00198
    00199 /*
    00200   Same than zipOpenNewFileInZip, except if raw=1, we write raw file
    00201  */
    00202
    00203 extern int ZEXPORT cpl_zipOpenNewFileInZip3 OF((zipFile file,
    00204                                             const char* filename,
    00205                                             const zip_fileinfo* zipfi,
    00206                                             const void* extrafield_local,
    00207                                             uInt size_extrafield_local,
    00208                                             const void* extrafield_global,
    00209                                             uInt size_extrafield_global,
    00210                                             const char* comment,
    00211                                             int method,
    00212                                             int level,
    00213                                             int raw,
    00214                                             int windowBits,
    00215                                             int memLevel,
    00216                                             int strategy,
    00217                                             const char* password,
    00218                                             uLong crcForCtypting));
    00219
    00220 /*
    00221   Same than zipOpenNewFileInZip2, except
    00222     windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
    00223     password : crypting password (NULL for no crypting)
    00224     crcForCtypting : crc of file to compress (needed for crypting)
    00225  */
    00226
    00227
    00228 extern int ZEXPORT cpl_zipWriteInFileInZip OF((zipFile file,
    00229                        const void* buf,
    00230                        unsigned len));
    00231 /*
    00232   Write data in the zipfile
    00233 */
    00234
    00235 extern int ZEXPORT cpl_zipCloseFileInZip OF((zipFile file));
    00236 /*
    00237   Close the current file in the zipfile
    00238 */
    00239
    00240 extern int ZEXPORT cpl_zipCloseFileInZipRaw OF((zipFile file,
    00241                                             uLong uncompressed_size,
    00242                                             uLong crc32));
    00243 /*
    00244   Close the current file in the zipfile, for fiel opened with
    00245     parameter raw=1 in zipOpenNewFileInZip2
    00246   uncompressed_size and crc32 are value for the uncompressed size
    00247 */
    00248
    00249 extern int ZEXPORT cpl_zipClose OF((zipFile file,
    00250                 const char* global_comment));
    00251 /*
    00252   Close the zipfile
    00253 */
    00254
    00255 #ifdef __cplusplus
    00256 }
    00257 #endif
    00258
    00259 #endif /* _zip_H */

Generated for GDAL by 1.5.6.