| OLD | NEW |
| 1 /* unzip.h -- IO for uncompress .zip files using zlib | 1 /* unzip.h -- IO for uncompress .zip files using zlib |
| 2 Version 1.01e, February 12th, 2005 | 2 Version 1.1, February 14h, 2010 |
| 3 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html
) |
| 3 | 4 |
| 4 Copyright (C) 1998-2005 Gilles Vollant | 5 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.
com/zLibDll/minizip.html ) |
| 5 | 6 |
| 6 This unzip package allow extract file from .ZIP file, compatible with PKZip 2
.04g | 7 Modifications of Unzip for Zip64 |
| 7 WinZip, InfoZip tools and compatible. | 8 Copyright (C) 2007-2008 Even Rouault |
| 8 | 9 |
| 9 Multi volume ZipFile (span) are not supported. | 10 Modifications for Zip64 support on both zip and unzip |
| 10 Encryption compatible with pkzip 2.04g only supported | 11 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) |
| 11 Old compressions used by old PKZip 1.x are not supported | |
| 12 | 12 |
| 13 For more info read MiniZip_info.txt |
| 13 | 14 |
| 14 I WAIT FEEDBACK at mail info@winimage.com | 15 -----------------------------------------------------------------------
---------- |
| 15 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution | |
| 16 | 16 |
| 17 Condition of use and distribution are the same than zlib : | 17 Condition of use and distribution are the same than zlib : |
| 18 | 18 |
| 19 This software is provided 'as-is', without any express or implied | 19 This software is provided 'as-is', without any express or implied |
| 20 warranty. In no event will the authors be held liable for any damages | 20 warranty. In no event will the authors be held liable for any damages |
| 21 arising from the use of this software. | 21 arising from the use of this software. |
| 22 | 22 |
| 23 Permission is granted to anyone to use this software for any purpose, | 23 Permission is granted to anyone to use this software for any purpose, |
| 24 including commercial applications, and to alter it and redistribute it | 24 including commercial applications, and to alter it and redistribute it |
| 25 freely, subject to the following restrictions: | 25 freely, subject to the following restrictions: |
| 26 | 26 |
| 27 1. The origin of this software must not be misrepresented; you must not | 27 1. The origin of this software must not be misrepresented; you must not |
| 28 claim that you wrote the original software. If you use this software | 28 claim that you wrote the original software. If you use this software |
| 29 in a product, an acknowledgment in the product documentation would be | 29 in a product, an acknowledgment in the product documentation would be |
| 30 appreciated but is not required. | 30 appreciated but is not required. |
| 31 2. Altered source versions must be plainly marked as such, and must not be | 31 2. Altered source versions must be plainly marked as such, and must not be |
| 32 misrepresented as being the original software. | 32 misrepresented as being the original software. |
| 33 3. This notice may not be removed or altered from any source distribution. | 33 3. This notice may not be removed or altered from any source distribution. |
| 34 | 34 |
| 35 ------------------------------------------------------------------------------
--- |
| 36 |
| 37 Changes |
| 38 |
| 39 See header of unzip64.c |
| 35 | 40 |
| 36 */ | 41 */ |
| 37 | 42 |
| 38 /* for more info about .ZIP format, see | 43 #ifndef _unz64_H |
| 39 http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip | 44 #define _unz64_H |
| 40 http://www.info-zip.org/pub/infozip/doc/ | |
| 41 PkWare has also a specification at : | |
| 42 ftp://ftp.pkware.com/probdesc.zip | |
| 43 */ | |
| 44 | |
| 45 #ifndef _unz_H | |
| 46 #define _unz_H | |
| 47 | 45 |
| 48 #ifdef __cplusplus | 46 #ifdef __cplusplus |
| 49 extern "C" { | 47 extern "C" { |
| 50 #endif | 48 #endif |
| 51 | 49 |
| 50 #ifndef _ZLIB_H |
| 52 #if defined(USE_SYSTEM_ZLIB) | 51 #if defined(USE_SYSTEM_ZLIB) |
| 53 #include <zlib.h> | 52 #include <zlib.h> |
| 54 #else | 53 #else |
| 55 #include "third_party/zlib/zlib.h" | 54 #include "third_party/zlib/zlib.h" |
| 56 #endif | 55 #endif |
| 56 #endif |
| 57 | 57 |
| 58 #ifndef _ZLIBIOAPI_H | 58 #ifndef _ZLIBIOAPI_H |
| 59 #include "ioapi.h" | 59 #include "ioapi.h" |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 #ifdef HAVE_BZIP2 |
| 63 #include "bzlib.h" |
| 64 #endif |
| 65 |
| 66 #define Z_BZIP2ED 12 |
| 67 |
| 62 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) | 68 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) |
| 63 /* like the STRICT of WIN32, we define a pointer that cannot be converted | 69 /* like the STRICT of WIN32, we define a pointer that cannot be converted |
| 64 from (void*) without cast */ | 70 from (void*) without cast */ |
| 65 typedef struct TagunzFile__ { int unused; } unzFile__; | 71 typedef struct TagunzFile__ { int unused; } unzFile__; |
| 66 typedef unzFile__ *unzFile; | 72 typedef unzFile__ *unzFile; |
| 67 #else | 73 #else |
| 68 typedef voidp unzFile; | 74 typedef voidp unzFile; |
| 69 #endif | 75 #endif |
| 70 | 76 |
| 71 | 77 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 uInt tm_sec; /* seconds after the minute - [0,59] */ | 90 uInt tm_sec; /* seconds after the minute - [0,59] */ |
| 85 uInt tm_min; /* minutes after the hour - [0,59] */ | 91 uInt tm_min; /* minutes after the hour - [0,59] */ |
| 86 uInt tm_hour; /* hours since midnight - [0,23] */ | 92 uInt tm_hour; /* hours since midnight - [0,23] */ |
| 87 uInt tm_mday; /* day of the month - [1,31] */ | 93 uInt tm_mday; /* day of the month - [1,31] */ |
| 88 uInt tm_mon; /* months since January - [0,11] */ | 94 uInt tm_mon; /* months since January - [0,11] */ |
| 89 uInt tm_year; /* years - [1980..2044] */ | 95 uInt tm_year; /* years - [1980..2044] */ |
| 90 } tm_unz; | 96 } tm_unz; |
| 91 | 97 |
| 92 /* unz_global_info structure contain global data about the ZIPfile | 98 /* unz_global_info structure contain global data about the ZIPfile |
| 93 These data comes from the end of central dir */ | 99 These data comes from the end of central dir */ |
| 100 typedef struct unz_global_info64_s |
| 101 { |
| 102 ZPOS64_T number_entry; /* total number of entries in |
| 103 the central dir on this disk */ |
| 104 uLong size_comment; /* size of the global comment of the zipfile */ |
| 105 } unz_global_info64; |
| 106 |
| 94 typedef struct unz_global_info_s | 107 typedef struct unz_global_info_s |
| 95 { | 108 { |
| 96 uLong number_entry; /* total number of entries in | 109 uLong number_entry; /* total number of entries in |
| 97 the central dir on this disk */ | 110 the central dir on this disk */ |
| 98 uLong size_comment; /* size of the global comment of the zipfile */ | 111 uLong size_comment; /* size of the global comment of the zipfile */ |
| 99 } unz_global_info; | 112 } unz_global_info; |
| 100 | 113 |
| 114 /* unz_file_info contain information about a file in the zipfile */ |
| 115 typedef struct unz_file_info64_s |
| 116 { |
| 117 uLong version; /* version made by 2 bytes */ |
| 118 uLong version_needed; /* version needed to extract 2 bytes */ |
| 119 uLong flag; /* general purpose bit flag 2 bytes */ |
| 120 uLong compression_method; /* compression method 2 bytes */ |
| 121 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ |
| 122 uLong crc; /* crc-32 4 bytes */ |
| 123 ZPOS64_T compressed_size; /* compressed size 8 bytes */ |
| 124 ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */ |
| 125 uLong size_filename; /* filename length 2 bytes */ |
| 126 uLong size_file_extra; /* extra field length 2 bytes */ |
| 127 uLong size_file_comment; /* file comment length 2 bytes */ |
| 101 | 128 |
| 102 /* unz_file_info contain information about a file in the zipfile */ | 129 uLong disk_num_start; /* disk number start 2 bytes */ |
| 130 uLong internal_fa; /* internal file attributes 2 bytes */ |
| 131 uLong external_fa; /* external file attributes 4 bytes */ |
| 132 |
| 133 tm_unz tmu_date; |
| 134 } unz_file_info64; |
| 135 |
| 103 typedef struct unz_file_info_s | 136 typedef struct unz_file_info_s |
| 104 { | 137 { |
| 105 uLong version; /* version made by 2 bytes */ | 138 uLong version; /* version made by 2 bytes */ |
| 106 uLong version_needed; /* version needed to extract 2 bytes */ | 139 uLong version_needed; /* version needed to extract 2 bytes */ |
| 107 uLong flag; /* general purpose bit flag 2 bytes */ | 140 uLong flag; /* general purpose bit flag 2 bytes */ |
| 108 uLong compression_method; /* compression method 2 bytes */ | 141 uLong compression_method; /* compression method 2 bytes */ |
| 109 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ | 142 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ |
| 110 uLong crc; /* crc-32 4 bytes */ | 143 uLong crc; /* crc-32 4 bytes */ |
| 111 uLong compressed_size; /* compressed size 4 bytes */ | 144 uLong compressed_size; /* compressed size 4 bytes */ |
| 112 uLong uncompressed_size; /* uncompressed size 4 bytes */ | 145 uLong uncompressed_size; /* uncompressed size 4 bytes */ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 128 Compare two filename (fileName1,fileName2). | 161 Compare two filename (fileName1,fileName2). |
| 129 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) | 162 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) |
| 130 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi | 163 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi |
| 131 or strcasecmp) | 164 or strcasecmp) |
| 132 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system | 165 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system |
| 133 (like 1 on Unix, 2 on Windows) | 166 (like 1 on Unix, 2 on Windows) |
| 134 */ | 167 */ |
| 135 | 168 |
| 136 | 169 |
| 137 extern unzFile ZEXPORT unzOpen OF((const char *path)); | 170 extern unzFile ZEXPORT unzOpen OF((const char *path)); |
| 171 extern unzFile ZEXPORT unzOpen64 OF((const void *path)); |
| 138 /* | 172 /* |
| 139 Open a Zip file. path contain the full pathname (by example, | 173 Open a Zip file. path contain the full pathname (by example, |
| 140 on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer | 174 on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer |
| 141 "zlib/zlib113.zip". | 175 "zlib/zlib113.zip". |
| 142 If the zipfile cannot be opened (file don't exist or in not valid), the | 176 If the zipfile cannot be opened (file don't exist or in not valid), the |
| 143 return value is NULL. | 177 return value is NULL. |
| 144 Else, the return value is a unzFile Handle, usable with other function | 178 Else, the return value is a unzFile Handle, usable with other function |
| 145 of this unzip package. | 179 of this unzip package. |
| 180 the "64" function take a const void* pointer, because the path is just the |
| 181 value passed to the open64_file_func callback. |
| 182 Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path |
| 183 is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char
* |
| 184 does not describe the reality |
| 146 */ | 185 */ |
| 147 | 186 |
| 187 |
| 148 extern unzFile ZEXPORT unzOpen2 OF((const char *path, | 188 extern unzFile ZEXPORT unzOpen2 OF((const char *path, |
| 149 zlib_filefunc_def* pzlib_filefunc_def)); | 189 zlib_filefunc_def* pzlib_filefunc_def)); |
| 150 /* | 190 /* |
| 151 Open a Zip file, like unzOpen, but provide a set of file low level API | 191 Open a Zip file, like unzOpen, but provide a set of file low level API |
| 152 for read/write the zip file (see ioapi.h) | 192 for read/write the zip file (see ioapi.h) |
| 153 */ | 193 */ |
| 154 | 194 |
| 195 extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, |
| 196 zlib_filefunc64_def* pzlib_filefunc_def)); |
| 197 /* |
| 198 Open a Zip file, like unz64Open, but provide a set of file low level API |
| 199 for read/write the zip file (see ioapi.h) |
| 200 */ |
| 201 |
| 155 extern int ZEXPORT unzClose OF((unzFile file)); | 202 extern int ZEXPORT unzClose OF((unzFile file)); |
| 156 /* | 203 /* |
| 157 Close a ZipFile opened with unzipOpen. | 204 Close a ZipFile opened with unzipOpen. |
| 158 If there is files inside the .Zip opened with unzOpenCurrentFile (see later), | 205 If there is files inside the .Zip opened with unzOpenCurrentFile (see later), |
| 159 these files MUST be closed with unzipCloseCurrentFile before call unzipClose
. | 206 these files MUST be closed with unzipCloseCurrentFile before call unzipClose
. |
| 160 return UNZ_OK if there is no problem. */ | 207 return UNZ_OK if there is no problem. */ |
| 161 | 208 |
| 162 extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, | 209 extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, |
| 163 unz_global_info *pglobal_info)); | 210 unz_global_info *pglobal_info)); |
| 211 |
| 212 extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, |
| 213 unz_global_info64 *pglobal_info)); |
| 164 /* | 214 /* |
| 165 Write info about the ZipFile in the *pglobal_info structure. | 215 Write info about the ZipFile in the *pglobal_info structure. |
| 166 No preparation of the structure is needed | 216 No preparation of the structure is needed |
| 167 return UNZ_OK if there is no problem. */ | 217 return UNZ_OK if there is no problem. */ |
| 168 | 218 |
| 169 | 219 |
| 170 extern int ZEXPORT unzGetGlobalComment OF((unzFile file, | 220 extern int ZEXPORT unzGetGlobalComment OF((unzFile file, |
| 171 char *szComment, | 221 char *szComment, |
| 172 uLong uSizeBuf)); | 222 uLong uSizeBuf)); |
| 173 /* | 223 /* |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } unz_file_pos; | 266 } unz_file_pos; |
| 217 | 267 |
| 218 extern int ZEXPORT unzGetFilePos( | 268 extern int ZEXPORT unzGetFilePos( |
| 219 unzFile file, | 269 unzFile file, |
| 220 unz_file_pos* file_pos); | 270 unz_file_pos* file_pos); |
| 221 | 271 |
| 222 extern int ZEXPORT unzGoToFilePos( | 272 extern int ZEXPORT unzGoToFilePos( |
| 223 unzFile file, | 273 unzFile file, |
| 224 unz_file_pos* file_pos); | 274 unz_file_pos* file_pos); |
| 225 | 275 |
| 276 typedef struct unz64_file_pos_s |
| 277 { |
| 278 ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */ |
| 279 ZPOS64_T num_of_file; /* # of file */ |
| 280 } unz64_file_pos; |
| 281 |
| 282 extern int ZEXPORT unzGetFilePos64( |
| 283 unzFile file, |
| 284 unz64_file_pos* file_pos); |
| 285 |
| 286 extern int ZEXPORT unzGoToFilePos64( |
| 287 unzFile file, |
| 288 const unz64_file_pos* file_pos); |
| 289 |
| 226 /* ****************************************** */ | 290 /* ****************************************** */ |
| 227 | 291 |
| 292 extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, |
| 293 unz_file_info64 *pfile_info, |
| 294 char *szFileName, |
| 295 uLong fileNameBufferSize, |
| 296 void *extraField, |
| 297 uLong extraFieldBufferSize, |
| 298 char *szComment, |
| 299 uLong commentBufferSize)); |
| 300 |
| 228 extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, | 301 extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, |
| 229 unz_file_info *pfile_info, | 302 unz_file_info *pfile_info, |
| 230 char *szFileName, | 303 char *szFileName, |
| 231 uLong fileNameBufferSize, | 304 uLong fileNameBufferSize, |
| 232 void *extraField, | 305 void *extraField, |
| 233 uLong extraFieldBufferSize, | 306 uLong extraFieldBufferSize, |
| 234 char *szComment, | 307 char *szComment, |
| 235 uLong commentBufferSize)); | 308 uLong commentBufferSize)); |
| 236 /* | 309 /* |
| 237 Get Info about the current file | 310 Get Info about the current file |
| 238 if pfile_info!=NULL, the *pfile_info structure will contain somes info about | 311 if pfile_info!=NULL, the *pfile_info structure will contain somes info about |
| 239 the current file | 312 the current file |
| 240 if szFileName!=NULL, the filemane string will be copied in szFileName | 313 if szFileName!=NULL, the filemane string will be copied in szFileName |
| 241 (fileNameBufferSize is the size of the buffer) | 314 (fileNameBufferSize is the size of the buffer) |
| 242 if extraField!=NULL, the extra field information will be copied in extraField | 315 if extraField!=NULL, the extra field information will be copied in extraField |
| 243 (extraFieldBufferSize is the size of the buffer). | 316 (extraFieldBufferSize is the size of the buffer). |
| 244 This is the Central-header version of the extra field | 317 This is the Central-header version of the extra field |
| 245 if szComment!=NULL, the comment string of the file will be copied in szComment | 318 if szComment!=NULL, the comment string of the file will be copied in szComment |
| 246 (commentBufferSize is the size of the buffer) | 319 (commentBufferSize is the size of the buffer) |
| 247 */ | 320 */ |
| 248 | 321 |
| 322 |
| 323 /** Addition for GDAL : START */ |
| 324 |
| 325 extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); |
| 326 |
| 327 /** Addition for GDAL : END */ |
| 328 |
| 329 |
| 249 /***************************************************************************/ | 330 /***************************************************************************/ |
| 250 /* for reading the content of the current zipfile, you can open it, read data | 331 /* for reading the content of the current zipfile, you can open it, read data |
| 251 from it, and close it (you can close it before reading all the file) | 332 from it, and close it (you can close it before reading all the file) |
| 252 */ | 333 */ |
| 253 | 334 |
| 254 extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); | 335 extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); |
| 255 /* | 336 /* |
| 256 Open for reading data the current file in the zipfile. | 337 Open for reading data the current file in the zipfile. |
| 257 If there is no error, the return value is UNZ_OK. | 338 If there is no error, the return value is UNZ_OK. |
| 258 */ | 339 */ |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 buf contain buffer where data must be copied | 388 buf contain buffer where data must be copied |
| 308 len the size of buf. | 389 len the size of buf. |
| 309 | 390 |
| 310 return the number of byte copied if somes bytes are copied | 391 return the number of byte copied if somes bytes are copied |
| 311 return 0 if the end of file was reached | 392 return 0 if the end of file was reached |
| 312 return <0 with error code if there is an error | 393 return <0 with error code if there is an error |
| 313 (UNZ_ERRNO for IO error, or zLib error for uncompress error) | 394 (UNZ_ERRNO for IO error, or zLib error for uncompress error) |
| 314 */ | 395 */ |
| 315 | 396 |
| 316 extern z_off_t ZEXPORT unztell OF((unzFile file)); | 397 extern z_off_t ZEXPORT unztell OF((unzFile file)); |
| 398 |
| 399 extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); |
| 317 /* | 400 /* |
| 318 Give the current position in uncompressed data | 401 Give the current position in uncompressed data |
| 319 */ | 402 */ |
| 320 | 403 |
| 321 extern int ZEXPORT unzeof OF((unzFile file)); | 404 extern int ZEXPORT unzeof OF((unzFile file)); |
| 322 /* | 405 /* |
| 323 return 1 if the end of file was reached, 0 elsewhere | 406 return 1 if the end of file was reached, 0 elsewhere |
| 324 */ | 407 */ |
| 325 | 408 |
| 326 extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, | 409 extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, |
| 327 voidp buf, | 410 voidp buf, |
| 328 unsigned len)); | 411 unsigned len)); |
| 329 /* | 412 /* |
| 330 Read extra field from the current file (opened by unzOpenCurrentFile) | 413 Read extra field from the current file (opened by unzOpenCurrentFile) |
| 331 This is the local-header version of the extra field (sometimes, there is | 414 This is the local-header version of the extra field (sometimes, there is |
| 332 more info in the local-header version than in the central-header) | 415 more info in the local-header version than in the central-header) |
| 333 | 416 |
| 334 if buf==NULL, it return the size of the local extra field | 417 if buf==NULL, it return the size of the local extra field |
| 335 | 418 |
| 336 if buf!=NULL, len is the size of the buffer, the extra header is copied in | 419 if buf!=NULL, len is the size of the buffer, the extra header is copied in |
| 337 buf. | 420 buf. |
| 338 the return value is the number of bytes copied in buf, or (if <0) | 421 the return value is the number of bytes copied in buf, or (if <0) |
| 339 the error code | 422 the error code |
| 340 */ | 423 */ |
| 341 | 424 |
| 342 /***************************************************************************/ | 425 /***************************************************************************/ |
| 343 | 426 |
| 344 /* Get the current file offset */ | 427 /* Get the current file offset */ |
| 428 extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file); |
| 345 extern uLong ZEXPORT unzGetOffset (unzFile file); | 429 extern uLong ZEXPORT unzGetOffset (unzFile file); |
| 346 | 430 |
| 347 /* Set the current file offset */ | 431 /* Set the current file offset */ |
| 432 extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos); |
| 348 extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); | 433 extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); |
| 349 | 434 |
| 350 | 435 |
| 351 | 436 |
| 352 #ifdef __cplusplus | 437 #ifdef __cplusplus |
| 353 } | 438 } |
| 354 #endif | 439 #endif |
| 355 | 440 |
| 356 #endif /* _unz_H */ | 441 #endif /* _unz64_H */ |
| OLD | NEW |