added iOS source code
[wl-app.git] / iOS / Pods / SSZipArchive / SSZipArchive / minizip / zip.h
1 /* zip.h -- IO on .zip files using zlib
2    Version 1.2.0, September 16th, 2017
3    part of the MiniZip project
4
5    Copyright (C) 2012-2017 Nathan Moinvaziri
6      https://github.com/nmoinvaz/minizip
7    Copyright (C) 2009-2010 Mathias Svensson
8      Modifications for Zip64 support
9      http://result42.com
10    Copyright (C) 1998-2010 Gilles Vollant
11      http://www.winimage.com/zLibDll/minizip.html
12
13    This program is distributed under the terms of the same license as zlib.
14    See the accompanying LICENSE file for the full text of the license.
15 */
16
17 #ifndef _ZIP_H
18 #define _ZIP_H
19
20 #define HAVE_AES
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 #ifndef _ZLIB_H
27 #  include "zlib.h"
28 #endif
29
30 #ifndef _ZLIBIOAPI_H
31 #  include "ioapi.h"
32 #endif
33
34 #ifdef HAVE_BZIP2
35 #  include "bzlib.h"
36 #endif
37
38 #define Z_BZIP2ED 12
39
40 #if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
41 /* like the STRICT of WIN32, we define a pointer that cannot be converted
42     from (void*) without cast */
43 typedef struct TagzipFile__ { int unused; } zip_file__;
44 typedef zip_file__ *zipFile;
45 #else
46 typedef voidp zipFile;
47 #endif
48
49 #define ZIP_OK                          (0)
50 #define ZIP_EOF                         (0)
51 #define ZIP_ERRNO                       (Z_ERRNO)
52 #define ZIP_PARAMERROR                  (-102)
53 #define ZIP_BADZIPFILE                  (-103)
54 #define ZIP_INTERNALERROR               (-104)
55
56 #ifndef DEF_MEM_LEVEL
57 #  if MAX_MEM_LEVEL >= 8
58 #    define DEF_MEM_LEVEL 8
59 #  else
60 #    define DEF_MEM_LEVEL  MAX_MEM_LEVEL
61 #  endif
62 #endif
63
64 typedef struct
65 {
66     uint32_t    dos_date;
67     uint16_t    internal_fa;        /* internal file attributes        2 bytes */
68     uint32_t    external_fa;        /* external file attributes        4 bytes */
69 } zip_fileinfo;
70
71 #define APPEND_STATUS_CREATE        (0)
72 #define APPEND_STATUS_CREATEAFTER   (1)
73 #define APPEND_STATUS_ADDINZIP      (2)
74
75 /***************************************************************************/
76 /* Writing a zip file */
77
78 extern zipFile ZEXPORT zipOpen(const char *path, int append);
79 extern zipFile ZEXPORT zipOpen64(const void *path, int append);
80 /* Create a zipfile.
81
82    path should contain the full path (by example, on a Windows XP computer 
83       "c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip". 
84
85    return NULL if zipfile cannot be opened
86    return zipFile handle if no error
87
88    If the file path exist and append == APPEND_STATUS_CREATEAFTER, the zip
89    will be created at the end of the file. (useful if the file contain a self extractor code)
90    If the file path exist and append == APPEND_STATUS_ADDINZIP, we will add files in existing 
91    zip (be sure you don't add file that doesn't exist)
92
93    NOTE: There is no delete function into a zipfile. If you want delete file into a zipfile, 
94    you must open a zipfile, and create another. Of course, you can use RAW reading and writing to copy
95    the file you did not want delete. */
96
97 extern zipFile ZEXPORT zipOpen2(const char *path, int append, const char **globalcomment, 
98     zlib_filefunc_def *pzlib_filefunc_def);
99
100 extern zipFile ZEXPORT zipOpen2_64(const void *path, int append, const char **globalcomment, 
101     zlib_filefunc64_def *pzlib_filefunc_def);
102
103 extern zipFile ZEXPORT zipOpen3(const char *path, int append, uint64_t disk_size, 
104     const char **globalcomment, zlib_filefunc_def *pzlib_filefunc_def);
105 /* Same as zipOpen2 but allows specification of spanned zip size */
106
107 extern zipFile ZEXPORT zipOpen3_64(const void *path, int append, uint64_t disk_size, 
108     const char **globalcomment, zlib_filefunc64_def *pzlib_filefunc_def);
109
110 extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi,
111     const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, 
112     uint16_t size_extrafield_global, const char *comment, uint16_t method, int level);
113 /* Open a file in the ZIP for writing.
114
115    filename : the filename in zip (if NULL, '-' without quote will be used
116    *zipfi contain supplemental information
117    extrafield_local buffer to store the local header extra field data, can be NULL
118    size_extrafield_local size of extrafield_local buffer
119    extrafield_global buffer to store the global header extra field data, can be NULL
120    size_extrafield_global size of extrafield_local buffer
121    comment buffer for comment string
122    method contain the compression method (0 for store, Z_DEFLATED for deflate)
123    level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
124    zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
125    this MUST be '1' if the uncompressed size is >= 0xffffffff. */
126
127 extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
128     const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
129     uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int zip64);
130 /* Same as zipOpenNewFileInZip with zip64 support */
131
132 extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi,
133     const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
134     uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw);
135 /* Same as zipOpenNewFileInZip, except if raw=1, we write raw file */
136
137 extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
138     const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
139     uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int zip64);
140 /* Same as zipOpenNewFileInZip3 with zip64 support */
141
142 extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi,
143     const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
144     uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
145     int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting);
146 /* Same as zipOpenNewFileInZip2, except
147     windowBits, memLevel, strategy : see parameter strategy in deflateInit2
148     password : crypting password (NULL for no crypting)
149     crc_for_crypting : crc of file to compress (needed for crypting) */
150
151 extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
152     const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
153     uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
154     int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, int zip64);
155 /* Same as zipOpenNewFileInZip3 with zip64 support */
156
157 extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi,
158     const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
159     uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
160     int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, uint16_t version_madeby, uint16_t flag_base);
161 /* Same as zipOpenNewFileInZip3 except versionMadeBy & flag fields */
162
163 extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
164     const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
165     uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
166     int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, uint16_t version_madeby, uint16_t flag_base, int zip64);
167 /* Same as zipOpenNewFileInZip4 with zip64 support */
168
169 extern int ZEXPORT zipOpenNewFileInZip5(zipFile file,
170                                         const char *filename,
171                                         const zip_fileinfo *zipfi,
172                                         const void *extrafield_local,
173                                         uint16_t size_extrafield_local,
174                                         const void *extrafield_global,
175                                         uint16_t size_extrafield_global,
176                                         const char *comment,
177                                         uint16_t flag_base,
178                                         int zip64,
179                                         uint16_t method,
180                                         int level,
181                                         int raw,
182                                         int windowBits,
183                                         int memLevel,
184                                         int strategy,
185                                         const char *password,
186                                         int aes);
187 /* Allowing optional aes */
188
189 extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len);
190 /* Write data in the zipfile */
191
192 extern int ZEXPORT zipCloseFileInZip(zipFile file);
193 /* Close the current file in the zipfile */
194
195 extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uint32_t uncompressed_size, uint32_t crc32);
196 extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, uint64_t uncompressed_size, uint32_t crc32);
197 /* Close the current file in the zipfile, for file opened with parameter raw=1 in zipOpenNewFileInZip2
198    where raw is compressed data. Parameters uncompressed_size and crc32 are value for the uncompressed data. */
199
200 extern int ZEXPORT zipClose(zipFile file, const char *global_comment);
201 /* Close the zipfile */
202
203 extern int ZEXPORT zipClose_64(zipFile file, const char *global_comment);
204
205 extern int ZEXPORT zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby);
206 /* Same as zipClose_64 except version_madeby field */
207
208 /***************************************************************************/
209
210 #ifdef __cplusplus
211 }
212 #endif
213
214 #endif /* _ZIP_H */