update build instructions
[rofl0r-VisualBoyAdvance.git] / src / unzip.h
blob003e7381e046fbb4eae37272fda8a768dc10462d
1 // -*- C++ -*-
2 // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
3 // Copyright (C) 1999-2003 Forgotten
4 // Copyright (C) 2004 Forgotten and the VBA development team
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2, or(at your option)
9 // any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 /* unzip.h -- IO for uncompress .zip files using zlib
21 Version 0.15 beta, Mar 19th, 1998,
23 Copyright (C) 1998 Gilles Vollant
25 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
26 WinZip, InfoZip tools and compatible.
27 Encryption and multi volume ZipFile (span) are not supported.
28 Old compressions used by old PKZip 1.x are not supported
30 THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
31 CAN CHANGE IN FUTURE VERSION !!
32 I WAIT FEEDBACK at mail info@winimage.com
33 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
35 Condition of use and distribution are the same than zlib :
37 This software is provided 'as-is', without any express or implied
38 warranty. In no event will the authors be held liable for any damages
39 arising from the use of this software.
41 Permission is granted to anyone to use this software for any purpose,
42 including commercial applications, and to alter it and redistribute it
43 freely, subject to the following restrictions:
45 1. The origin of this software must not be misrepresented; you must not
46 claim that you wrote the original software. If you use this software
47 in a product, an acknowledgment in the product documentation would be
48 appreciated but is not required.
49 2. Altered source versions must be plainly marked as such, and must not be
50 misrepresented as being the original software.
51 3. This notice may not be removed or altered from any source distribution.
55 /* for more info about .ZIP format, see
56 ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
57 PkWare has also a specification at :
58 ftp://ftp.pkware.com/probdesc.zip */
60 #ifndef _unz_H
61 #define _unz_H
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
67 #ifndef _ZLIB_H
68 #include "zlib.h"
69 #endif
71 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
72 /* like the STRICT of WIN32, we define a pointer that cannot be converted
73 from (void*) without cast */
74 typedef struct TagunzFile__ { int unused; } unzFile__;
75 typedef unzFile__ *unzFile;
76 #else
77 typedef voidp unzFile;
78 #endif
81 #define UNZ_OK (0)
82 #define UNZ_END_OF_LIST_OF_FILE (-100)
83 #define UNZ_ERRNO (Z_ERRNO)
84 #define UNZ_EOF (0)
85 #define UNZ_PARAMERROR (-102)
86 #define UNZ_BADZIPFILE (-103)
87 #define UNZ_INTERNALERROR (-104)
88 #define UNZ_CRCERROR (-105)
90 /* tm_unz contain date/time info */
91 typedef struct tm_unz_s
93 uInt tm_sec; /* seconds after the minute - [0,59] */
94 uInt tm_min; /* minutes after the hour - [0,59] */
95 uInt tm_hour; /* hours since midnight - [0,23] */
96 uInt tm_mday; /* day of the month - [1,31] */
97 uInt tm_mon; /* months since January - [0,11] */
98 uInt tm_year; /* years - [1980..2044] */
99 } tm_unz;
101 /* unz_global_info structure contain global data about the ZIPfile
102 These data comes from the end of central dir */
103 typedef struct unz_global_info_s
105 uLong number_entry; /* total number of entries in
106 the central dir on this disk */
107 uLong size_comment; /* size of the global comment of the zipfile */
108 } unz_global_info;
111 /* unz_file_info contain information about a file in the zipfile */
112 typedef struct unz_file_info_s
114 uLong version; /* version made by 2 bytes */
115 uLong version_needed; /* version needed to extract 2 bytes */
116 uLong flag; /* general purpose bit flag 2 bytes */
117 uLong compression_method; /* compression method 2 bytes */
118 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
119 uLong crc; /* crc-32 4 bytes */
120 uLong compressed_size; /* compressed size 4 bytes */
121 uLong uncompressed_size; /* uncompressed size 4 bytes */
122 uLong size_filename; /* filename length 2 bytes */
123 uLong size_file_extra; /* extra field length 2 bytes */
124 uLong size_file_comment; /* file comment length 2 bytes */
126 uLong disk_num_start; /* disk number start 2 bytes */
127 uLong internal_fa; /* internal file attributes 2 bytes */
128 uLong external_fa; /* external file attributes 4 bytes */
130 tm_unz tmu_date;
131 } unz_file_info;
133 extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
134 const char* fileName2,
135 int iCaseSensitivity));
137 Compare two filename (fileName1,fileName2).
138 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
139 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
140 or strcasecmp)
141 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
142 (like 1 on Unix, 2 on Windows)
146 extern unzFile ZEXPORT unzOpen OF((const char *path));
148 Open a Zip file. path contain the full pathname (by example,
149 on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
150 "zlib/zlib111.zip".
151 If the zipfile cannot be opened (file don't exist or in not valid), the
152 return value is NULL.
153 Else, the return value is a unzFile Handle, usable with other function
154 of this unzip package.
157 extern int ZEXPORT unzClose OF((unzFile file));
159 Close a ZipFile opened with unzipOpen.
160 If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
161 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
162 return UNZ_OK if there is no problem. */
164 extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
165 unz_global_info *pglobal_info));
167 Write info about the ZipFile in the *pglobal_info structure.
168 No preparation of the structure is needed
169 return UNZ_OK if there is no problem. */
172 extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
173 char *szComment,
174 uLong uSizeBuf));
176 Get the global comment string of the ZipFile, in the szComment buffer.
177 uSizeBuf is the size of the szComment buffer.
178 return the number of byte copied or an error code <0
182 /***************************************************************************/
183 /* Unzip package allow you browse the directory of the zipfile */
185 extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
187 Set the current file of the zipfile to the first file.
188 return UNZ_OK if there is no problem
191 extern int ZEXPORT unzGoToNextFile OF((unzFile file));
193 Set the current file of the zipfile to the next file.
194 return UNZ_OK if there is no problem
195 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
198 extern int ZEXPORT unzLocateFile OF((unzFile file,
199 const char *szFileName,
200 int iCaseSensitivity));
202 Try locate the file szFileName in the zipfile.
203 For the iCaseSensitivity signification, see unzStringFileNameCompare
205 return value :
206 UNZ_OK if the file is found. It becomes the current file.
207 UNZ_END_OF_LIST_OF_FILE if the file is not found
211 extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
212 unz_file_info *pfile_info,
213 char *szFileName,
214 uLong fileNameBufferSize,
215 void *extraField,
216 uLong extraFieldBufferSize,
217 char *szComment,
218 uLong commentBufferSize));
220 Get Info about the current file
221 if pfile_info!=NULL, the *pfile_info structure will contain somes info about
222 the current file
223 if szFileName!=NULL, the filemane string will be copied in szFileName
224 (fileNameBufferSize is the size of the buffer)
225 if extraField!=NULL, the extra field information will be copied in extraField
226 (extraFieldBufferSize is the size of the buffer).
227 This is the Central-header version of the extra field
228 if szComment!=NULL, the comment string of the file will be copied in szComment
229 (commentBufferSize is the size of the buffer)
232 /***************************************************************************/
233 /* for reading the content of the current zipfile, you can open it, read data
234 from it, and close it (you can close it before reading all the file)
237 extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
239 Open for reading data the current file in the zipfile.
240 If there is no error, the return value is UNZ_OK.
243 extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
245 Close the file in zip opened with unzOpenCurrentFile
246 Return UNZ_CRCERROR if all the file was read but the CRC is not good
250 extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
251 voidp buf,
252 unsigned len));
254 Read bytes from the current file (opened by unzOpenCurrentFile)
255 buf contain buffer where data must be copied
256 len the size of buf.
258 return the number of byte copied if somes bytes are copied
259 return 0 if the end of file was reached
260 return <0 with error code if there is an error
261 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
264 extern z_off_t ZEXPORT unztell OF((unzFile file));
266 Give the current position in uncompressed data
269 extern int ZEXPORT unzeof OF((unzFile file));
271 return 1 if the end of file was reached, 0 elsewhere
274 extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
275 voidp buf,
276 unsigned len));
278 Read extra field from the current file (opened by unzOpenCurrentFile)
279 This is the local-header version of the extra field (sometimes, there is
280 more info in the local-header version than in the central-header)
282 if buf==NULL, it return the size of the local extra field
284 if buf!=NULL, len is the size of the buffer, the extra header is copied in
285 buf.
286 the return value is the number of bytes copied in buf, or (if <0)
287 the error code
290 #ifdef __cplusplus
292 #endif
294 #endif /* _unz_H */