]> git.saurik.com Git - wxWidgets.git/blame - src/common/unzip.h
Added code to handle SQLSERVER, ACCESS, and MSDE allowing spaces in table names and...
[wxWidgets.git] / src / common / unzip.h
CommitLineData
076bae67
VS
1/*
2
3This file was altered for needs of wxWindows.
4$Id$
5
6*/
7
913df6f2 8/* unzip.h -- IO for uncompress .zip files using zlib
5526e819
VS
9 Version 0.15 beta, Mar 19th, 1998,
10
11 Copyright (C) 1998 Gilles Vollant
12
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
17
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
22
23 Condition of use and distribution are the same than zlib :
24
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.
28
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:
32
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.
40
41
42*/
913df6f2 43/* for more info about .ZIP format, see
5526e819
VS
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 */
47
48#ifndef _unz_H
49#define _unz_H
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55#ifndef _ZLIB_H
ac2834ab
GT
56//#include "zlib.h"
57// normally, the compiler options should contain -I../zlib, but it is
58// apparently not the case for all MSW makefiles and so, unless we use
59// configure (which defines __WX_SETUP_H__) or it is explicitly overridden by
60// the user (who can define wxUSE_ZLIB_H_IN_PATH), we hardcode the path here
61#if defined(__WXMSW__) && !defined(__WX_SETUP_H__) && !defined(wxUSE_ZLIB_H_IN_PATH)
62 #include "../zlib/zlib.h"
63#elif defined(__WXMAC__) && defined(__UNIX__)
64 #include <Kernel/net/zlib.h>
65#else
66 #include "zlib.h"
67#endif
5526e819
VS
68#endif
69
70#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
71/* like the STRICT of WIN32, we define a pointer that cannot be converted
72 from (void*) without cast */
913df6f2 73typedef struct TagunzFile__ { int unused; } unzFile__;
5526e819
VS
74typedef unzFile__ *unzFile;
75#else
76typedef voidp unzFile;
77#endif
78
79
80#define UNZ_OK (0)
81#define UNZ_END_OF_LIST_OF_FILE (-100)
82#define UNZ_ERRNO (Z_ERRNO)
83#define UNZ_EOF (0)
84#define UNZ_PARAMERROR (-102)
85#define UNZ_BADZIPFILE (-103)
86#define UNZ_INTERNALERROR (-104)
87#define UNZ_CRCERROR (-105)
88
89/* tm_unz contain date/time info */
913df6f2 90typedef struct tm_unz_s
5526e819
VS
91{
92 uInt tm_sec; /* seconds after the minute - [0,59] */
93 uInt tm_min; /* minutes after the hour - [0,59] */
94 uInt tm_hour; /* hours since midnight - [0,23] */
95 uInt tm_mday; /* day of the month - [1,31] */
96 uInt tm_mon; /* months since January - [0,11] */
97 uInt tm_year; /* years - [1980..2044] */
98} tm_unz;
99
100/* unz_global_info structure contain global data about the ZIPfile
101 These data comes from the end of central dir */
102typedef struct unz_global_info_s
103{
104 uLong number_entry; /* total number of entries in
105 the central dir on this disk */
106 uLong size_comment; /* size of the global comment of the zipfile */
107} unz_global_info;
108
109
110/* unz_file_info contain information about a file in the zipfile */
111typedef struct unz_file_info_s
112{
113 uLong version; /* version made by 2 bytes */
114 uLong version_needed; /* version needed to extract 2 bytes */
115 uLong flag; /* general purpose bit flag 2 bytes */
116 uLong compression_method; /* compression method 2 bytes */
117 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
118 uLong crc; /* crc-32 4 bytes */
913df6f2
DW
119 uLong compressed_size; /* compressed size 4 bytes */
120 uLong uncompressed_size; /* uncompressed size 4 bytes */
5526e819
VS
121 uLong size_filename; /* filename length 2 bytes */
122 uLong size_file_extra; /* extra field length 2 bytes */
123 uLong size_file_comment; /* file comment length 2 bytes */
124
125 uLong disk_num_start; /* disk number start 2 bytes */
126 uLong internal_fa; /* internal file attributes 2 bytes */
127 uLong external_fa; /* external file attributes 4 bytes */
128
129 tm_unz tmu_date;
130} unz_file_info;
131
132extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
133 const char* fileName2,
134 int iCaseSensitivity));
135/*
136 Compare two filename (fileName1,fileName2).
137 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
138 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
139 or strcasecmp)
140 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
141 (like 1 on Unix, 2 on Windows)
142*/
143
144
145extern unzFile ZEXPORT unzOpen OF((const char *path));
146/*
147 Open a Zip file. path contain the full pathname (by example,
148 on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
149 "zlib/zlib111.zip".
150 If the zipfile cannot be opened (file don't exist or in not valid), the
151 return value is NULL.
152 Else, the return value is a unzFile Handle, usable with other function
153 of this unzip package.
154*/
155
156extern int ZEXPORT unzClose OF((unzFile file));
157/*
158 Close a ZipFile opened with unzipOpen.
159 If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
160 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
161 return UNZ_OK if there is no problem. */
162
163extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
164 unz_global_info *pglobal_info));
165/*
166 Write info about the ZipFile in the *pglobal_info structure.
167 No preparation of the structure is needed
168 return UNZ_OK if there is no problem. */
169
170
171extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
172 char *szComment,
173 uLong uSizeBuf));
174/*
175 Get the global comment string of the ZipFile, in the szComment buffer.
176 uSizeBuf is the size of the szComment buffer.
177 return the number of byte copied or an error code <0
178*/
179
180
181/***************************************************************************/
182/* Unzip package allow you browse the directory of the zipfile */
183
184extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
185/*
186 Set the current file of the zipfile to the first file.
187 return UNZ_OK if there is no problem
188*/
189
190extern int ZEXPORT unzGoToNextFile OF((unzFile file));
191/*
192 Set the current file of the zipfile to the next file.
193 return UNZ_OK if there is no problem
194 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
195*/
196
913df6f2 197extern int ZEXPORT unzLocateFile OF((unzFile file,
5526e819
VS
198 const char *szFileName,
199 int iCaseSensitivity));
200/*
201 Try locate the file szFileName in the zipfile.
202 For the iCaseSensitivity signification, see unzStringFileNameCompare
203
204 return value :
205 UNZ_OK if the file is found. It becomes the current file.
206 UNZ_END_OF_LIST_OF_FILE if the file is not found
207*/
208
209
210extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
211 unz_file_info *pfile_info,
212 char *szFileName,
213 uLong fileNameBufferSize,
214 void *extraField,
215 uLong extraFieldBufferSize,
216 char *szComment,
217 uLong commentBufferSize));
218/*
219 Get Info about the current file
220 if pfile_info!=NULL, the *pfile_info structure will contain somes info about
221 the current file
222 if szFileName!=NULL, the filemane string will be copied in szFileName
223 (fileNameBufferSize is the size of the buffer)
224 if extraField!=NULL, the extra field information will be copied in extraField
225 (extraFieldBufferSize is the size of the buffer).
226 This is the Central-header version of the extra field
227 if szComment!=NULL, the comment string of the file will be copied in szComment
228 (commentBufferSize is the size of the buffer)
229*/
230
231/***************************************************************************/
232/* for reading the content of the current zipfile, you can open it, read data
233 from it, and close it (you can close it before reading all the file)
234 */
235
236extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
237/*
238 Open for reading data the current file in the zipfile.
239 If there is no error, the return value is UNZ_OK.
240*/
241
242extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
243/*
244 Close the file in zip opened with unzOpenCurrentFile
245 Return UNZ_CRCERROR if all the file was read but the CRC is not good
246*/
247
248
913df6f2 249extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
5526e819
VS
250 voidp buf,
251 unsigned len));
252/*
253 Read bytes from the current file (opened by unzOpenCurrentFile)
254 buf contain buffer where data must be copied
255 len the size of buf.
256
257 return the number of byte copied if somes bytes are copied
258 return 0 if the end of file was reached
259 return <0 with error code if there is an error
260 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
261*/
262
263extern z_off_t ZEXPORT unztell OF((unzFile file));
264/*
265 Give the current position in uncompressed data
266*/
267
268extern int ZEXPORT unzeof OF((unzFile file));
269/*
913df6f2 270 return 1 if the end of file was reached, 0 elsewhere
5526e819
VS
271*/
272
273extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
274 voidp buf,
275 unsigned len));
276/*
277 Read extra field from the current file (opened by unzOpenCurrentFile)
278 This is the local-header version of the extra field (sometimes, there is
279 more info in the local-header version than in the central-header)
280
281 if buf==NULL, it return the size of the local extra field
282
283 if buf!=NULL, len is the size of the buffer, the extra header is copied in
284 buf.
913df6f2 285 the return value is the number of bytes copied in buf, or (if <0)
5526e819
VS
286 the error code
287*/
288
c0bcc480 289#if defined(__VISAGECPP__) || defined(__BORLANDC__)
076bae67 290/*Visualage complains of no prototypes*/
913df6f2
DW
291int unzlocal_getByte(FILE* , int*);
292int strcmpcasenosensitive_internal (const char*, const char*);
293int unzlocal_getShort (FILE*, uLong*);
294int unzlocal_getLong (FILE*, uLong*);
295uLong unzlocal_SearchCentralDir(FILE*);
296void unzlocal_DosDateToTmuDate (uLong, tm_unz*);
297#endif
298
5526e819
VS
299#ifdef __cplusplus
300}
301#endif
302
303#endif /* _unz_H */