annotate src/zlib-1.2.8/contrib/minizip/unzip.h @ 83:ae30d91d2ffe

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