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