annotate src/zlib-1.2.7/contrib/minizip/unzip.h @ 124:e3d5853d5918

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