diff options
Diffstat (limited to 'contrib/minizip/unzip.h')
-rw-r--r-- | contrib/minizip/unzip.h | 191 |
1 files changed, 129 insertions, 62 deletions
diff --git a/contrib/minizip/unzip.h b/contrib/minizip/unzip.h index 76692cb..67ca851 100644 --- a/contrib/minizip/unzip.h +++ b/contrib/minizip/unzip.h | |||
@@ -1,15 +1,14 @@ | |||
1 | /* unzip.h -- IO for uncompress .zip files using zlib | 1 | /* unzip.h -- IO for uncompress .zip files using zlib |
2 | Version 0.15 beta, Mar 19th, 1998, | 2 | Version 0.21, March 10th, 2003 |
3 | 3 | ||
4 | Copyright (C) 1998 Gilles Vollant | 4 | Copyright (C) 1998-2003 Gilles Vollant |
5 | 5 | ||
6 | This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g | 6 | This unzip package allow extract file from .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 | Encryption and multi volume ZipFile (span) are not supported. |
9 | Old compressions used by old PKZip 1.x are not supported | 9 | Old compressions used by old PKZip 1.x are not supported |
10 | 10 | ||
11 | THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE | 11 | |
12 | CAN CHANGE IN FUTURE VERSION !! | ||
13 | I WAIT FEEDBACK at mail info@winimage.com | 12 | I WAIT FEEDBACK at mail info@winimage.com |
14 | Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution | 13 | Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution |
15 | 14 | ||
@@ -33,10 +32,13 @@ | |||
33 | 32 | ||
34 | 33 | ||
35 | */ | 34 | */ |
36 | /* for more info about .ZIP format, see | 35 | |
37 | ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip | 36 | /* for more info about .ZIP format, see |
37 | http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip | ||
38 | http://www.info-zip.org/pub/infozip/doc/ | ||
38 | PkWare has also a specification at : | 39 | PkWare has also a specification at : |
39 | ftp://ftp.pkware.com/probdesc.zip */ | 40 | ftp://ftp.pkware.com/probdesc.zip |
41 | */ | ||
40 | 42 | ||
41 | #ifndef _unz_H | 43 | #ifndef _unz_H |
42 | #define _unz_H | 44 | #define _unz_H |
@@ -49,43 +51,47 @@ extern "C" { | |||
49 | #include "zlib.h" | 51 | #include "zlib.h" |
50 | #endif | 52 | #endif |
51 | 53 | ||
54 | #ifndef _ZLIBIOAPI_H | ||
55 | #include "ioapi.h" | ||
56 | #endif | ||
57 | |||
52 | #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) | 58 | #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) |
53 | /* like the STRICT of WIN32, we define a pointer that cannot be converted | 59 | /* like the STRICT of WIN32, we define a pointer that cannot be converted |
54 | from (void*) without cast */ | 60 | from (void*) without cast */ |
55 | typedef struct TagunzFile__ { int unused; } unzFile__; | 61 | typedef struct TagunzFile__ { int unused; } unzFile__; |
56 | typedef unzFile__ *unzFile; | 62 | typedef unzFile__ *unzFile; |
57 | #else | 63 | #else |
58 | typedef voidp unzFile; | 64 | typedef voidp unzFile; |
59 | #endif | 65 | #endif |
60 | 66 | ||
61 | 67 | ||
62 | #define UNZ_OK (0) | 68 | #define UNZ_OK (0) |
63 | #define UNZ_END_OF_LIST_OF_FILE (-100) | 69 | #define UNZ_END_OF_LIST_OF_FILE (-100) |
64 | #define UNZ_ERRNO (Z_ERRNO) | 70 | #define UNZ_ERRNO (Z_ERRNO) |
65 | #define UNZ_EOF (0) | 71 | #define UNZ_EOF (0) |
66 | #define UNZ_PARAMERROR (-102) | 72 | #define UNZ_PARAMERROR (-102) |
67 | #define UNZ_BADZIPFILE (-103) | 73 | #define UNZ_BADZIPFILE (-103) |
68 | #define UNZ_INTERNALERROR (-104) | 74 | #define UNZ_INTERNALERROR (-104) |
69 | #define UNZ_CRCERROR (-105) | 75 | #define UNZ_CRCERROR (-105) |
70 | 76 | ||
71 | /* tm_unz contain date/time info */ | 77 | /* tm_unz contain date/time info */ |
72 | typedef struct tm_unz_s | 78 | typedef struct tm_unz_s |
73 | { | 79 | { |
74 | uInt tm_sec; /* seconds after the minute - [0,59] */ | 80 | uInt tm_sec; /* seconds after the minute - [0,59] */ |
75 | uInt tm_min; /* minutes after the hour - [0,59] */ | 81 | uInt tm_min; /* minutes after the hour - [0,59] */ |
76 | uInt tm_hour; /* hours since midnight - [0,23] */ | 82 | uInt tm_hour; /* hours since midnight - [0,23] */ |
77 | uInt tm_mday; /* day of the month - [1,31] */ | 83 | uInt tm_mday; /* day of the month - [1,31] */ |
78 | uInt tm_mon; /* months since January - [0,11] */ | 84 | uInt tm_mon; /* months since January - [0,11] */ |
79 | uInt tm_year; /* years - [1980..2044] */ | 85 | uInt tm_year; /* years - [1980..2044] */ |
80 | } tm_unz; | 86 | } tm_unz; |
81 | 87 | ||
82 | /* unz_global_info structure contain global data about the ZIPfile | 88 | /* unz_global_info structure contain global data about the ZIPfile |
83 | These data comes from the end of central dir */ | 89 | These data comes from the end of central dir */ |
84 | typedef struct unz_global_info_s | 90 | typedef struct unz_global_info_s |
85 | { | 91 | { |
86 | uLong number_entry; /* total number of entries in | 92 | uLong number_entry; /* total number of entries in |
87 | the central dir on this disk */ | 93 | the central dir on this disk */ |
88 | uLong size_comment; /* size of the global comment of the zipfile */ | 94 | uLong size_comment; /* size of the global comment of the zipfile */ |
89 | } unz_global_info; | 95 | } unz_global_info; |
90 | 96 | ||
91 | 97 | ||
@@ -98,8 +104,8 @@ typedef struct unz_file_info_s | |||
98 | uLong compression_method; /* compression method 2 bytes */ | 104 | uLong compression_method; /* compression method 2 bytes */ |
99 | uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ | 105 | uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ |
100 | uLong crc; /* crc-32 4 bytes */ | 106 | uLong crc; /* crc-32 4 bytes */ |
101 | uLong compressed_size; /* compressed size 4 bytes */ | 107 | uLong compressed_size; /* compressed size 4 bytes */ |
102 | uLong uncompressed_size; /* uncompressed size 4 bytes */ | 108 | uLong uncompressed_size; /* uncompressed size 4 bytes */ |
103 | uLong size_filename; /* filename length 2 bytes */ | 109 | uLong size_filename; /* filename length 2 bytes */ |
104 | uLong size_file_extra; /* extra field length 2 bytes */ | 110 | uLong size_file_extra; /* extra field length 2 bytes */ |
105 | uLong size_file_comment; /* file comment length 2 bytes */ | 111 | uLong size_file_comment; /* file comment length 2 bytes */ |
@@ -112,27 +118,34 @@ typedef struct unz_file_info_s | |||
112 | } unz_file_info; | 118 | } unz_file_info; |
113 | 119 | ||
114 | extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, | 120 | extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, |
115 | const char* fileName2, | 121 | const char* fileName2, |
116 | int iCaseSensitivity)); | 122 | int iCaseSensitivity)); |
117 | /* | 123 | /* |
118 | Compare two filename (fileName1,fileName2). | 124 | Compare two filename (fileName1,fileName2). |
119 | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) | 125 | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) |
120 | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi | 126 | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi |
121 | or strcasecmp) | 127 | or strcasecmp) |
122 | If iCaseSenisivity = 0, case sensitivity is defaut of your operating system | 128 | If iCaseSenisivity = 0, case sensitivity is defaut of your operating system |
123 | (like 1 on Unix, 2 on Windows) | 129 | (like 1 on Unix, 2 on Windows) |
124 | */ | 130 | */ |
125 | 131 | ||
126 | 132 | ||
127 | extern unzFile ZEXPORT unzOpen OF((const char *path)); | 133 | extern unzFile ZEXPORT unzOpen OF((const char *path)); |
128 | /* | 134 | /* |
129 | Open a Zip file. path contain the full pathname (by example, | 135 | Open a Zip file. path contain the full pathname (by example, |
130 | on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer | 136 | on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer |
131 | "zlib/zlib111.zip". | 137 | "zlib/zlib113.zip". |
132 | If the zipfile cannot be opened (file don't exist or in not valid), the | 138 | If the zipfile cannot be opened (file don't exist or in not valid), the |
133 | return value is NULL. | 139 | return value is NULL. |
134 | Else, the return value is a unzFile Handle, usable with other function | 140 | Else, the return value is a unzFile Handle, usable with other function |
135 | of this unzip package. | 141 | of this unzip package. |
142 | */ | ||
143 | |||
144 | extern unzFile ZEXPORT unzOpen2 OF((const char *path, | ||
145 | zlib_filefunc_def* pzlib_filefunc_def)); | ||
146 | /* | ||
147 | Open a Zip file, like unzOpen, but provide a set of file low level API | ||
148 | for read/write the zip file (see ioapi.h) | ||
136 | */ | 149 | */ |
137 | 150 | ||
138 | extern int ZEXPORT unzClose OF((unzFile file)); | 151 | extern int ZEXPORT unzClose OF((unzFile file)); |
@@ -143,7 +156,7 @@ extern int ZEXPORT unzClose OF((unzFile file)); | |||
143 | return UNZ_OK if there is no problem. */ | 156 | return UNZ_OK if there is no problem. */ |
144 | 157 | ||
145 | extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, | 158 | extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, |
146 | unz_global_info *pglobal_info)); | 159 | unz_global_info *pglobal_info)); |
147 | /* | 160 | /* |
148 | Write info about the ZipFile in the *pglobal_info structure. | 161 | Write info about the ZipFile in the *pglobal_info structure. |
149 | No preparation of the structure is needed | 162 | No preparation of the structure is needed |
@@ -151,8 +164,8 @@ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, | |||
151 | 164 | ||
152 | 165 | ||
153 | extern int ZEXPORT unzGetGlobalComment OF((unzFile file, | 166 | extern int ZEXPORT unzGetGlobalComment OF((unzFile file, |
154 | char *szComment, | 167 | char *szComment, |
155 | uLong uSizeBuf)); | 168 | uLong uSizeBuf)); |
156 | /* | 169 | /* |
157 | Get the global comment string of the ZipFile, in the szComment buffer. | 170 | Get the global comment string of the ZipFile, in the szComment buffer. |
158 | uSizeBuf is the size of the szComment buffer. | 171 | uSizeBuf is the size of the szComment buffer. |
@@ -176,9 +189,9 @@ extern int ZEXPORT unzGoToNextFile OF((unzFile file)); | |||
176 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. | 189 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. |
177 | */ | 190 | */ |
178 | 191 | ||
179 | extern int ZEXPORT unzLocateFile OF((unzFile file, | 192 | extern int ZEXPORT unzLocateFile OF((unzFile file, |
180 | const char *szFileName, | 193 | const char *szFileName, |
181 | int iCaseSensitivity)); | 194 | int iCaseSensitivity)); |
182 | /* | 195 | /* |
183 | Try locate the file szFileName in the zipfile. | 196 | Try locate the file szFileName in the zipfile. |
184 | For the iCaseSensitivity signification, see unzStringFileNameCompare | 197 | For the iCaseSensitivity signification, see unzStringFileNameCompare |
@@ -189,25 +202,44 @@ extern int ZEXPORT unzLocateFile OF((unzFile file, | |||
189 | */ | 202 | */ |
190 | 203 | ||
191 | 204 | ||
205 | /* ****************************************** */ | ||
206 | /* Ryan supplied functions */ | ||
207 | /* unz_file_info contain information about a file in the zipfile */ | ||
208 | typedef struct unz_file_pos_s | ||
209 | { | ||
210 | uLong pos_in_zip_directory; /* offset in zip file directory */ | ||
211 | uLong num_of_file; /* # of file */ | ||
212 | } unz_file_pos; | ||
213 | |||
214 | extern int ZEXPORT unzGetFilePos( | ||
215 | unzFile file, | ||
216 | unz_file_pos* file_pos); | ||
217 | |||
218 | extern int ZEXPORT unzGoToFilePos( | ||
219 | unzFile file, | ||
220 | unz_file_pos* file_pos); | ||
221 | |||
222 | /* ****************************************** */ | ||
223 | |||
192 | extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, | 224 | extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, |
193 | unz_file_info *pfile_info, | 225 | unz_file_info *pfile_info, |
194 | char *szFileName, | 226 | char *szFileName, |
195 | uLong fileNameBufferSize, | 227 | uLong fileNameBufferSize, |
196 | void *extraField, | 228 | void *extraField, |
197 | uLong extraFieldBufferSize, | 229 | uLong extraFieldBufferSize, |
198 | char *szComment, | 230 | char *szComment, |
199 | uLong commentBufferSize)); | 231 | uLong commentBufferSize)); |
200 | /* | 232 | /* |
201 | Get Info about the current file | 233 | Get Info about the current file |
202 | if pfile_info!=NULL, the *pfile_info structure will contain somes info about | 234 | if pfile_info!=NULL, the *pfile_info structure will contain somes info about |
203 | the current file | 235 | the current file |
204 | if szFileName!=NULL, the filemane string will be copied in szFileName | 236 | if szFileName!=NULL, the filemane string will be copied in szFileName |
205 | (fileNameBufferSize is the size of the buffer) | 237 | (fileNameBufferSize is the size of the buffer) |
206 | if extraField!=NULL, the extra field information will be copied in extraField | 238 | if extraField!=NULL, the extra field information will be copied in extraField |
207 | (extraFieldBufferSize is the size of the buffer). | 239 | (extraFieldBufferSize is the size of the buffer). |
208 | This is the Central-header version of the extra field | 240 | This is the Central-header version of the extra field |
209 | if szComment!=NULL, the comment string of the file will be copied in szComment | 241 | if szComment!=NULL, the comment string of the file will be copied in szComment |
210 | (commentBufferSize is the size of the buffer) | 242 | (commentBufferSize is the size of the buffer) |
211 | */ | 243 | */ |
212 | 244 | ||
213 | /***************************************************************************/ | 245 | /***************************************************************************/ |
@@ -221,16 +253,51 @@ extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); | |||
221 | If there is no error, the return value is UNZ_OK. | 253 | If there is no error, the return value is UNZ_OK. |
222 | */ | 254 | */ |
223 | 255 | ||
256 | extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, | ||
257 | const char* password)); | ||
258 | /* | ||
259 | Open for reading data the current file in the zipfile. | ||
260 | password is a crypting password | ||
261 | If there is no error, the return value is UNZ_OK. | ||
262 | */ | ||
263 | |||
264 | extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, | ||
265 | int* method, | ||
266 | int* level, | ||
267 | int raw)); | ||
268 | /* | ||
269 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) | ||
270 | if raw==1 | ||
271 | *method will receive method of compression, *level will receive level of | ||
272 | compression | ||
273 | note : you can set level parameter as NULL (if you did not want known level, | ||
274 | but you CANNOT set method parameter as NULL | ||
275 | */ | ||
276 | |||
277 | extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, | ||
278 | int* method, | ||
279 | int* level, | ||
280 | int raw, | ||
281 | const char* password)); | ||
282 | /* | ||
283 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) | ||
284 | if raw==1 | ||
285 | *method will receive method of compression, *level will receive level of | ||
286 | compression | ||
287 | note : you can set level parameter as NULL (if you did not want known level, | ||
288 | but you CANNOT set method parameter as NULL | ||
289 | */ | ||
290 | |||
291 | |||
224 | extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); | 292 | extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); |
225 | /* | 293 | /* |
226 | Close the file in zip opened with unzOpenCurrentFile | 294 | Close the file in zip opened with unzOpenCurrentFile |
227 | Return UNZ_CRCERROR if all the file was read but the CRC is not good | 295 | Return UNZ_CRCERROR if all the file was read but the CRC is not good |
228 | */ | 296 | */ |
229 | 297 | ||
230 | 298 | extern int ZEXPORT unzReadCurrentFile OF((unzFile file, | |
231 | extern int ZEXPORT unzReadCurrentFile OF((unzFile file, | 299 | voidp buf, |
232 | voidp buf, | 300 | unsigned len)); |
233 | unsigned len)); | ||
234 | /* | 301 | /* |
235 | Read bytes from the current file (opened by unzOpenCurrentFile) | 302 | Read bytes from the current file (opened by unzOpenCurrentFile) |
236 | buf contain buffer where data must be copied | 303 | buf contain buffer where data must be copied |
@@ -249,12 +316,12 @@ extern z_off_t ZEXPORT unztell OF((unzFile file)); | |||
249 | 316 | ||
250 | extern int ZEXPORT unzeof OF((unzFile file)); | 317 | extern int ZEXPORT unzeof OF((unzFile file)); |
251 | /* | 318 | /* |
252 | return 1 if the end of file was reached, 0 elsewhere | 319 | return 1 if the end of file was reached, 0 elsewhere |
253 | */ | 320 | */ |
254 | 321 | ||
255 | extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, | 322 | extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, |
256 | voidp buf, | 323 | voidp buf, |
257 | unsigned len)); | 324 | unsigned len)); |
258 | /* | 325 | /* |
259 | Read extra field from the current file (opened by unzOpenCurrentFile) | 326 | Read extra field from the current file (opened by unzOpenCurrentFile) |
260 | This is the local-header version of the extra field (sometimes, there is | 327 | This is the local-header version of the extra field (sometimes, there is |
@@ -263,9 +330,9 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, | |||
263 | if buf==NULL, it return the size of the local extra field | 330 | if buf==NULL, it return the size of the local extra field |
264 | 331 | ||
265 | if buf!=NULL, len is the size of the buffer, the extra header is copied in | 332 | if buf!=NULL, len is the size of the buffer, the extra header is copied in |
266 | buf. | 333 | buf. |
267 | the return value is the number of bytes copied in buf, or (if <0) | 334 | the return value is the number of bytes copied in buf, or (if <0) |
268 | the error code | 335 | the error code |
269 | */ | 336 | */ |
270 | 337 | ||
271 | #ifdef __cplusplus | 338 | #ifdef __cplusplus |