gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

373 lines
14KB

  1. /* $Id: cpl_minizip_unzip.h 44e0c0ecc2e12f7885d8572d0f18dd94e7fbda1c 2016-10-25 02:28:29Z Kurt Schwehr $ */
  2. /* Modified version by Even Rouault. :
  3. - Addition of cpl_unzGetCurrentFileZStreamPos
  4. - Decoration of symbol names unz* -> cpl_unz*
  5. - Undef EXPORT so that we are sure the symbols are not exported
  6. - Add support for ZIP64
  7. * Copyright (c) 2008, Even Rouault <even dot rouault at mines-paris dot org>
  8. Original licence available in port/LICENCE_minizip
  9. */
  10. /* unzip.h -- IO for uncompress .zip files using zlib
  11. Version 1.01e, February 12th, 2005
  12. Copyright (C) 1998-2005 Gilles Vollant
  13. This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
  14. WinZip, InfoZip tools and compatible.
  15. Multi volume ZipFile (span) are not supported.
  16. Encryption compatible with pkzip 2.04g only supported
  17. Old compressions used by old PKZip 1.x are not supported
  18. I WAIT FEEDBACK at mail info@winimage.com
  19. Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
  20. Condition of use and distribution are the same than zlib :
  21. This software is provided 'as-is', without any express or implied
  22. warranty. In no event will the authors be held liable for any damages
  23. arising from the use of this software.
  24. Permission is granted to anyone to use this software for any purpose,
  25. including commercial applications, and to alter it and redistribute it
  26. freely, subject to the following restrictions:
  27. 1. The origin of this software must not be misrepresented; you must not
  28. claim that you wrote the original software. If you use this software
  29. in a product, an acknowledgment in the product documentation would be
  30. appreciated but is not required.
  31. 2. Altered source versions must be plainly marked as such, and must not be
  32. misrepresented as being the original software.
  33. 3. This notice may not be removed or altered from any source distribution.
  34. */
  35. /* for more info about .ZIP format, see
  36. http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
  37. http://www.info-zip.org/pub/infozip/doc/
  38. PkWare has also a specification at :
  39. ftp://ftp.pkware.com/probdesc.zip
  40. */
  41. #ifndef CPL_MINIZIP_UNZIP_H_INCLUDED
  42. #define CPL_MINIZIP_UNZIP_H_INCLUDED
  43. #ifndef DOXYGEN_SKIP
  44. #include "cpl_vsi.h"
  45. #define uLong64 vsi_l_offset
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. #ifndef _ZLIB_H
  50. #include <zlib.h>
  51. #endif
  52. #ifndef CPL_MINIZIP_IOAPI_H_INCLUDED
  53. #include "cpl_minizip_ioapi.h"
  54. #endif
  55. /* GDAL addition */
  56. #define NOUNCRYPT
  57. #undef ZEXPORT
  58. #define ZEXPORT
  59. #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
  60. /* like the STRICT of WIN32, we define a pointer that cannot be converted
  61. from (void*) without cast */
  62. typedef struct TagunzFile__ { int unused; } unzFile__;
  63. typedef unzFile__ *unzFile;
  64. #else
  65. typedef voidp unzFile;
  66. #endif
  67. #define UNZ_OK (0)
  68. #define UNZ_END_OF_LIST_OF_FILE (-100)
  69. #define UNZ_ERRNO (Z_ERRNO)
  70. #define UNZ_EOF (0)
  71. #define UNZ_PARAMERROR (-102)
  72. #define UNZ_BADZIPFILE (-103)
  73. #define UNZ_INTERNALERROR (-104)
  74. #define UNZ_CRCERROR (-105)
  75. /* tm_unz contain date/time info */
  76. typedef struct tm_unz_s
  77. {
  78. uInt tm_sec; /* seconds after the minute - [0,59] */
  79. uInt tm_min; /* minutes after the hour - [0,59] */
  80. uInt tm_hour; /* hours since midnight - [0,23] */
  81. uInt tm_mday; /* day of the month - [1,31] */
  82. uInt tm_mon; /* months since January - [0,11] */
  83. uInt tm_year; /* years - [1980..2044] */
  84. } tm_unz;
  85. /* unz_global_info structure contain global data about the ZIPfile
  86. These data comes from the end of central dir */
  87. typedef struct unz_global_info_s
  88. {
  89. uLong64 number_entry; /* total number of entries in
  90. the central dir on this disk */
  91. uLong size_comment; /* size of the global comment of the zipfile */
  92. } unz_global_info;
  93. /* unz_file_info contain information about a file in the zipfile */
  94. typedef struct unz_file_info_s
  95. {
  96. uLong version; /* version made by 2 bytes */
  97. uLong version_needed; /* version needed to extract 2 bytes */
  98. uLong flag; /* general purpose bit flag 2 bytes */
  99. uLong compression_method; /* compression method 2 bytes */
  100. uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
  101. uLong crc; /* crc-32 4 bytes */
  102. uLong64 compressed_size; /* compressed size 4 bytes */
  103. uLong64 uncompressed_size; /* uncompressed size 4 bytes */
  104. uLong size_filename; /* filename length 2 bytes */
  105. uLong size_file_extra; /* extra field length 2 bytes */
  106. uLong size_file_comment; /* file comment length 2 bytes */
  107. uLong disk_num_start; /* disk number start 2 bytes */
  108. uLong internal_fa; /* internal file attributes 2 bytes */
  109. uLong external_fa; /* external file attributes 4 bytes */
  110. tm_unz tmu_date;
  111. } unz_file_info;
  112. extern int ZEXPORT cpl_unzStringFileNameCompare (const char* fileName1,
  113. const char* fileName2,
  114. int iCaseSensitivity);
  115. /*
  116. Compare two filename (fileName1,fileName2).
  117. If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp)
  118. If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi
  119. or strcasecmp)
  120. If iCaseSenisivity = 0, case sensitivity is default of your operating system
  121. (like 1 on Unix, 2 on Windows)
  122. */
  123. extern unzFile ZEXPORT cpl_unzOpen (const char *path);
  124. /*
  125. Open a Zip file. path contain the full pathname (by example,
  126. on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
  127. "zlib/zlib113.zip".
  128. If the zipfile cannot be opened (file don't exist or in not valid), the
  129. return value is NULL.
  130. Else, the return value is a unzFile Handle, usable with other function
  131. of this unzip package.
  132. */
  133. extern unzFile ZEXPORT cpl_unzOpen2 (const char *path,
  134. zlib_filefunc_def* pzlib_filefunc_def);
  135. /*
  136. Open a Zip file, like unzOpen, but provide a set of file low level API
  137. for read/write the zip file (see ioapi.h)
  138. */
  139. extern int ZEXPORT cpl_unzClose (unzFile file);
  140. /*
  141. Close a ZipFile opened with unzipOpen.
  142. If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
  143. these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
  144. return UNZ_OK if there is no problem. */
  145. extern int ZEXPORT cpl_unzGetGlobalInfo (unzFile file,
  146. unz_global_info *pglobal_info);
  147. /*
  148. Write info about the ZipFile in the *pglobal_info structure.
  149. No preparation of the structure is needed
  150. return UNZ_OK if there is no problem. */
  151. extern int ZEXPORT cpl_unzGetGlobalComment (unzFile file,
  152. char *szComment,
  153. uLong uSizeBuf);
  154. /*
  155. Get the global comment string of the ZipFile, in the szComment buffer.
  156. uSizeBuf is the size of the szComment buffer.
  157. return the number of byte copied or an error code <0
  158. */
  159. /***************************************************************************/
  160. /* Unzip package allow you browse the directory of the zipfile */
  161. extern int ZEXPORT cpl_unzGoToFirstFile (unzFile file);
  162. /*
  163. Set the current file of the zipfile to the first file.
  164. return UNZ_OK if there is no problem
  165. */
  166. extern int ZEXPORT cpl_unzGoToNextFile (unzFile file);
  167. /*
  168. Set the current file of the zipfile to the next file.
  169. return UNZ_OK if there is no problem
  170. return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
  171. */
  172. extern int ZEXPORT cpl_unzLocateFile (unzFile file,
  173. const char *szFileName,
  174. int iCaseSensitivity);
  175. /*
  176. Try locate the file szFileName in the zipfile.
  177. For the iCaseSensitivity signification, see unzStringFileNameCompare
  178. return value :
  179. UNZ_OK if the file is found. It becomes the current file.
  180. UNZ_END_OF_LIST_OF_FILE if the file is not found
  181. */
  182. /* ****************************************** */
  183. /* Ryan supplied functions */
  184. /* unz_file_info contain information about a file in the zipfile */
  185. typedef struct unz_file_pos_s
  186. {
  187. uLong64 pos_in_zip_directory; /* offset in zip file directory */
  188. uLong64 num_of_file; /* # of file */
  189. } unz_file_pos;
  190. extern int ZEXPORT cpl_unzGetFilePos(
  191. unzFile file,
  192. unz_file_pos* file_pos);
  193. extern int ZEXPORT cpl_unzGoToFilePos(
  194. unzFile file,
  195. unz_file_pos* file_pos);
  196. /* ****************************************** */
  197. extern int ZEXPORT cpl_unzGetCurrentFileInfo (unzFile file,
  198. unz_file_info *pfile_info,
  199. char *szFileName,
  200. uLong fileNameBufferSize,
  201. void *extraField,
  202. uLong extraFieldBufferSize,
  203. char *szComment,
  204. uLong commentBufferSize);
  205. /*
  206. Get Info about the current file
  207. if pfile_info!=NULL, the *pfile_info structure will contain some info about
  208. the current file
  209. if szFileName!=NULL, the filename string will be copied in szFileName
  210. (fileNameBufferSize is the size of the buffer)
  211. if extraField!=NULL, the extra field information will be copied in extraField
  212. (extraFieldBufferSize is the size of the buffer).
  213. This is the Central-header version of the extra field
  214. if szComment!=NULL, the comment string of the file will be copied in szComment
  215. (commentBufferSize is the size of the buffer)
  216. */
  217. /** Addition for GDAL : START */
  218. extern uLong64 ZEXPORT cpl_unzGetCurrentFileZStreamPos (unzFile file);
  219. /** Addition for GDAL : END */
  220. /***************************************************************************/
  221. /* for reading the content of the current zipfile, you can open it, read data
  222. from it, and close it (you can close it before reading all the file)
  223. */
  224. extern int ZEXPORT cpl_unzOpenCurrentFile (unzFile file);
  225. /*
  226. Open for reading data the current file in the zipfile.
  227. If there is no error, the return value is UNZ_OK.
  228. */
  229. extern int ZEXPORT cpl_unzOpenCurrentFilePassword (unzFile file,
  230. const char* password);
  231. /*
  232. Open for reading data the current file in the zipfile.
  233. password is a crypting password
  234. If there is no error, the return value is UNZ_OK.
  235. */
  236. extern int ZEXPORT cpl_unzOpenCurrentFile2 (unzFile file,
  237. int* method,
  238. int* level,
  239. int raw);
  240. /*
  241. Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
  242. if raw==1
  243. *method will receive method of compression, *level will receive level of
  244. compression
  245. note : you can set level parameter as NULL (if you did not want known level,
  246. but you CANNOT set method parameter as NULL
  247. */
  248. extern int ZEXPORT cpl_unzOpenCurrentFile3 (unzFile file,
  249. int* method,
  250. int* level,
  251. int raw,
  252. const char* password);
  253. /*
  254. Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
  255. if raw==1
  256. *method will receive method of compression, *level will receive level of
  257. compression
  258. note : you can set level parameter as NULL (if you did not want known level,
  259. but you CANNOT set method parameter as NULL
  260. */
  261. extern int ZEXPORT cpl_unzCloseCurrentFile (unzFile file);
  262. /*
  263. Close the file in zip opened with unzOpenCurrentFile
  264. Return UNZ_CRCERROR if all the file was read but the CRC is not good
  265. */
  266. extern int ZEXPORT cpl_unzReadCurrentFile (unzFile file,
  267. voidp buf,
  268. unsigned len);
  269. /*
  270. Read bytes from the current file (opened by unzOpenCurrentFile)
  271. buf contain buffer where data must be copied
  272. len the size of buf.
  273. return the number of byte copied if some bytes are copied
  274. return 0 if the end of file was reached
  275. return <0 with error code if there is an error
  276. (UNZ_ERRNO for IO error, or zLib error for uncompress error)
  277. */
  278. extern z_off_t ZEXPORT cpl_unztell (unzFile file);
  279. /*
  280. Give the current position in uncompressed data
  281. */
  282. extern int ZEXPORT cpl_unzeof (unzFile file);
  283. /*
  284. return 1 if the end of file was reached, 0 elsewhere
  285. */
  286. extern int ZEXPORT cpl_unzGetLocalExtrafield (unzFile file,
  287. voidp buf,
  288. unsigned len);
  289. /*
  290. Read extra field from the current file (opened by unzOpenCurrentFile)
  291. This is the local-header version of the extra field (sometimes, there is
  292. more info in the local-header version than in the central-header)
  293. if buf==NULL, it return the size of the local extra field
  294. if buf!=NULL, len is the size of the buffer, the extra header is copied in
  295. buf.
  296. the return value is the number of bytes copied in buf, or (if <0)
  297. the error code
  298. */
  299. /***************************************************************************/
  300. /* Get the current file offset */
  301. extern uLong64 ZEXPORT cpl_unzGetOffset (unzFile file);
  302. /* Set the current file offset */
  303. extern int ZEXPORT cpl_unzSetOffset (unzFile file, uLong64 pos);
  304. #ifdef __cplusplus
  305. }
  306. #endif
  307. #endif /* #ifndef DOXYGEN_SKIP */
  308. #endif /* CPL_MINIZIP_UNZIP_H_INCLUDED */
上海开阖软件有限公司 沪ICP备12045867号-1