GDAL

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