/src/libtomahawk/thirdparty/quazip/quazip/zip.h

http://github.com/tomahawk-player/tomahawk · C Header · 237 lines · 105 code · 30 blank · 102 comment · 2 complexity · 972407afaf46c5da7ba4b7348d95f210 MD5 · raw file

  1. /* zip.h -- IO for compress .zip files using zlib
  2. Version 1.01e, February 12th, 2005
  3. Copyright (C) 1998-2005 Gilles Vollant
  4. This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
  5. WinZip, InfoZip tools and compatible.
  6. Multi volume ZipFile (span) are not supported.
  7. Encryption compatible with pkzip 2.04g only supported
  8. Old compressions used by old PKZip 1.x are not supported
  9. For uncompress .zip file, look at unzip.h
  10. I WAIT FEEDBACK at mail info@winimage.com
  11. Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
  12. Condition of use and distribution are the same than zlib :
  13. This software is provided 'as-is', without any express or implied
  14. warranty. In no event will the authors be held liable for any damages
  15. arising from the use of this software.
  16. Permission is granted to anyone to use this software for any purpose,
  17. including commercial applications, and to alter it and redistribute it
  18. freely, subject to the following restrictions:
  19. 1. The origin of this software must not be misrepresented; you must not
  20. claim that you wrote the original software. If you use this software
  21. in a product, an acknowledgment in the product documentation would be
  22. appreciated but is not required.
  23. 2. Altered source versions must be plainly marked as such, and must not be
  24. misrepresented as being the original software.
  25. 3. This notice may not be removed or altered from any source distribution.
  26. Modified by Sergey A. Tachenov to integrate with Qt.
  27. */
  28. /* for more info about .ZIP format, see
  29. http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
  30. http://www.info-zip.org/pub/infozip/doc/
  31. PkWare has also a specification at :
  32. ftp://ftp.pkware.com/probdesc.zip
  33. */
  34. #ifndef _zip_H
  35. #define _zip_H
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #ifndef _ZLIB_H
  40. #include "zlib.h"
  41. #endif
  42. #ifndef _ZLIBIOAPI_H
  43. #include "ioapi.h"
  44. #endif
  45. #if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
  46. /* like the STRICT of WIN32, we define a pointer that cannot be converted
  47. from (void*) without cast */
  48. typedef struct TagzipFile__ { int unused; } zipFile__;
  49. typedef zipFile__ *zipFile;
  50. #else
  51. typedef voidp zipFile;
  52. #endif
  53. #define ZIP_OK (0)
  54. #define ZIP_EOF (0)
  55. #define ZIP_ERRNO (Z_ERRNO)
  56. #define ZIP_PARAMERROR (-102)
  57. #define ZIP_BADZIPFILE (-103)
  58. #define ZIP_INTERNALERROR (-104)
  59. #ifndef DEF_MEM_LEVEL
  60. # if MAX_MEM_LEVEL >= 8
  61. # define DEF_MEM_LEVEL 8
  62. # else
  63. # define DEF_MEM_LEVEL MAX_MEM_LEVEL
  64. # endif
  65. #endif
  66. /* default memLevel */
  67. /* tm_zip contain date/time info */
  68. typedef struct tm_zip_s
  69. {
  70. uInt tm_sec; /* seconds after the minute - [0,59] */
  71. uInt tm_min; /* minutes after the hour - [0,59] */
  72. uInt tm_hour; /* hours since midnight - [0,23] */
  73. uInt tm_mday; /* day of the month - [1,31] */
  74. uInt tm_mon; /* months since January - [0,11] */
  75. uInt tm_year; /* years - [1980..2044] */
  76. } tm_zip;
  77. typedef struct
  78. {
  79. tm_zip tmz_date; /* date in understandable format */
  80. uLong dosDate; /* if dos_date == 0, tmu_date is used */
  81. /* uLong flag; */ /* general purpose bit flag 2 bytes */
  82. uLong internal_fa; /* internal file attributes 2 bytes */
  83. uLong external_fa; /* external file attributes 4 bytes */
  84. } zip_fileinfo;
  85. typedef const char* zipcharpc;
  86. #define APPEND_STATUS_CREATE (0)
  87. #define APPEND_STATUS_CREATEAFTER (1)
  88. #define APPEND_STATUS_ADDINZIP (2)
  89. extern zipFile ZEXPORT zipOpen OF((voidpf file, int append));
  90. /*
  91. Create a zipfile.
  92. file is whatever the IO API accepts. For Qt IO API it's a pointer to
  93. QIODevice. For fopen() IO API it's a file name (const char*).
  94. if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
  95. will be created at the end of the file.
  96. (useful if the file contain a self extractor code)
  97. if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
  98. add files in existing zip (be sure you don't add file that doesn't exist)
  99. If the zipfile cannot be opened, the return value is NULL.
  100. Else, the return value is a zipFile Handle, usable with other function
  101. of this zip package.
  102. */
  103. /* Note : there is no delete function into a zipfile.
  104. If you want delete file into a zipfile, you must open a zipfile, and create another
  105. Of couse, you can use RAW reading and writing to copy the file you did not want delte
  106. */
  107. extern zipFile ZEXPORT zipOpen2 OF((voidpf file,
  108. int append,
  109. zipcharpc* globalcomment,
  110. zlib_filefunc_def* pzlib_filefunc_def));
  111. extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
  112. const char* filename,
  113. const zip_fileinfo* zipfi,
  114. const void* extrafield_local,
  115. uInt size_extrafield_local,
  116. const void* extrafield_global,
  117. uInt size_extrafield_global,
  118. const char* comment,
  119. int method,
  120. int level));
  121. /*
  122. Open a file in the ZIP for writing.
  123. filename : the filename in zip (if NULL, '-' without quote will be used
  124. *zipfi contain supplemental information
  125. if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
  126. contains the extrafield data the the local header
  127. if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
  128. contains the extrafield data the the local header
  129. if comment != NULL, comment contain the comment string
  130. method contain the compression method (0 for store, Z_DEFLATED for deflate)
  131. level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
  132. */
  133. extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
  134. const char* filename,
  135. const zip_fileinfo* zipfi,
  136. const void* extrafield_local,
  137. uInt size_extrafield_local,
  138. const void* extrafield_global,
  139. uInt size_extrafield_global,
  140. const char* comment,
  141. int method,
  142. int level,
  143. int raw));
  144. /*
  145. Same than zipOpenNewFileInZip, except if raw=1, we write raw file
  146. */
  147. extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
  148. const char* filename,
  149. const zip_fileinfo* zipfi,
  150. const void* extrafield_local,
  151. uInt size_extrafield_local,
  152. const void* extrafield_global,
  153. uInt size_extrafield_global,
  154. const char* comment,
  155. int method,
  156. int level,
  157. int raw,
  158. int windowBits,
  159. int memLevel,
  160. int strategy,
  161. const char* password,
  162. uLong crcForCtypting));
  163. /*
  164. Same than zipOpenNewFileInZip2, except
  165. windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
  166. password : crypting password (NULL for no crypting)
  167. crcForCtypting : crc of file to compress (needed for crypting)
  168. */
  169. extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
  170. const void* buf,
  171. unsigned len));
  172. /*
  173. Write data in the zipfile
  174. */
  175. extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
  176. /*
  177. Close the current file in the zipfile
  178. */
  179. extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
  180. uLong uncompressed_size,
  181. uLong crc32));
  182. /*
  183. Close the current file in the zipfile, for fiel opened with
  184. parameter raw=1 in zipOpenNewFileInZip2
  185. uncompressed_size and crc32 are value for the uncompressed size
  186. */
  187. extern int ZEXPORT zipClose OF((zipFile file,
  188. const char* global_comment));
  189. /*
  190. Close the zipfile
  191. */
  192. #ifdef __cplusplus
  193. }
  194. #endif
  195. #endif /* _zip_H */