OGR
cpl_minizip_zip.h
1 /******************************************************************************
2  * $Id: cpl_minizip_zip.h 20794 2010-10-08 16:58:27Z warmerdam $
3  *
4  * Project: CPL - Common Portability Library
5  * Author: Frank Warmerdam, warmerdam@pobox.com
6  * Purpose: Adjusted minizip "zip.h" include file for zip services.
7  *
8  * Modified version by Even Rouault. :
9  * - Decoration of symbol names unz* -> cpl_unz*
10  * - Undef EXPORT so that we are sure the symbols are not exported
11  * - Remove old C style function prototypes
12  * - Added CPL* simplified API at bottom.
13  *
14  * Original licence available in port/LICENCE_minizip
15  *
16  *****************************************************************************/
17 
18 /* zip.h -- IO for compress .zip files using zlib
19  Version 1.01e, February 12th, 2005
20 
21  Copyright (C) 1998-2005 Gilles Vollant
22 
23  This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
24  WinZip, InfoZip tools and compatible.
25  Multi volume ZipFile (span) are not supported.
26  Encryption compatible with pkzip 2.04g only supported
27  Old compressions used by old PKZip 1.x are not supported
28 
29  For uncompress .zip file, look at unzip.h
30 
31 
32  I WAIT FEEDBACK at mail info@winimage.com
33  Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
34 
35  Condition of use and distribution are the same than zlib :
36 
37  This software is provided 'as-is', without any express or implied
38  warranty. In no event will the authors be held liable for any damages
39  arising from the use of this software.
40 
41  Permission is granted to anyone to use this software for any purpose,
42  including commercial applications, and to alter it and redistribute it
43  freely, subject to the following restrictions:
44 
45  1. The origin of this software must not be misrepresented; you must not
46  claim that you wrote the original software. If you use this software
47  in a product, an acknowledgment in the product documentation would be
48  appreciated but is not required.
49  2. Altered source versions must be plainly marked as such, and must not be
50  misrepresented as being the original software.
51  3. This notice may not be removed or altered from any source distribution.
52 
53 
54 */
55 
56 /* for more info about .ZIP format, see
57  http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
58  http://www.info-zip.org/pub/infozip/doc/
59  PkWare has also a specification at :
60  ftp://ftp.pkware.com/probdesc.zip
61 */
62 
63 #ifndef CPL_MINIZIP_ZIP_H_INCLUDED
64 #define CPL_MINIZIP_ZIP_H_INCLUDED
65 
66 #include "cpl_vsi.h"
67 #define uLong64 vsi_l_offset
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
73 #ifndef _ZLIB_H
74 #include "zlib.h"
75 #endif
76 
77 #ifndef CPL_MINIZIP_IOAPI_H_INCLUDED
78 #include "cpl_minizip_ioapi.h"
79 #endif
80 
81 #define NOCRYPT
82 #undef ZEXPORT
83 #define ZEXPORT
84 
85 #if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
86 /* like the STRICT of WIN32, we define a pointer that cannot be converted
87  from (void*) without cast */
88 typedef struct TagzipFile__ { int unused; } zipFile__;
89 typedef zipFile__ *zipFile;
90 #else
91 typedef voidp zipFile;
92 #endif
93 
94 #define ZIP_OK (0)
95 #define ZIP_EOF (0)
96 #define ZIP_ERRNO (Z_ERRNO)
97 #define ZIP_PARAMERROR (-102)
98 #define ZIP_BADZIPFILE (-103)
99 #define ZIP_INTERNALERROR (-104)
100 
101 #ifndef DEF_MEM_LEVEL
102 # if MAX_MEM_LEVEL >= 8
103 # define DEF_MEM_LEVEL 8
104 # else
105 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
106 # endif
107 #endif
108 /* default memLevel */
109 
110 /* tm_zip contain date/time info */
111 typedef struct tm_zip_s
112 {
113  uInt tm_sec; /* seconds after the minute - [0,59] */
114  uInt tm_min; /* minutes after the hour - [0,59] */
115  uInt tm_hour; /* hours since midnight - [0,23] */
116  uInt tm_mday; /* day of the month - [1,31] */
117  uInt tm_mon; /* months since January - [0,11] */
118  uInt tm_year; /* years - [1980..2044] */
119 } tm_zip;
120 
121 typedef struct
122 {
123  tm_zip tmz_date; /* date in understandable format */
124  uLong dosDate; /* if dos_date == 0, tmu_date is used */
125 /* uLong flag; */ /* general purpose bit flag 2 bytes */
126 
127  uLong internal_fa; /* internal file attributes 2 bytes */
128  uLong external_fa; /* external file attributes 4 bytes */
129 } zip_fileinfo;
130 
131 typedef const char* zipcharpc;
132 
133 
134 #define APPEND_STATUS_CREATE (0)
135 #define APPEND_STATUS_CREATEAFTER (1)
136 #define APPEND_STATUS_ADDINZIP (2)
137 
138 extern zipFile ZEXPORT cpl_zipOpen OF((const char *pathname, int append));
139 /*
140  Create a zipfile.
141  pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
142  an Unix computer "zlib/zlib113.zip".
143  if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
144  will be created at the end of the file.
145  (useful if the file contain a self extractor code)
146  if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
147  add files in existing zip (be sure you don't add file that doesn't exist)
148  If the zipfile cannot be opened, the return value is NULL.
149  Else, the return value is a zipFile Handle, usable with other function
150  of this zip package.
151 */
152 
153 /* Note : there is no delete function into a zipfile.
154  If you want delete file into a zipfile, you must open a zipfile, and create another
155  Of couse, you can use RAW reading and writing to copy the file you did not want delte
156 */
157 
158 extern zipFile ZEXPORT cpl_zipOpen2 OF((const char *pathname,
159  int append,
160  zipcharpc* globalcomment,
161  zlib_filefunc_def* pzlib_filefunc_def));
162 
163 extern int ZEXPORT cpl_zipOpenNewFileInZip OF((zipFile file,
164  const char* filename,
165  const zip_fileinfo* zipfi,
166  const void* extrafield_local,
167  uInt size_extrafield_local,
168  const void* extrafield_global,
169  uInt size_extrafield_global,
170  const char* comment,
171  int method,
172  int level));
173 /*
174  Open a file in the ZIP for writing.
175  filename : the filename in zip (if NULL, '-' without quote will be used
176  *zipfi contain supplemental information
177  if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
178  contains the extrafield data the the local header
179  if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
180  contains the extrafield data the the local header
181  if comment != NULL, comment contain the comment string
182  method contain the compression method (0 for store, Z_DEFLATED for deflate)
183  level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
184 */
185 
186 
187 extern int ZEXPORT cpl_zipOpenNewFileInZip2 OF((zipFile file,
188  const char* filename,
189  const zip_fileinfo* zipfi,
190  const void* extrafield_local,
191  uInt size_extrafield_local,
192  const void* extrafield_global,
193  uInt size_extrafield_global,
194  const char* comment,
195  int method,
196  int level,
197  int raw));
198 
199 /*
200  Same than zipOpenNewFileInZip, except if raw=1, we write raw file
201  */
202 
203 extern int ZEXPORT cpl_zipOpenNewFileInZip3 OF((zipFile file,
204  const char* filename,
205  const zip_fileinfo* zipfi,
206  const void* extrafield_local,
207  uInt size_extrafield_local,
208  const void* extrafield_global,
209  uInt size_extrafield_global,
210  const char* comment,
211  int method,
212  int level,
213  int raw,
214  int windowBits,
215  int memLevel,
216  int strategy,
217  const char* password,
218  uLong crcForCtypting));
219 
220 /*
221  Same than zipOpenNewFileInZip2, except
222  windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
223  password : crypting password (NULL for no crypting)
224  crcForCtypting : crc of file to compress (needed for crypting)
225  */
226 
227 
228 extern int ZEXPORT cpl_zipWriteInFileInZip OF((zipFile file,
229  const void* buf,
230  unsigned len));
231 /*
232  Write data in the zipfile
233 */
234 
235 extern int ZEXPORT cpl_zipCloseFileInZip OF((zipFile file));
236 /*
237  Close the current file in the zipfile
238 */
239 
240 extern int ZEXPORT cpl_zipCloseFileInZipRaw OF((zipFile file,
241  uLong uncompressed_size,
242  uLong crc32));
243 /*
244  Close the current file in the zipfile, for fiel opened with
245  parameter raw=1 in zipOpenNewFileInZip2
246  uncompressed_size and crc32 are value for the uncompressed size
247 */
248 
249 extern int ZEXPORT cpl_zipClose OF((zipFile file,
250  const char* global_comment));
251 /*
252  Close the zipfile
253 */
254 
255 #ifdef __cplusplus
256 }
257 #endif
258 
259 #endif /* _zip_H */
Definition: cpl_minizip_zip.h:111
Definition: cpl_minizip_ioapi.h:62
Definition: cpl_minizip_zip.h:121

Generated for GDAL by doxygen 1.8.11.