Debian Codegraph @

compat/zlib/contrib/minizip/zip.h

raw
1 /* zip.h -- IO on .zip files using zlib
2 part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
3
4 Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
5
6 Modifications for Zip64 support
7 Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
8
9 For more info read MiniZip_info.txt
10
11 ---------------------------------------------------------------------------
12
13 Condition of use and distribution are the same than zlib :
14
15 This software is provided 'as-is', without any express or implied
16 warranty. In no event will the authors be held liable for any damages
17 arising from the use of this software.
18
19 Permission is granted to anyone to use this software for any purpose,
20 including commercial applications, and to alter it and redistribute it
21 freely, subject to the following restrictions:
22
23 1. The origin of this software must not be misrepresented; you must not
24 claim that you wrote the original software. If you use this software
25 in a product, an acknowledgment in the product documentation would be
26 appreciated but is not required.
27 2. Altered source versions must be plainly marked as such, and must not be
28 misrepresented as being the original software.
29 3. This notice may not be removed or altered from any source distribution.
30
31 ---------------------------------------------------------------------------
32
33 Changes
34
35 See header of zip.h
36
37 */
38
39 #ifndef _zip12_H
40 #define _zip12_H
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 /* #define HAVE_BZIP2 */
47
48 #ifndef _ZLIB_H
49 #include "zlib.h"
50 #endif
51
52 #ifndef _ZLIBIOAPI_H
53 #include "ioapi.h"
54 #endif
55
56 #ifdef HAVE_BZIP2
57 #include "bzlib.h"
58 #endif
59
60 #define Z_BZIP2ED 12
61
62 #if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
63 /* like the STRICT of WIN32, we define a pointer that cannot be converted
64 from (void*) without cast */
65 typedef struct TagzipFile__ { int unused; } zipFile__;
66 typedef zipFile__ *zipFile;
67 #else
68 typedef voidp zipFile;
69 #endif
70
71 extern const char zip_copyright[];
72
73 #define ZIP_OK (0)
74 #define ZIP_EOF (0)
75 #define ZIP_ERRNO (Z_ERRNO)
76 #define ZIP_PARAMERROR (-102)
77 #define ZIP_BADZIPFILE (-103)
78 #define ZIP_INTERNALERROR (-104)
79
80 #ifndef DEF_MEM_LEVEL
81 # if MAX_MEM_LEVEL >= 8
82 # define DEF_MEM_LEVEL 8
83 # else
84 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
85 # endif
86 #endif
87 /* default memLevel */
88
89 /* tm_zip contain date/time info */
90 typedef struct tm_zip_s
91 {
92 int tm_sec; /* seconds after the minute - [0,59] */
93 int tm_min; /* minutes after the hour - [0,59] */
94 int tm_hour; /* hours since midnight - [0,23] */
95 int tm_mday; /* day of the month - [1,31] */
96 int tm_mon; /* months since January - [0,11] */
97 int tm_year; /* years - [1980..2044] */
98 } tm_zip;
99
100 typedef struct
101 {
102 tm_zip tmz_date; /* date in understandable format */
103 uLong dosDate; /* if dos_date == 0, tmu_date is used */
104 /* uLong flag; */ /* general purpose bit flag 2 bytes */
105
106 uLong internal_fa; /* internal file attributes 2 bytes */
107 uLong external_fa; /* external file attributes 4 bytes */
108 } zip_fileinfo;
109
110 typedef const char* zipcharpc;
111
112
113 #define APPEND_STATUS_CREATE (0)
114 #define APPEND_STATUS_CREATEAFTER (1)
115 #define APPEND_STATUS_ADDINZIP (2)
116
117 extern zipFile ZEXPORT zipOpen(const char *pathname, int append);
118 extern zipFile ZEXPORT zipOpen64(const void *pathname, int append);
119 /*
120 Create a zipfile.
121 pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
122 an Unix computer "zlib/zlib113.zip".
123 if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
124 will be created at the end of the file.
125 (useful if the file contain a self extractor code)
126 if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
127 add files in existing zip (be sure you don't add file that doesn't exist)
128 If the zipfile cannot be opened, the return value is NULL.
129 Else, the return value is a zipFile Handle, usable with other function
130 of this zip package.
131 */
132
133 /* Note : there is no delete function into a zipfile.
134 If you want delete file into a zipfile, you must open a zipfile, and create another
135 Of course, you can use RAW reading and writing to copy the file you did not want delete
136 */
137
138 extern zipFile ZEXPORT zipOpen2(const char *pathname,
139 int append,
140 zipcharpc* globalcomment,
141 zlib_filefunc_def* pzlib_filefunc_def);
142
143 extern zipFile ZEXPORT zipOpen2_64(const void *pathname,
144 int append,
145 zipcharpc* globalcomment,
146 zlib_filefunc64_def* pzlib_filefunc_def);
147
148 extern zipFile ZEXPORT zipOpen3(const void *pathname,
149 int append,
150 zipcharpc* globalcomment,
151 zlib_filefunc64_32_def* pzlib_filefunc64_32_def);
152
153 extern int ZEXPORT zipOpenNewFileInZip(zipFile file,
154 const char* filename,
155 const zip_fileinfo* zipfi,
156 const void* extrafield_local,
157 uInt size_extrafield_local,
158 const void* extrafield_global,
159 uInt size_extrafield_global,
160 const char* comment,
161 int method,
162 int level);
163
164 extern int ZEXPORT zipOpenNewFileInZip64(zipFile file,
165 const char* filename,
166 const zip_fileinfo* zipfi,
167 const void* extrafield_local,
168 uInt size_extrafield_local,
169 const void* extrafield_global,
170 uInt size_extrafield_global,
171 const char* comment,
172 int method,
173 int level,
174 int zip64);
175
176 /*
177 Open a file in the ZIP for writing.
178 filename : the filename in zip (if NULL, '-' without quote will be used
179 *zipfi contain supplemental information
180 if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
181 contains the extrafield data for the local header
182 if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
183 contains the extrafield data for the global header
184 if comment != NULL, comment contain the comment string
185 method contain the compression method (0 for store, Z_DEFLATED for deflate)
186 level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
187 zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
188 this MUST be '1' if the uncompressed size is >= 0xffffffff.
189
190 */
191
192
193 extern int ZEXPORT zipOpenNewFileInZip2(zipFile file,
194 const char* filename,
195 const zip_fileinfo* zipfi,
196 const void* extrafield_local,
197 uInt size_extrafield_local,
198 const void* extrafield_global,
199 uInt size_extrafield_global,
200 const char* comment,
201 int method,
202 int level,
203 int raw);
204
205
206 extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file,
207 const char* filename,
208 const zip_fileinfo* zipfi,
209 const void* extrafield_local,
210 uInt size_extrafield_local,
211 const void* extrafield_global,
212 uInt size_extrafield_global,
213 const char* comment,
214 int method,
215 int level,
216 int raw,
217 int zip64);
218 /*
219 Same than zipOpenNewFileInZip, except if raw=1, we write raw file
220 */
221
222 extern int ZEXPORT zipOpenNewFileInZip3(zipFile file,
223 const char* filename,
224 const zip_fileinfo* zipfi,
225 const void* extrafield_local,
226 uInt size_extrafield_local,
227 const void* extrafield_global,
228 uInt size_extrafield_global,
229 const char* comment,
230 int method,
231 int level,
232 int raw,
233 int windowBits,
234 int memLevel,
235 int strategy,
236 const char* password,
237 uLong crcForCrypting);
238
239 extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file,
240 const char* filename,
241 const zip_fileinfo* zipfi,
242 const void* extrafield_local,
243 uInt size_extrafield_local,
244 const void* extrafield_global,
245 uInt size_extrafield_global,
246 const char* comment,
247 int method,
248 int level,
249 int raw,
250 int windowBits,
251 int memLevel,
252 int strategy,
253 const char* password,
254 uLong crcForCrypting,
255 int zip64);
256
257 /*
258 Same than zipOpenNewFileInZip2, except
259 windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
260 password : crypting password (NULL for no crypting)
261 crcForCrypting : crc of file to compress (needed for crypting)
262 */
263
264 extern int ZEXPORT zipOpenNewFileInZip4(zipFile file,
265 const char* filename,
266 const zip_fileinfo* zipfi,
267 const void* extrafield_local,
268 uInt size_extrafield_local,
269 const void* extrafield_global,
270 uInt size_extrafield_global,
271 const char* comment,
272 int method,
273 int level,
274 int raw,
275 int windowBits,
276 int memLevel,
277 int strategy,
278 const char* password,
279 uLong crcForCrypting,
280 uLong versionMadeBy,
281 uLong flagBase);
282
283
284 extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file,
285 const char* filename,
286 const zip_fileinfo* zipfi,
287 const void* extrafield_local,
288 uInt size_extrafield_local,
289 const void* extrafield_global,
290 uInt size_extrafield_global,
291 const char* comment,
292 int method,
293 int level,
294 int raw,
295 int windowBits,
296 int memLevel,
297 int strategy,
298 const char* password,
299 uLong crcForCrypting,
300 uLong versionMadeBy,
301 uLong flagBase,
302 int zip64);
303 /*
304 Same than zipOpenNewFileInZip4, except
305 versionMadeBy : value for Version made by field
306 flag : value for flag field (compression level info will be added)
307 */
308
309
310 extern int ZEXPORT zipWriteInFileInZip(zipFile file,
311 const void* buf,
312 unsigned len);
313 /*
314 Write data in the zipfile
315 */
316
317 extern int ZEXPORT zipCloseFileInZip(zipFile file);
318 /*
319 Close the current file in the zipfile
320 */
321
322 extern int ZEXPORT zipCloseFileInZipRaw(zipFile file,
323 uLong uncompressed_size,
324 uLong crc32);
325
326 extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file,
327 ZPOS64_T uncompressed_size,
328 uLong crc32);
329
330 extern int ZEXPORT zipAlreadyThere(zipFile file,
331 char const* name);
332 /*
333 See if name is already in file's central directory.
334 */
335
336 /*
337 Close the current file in the zipfile, for file opened with
338 parameter raw=1 in zipOpenNewFileInZip2
339 uncompressed_size and crc32 are value for the uncompressed size
340 */
341
342 extern int ZEXPORT zipClose(zipFile file,
343 const char* global_comment);
344 /*
345 Close the zipfile
346 */
347
348
349 extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader);
350 /*
351 zipRemoveExtraInfoBlock - Added by Mathias Svensson
352
353 Remove extra information block from a extra information data for the local file header or central directory header
354
355 It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.
356
357 0x0001 is the signature header for the ZIP64 extra information blocks
358
359 usage.
360 Remove ZIP64 Extra information from a central director extra field data
361 zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);
362
363 Remove ZIP64 Extra information from a Local File Header extra field data
364 zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);
365 */
366
367 #ifdef __cplusplus
368 }
369 #endif
370
371 #endif /* _zip64_H */