1 /* zip.h -- IO for compress .zip files using zlib
2 Version 1.00, September 10th, 2003
4 Copyright (C) 1998-2003 Gilles Vollant
6 This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
7 WinZip, InfoZip tools and compatible.
8 Encryption and multi volume ZipFile (span) are not supported.
9 Old compressions used by old PKZip 1.x are not supported
11 For uncompress .zip file, look at unzip.h
14 I WAIT FEEDBACK at mail info@winimage.com
15 Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
17 Condition of use and distribution are the same than zlib :
19 This software is provided 'as-is', without any express or implied
20 warranty. In no event will the authors be held liable for any damages
21 arising from the use of this software.
23 Permission is granted to anyone to use this software for any purpose,
24 including commercial applications, and to alter it and redistribute it
25 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.
38 /* for more info about .ZIP format, see
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 :
42 ftp://ftp.pkware.com/probdesc.zip
60 #if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
61 /* like the STRICT of WIN32, we define a pointer that cannot be converted
62 from (void*) without cast */
63 typedef struct TagzipFile__ { int unused; } zipFile__;
64 typedef zipFile__ *zipFile;
66 typedef voidp zipFile;
71 #define ZIP_ERRNO (Z_ERRNO)
72 #define ZIP_PARAMERROR (-102)
73 #define ZIP_BADZIPFILE (-103)
74 #define ZIP_INTERNALERROR (-104)
77 # if MAX_MEM_LEVEL >= 8
78 # define DEF_MEM_LEVEL 8
80 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
83 /* default memLevel */
85 /* tm_zip contain date/time info */
86 typedef struct tm_zip_s
88 uInt tm_sec; /* seconds after the minute - [0,59] */
89 uInt tm_min; /* minutes after the hour - [0,59] */
90 uInt tm_hour; /* hours since midnight - [0,23] */
91 uInt tm_mday; /* day of the month - [1,31] */
92 uInt tm_mon; /* months since January - [0,11] */
93 uInt tm_year; /* years - [1980..2044] */
98 tm_zip tmz_date; /* date in understandable format */
99 uLong dosDate; /* if dos_date == 0, tmu_date is used */
100 /* uLong flag; */ /* general purpose bit flag 2 bytes */
102 uLong internal_fa; /* internal file attributes 2 bytes */
103 uLong external_fa; /* external file attributes 4 bytes */
106 typedef const char* zipcharpc;
109 #define APPEND_STATUS_CREATE (0)
110 #define APPEND_STATUS_CREATEAFTER (1)
111 #define APPEND_STATUS_ADDINZIP (2)
113 extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
116 pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
117 an Unix computer "zlib/zlib113.zip".
118 if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
119 will be created at the end of the file.
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.
124 Else, the return value is a zipFile Handle, usable with other function
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
133 extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
135 zipcharpc* globalcomment,
136 zlib_filefunc_def* pzlib_filefunc_def));
138 extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
139 const char* filename,
140 const zip_fileinfo* zipfi,
141 const void* extrafield_local,
142 uInt size_extrafield_local,
143 const void* extrafield_global,
144 uInt size_extrafield_global,
149 Open a file in the ZIP for writing.
150 filename : the filename in zip (if NULL, '-' without quote will be used
151 *zipfi contain supplemental information
152 if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
153 contains the extrafield data the the local header
154 if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
155 contains the extrafield data the the local header
156 if comment != NULL, comment contain the comment string
157 method contain the compression method (0 for store, Z_DEFLATED for deflate)
158 level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
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,
175 Same than zipOpenNewFileInZip, except if raw=1, we write raw file
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,
192 const char* password,
193 uLong crcForCtypting));
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)
203 extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
207 Write data in the zipfile
210 extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
212 Close the current file in the zipfile
216 extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
217 uLong uncompressed_size,
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
225 extern int ZEXPORT zipClose OF((zipFile file,
226 const char* global_comment));