3 This file was altered for needs of wxWindows.
8 /* unzip.h -- IO for uncompress .zip files using zlib
9 Version 0.15 beta, Mar 19th, 1998,
11 Copyright (C) 1998 Gilles Vollant
13 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
14 WinZip, InfoZip tools and compatible.
15 Encryption and multi volume ZipFile (span) are not supported.
16 Old compressions used by old PKZip 1.x are not supported
18 THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
19 CAN CHANGE IN FUTURE VERSION !!
20 I WAIT FEEDBACK at mail info@winimage.com
21 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
23 Condition of use and distribution are the same than zlib :
25 This software is provided 'as-is', without any express or implied
26 warranty. In no event will the authors be held liable for any damages
27 arising from the use of this software.
29 Permission is granted to anyone to use this software for any purpose,
30 including commercial applications, and to alter it and redistribute it
31 freely, subject to the following restrictions:
33 1. The origin of this software must not be misrepresented; you must not
34 claim that you wrote the original software. If you use this software
35 in a product, an acknowledgment in the product documentation would be
36 appreciated but is not required.
37 2. Altered source versions must be plainly marked as such, and must not be
38 misrepresented as being the original software.
39 3. This notice may not be removed or altered from any source distribution.
43 /* for more info about .ZIP format, see
44 ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
45 PkWare has also a specification at :
46 ftp://ftp.pkware.com/probdesc.zip */
59 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
60 /* like the STRICT of WIN32, we define a pointer that cannot be converted
61 from (void*) without cast */
62 typedef struct TagunzFile__
{ int unused
; } unzFile__
;
63 typedef unzFile__
*unzFile
;
65 typedef voidp unzFile
;
70 #define UNZ_END_OF_LIST_OF_FILE (-100)
71 #define UNZ_ERRNO (Z_ERRNO)
73 #define UNZ_PARAMERROR (-102)
74 #define UNZ_BADZIPFILE (-103)
75 #define UNZ_INTERNALERROR (-104)
76 #define UNZ_CRCERROR (-105)
78 /* tm_unz contain date/time info */
79 typedef struct tm_unz_s
81 uInt tm_sec
; /* seconds after the minute - [0,59] */
82 uInt tm_min
; /* minutes after the hour - [0,59] */
83 uInt tm_hour
; /* hours since midnight - [0,23] */
84 uInt tm_mday
; /* day of the month - [1,31] */
85 uInt tm_mon
; /* months since January - [0,11] */
86 uInt tm_year
; /* years - [1980..2044] */
89 /* unz_global_info structure contain global data about the ZIPfile
90 These data comes from the end of central dir */
91 typedef struct unz_global_info_s
93 uLong number_entry
; /* total number of entries in
94 the central dir on this disk */
95 uLong size_comment
; /* size of the global comment of the zipfile */
99 /* unz_file_info contain information about a file in the zipfile */
100 typedef struct unz_file_info_s
102 uLong version
; /* version made by 2 bytes */
103 uLong version_needed
; /* version needed to extract 2 bytes */
104 uLong flag
; /* general purpose bit flag 2 bytes */
105 uLong compression_method
; /* compression method 2 bytes */
106 uLong dosDate
; /* last mod file date in Dos fmt 4 bytes */
107 uLong crc
; /* crc-32 4 bytes */
108 uLong compressed_size
; /* compressed size 4 bytes */
109 uLong uncompressed_size
; /* uncompressed size 4 bytes */
110 uLong size_filename
; /* filename length 2 bytes */
111 uLong size_file_extra
; /* extra field length 2 bytes */
112 uLong size_file_comment
; /* file comment length 2 bytes */
114 uLong disk_num_start
; /* disk number start 2 bytes */
115 uLong internal_fa
; /* internal file attributes 2 bytes */
116 uLong external_fa
; /* external file attributes 4 bytes */
121 extern int ZEXPORT unzStringFileNameCompare
OF ((const char* fileName1
,
122 const char* fileName2
,
123 int iCaseSensitivity
));
125 Compare two filename (fileName1,fileName2).
126 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
127 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
129 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
130 (like 1 on Unix, 2 on Windows)
134 extern unzFile ZEXPORT unzOpen
OF((const char *path
));
136 Open a Zip file. path contain the full pathname (by example,
137 on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
139 If the zipfile cannot be opened (file don't exist or in not valid), the
140 return value is NULL.
141 Else, the return value is a unzFile Handle, usable with other function
142 of this unzip package.
145 extern int ZEXPORT unzClose
OF((unzFile file
));
147 Close a ZipFile opened with unzipOpen.
148 If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
149 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
150 return UNZ_OK if there is no problem. */
152 extern int ZEXPORT unzGetGlobalInfo
OF((unzFile file
,
153 unz_global_info
*pglobal_info
));
155 Write info about the ZipFile in the *pglobal_info structure.
156 No preparation of the structure is needed
157 return UNZ_OK if there is no problem. */
160 extern int ZEXPORT unzGetGlobalComment
OF((unzFile file
,
164 Get the global comment string of the ZipFile, in the szComment buffer.
165 uSizeBuf is the size of the szComment buffer.
166 return the number of byte copied or an error code <0
170 /***************************************************************************/
171 /* Unzip package allow you browse the directory of the zipfile */
173 extern int ZEXPORT unzGoToFirstFile
OF((unzFile file
));
175 Set the current file of the zipfile to the first file.
176 return UNZ_OK if there is no problem
179 extern int ZEXPORT unzGoToNextFile
OF((unzFile file
));
181 Set the current file of the zipfile to the next file.
182 return UNZ_OK if there is no problem
183 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
186 extern int ZEXPORT unzLocateFile
OF((unzFile file
,
187 const char *szFileName
,
188 int iCaseSensitivity
));
190 Try locate the file szFileName in the zipfile.
191 For the iCaseSensitivity signification, see unzStringFileNameCompare
194 UNZ_OK if the file is found. It becomes the current file.
195 UNZ_END_OF_LIST_OF_FILE if the file is not found
199 extern int ZEXPORT unzGetCurrentFileInfo
OF((unzFile file
,
200 unz_file_info
*pfile_info
,
202 uLong fileNameBufferSize
,
204 uLong extraFieldBufferSize
,
206 uLong commentBufferSize
));
208 Get Info about the current file
209 if pfile_info!=NULL, the *pfile_info structure will contain somes info about
211 if szFileName!=NULL, the filemane string will be copied in szFileName
212 (fileNameBufferSize is the size of the buffer)
213 if extraField!=NULL, the extra field information will be copied in extraField
214 (extraFieldBufferSize is the size of the buffer).
215 This is the Central-header version of the extra field
216 if szComment!=NULL, the comment string of the file will be copied in szComment
217 (commentBufferSize is the size of the buffer)
220 /***************************************************************************/
221 /* for reading the content of the current zipfile, you can open it, read data
222 from it, and close it (you can close it before reading all the file)
225 extern int ZEXPORT unzOpenCurrentFile
OF((unzFile file
));
227 Open for reading data the current file in the zipfile.
228 If there is no error, the return value is UNZ_OK.
231 extern int ZEXPORT unzCloseCurrentFile
OF((unzFile file
));
233 Close the file in zip opened with unzOpenCurrentFile
234 Return UNZ_CRCERROR if all the file was read but the CRC is not good
238 extern int ZEXPORT unzReadCurrentFile
OF((unzFile file
,
242 Read bytes from the current file (opened by unzOpenCurrentFile)
243 buf contain buffer where data must be copied
246 return the number of byte copied if somes bytes are copied
247 return 0 if the end of file was reached
248 return <0 with error code if there is an error
249 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
252 extern z_off_t ZEXPORT unztell
OF((unzFile file
));
254 Give the current position in uncompressed data
257 extern int ZEXPORT unzeof
OF((unzFile file
));
259 return 1 if the end of file was reached, 0 elsewhere
262 extern int ZEXPORT unzGetLocalExtrafield
OF((unzFile file
,
266 Read extra field from the current file (opened by unzOpenCurrentFile)
267 This is the local-header version of the extra field (sometimes, there is
268 more info in the local-header version than in the central-header)
270 if buf==NULL, it return the size of the local extra field
272 if buf!=NULL, len is the size of the buffer, the extra header is copied in
274 the return value is the number of bytes copied in buf, or (if <0)
278 #if defined(__VISAGECPP__)
279 /*Visualage complains of no prototypes*/
280 int unzlocal_getByte(FILE* , int*);
281 int strcmpcasenosensitive_internal (const char*, const char*);
282 int unzlocal_getShort (FILE*, uLong
*);
283 int unzlocal_getLong (FILE*, uLong
*);
284 uLong
unzlocal_SearchCentralDir(FILE*);
285 void unzlocal_DosDateToTmuDate (uLong
, tm_unz
*);