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

Generated for GDAL by doxygen 1.7.6.1.