annotate src/zlib-1.2.7/contrib/minizip/unzip.h @ 4:e13257ea84a4

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