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