nuclear@0: /* unzip.h -- IO for uncompress .zip files using zlib nuclear@0: Version 1.1, February 14h, 2010 nuclear@0: part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) nuclear@0: nuclear@0: Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) nuclear@0: nuclear@0: Modifications of Unzip for Zip64 nuclear@0: Copyright (C) 2007-2008 Even Rouault nuclear@0: nuclear@0: Modifications for Zip64 support on both zip and unzip nuclear@0: Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) nuclear@0: nuclear@0: For more info read MiniZip_info.txt nuclear@0: nuclear@0: --------------------------------------------------------------------------------- nuclear@0: nuclear@0: Condition of use and distribution are the same than zlib : nuclear@0: nuclear@0: This software is provided 'as-is', without any express or implied nuclear@0: warranty. In no event will the authors be held liable for any damages nuclear@0: arising from the use of this software. nuclear@0: nuclear@0: Permission is granted to anyone to use this software for any purpose, nuclear@0: including commercial applications, and to alter it and redistribute it nuclear@0: freely, subject to the following restrictions: nuclear@0: nuclear@0: 1. The origin of this software must not be misrepresented; you must not nuclear@0: claim that you wrote the original software. If you use this software nuclear@0: in a product, an acknowledgment in the product documentation would be nuclear@0: appreciated but is not required. nuclear@0: 2. Altered source versions must be plainly marked as such, and must not be nuclear@0: misrepresented as being the original software. nuclear@0: 3. This notice may not be removed or altered from any source distribution. nuclear@0: nuclear@0: --------------------------------------------------------------------------------- nuclear@0: nuclear@0: Changes nuclear@0: nuclear@0: See header of unzip64.c nuclear@0: nuclear@0: */ nuclear@0: nuclear@0: #ifndef _unz64_H nuclear@0: #define _unz64_H nuclear@0: nuclear@0: #ifdef __cplusplus nuclear@0: extern "C" { nuclear@0: #endif nuclear@0: nuclear@0: #ifndef _ZLIB_H nuclear@0: #include "zlib.h" nuclear@0: #endif nuclear@0: nuclear@0: #ifndef _ZLIBIOAPI_H nuclear@0: #include "ioapi.h" nuclear@0: #endif nuclear@0: nuclear@0: #ifdef HAVE_BZIP2 nuclear@0: #include "bzlib.h" nuclear@0: #endif nuclear@0: nuclear@0: #define Z_BZIP2ED 12 nuclear@0: nuclear@0: #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) nuclear@0: /* like the STRICT of WIN32, we define a pointer that cannot be converted nuclear@0: from (void*) without cast */ nuclear@0: typedef struct TagunzFile__ { int unused; } unzFile__; nuclear@0: typedef unzFile__ *unzFile; nuclear@0: #else nuclear@0: typedef voidp unzFile; nuclear@0: #endif nuclear@0: nuclear@0: nuclear@0: #define UNZ_OK (0) nuclear@0: #define UNZ_END_OF_LIST_OF_FILE (-100) nuclear@0: #define UNZ_ERRNO (Z_ERRNO) nuclear@0: #define UNZ_EOF (0) nuclear@0: #define UNZ_PARAMERROR (-102) nuclear@0: #define UNZ_BADZIPFILE (-103) nuclear@0: #define UNZ_INTERNALERROR (-104) nuclear@0: #define UNZ_CRCERROR (-105) nuclear@0: nuclear@0: /* tm_unz contain date/time info */ nuclear@0: typedef struct tm_unz_s nuclear@0: { nuclear@0: uInt tm_sec; /* seconds after the minute - [0,59] */ nuclear@0: uInt tm_min; /* minutes after the hour - [0,59] */ nuclear@0: uInt tm_hour; /* hours since midnight - [0,23] */ nuclear@0: uInt tm_mday; /* day of the month - [1,31] */ nuclear@0: uInt tm_mon; /* months since January - [0,11] */ nuclear@0: uInt tm_year; /* years - [1980..2044] */ nuclear@0: } tm_unz; nuclear@0: nuclear@0: /* unz_global_info structure contain global data about the ZIPfile nuclear@0: These data comes from the end of central dir */ nuclear@0: typedef struct unz_global_info64_s nuclear@0: { nuclear@0: ZPOS64_T number_entry; /* total number of entries in nuclear@0: the central dir on this disk */ nuclear@0: uLong size_comment; /* size of the global comment of the zipfile */ nuclear@0: } unz_global_info64; nuclear@0: nuclear@0: typedef struct unz_global_info_s nuclear@0: { nuclear@0: uLong number_entry; /* total number of entries in nuclear@0: the central dir on this disk */ nuclear@0: uLong size_comment; /* size of the global comment of the zipfile */ nuclear@0: } unz_global_info; nuclear@0: nuclear@0: /* unz_file_info contain information about a file in the zipfile */ nuclear@0: typedef struct unz_file_info64_s nuclear@0: { nuclear@0: uLong version; /* version made by 2 bytes */ nuclear@0: uLong version_needed; /* version needed to extract 2 bytes */ nuclear@0: uLong flag; /* general purpose bit flag 2 bytes */ nuclear@0: uLong compression_method; /* compression method 2 bytes */ nuclear@0: uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ nuclear@0: uLong crc; /* crc-32 4 bytes */ nuclear@0: ZPOS64_T compressed_size; /* compressed size 8 bytes */ nuclear@0: ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */ nuclear@0: uLong size_filename; /* filename length 2 bytes */ nuclear@0: uLong size_file_extra; /* extra field length 2 bytes */ nuclear@0: uLong size_file_comment; /* file comment length 2 bytes */ nuclear@0: nuclear@0: uLong disk_num_start; /* disk number start 2 bytes */ nuclear@0: uLong internal_fa; /* internal file attributes 2 bytes */ nuclear@0: uLong external_fa; /* external file attributes 4 bytes */ nuclear@0: nuclear@0: tm_unz tmu_date; nuclear@0: } unz_file_info64; nuclear@0: nuclear@0: typedef struct unz_file_info_s nuclear@0: { nuclear@0: uLong version; /* version made by 2 bytes */ nuclear@0: uLong version_needed; /* version needed to extract 2 bytes */ nuclear@0: uLong flag; /* general purpose bit flag 2 bytes */ nuclear@0: uLong compression_method; /* compression method 2 bytes */ nuclear@0: uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ nuclear@0: uLong crc; /* crc-32 4 bytes */ nuclear@0: uLong compressed_size; /* compressed size 4 bytes */ nuclear@0: uLong uncompressed_size; /* uncompressed size 4 bytes */ nuclear@0: uLong size_filename; /* filename length 2 bytes */ nuclear@0: uLong size_file_extra; /* extra field length 2 bytes */ nuclear@0: uLong size_file_comment; /* file comment length 2 bytes */ nuclear@0: nuclear@0: uLong disk_num_start; /* disk number start 2 bytes */ nuclear@0: uLong internal_fa; /* internal file attributes 2 bytes */ nuclear@0: uLong external_fa; /* external file attributes 4 bytes */ nuclear@0: nuclear@0: tm_unz tmu_date; nuclear@0: } unz_file_info; nuclear@0: nuclear@0: extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, nuclear@0: const char* fileName2, nuclear@0: int iCaseSensitivity)); nuclear@0: /* nuclear@0: Compare two filename (fileName1,fileName2). nuclear@0: If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) nuclear@0: If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi nuclear@0: or strcasecmp) nuclear@0: If iCaseSenisivity = 0, case sensitivity is defaut of your operating system nuclear@0: (like 1 on Unix, 2 on Windows) nuclear@0: */ nuclear@0: nuclear@0: nuclear@0: extern unzFile ZEXPORT unzOpen OF((const char *path)); nuclear@0: extern unzFile ZEXPORT unzOpen64 OF((const void *path)); nuclear@0: /* nuclear@0: Open a Zip file. path contain the full pathname (by example, nuclear@0: on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer nuclear@0: "zlib/zlib113.zip". nuclear@0: If the zipfile cannot be opened (file don't exist or in not valid), the nuclear@0: return value is NULL. nuclear@0: Else, the return value is a unzFile Handle, usable with other function nuclear@0: of this unzip package. nuclear@0: the "64" function take a const void* pointer, because the path is just the nuclear@0: value passed to the open64_file_func callback. nuclear@0: Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path nuclear@0: is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* nuclear@0: does not describe the reality nuclear@0: */ nuclear@0: nuclear@0: nuclear@0: extern unzFile ZEXPORT unzOpen2 OF((const char *path, nuclear@0: zlib_filefunc_def* pzlib_filefunc_def)); nuclear@0: /* nuclear@0: Open a Zip file, like unzOpen, but provide a set of file low level API nuclear@0: for read/write the zip file (see ioapi.h) nuclear@0: */ nuclear@0: nuclear@0: extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, nuclear@0: zlib_filefunc64_def* pzlib_filefunc_def)); nuclear@0: /* nuclear@0: Open a Zip file, like unz64Open, but provide a set of file low level API nuclear@0: for read/write the zip file (see ioapi.h) nuclear@0: */ nuclear@0: nuclear@0: extern int ZEXPORT unzClose OF((unzFile file)); nuclear@0: /* nuclear@0: Close a ZipFile opened with unzipOpen. nuclear@0: If there is files inside the .Zip opened with unzOpenCurrentFile (see later), nuclear@0: these files MUST be closed with unzipCloseCurrentFile before call unzipClose. nuclear@0: return UNZ_OK if there is no problem. */ nuclear@0: nuclear@0: extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, nuclear@0: unz_global_info *pglobal_info)); nuclear@0: nuclear@0: extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, nuclear@0: unz_global_info64 *pglobal_info)); nuclear@0: /* nuclear@0: Write info about the ZipFile in the *pglobal_info structure. nuclear@0: No preparation of the structure is needed nuclear@0: return UNZ_OK if there is no problem. */ nuclear@0: nuclear@0: nuclear@0: extern int ZEXPORT unzGetGlobalComment OF((unzFile file, nuclear@0: char *szComment, nuclear@0: uLong uSizeBuf)); nuclear@0: /* nuclear@0: Get the global comment string of the ZipFile, in the szComment buffer. nuclear@0: uSizeBuf is the size of the szComment buffer. nuclear@0: return the number of byte copied or an error code <0 nuclear@0: */ nuclear@0: nuclear@0: nuclear@0: /***************************************************************************/ nuclear@0: /* Unzip package allow you browse the directory of the zipfile */ nuclear@0: nuclear@0: extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); nuclear@0: /* nuclear@0: Set the current file of the zipfile to the first file. nuclear@0: return UNZ_OK if there is no problem nuclear@0: */ nuclear@0: nuclear@0: extern int ZEXPORT unzGoToNextFile OF((unzFile file)); nuclear@0: /* nuclear@0: Set the current file of the zipfile to the next file. nuclear@0: return UNZ_OK if there is no problem nuclear@0: return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. nuclear@0: */ nuclear@0: nuclear@0: extern int ZEXPORT unzLocateFile OF((unzFile file, nuclear@0: const char *szFileName, nuclear@0: int iCaseSensitivity)); nuclear@0: /* nuclear@0: Try locate the file szFileName in the zipfile. nuclear@0: For the iCaseSensitivity signification, see unzStringFileNameCompare nuclear@0: nuclear@0: return value : nuclear@0: UNZ_OK if the file is found. It becomes the current file. nuclear@0: UNZ_END_OF_LIST_OF_FILE if the file is not found nuclear@0: */ nuclear@0: nuclear@0: nuclear@0: /* ****************************************** */ nuclear@0: /* Ryan supplied functions */ nuclear@0: /* unz_file_info contain information about a file in the zipfile */ nuclear@0: typedef struct unz_file_pos_s nuclear@0: { nuclear@0: uLong pos_in_zip_directory; /* offset in zip file directory */ nuclear@0: uLong num_of_file; /* # of file */ nuclear@0: } unz_file_pos; nuclear@0: nuclear@0: extern int ZEXPORT unzGetFilePos( nuclear@0: unzFile file, nuclear@0: unz_file_pos* file_pos); nuclear@0: nuclear@0: extern int ZEXPORT unzGoToFilePos( nuclear@0: unzFile file, nuclear@0: unz_file_pos* file_pos); nuclear@0: nuclear@0: typedef struct unz64_file_pos_s nuclear@0: { nuclear@0: ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */ nuclear@0: ZPOS64_T num_of_file; /* # of file */ nuclear@0: } unz64_file_pos; nuclear@0: nuclear@0: extern int ZEXPORT unzGetFilePos64( nuclear@0: unzFile file, nuclear@0: unz64_file_pos* file_pos); nuclear@0: nuclear@0: extern int ZEXPORT unzGoToFilePos64( nuclear@0: unzFile file, nuclear@0: const unz64_file_pos* file_pos); nuclear@0: nuclear@0: /* ****************************************** */ nuclear@0: nuclear@0: extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, nuclear@0: unz_file_info64 *pfile_info, nuclear@0: char *szFileName, nuclear@0: uLong fileNameBufferSize, nuclear@0: void *extraField, nuclear@0: uLong extraFieldBufferSize, nuclear@0: char *szComment, nuclear@0: uLong commentBufferSize)); nuclear@0: nuclear@0: extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, nuclear@0: unz_file_info *pfile_info, nuclear@0: char *szFileName, nuclear@0: uLong fileNameBufferSize, nuclear@0: void *extraField, nuclear@0: uLong extraFieldBufferSize, nuclear@0: char *szComment, nuclear@0: uLong commentBufferSize)); nuclear@0: /* nuclear@0: Get Info about the current file nuclear@0: if pfile_info!=NULL, the *pfile_info structure will contain somes info about nuclear@0: the current file nuclear@0: if szFileName!=NULL, the filemane string will be copied in szFileName nuclear@0: (fileNameBufferSize is the size of the buffer) nuclear@0: if extraField!=NULL, the extra field information will be copied in extraField nuclear@0: (extraFieldBufferSize is the size of the buffer). nuclear@0: This is the Central-header version of the extra field nuclear@0: if szComment!=NULL, the comment string of the file will be copied in szComment nuclear@0: (commentBufferSize is the size of the buffer) nuclear@0: */ nuclear@0: nuclear@0: nuclear@0: /** Addition for GDAL : START */ nuclear@0: nuclear@0: extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); nuclear@0: nuclear@0: /** Addition for GDAL : END */ nuclear@0: nuclear@0: nuclear@0: /***************************************************************************/ nuclear@0: /* for reading the content of the current zipfile, you can open it, read data nuclear@0: from it, and close it (you can close it before reading all the file) nuclear@0: */ nuclear@0: nuclear@0: extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); nuclear@0: /* nuclear@0: Open for reading data the current file in the zipfile. nuclear@0: If there is no error, the return value is UNZ_OK. nuclear@0: */ nuclear@0: nuclear@0: extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, nuclear@0: const char* password)); nuclear@0: /* nuclear@0: Open for reading data the current file in the zipfile. nuclear@0: password is a crypting password nuclear@0: If there is no error, the return value is UNZ_OK. nuclear@0: */ nuclear@0: nuclear@0: extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, nuclear@0: int* method, nuclear@0: int* level, nuclear@0: int raw)); nuclear@0: /* nuclear@0: Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) nuclear@0: if raw==1 nuclear@0: *method will receive method of compression, *level will receive level of nuclear@0: compression nuclear@0: note : you can set level parameter as NULL (if you did not want known level, nuclear@0: but you CANNOT set method parameter as NULL nuclear@0: */ nuclear@0: nuclear@0: extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, nuclear@0: int* method, nuclear@0: int* level, nuclear@0: int raw, nuclear@0: const char* password)); nuclear@0: /* nuclear@0: Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) nuclear@0: if raw==1 nuclear@0: *method will receive method of compression, *level will receive level of nuclear@0: compression nuclear@0: note : you can set level parameter as NULL (if you did not want known level, nuclear@0: but you CANNOT set method parameter as NULL nuclear@0: */ nuclear@0: nuclear@0: nuclear@0: extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); nuclear@0: /* nuclear@0: Close the file in zip opened with unzOpenCurrentFile nuclear@0: Return UNZ_CRCERROR if all the file was read but the CRC is not good nuclear@0: */ nuclear@0: nuclear@0: extern int ZEXPORT unzReadCurrentFile OF((unzFile file, nuclear@0: voidp buf, nuclear@0: unsigned len)); nuclear@0: /* nuclear@0: Read bytes from the current file (opened by unzOpenCurrentFile) nuclear@0: buf contain buffer where data must be copied nuclear@0: len the size of buf. nuclear@0: nuclear@0: return the number of byte copied if somes bytes are copied nuclear@0: return 0 if the end of file was reached nuclear@0: return <0 with error code if there is an error nuclear@0: (UNZ_ERRNO for IO error, or zLib error for uncompress error) nuclear@0: */ nuclear@0: nuclear@0: extern z_off_t ZEXPORT unztell OF((unzFile file)); nuclear@0: nuclear@0: extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); nuclear@0: /* nuclear@0: Give the current position in uncompressed data nuclear@0: */ nuclear@0: nuclear@0: extern int ZEXPORT unzeof OF((unzFile file)); nuclear@0: /* nuclear@0: return 1 if the end of file was reached, 0 elsewhere nuclear@0: */ nuclear@0: nuclear@0: extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, nuclear@0: voidp buf, nuclear@0: unsigned len)); nuclear@0: /* nuclear@0: Read extra field from the current file (opened by unzOpenCurrentFile) nuclear@0: This is the local-header version of the extra field (sometimes, there is nuclear@0: more info in the local-header version than in the central-header) nuclear@0: nuclear@0: if buf==NULL, it return the size of the local extra field nuclear@0: nuclear@0: if buf!=NULL, len is the size of the buffer, the extra header is copied in nuclear@0: buf. nuclear@0: the return value is the number of bytes copied in buf, or (if <0) nuclear@0: the error code nuclear@0: */ nuclear@0: nuclear@0: /***************************************************************************/ nuclear@0: nuclear@0: /* Get the current file offset */ nuclear@0: extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file); nuclear@0: extern uLong ZEXPORT unzGetOffset (unzFile file); nuclear@0: nuclear@0: /* Set the current file offset */ nuclear@0: extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos); nuclear@0: extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); nuclear@0: nuclear@0: nuclear@0: nuclear@0: #ifdef __cplusplus nuclear@0: } nuclear@0: #endif nuclear@0: nuclear@0: #endif /* _unz64_H */