diff options
Diffstat (limited to 'contrib/minizip/zip.h')
-rw-r--r-- | contrib/minizip/zip.h | 161 |
1 files changed, 123 insertions, 38 deletions
diff --git a/contrib/minizip/zip.h b/contrib/minizip/zip.h index 678260b..4bc6aa4 100644 --- a/contrib/minizip/zip.h +++ b/contrib/minizip/zip.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* zip.h -- IO for compress .zip files using zlib | 1 | /* zip.h -- IO for compress .zip files using zlib |
2 | Version 0.15 alpha, Mar 19th, 1998, | 2 | Version 0.21, March 10th, 2003 |
3 | 3 | ||
4 | Copyright (C) 1998 Gilles Vollant | 4 | Copyright (C) 1998-2003 Gilles Vollant |
5 | 5 | ||
6 | This unzip package allow creates .ZIP file, compatible with PKZip 2.04g | 6 | This unzip package allow creates .ZIP file, compatible with PKZip 2.04g |
7 | WinZip, InfoZip tools and compatible. | 7 | WinZip, InfoZip tools and compatible. |
@@ -10,10 +10,9 @@ | |||
10 | 10 | ||
11 | For uncompress .zip file, look at unzip.h | 11 | For uncompress .zip file, look at unzip.h |
12 | 12 | ||
13 | THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE | 13 | |
14 | CAN CHANGE IN FUTURE VERSION !! | ||
15 | I WAIT FEEDBACK at mail info@winimage.com | 14 | I WAIT FEEDBACK at mail info@winimage.com |
16 | Visit also http://www.winimage.com/zLibDll/zip.htm for evolution | 15 | Visit also http://www.winimage.com/zLibDll/unzip.html for evolution |
17 | 16 | ||
18 | Condition of use and distribution are the same than zlib : | 17 | Condition of use and distribution are the same than zlib : |
19 | 18 | ||
@@ -36,8 +35,9 @@ | |||
36 | 35 | ||
37 | */ | 36 | */ |
38 | 37 | ||
39 | /* for more info about .ZIP format, see | 38 | /* for more info about .ZIP format, see |
40 | ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip | 39 | http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip |
40 | http://www.info-zip.org/pub/infozip/doc/ | ||
41 | PkWare has also a specification at : | 41 | PkWare has also a specification at : |
42 | ftp://ftp.pkware.com/probdesc.zip | 42 | ftp://ftp.pkware.com/probdesc.zip |
43 | */ | 43 | */ |
@@ -53,34 +53,49 @@ extern "C" { | |||
53 | #include "zlib.h" | 53 | #include "zlib.h" |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef _ZLIBIOAPI_H | ||
57 | #include "ioapi.h" | ||
58 | #endif | ||
59 | |||
56 | #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) | 60 | #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) |
57 | /* like the STRICT of WIN32, we define a pointer that cannot be converted | 61 | /* like the STRICT of WIN32, we define a pointer that cannot be converted |
58 | from (void*) without cast */ | 62 | from (void*) without cast */ |
59 | typedef struct TagzipFile__ { int unused; } zipFile__; | 63 | typedef struct TagzipFile__ { int unused; } zipFile__; |
60 | typedef zipFile__ *zipFile; | 64 | typedef zipFile__ *zipFile; |
61 | #else | 65 | #else |
62 | typedef voidp zipFile; | 66 | typedef voidp zipFile; |
63 | #endif | 67 | #endif |
64 | 68 | ||
65 | #define ZIP_OK (0) | 69 | #define ZIP_OK (0) |
66 | #define ZIP_ERRNO (Z_ERRNO) | 70 | #define ZIP_EOF (0) |
71 | #define ZIP_ERRNO (Z_ERRNO) | ||
67 | #define ZIP_PARAMERROR (-102) | 72 | #define ZIP_PARAMERROR (-102) |
73 | #define ZIP_BADZIPFILE (-103) | ||
68 | #define ZIP_INTERNALERROR (-104) | 74 | #define ZIP_INTERNALERROR (-104) |
69 | 75 | ||
76 | #ifndef DEF_MEM_LEVEL | ||
77 | # if MAX_MEM_LEVEL >= 8 | ||
78 | # define DEF_MEM_LEVEL 8 | ||
79 | # else | ||
80 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL | ||
81 | # endif | ||
82 | #endif | ||
83 | /* default memLevel */ | ||
84 | |||
70 | /* tm_zip contain date/time info */ | 85 | /* tm_zip contain date/time info */ |
71 | typedef struct tm_zip_s | 86 | typedef struct tm_zip_s |
72 | { | 87 | { |
73 | uInt tm_sec; /* seconds after the minute - [0,59] */ | 88 | uInt tm_sec; /* seconds after the minute - [0,59] */ |
74 | uInt tm_min; /* minutes after the hour - [0,59] */ | 89 | uInt tm_min; /* minutes after the hour - [0,59] */ |
75 | uInt tm_hour; /* hours since midnight - [0,23] */ | 90 | uInt tm_hour; /* hours since midnight - [0,23] */ |
76 | uInt tm_mday; /* day of the month - [1,31] */ | 91 | uInt tm_mday; /* day of the month - [1,31] */ |
77 | uInt tm_mon; /* months since January - [0,11] */ | 92 | uInt tm_mon; /* months since January - [0,11] */ |
78 | uInt tm_year; /* years - [1980..2044] */ | 93 | uInt tm_year; /* years - [1980..2044] */ |
79 | } tm_zip; | 94 | } tm_zip; |
80 | 95 | ||
81 | typedef struct | 96 | typedef struct |
82 | { | 97 | { |
83 | tm_zip tmz_date; /* date in understandable format */ | 98 | tm_zip tmz_date; /* date in understandable format */ |
84 | uLong dosDate; /* if dos_date == 0, tmu_date is used */ | 99 | uLong dosDate; /* if dos_date == 0, tmu_date is used */ |
85 | /* uLong flag; */ /* general purpose bit flag 2 bytes */ | 100 | /* uLong flag; */ /* general purpose bit flag 2 bytes */ |
86 | 101 | ||
@@ -88,30 +103,48 @@ typedef struct | |||
88 | uLong external_fa; /* external file attributes 4 bytes */ | 103 | uLong external_fa; /* external file attributes 4 bytes */ |
89 | } zip_fileinfo; | 104 | } zip_fileinfo; |
90 | 105 | ||
106 | typedef const char* zipcharpc; | ||
107 | |||
108 | |||
109 | #define APPEND_STATUS_CREATE (0) | ||
110 | #define APPEND_STATUS_CREATEAFTER (1) | ||
111 | #define APPEND_STATUS_ADDINZIP (2) | ||
112 | |||
91 | extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); | 113 | extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); |
92 | /* | 114 | /* |
93 | Create a zipfile. | 115 | Create a zipfile. |
94 | pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on | 116 | pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on |
95 | an Unix computer "zlib/zlib111.zip". | 117 | an Unix computer "zlib/zlib113.zip". |
96 | if the file pathname exist and append=1, the zip will be created at the end | 118 | if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip |
97 | of the file. (useful if the file contain a self extractor code) | 119 | will be created at the end of the file. |
98 | If the zipfile cannot be opened, the return value is NULL. | 120 | (useful if the file contain a self extractor code) |
121 | if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will | ||
122 | add files in existing zip (be sure you don't add file that doesn't exist) | ||
123 | If the zipfile cannot be opened, the return value is NULL. | ||
99 | Else, the return value is a zipFile Handle, usable with other function | 124 | Else, the return value is a zipFile Handle, usable with other function |
100 | of this zip package. | 125 | of this zip package. |
101 | 126 | */ | |
102 | 127 | ||
128 | /* Note : there is no delete function into a zipfile. | ||
129 | If you want delete file into a zipfile, you must open a zipfile, and create another | ||
130 | Of couse, you can use RAW reading and writing to copy the file you did not want delte | ||
103 | */ | 131 | */ |
104 | 132 | ||
133 | extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, | ||
134 | int append, | ||
135 | zipcharpc* globalcomment, | ||
136 | zlib_filefunc_def* pzlib_filefunc_def)); | ||
137 | |||
105 | extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, | 138 | extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, |
106 | const char* filename, | 139 | const char* filename, |
107 | const zip_fileinfo* zipfi, | 140 | const zip_fileinfo* zipfi, |
108 | const void* extrafield_local, | 141 | const void* extrafield_local, |
109 | uInt size_extrafield_local, | 142 | uInt size_extrafield_local, |
110 | const void* extrafield_global, | 143 | const void* extrafield_global, |
111 | uInt size_extrafield_global, | 144 | uInt size_extrafield_global, |
112 | const char* comment, | 145 | const char* comment, |
113 | int method, | 146 | int method, |
114 | int level)); | 147 | int level)); |
115 | /* | 148 | /* |
116 | Open a file in the ZIP for writing. | 149 | Open a file in the ZIP for writing. |
117 | filename : the filename in zip (if NULL, '-' without quote will be used | 150 | filename : the filename in zip (if NULL, '-' without quote will be used |
@@ -125,9 +158,51 @@ extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, | |||
125 | level contain the level of compression (can be Z_DEFAULT_COMPRESSION) | 158 | level contain the level of compression (can be Z_DEFAULT_COMPRESSION) |
126 | */ | 159 | */ |
127 | 160 | ||
161 | |||
162 | extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, | ||
163 | const char* filename, | ||
164 | const zip_fileinfo* zipfi, | ||
165 | const void* extrafield_local, | ||
166 | uInt size_extrafield_local, | ||
167 | const void* extrafield_global, | ||
168 | uInt size_extrafield_global, | ||
169 | const char* comment, | ||
170 | int method, | ||
171 | int level, | ||
172 | int raw)); | ||
173 | |||
174 | /* | ||
175 | Same than zipOpenNewFileInZip, except if raw=1, we write raw file | ||
176 | */ | ||
177 | |||
178 | extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, | ||
179 | const char* filename, | ||
180 | const zip_fileinfo* zipfi, | ||
181 | const void* extrafield_local, | ||
182 | uInt size_extrafield_local, | ||
183 | const void* extrafield_global, | ||
184 | uInt size_extrafield_global, | ||
185 | const char* comment, | ||
186 | int method, | ||
187 | int level, | ||
188 | int raw, | ||
189 | int windowBits, | ||
190 | int memLevel, | ||
191 | int strategy, | ||
192 | const char* password, | ||
193 | uLong crcForCtypting)); | ||
194 | |||
195 | /* | ||
196 | Same than zipOpenNewFileInZip2, except | ||
197 | windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 | ||
198 | password : crypting password (NULL for no crypting) | ||
199 | crcForCtypting : crc of file to compress (needed for crypting) | ||
200 | */ | ||
201 | |||
202 | |||
128 | extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, | 203 | extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, |
129 | const voidp buf, | 204 | const void* buf, |
130 | unsigned len)); | 205 | unsigned len)); |
131 | /* | 206 | /* |
132 | Write data in the zipfile | 207 | Write data in the zipfile |
133 | */ | 208 | */ |
@@ -137,8 +212,18 @@ extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); | |||
137 | Close the current file in the zipfile | 212 | Close the current file in the zipfile |
138 | */ | 213 | */ |
139 | 214 | ||
215 | |||
216 | extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, | ||
217 | uLong uncompressed_size, | ||
218 | uLong crc32)); | ||
219 | /* | ||
220 | Close the current file in the zipfile, for fiel opened with | ||
221 | parameter raw=1 in zipOpenNewFileInZip2 | ||
222 | uncompressed_size and crc32 are value for the uncompressed size | ||
223 | */ | ||
224 | |||
140 | extern int ZEXPORT zipClose OF((zipFile file, | 225 | extern int ZEXPORT zipClose OF((zipFile file, |
141 | const char* global_comment)); | 226 | const char* global_comment)); |
142 | /* | 227 | /* |
143 | Close the zipfile | 228 | Close the zipfile |
144 | */ | 229 | */ |