|
GDAL
|
00001 /* $Id: cpl_minizip_unzip.h 35921 2016-10-25 02:28:29Z goatbar $ */ 00002 /* Modified version by Even Rouault. : 00003 - Addition of cpl_unzGetCurrentFileZStreamPos 00004 - Decoration of symbol names unz* -> cpl_unz* 00005 - Undef EXPORT so that we are sure the symbols are not exported 00006 - Add support for ZIP64 00007 00008 * Copyright (c) 2008, Even Rouault <even dot rouault at mines-paris dot org> 00009 00010 Original licence available in port/LICENCE_minizip 00011 */ 00012 00013 /* unzip.h -- IO for uncompress .zip files using zlib 00014 Version 1.01e, February 12th, 2005 00015 00016 Copyright (C) 1998-2005 Gilles Vollant 00017 00018 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g 00019 WinZip, InfoZip tools and compatible. 00020 00021 Multi volume ZipFile (span) are not supported. 00022 Encryption compatible with pkzip 2.04g only supported 00023 Old compressions used by old PKZip 1.x are not supported 00024 00025 I WAIT FEEDBACK at mail info@winimage.com 00026 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution 00027 00028 Condition of use and distribution are the same than zlib : 00029 00030 This software is provided 'as-is', without any express or implied 00031 warranty. In no event will the authors be held liable for any damages 00032 arising from the use of this software. 00033 00034 Permission is granted to anyone to use this software for any purpose, 00035 including commercial applications, and to alter it and redistribute it 00036 freely, subject to the following restrictions: 00037 00038 1. The origin of this software must not be misrepresented; you must not 00039 claim that you wrote the original software. If you use this software 00040 in a product, an acknowledgment in the product documentation would be 00041 appreciated but is not required. 00042 2. Altered source versions must be plainly marked as such, and must not be 00043 misrepresented as being the original software. 00044 3. This notice may not be removed or altered from any source distribution. 00045 */ 00046 00047 /* for more info about .ZIP format, see 00048 http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip 00049 http://www.info-zip.org/pub/infozip/doc/ 00050 PkWare has also a specification at : 00051 ftp://ftp.pkware.com/probdesc.zip 00052 */ 00053 00054 #ifndef CPL_MINIZIP_UNZIP_H_INCLUDED 00055 #define CPL_MINIZIP_UNZIP_H_INCLUDED 00056 00057 #ifndef DOXYGEN_SKIP 00058 00059 #include "cpl_vsi.h" 00060 #define uLong64 vsi_l_offset 00061 00062 #ifdef __cplusplus 00063 extern "C" { 00064 #endif 00065 00066 #ifndef _ZLIB_H 00067 #include <zlib.h> 00068 #endif 00069 00070 #ifndef CPL_MINIZIP_IOAPI_H_INCLUDED 00071 #include "cpl_minizip_ioapi.h" 00072 #endif 00073 00074 /* GDAL addition */ 00075 #define NOUNCRYPT 00076 #undef ZEXPORT 00077 #define ZEXPORT 00078 00079 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) 00080 /* like the STRICT of WIN32, we define a pointer that cannot be converted 00081 from (void*) without cast */ 00082 typedef struct TagunzFile__ { int unused; } unzFile__; 00083 typedef unzFile__ *unzFile; 00084 #else 00085 typedef voidp unzFile; 00086 #endif 00087 00088 #define UNZ_OK (0) 00089 #define UNZ_END_OF_LIST_OF_FILE (-100) 00090 #define UNZ_ERRNO (Z_ERRNO) 00091 #define UNZ_EOF (0) 00092 #define UNZ_PARAMERROR (-102) 00093 #define UNZ_BADZIPFILE (-103) 00094 #define UNZ_INTERNALERROR (-104) 00095 #define UNZ_CRCERROR (-105) 00096 00097 /* tm_unz contain date/time info */ 00098 typedef struct tm_unz_s 00099 { 00100 uInt tm_sec; /* seconds after the minute - [0,59] */ 00101 uInt tm_min; /* minutes after the hour - [0,59] */ 00102 uInt tm_hour; /* hours since midnight - [0,23] */ 00103 uInt tm_mday; /* day of the month - [1,31] */ 00104 uInt tm_mon; /* months since January - [0,11] */ 00105 uInt tm_year; /* years - [1980..2044] */ 00106 } tm_unz; 00107 00108 /* unz_global_info structure contain global data about the ZIPfile 00109 These data comes from the end of central dir */ 00110 typedef struct unz_global_info_s 00111 { 00112 uLong64 number_entry; /* total number of entries in 00113 the central dir on this disk */ 00114 uLong size_comment; /* size of the global comment of the zipfile */ 00115 } unz_global_info; 00116 00117 /* unz_file_info contain information about a file in the zipfile */ 00118 typedef struct unz_file_info_s 00119 { 00120 uLong version; /* version made by 2 bytes */ 00121 uLong version_needed; /* version needed to extract 2 bytes */ 00122 uLong flag; /* general purpose bit flag 2 bytes */ 00123 uLong compression_method; /* compression method 2 bytes */ 00124 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ 00125 uLong crc; /* crc-32 4 bytes */ 00126 uLong64 compressed_size; /* compressed size 4 bytes */ 00127 uLong64 uncompressed_size; /* uncompressed size 4 bytes */ 00128 uLong size_filename; /* filename length 2 bytes */ 00129 uLong size_file_extra; /* extra field length 2 bytes */ 00130 uLong size_file_comment; /* file comment length 2 bytes */ 00131 00132 uLong disk_num_start; /* disk number start 2 bytes */ 00133 uLong internal_fa; /* internal file attributes 2 bytes */ 00134 uLong external_fa; /* external file attributes 4 bytes */ 00135 00136 tm_unz tmu_date; 00137 } unz_file_info; 00138 00139 extern int ZEXPORT cpl_unzStringFileNameCompare (const char* fileName1, 00140 const char* fileName2, 00141 int iCaseSensitivity); 00142 /* 00143 Compare two filename (fileName1,fileName2). 00144 If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp) 00145 If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi 00146 or strcasecmp) 00147 If iCaseSenisivity = 0, case sensitivity is default of your operating system 00148 (like 1 on Unix, 2 on Windows) 00149 */ 00150 00151 extern unzFile ZEXPORT cpl_unzOpen (const char *path); 00152 /* 00153 Open a Zip file. path contain the full pathname (by example, 00154 on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer 00155 "zlib/zlib113.zip". 00156 If the zipfile cannot be opened (file don't exist or in not valid), the 00157 return value is NULL. 00158 Else, the return value is a unzFile Handle, usable with other function 00159 of this unzip package. 00160 */ 00161 00162 extern unzFile ZEXPORT cpl_unzOpen2 (const char *path, 00163 zlib_filefunc_def* pzlib_filefunc_def); 00164 /* 00165 Open a Zip file, like unzOpen, but provide a set of file low level API 00166 for read/write the zip file (see ioapi.h) 00167 */ 00168 00169 extern int ZEXPORT cpl_unzClose (unzFile file); 00170 /* 00171 Close a ZipFile opened with unzipOpen. 00172 If there is files inside the .Zip opened with unzOpenCurrentFile (see later), 00173 these files MUST be closed with unzipCloseCurrentFile before call unzipClose. 00174 return UNZ_OK if there is no problem. */ 00175 00176 extern int ZEXPORT cpl_unzGetGlobalInfo (unzFile file, 00177 unz_global_info *pglobal_info); 00178 /* 00179 Write info about the ZipFile in the *pglobal_info structure. 00180 No preparation of the structure is needed 00181 return UNZ_OK if there is no problem. */ 00182 00183 extern int ZEXPORT cpl_unzGetGlobalComment (unzFile file, 00184 char *szComment, 00185 uLong uSizeBuf); 00186 /* 00187 Get the global comment string of the ZipFile, in the szComment buffer. 00188 uSizeBuf is the size of the szComment buffer. 00189 return the number of byte copied or an error code <0 00190 */ 00191 00192 /***************************************************************************/ 00193 /* Unzip package allow you browse the directory of the zipfile */ 00194 00195 extern int ZEXPORT cpl_unzGoToFirstFile (unzFile file); 00196 /* 00197 Set the current file of the zipfile to the first file. 00198 return UNZ_OK if there is no problem 00199 */ 00200 00201 extern int ZEXPORT cpl_unzGoToNextFile (unzFile file); 00202 /* 00203 Set the current file of the zipfile to the next file. 00204 return UNZ_OK if there is no problem 00205 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. 00206 */ 00207 00208 extern int ZEXPORT cpl_unzLocateFile (unzFile file, 00209 const char *szFileName, 00210 int iCaseSensitivity); 00211 /* 00212 Try locate the file szFileName in the zipfile. 00213 For the iCaseSensitivity signification, see unzStringFileNameCompare 00214 00215 return value : 00216 UNZ_OK if the file is found. It becomes the current file. 00217 UNZ_END_OF_LIST_OF_FILE if the file is not found 00218 */ 00219 00220 /* ****************************************** */ 00221 /* Ryan supplied functions */ 00222 /* unz_file_info contain information about a file in the zipfile */ 00223 typedef struct unz_file_pos_s 00224 { 00225 uLong64 pos_in_zip_directory; /* offset in zip file directory */ 00226 uLong64 num_of_file; /* # of file */ 00227 } unz_file_pos; 00228 00229 extern int ZEXPORT cpl_unzGetFilePos( 00230 unzFile file, 00231 unz_file_pos* file_pos); 00232 00233 extern int ZEXPORT cpl_unzGoToFilePos( 00234 unzFile file, 00235 unz_file_pos* file_pos); 00236 00237 /* ****************************************** */ 00238 00239 extern int ZEXPORT cpl_unzGetCurrentFileInfo (unzFile file, 00240 unz_file_info *pfile_info, 00241 char *szFileName, 00242 uLong fileNameBufferSize, 00243 void *extraField, 00244 uLong extraFieldBufferSize, 00245 char *szComment, 00246 uLong commentBufferSize); 00247 /* 00248 Get Info about the current file 00249 if pfile_info!=NULL, the *pfile_info structure will contain some info about 00250 the current file 00251 if szFileName!=NULL, the filename string will be copied in szFileName 00252 (fileNameBufferSize is the size of the buffer) 00253 if extraField!=NULL, the extra field information will be copied in extraField 00254 (extraFieldBufferSize is the size of the buffer). 00255 This is the Central-header version of the extra field 00256 if szComment!=NULL, the comment string of the file will be copied in szComment 00257 (commentBufferSize is the size of the buffer) 00258 */ 00259 00262 extern uLong64 ZEXPORT cpl_unzGetCurrentFileZStreamPos (unzFile file); 00263 00266 /***************************************************************************/ 00267 /* for reading the content of the current zipfile, you can open it, read data 00268 from it, and close it (you can close it before reading all the file) 00269 */ 00270 00271 extern int ZEXPORT cpl_unzOpenCurrentFile (unzFile file); 00272 /* 00273 Open for reading data the current file in the zipfile. 00274 If there is no error, the return value is UNZ_OK. 00275 */ 00276 00277 extern int ZEXPORT cpl_unzOpenCurrentFilePassword (unzFile file, 00278 const char* password); 00279 /* 00280 Open for reading data the current file in the zipfile. 00281 password is a crypting password 00282 If there is no error, the return value is UNZ_OK. 00283 */ 00284 00285 extern int ZEXPORT cpl_unzOpenCurrentFile2 (unzFile file, 00286 int* method, 00287 int* level, 00288 int raw); 00289 /* 00290 Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) 00291 if raw==1 00292 *method will receive method of compression, *level will receive level of 00293 compression 00294 note : you can set level parameter as NULL (if you did not want known level, 00295 but you CANNOT set method parameter as NULL 00296 */ 00297 00298 extern int ZEXPORT cpl_unzOpenCurrentFile3 (unzFile file, 00299 int* method, 00300 int* level, 00301 int raw, 00302 const char* password); 00303 /* 00304 Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) 00305 if raw==1 00306 *method will receive method of compression, *level will receive level of 00307 compression 00308 note : you can set level parameter as NULL (if you did not want known level, 00309 but you CANNOT set method parameter as NULL 00310 */ 00311 00312 extern int ZEXPORT cpl_unzCloseCurrentFile (unzFile file); 00313 /* 00314 Close the file in zip opened with unzOpenCurrentFile 00315 Return UNZ_CRCERROR if all the file was read but the CRC is not good 00316 */ 00317 00318 extern int ZEXPORT cpl_unzReadCurrentFile (unzFile file, 00319 voidp buf, 00320 unsigned len); 00321 /* 00322 Read bytes from the current file (opened by unzOpenCurrentFile) 00323 buf contain buffer where data must be copied 00324 len the size of buf. 00325 00326 return the number of byte copied if some bytes are copied 00327 return 0 if the end of file was reached 00328 return <0 with error code if there is an error 00329 (UNZ_ERRNO for IO error, or zLib error for uncompress error) 00330 */ 00331 00332 extern z_off_t ZEXPORT cpl_unztell (unzFile file); 00333 /* 00334 Give the current position in uncompressed data 00335 */ 00336 00337 extern int ZEXPORT cpl_unzeof (unzFile file); 00338 /* 00339 return 1 if the end of file was reached, 0 elsewhere 00340 */ 00341 00342 extern int ZEXPORT cpl_unzGetLocalExtrafield (unzFile file, 00343 voidp buf, 00344 unsigned len); 00345 /* 00346 Read extra field from the current file (opened by unzOpenCurrentFile) 00347 This is the local-header version of the extra field (sometimes, there is 00348 more info in the local-header version than in the central-header) 00349 00350 if buf==NULL, it return the size of the local extra field 00351 00352 if buf!=NULL, len is the size of the buffer, the extra header is copied in 00353 buf. 00354 the return value is the number of bytes copied in buf, or (if <0) 00355 the error code 00356 */ 00357 00358 /***************************************************************************/ 00359 00360 /* Get the current file offset */ 00361 extern uLong64 ZEXPORT cpl_unzGetOffset (unzFile file); 00362 00363 /* Set the current file offset */ 00364 extern int ZEXPORT cpl_unzSetOffset (unzFile file, uLong64 pos); 00365 00366 #ifdef __cplusplus 00367 } 00368 #endif 00369 00370 #endif /* #ifndef DOXYGEN_SKIP */ 00371 00372 #endif /* CPL_MINIZIP_UNZIP_H_INCLUDED */
1.7.6.1.