GDAL
cpl_minizip_zip.h
1/******************************************************************************
2 * $Id$
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 I WAIT FEEDBACK at mail info@winimage.com
32 Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
33
34 Condition of use and distribution are the same than zlib :
35
36 This software is provided 'as-is', without any express or implied
37 warranty. In no event will the authors be held liable for any damages
38 arising from the use of this software.
39
40 Permission is granted to anyone to use this software for any purpose,
41 including commercial applications, and to alter it and redistribute it
42 freely, subject to the following restrictions:
43
44 1. The origin of this software must not be misrepresented; you must not
45 claim that you wrote the original software. If you use this software
46 in a product, an acknowledgment in the product documentation would be
47 appreciated but is not required.
48 2. Altered source versions must be plainly marked as such, and must not be
49 misrepresented as being the original software.
50 3. This notice may not be removed or altered from any source distribution.
51*/
52
53/* for more info about .ZIP format, see
54 http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
55 http://www.info-zip.org/pub/infozip/doc/
56 PkWare has also a specification at :
57 ftp://ftp.pkware.com/probdesc.zip
58*/
59
60#ifndef CPL_MINIZIP_ZIP_H_INCLUDED
61#define CPL_MINIZIP_ZIP_H_INCLUDED
62
63#ifndef DOXYGEN_SKIP
64
65#include "cpl_vsi.h"
66#define uLong64 vsi_l_offset
67typedef vsi_l_offset ZPOS64_T;
68
69#ifdef __cplusplus
70extern "C"
71{
72#endif
73
74#ifndef _ZLIB_H
75#include "cpl_zlib_header.h" // to avoid warnings when including zlib.h
76#endif
77
78#ifndef CPL_MINIZIP_IOAPI_H_INCLUDED
79#include "cpl_minizip_ioapi.h"
80#endif
81
82#define NOCRYPT
83#undef ZEXPORT
84#define ZEXPORT
85
86#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
87 /* like the STRICT of WIN32, we define a pointer that cannot be converted
88 from (void*) without cast */
89 typedef struct TagzipFile__
90 {
91 int unused;
92 } zipFile__;
93 typedef zipFile__ *zipFile;
94#else
95typedef voidp zipFile;
96#endif
97
98#define ZIP_OK (0)
99#define ZIP_EOF (0)
100#define ZIP_ERRNO (Z_ERRNO)
101#define ZIP_PARAMERROR (-102)
102#define ZIP_BADZIPFILE (-103)
103#define ZIP_INTERNALERROR (-104)
104
105#ifndef DEF_MEM_LEVEL
106#if MAX_MEM_LEVEL >= 8
107#define DEF_MEM_LEVEL 8
108#else
109#define DEF_MEM_LEVEL MAX_MEM_LEVEL
110#endif
111#endif
112 /* default memLevel */
113
114 /* tm_zip contain date/time info */
115 typedef struct tm_zip_s
116 {
117 uInt tm_sec; /* seconds after the minute - [0,59] */
118 uInt tm_min; /* minutes after the hour - [0,59] */
119 uInt tm_hour; /* hours since midnight - [0,23] */
120 uInt tm_mday; /* day of the month - [1,31] */
121 uInt tm_mon; /* months since January - [0,11] */
122 uInt tm_year; /* years - [1980..2044] */
123 } tm_zip;
124
125 typedef struct
126 {
127 tm_zip tmz_date; /* date in understandable format */
128 uLong dosDate; /* if dos_date == 0, tmu_date is used */
129 /* uLong flag; */ /* general purpose bit flag 2
130 bytes */
131
132 uLong internal_fa; /* internal file attributes 2 bytes */
133 uLong external_fa; /* external file attributes 4 bytes */
134 } zip_fileinfo;
135
136 typedef const char *zipcharpc;
137
138#define APPEND_STATUS_CREATE (0)
139#define APPEND_STATUS_CREATEAFTER (1)
140#define APPEND_STATUS_ADDINZIP (2)
141
142 extern zipFile ZEXPORT cpl_zipOpen(const char *pathname, int append);
143 /*
144 Create a zipfile.
145 pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip"
146 or on an Unix computer "zlib/zlib113.zip". if the file pathname exist and
147 append==APPEND_STATUS_CREATEAFTER, the zip will be created at the end of
148 the file. (useful if the file contain a self extractor code) if the file
149 pathname exist and append==APPEND_STATUS_ADDINZIP, we will add files in
150 existing zip (be sure you don't add file that doesn't exist) If the
151 zipfile cannot be opened, the return value is NULL. Else, the return value
152 is a zipFile Handle, usable with other function of this zip package.
153 */
154
155 /* Note : there is no delete function for a zipfile.
156 If you want delete file in a zipfile, you must open a zipfile, and create
157 another. Of course, you can use RAW reading and writing to copy the file
158 you did not want delete.
159 */
160
161 extern zipFile ZEXPORT cpl_zipOpen2(const char *pathname, int append,
162 zipcharpc *globalcomment,
163 zlib_filefunc_def *pzlib_filefunc_def);
164
165 extern int ZEXPORT cpl_zipOpenNewFileInZip(
166 zipFile file, const char *filename, const zip_fileinfo *zipfi,
167 const void *extrafield_local, uInt size_extrafield_local,
168 const void *extrafield_global, uInt size_extrafield_global,
169 const char *comment, int method, int level);
170 /*
171 Open a file in the ZIP for writing.
172 filename : the filename in zip (if NULL, '-' without quote will be used
173 *zipfi contain supplemental information
174 if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
175 contains the extrafield data the local header
176 if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
177 contains the extrafield data the local header
178 if comment != NULL, comment contain the comment string
179 method contain the compression method (0 for store, Z_DEFLATED for
180 deflate) level contain the level of compression (can be
181 Z_DEFAULT_COMPRESSION)
182 */
183
184 extern int ZEXPORT cpl_zipOpenNewFileInZip2(
185 zipFile file, const char *filename, const zip_fileinfo *zipfi,
186 const void *extrafield_local, uInt size_extrafield_local,
187 const void *extrafield_global, uInt size_extrafield_global,
188 const char *comment, int method, int level, int raw);
189
190 /*
191 Same than zipOpenNewFileInZip, except if raw=1, we write raw file
192 */
193
194 extern int ZEXPORT cpl_zipOpenNewFileInZip3(
195 zipFile file, const char *filename, const zip_fileinfo *zipfi,
196 const void *extrafield_local, uInt size_extrafield_local,
197 const void *extrafield_global, uInt size_extrafield_global,
198 const char *comment, int method, int level, int raw, int windowBits,
199 int memLevel, int strategy, const char *password, uLong crcForCtypting);
200
201 /*
202 Same than zipOpenNewFileInZip2, except
203 windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
204 password : crypting password (NULL for no crypting)
205 crcForCtypting : crc of file to compress (needed for crypting)
206 */
207
208 extern int ZEXPORT cpl_zipWriteInFileInZip(zipFile file, const void *buf,
209 unsigned len);
210 /*
211 Write data in the zipfile
212 */
213
214 extern int ZEXPORT cpl_zipCloseFileInZip(zipFile file);
215 /*
216 Close the current file in the zipfile
217 */
218
219 extern int ZEXPORT cpl_zipCloseFileInZipRaw(zipFile file,
220 ZPOS64_T uncompressed_size,
221 uLong crc32);
222 /*
223 Close the current file in the zipfile, for file opened with
224 parameter raw=1 in zipOpenNewFileInZip2
225 uncompressed_size and crc32 are value for the uncompressed size
226 */
227
228 extern int ZEXPORT cpl_zipClose(zipFile file, const char *global_comment);
229 /*
230 Close the zipfile
231 */
232
233#ifdef __cplusplus
234}
235#endif
236
237#endif /* #ifndef DOXYGEN_SKIP */
238
239#endif /* _zip_H */
Standard C Covers.
GUIntBig vsi_l_offset
Type for a file offset.
Definition cpl_vsi.h:146