No Description

zip.h 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /* zip.h -- IO on .zip files using zlib
  2. Version 1.1, February 14h, 2010
  3. part of the MiniZip project
  4. Copyright (C) 1998-2010 Gilles Vollant
  5. http://www.winimage.com/zLibDll/minizip.html
  6. Modifications for Zip64 support
  7. Copyright (C) 2009-2010 Mathias Svensson
  8. http://result42.com
  9. This program is distributed under the terms of the same license as zlib.
  10. See the accompanying LICENSE file for the full text of the license.
  11. */
  12. #ifndef _ZIP_H
  13. #define _ZIP_H
  14. #define HAVE_AES
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #ifndef _ZLIB_H
  19. # include "zlib.h"
  20. #endif
  21. #ifndef _ZLIBIOAPI_H
  22. # include "ioapi.h"
  23. #endif
  24. #ifdef HAVE_BZIP2
  25. # include "bzlib.h"
  26. #endif
  27. #define Z_BZIP2ED 12
  28. #if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
  29. /* like the STRICT of WIN32, we define a pointer that cannot be converted
  30. from (void*) without cast */
  31. typedef struct TagzipFile__ { int unused; } zipFile__;
  32. typedef zipFile__ *zipFile;
  33. #else
  34. typedef voidp zipFile;
  35. #endif
  36. #define ZIP_OK (0)
  37. #define ZIP_EOF (0)
  38. #define ZIP_ERRNO (Z_ERRNO)
  39. #define ZIP_PARAMERROR (-102)
  40. #define ZIP_BADZIPFILE (-103)
  41. #define ZIP_INTERNALERROR (-104)
  42. #ifndef DEF_MEM_LEVEL
  43. # if MAX_MEM_LEVEL >= 8
  44. # define DEF_MEM_LEVEL 8
  45. # else
  46. # define DEF_MEM_LEVEL MAX_MEM_LEVEL
  47. # endif
  48. #endif
  49. /* default memLevel */
  50. /* tm_zip contain date/time info */
  51. typedef struct tm_zip_s
  52. {
  53. uInt tm_sec; /* seconds after the minute - [0,59] */
  54. uInt tm_min; /* minutes after the hour - [0,59] */
  55. uInt tm_hour; /* hours since midnight - [0,23] */
  56. uInt tm_mday; /* day of the month - [1,31] */
  57. uInt tm_mon; /* months since January - [0,11] */
  58. uInt tm_year; /* years - [1980..2044] */
  59. } tm_zip;
  60. typedef struct
  61. {
  62. tm_zip tmz_date; /* date in understandable format */
  63. uLong dosDate; /* if dos_date == 0, tmu_date is used */
  64. uLong internal_fa; /* internal file attributes 2 bytes */
  65. uLong external_fa; /* external file attributes 4 bytes */
  66. } zip_fileinfo;
  67. typedef const char* zipcharpc;
  68. #define APPEND_STATUS_CREATE (0)
  69. #define APPEND_STATUS_CREATEAFTER (1)
  70. #define APPEND_STATUS_ADDINZIP (2)
  71. /***************************************************************************/
  72. /* Writing a zip file */
  73. extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
  74. extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
  75. /* Create a zipfile.
  76. pathname should contain the full pathname (by example, on a Windows XP computer
  77. "c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip".
  78. return NULL if zipfile cannot be opened
  79. return zipFile handle if no error
  80. If the file pathname exist and append == APPEND_STATUS_CREATEAFTER, the zip
  81. will be created at the end of the file. (useful if the file contain a self extractor code)
  82. If the file pathname exist and append == APPEND_STATUS_ADDINZIP, we will add files in existing
  83. zip (be sure you don't add file that doesn't exist)
  84. NOTE: There is no delete function into a zipfile. If you want delete file into a zipfile,
  85. you must open a zipfile, and create another. Of course, you can use RAW reading and writing to copy
  86. the file you did not want delete. */
  87. extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, int append, zipcharpc* globalcomment,
  88. zlib_filefunc_def* pzlib_filefunc_def));
  89. extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, int append, zipcharpc* globalcomment,
  90. zlib_filefunc64_def* pzlib_filefunc_def));
  91. extern zipFile ZEXPORT zipOpen3 OF((const char *pathname, int append, ZPOS64_T disk_size,
  92. zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc_def));
  93. /* Same as zipOpen2 but allows specification of spanned zip size */
  94. extern zipFile ZEXPORT zipOpen3_64 OF((const void *pathname, int append, ZPOS64_T disk_size,
  95. zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def));
  96. extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
  97. const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
  98. uInt size_extrafield_global, const char* comment, int method, int level));
  99. /* Open a file in the ZIP for writing.
  100. filename : the filename in zip (if NULL, '-' without quote will be used
  101. *zipfi contain supplemental information
  102. extrafield_local buffer to store the local header extra field data, can be NULL
  103. size_extrafield_local size of extrafield_local buffer
  104. extrafield_global buffer to store the global header extra field data, can be NULL
  105. size_extrafield_global size of extrafield_local buffer
  106. comment buffer for comment string
  107. method contain the compression method (0 for store, Z_DEFLATED for deflate)
  108. level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
  109. zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
  110. this MUST be '1' if the uncompressed size is >= 0xffffffff. */
  111. extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
  112. const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
  113. uInt size_extrafield_global, const char* comment, int method, int level, int zip64));
  114. /* Same as zipOpenNewFileInZip with zip64 support */
  115. extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
  116. const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
  117. uInt size_extrafield_global, const char* comment, int method, int level, int raw));
  118. /* Same as zipOpenNewFileInZip, except if raw=1, we write raw file */
  119. extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
  120. const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
  121. uInt size_extrafield_global, const char* comment, int method, int level, int raw, int zip64));
  122. /* Same as zipOpenNewFileInZip3 with zip64 support */
  123. extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
  124. const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
  125. uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
  126. int strategy, const char* password, uLong crcForCrypting));
  127. /* Same as zipOpenNewFileInZip2, except
  128. windowBits, memLevel, strategy : see parameter strategy in deflateInit2
  129. password : crypting password (NULL for no crypting)
  130. crcForCrypting : crc of file to compress (needed for crypting) */
  131. extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
  132. const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
  133. uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
  134. int strategy, const char* password, uLong crcForCrypting, int zip64));
  135. /* Same as zipOpenNewFileInZip3 with zip64 support */
  136. extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
  137. const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
  138. uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
  139. int strategy, const char* password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase));
  140. /* Same as zipOpenNewFileInZip3 except versionMadeBy & flag fields */
  141. extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi,
  142. const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global,
  143. uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel,
  144. int strategy, const char* password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64));
  145. /* Same as zipOpenNewFileInZip4 with zip64 support */
  146. extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, const void* buf, unsigned len));
  147. /* Write data in the zipfile */
  148. extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
  149. /* Close the current file in the zipfile */
  150. extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, uLong uncompressed_size, uLong crc32));
  151. extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, ZPOS64_T uncompressed_size, uLong crc32));
  152. /* Close the current file in the zipfile, for file opened with parameter raw=1 in zipOpenNewFileInZip2
  153. uncompressed_size and crc32 are value for the uncompressed size */
  154. extern int ZEXPORT zipClose OF((zipFile file, const char* global_comment));
  155. /* Close the zipfile */
  156. /***************************************************************************/
  157. #ifdef __cplusplus
  158. }
  159. #endif
  160. #endif /* _ZIP_H */