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