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