annotate src/zlib-1.2.8/contrib/minizip/unzip.h @ 128:5b4145a0d408

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