00001 /* unzip.h -- IO for uncompress .zip files using zlib 00002 Version 0.15 beta, Mar 19th, 1998, 00003 00004 Copyright (C) 1998 Gilles Vollant 00005 00006 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g 00007 WinZip, InfoZip tools and compatible. 00008 Encryption and multi volume ZipFile (span) are not supported. 00009 Old compressions used by old PKZip 1.x are not supported 00010 00011 THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE 00012 CAN CHANGE IN FUTURE VERSION !! 00013 I WAIT FEEDBACK at mail info@winimage.com 00014 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution 00015 00016 Condition of use and distribution are the same than zlib : 00017 00018 This software is provided 'as-is', without any express or implied 00019 warranty. In no event will the authors be held liable for any damages 00020 arising from the use of this software. 00021 00022 Permission is granted to anyone to use this software for any purpose, 00023 including commercial applications, and to alter it and redistribute it 00024 freely, subject to the following restrictions: 00025 00026 1. The origin of this software must not be misrepresented; you must not 00027 claim that you wrote the original software. If you use this software 00028 in a product, an acknowledgment in the product documentation would be 00029 appreciated but is not required. 00030 2. Altered source versions must be plainly marked as such, and must not be 00031 misrepresented as being the original software. 00032 3. This notice may not be removed or altered from any source distribution. 00033 00034 00035 */ 00036 /* for more info about .ZIP format, see 00037 ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip 00038 PkWare has also a specification at : 00039 ftp://ftp.pkware.com/probdesc.zip */ 00040 00041 #ifndef _unz_H 00042 #define _unz_H 00043 00044 #ifdef __cplusplus 00045 extern "C" { 00046 #endif 00047 00048 #ifndef _ZLIB_H 00049 #include "zlib.h" 00050 #endif 00051 00052 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) 00053 /* like the STRICT of WIN32, we define a pointer that cannot be converted 00054 from (void*) without cast */ 00055 typedef struct TagunzFile__ { int unused; } unzFile__; 00056 typedef unzFile__ *unzFile; 00057 #else 00058 typedef voidp unzFile; 00059 #endif 00060 00061 00062 #define UNZ_OK (0) 00063 #define UNZ_END_OF_LIST_OF_FILE (-100) 00064 #define UNZ_ERRNO (Z_ERRNO) 00065 #define UNZ_EOF (0) 00066 #define UNZ_PARAMERROR (-102) 00067 #define UNZ_BADZIPFILE (-103) 00068 #define UNZ_INTERNALERROR (-104) 00069 #define UNZ_CRCERROR (-105) 00070 00071 /* tm_unz contain date/time info */ 00072 typedef struct tm_unz_s 00073 { 00074 uInt tm_sec; /* seconds after the minute - [0,59] */ 00075 uInt tm_min; /* minutes after the hour - [0,59] */ 00076 uInt tm_hour; /* hours since midnight - [0,23] */ 00077 uInt tm_mday; /* day of the month - [1,31] */ 00078 uInt tm_mon; /* months since January - [0,11] */ 00079 uInt tm_year; /* years - [1980..2044] */ 00080 } tm_unz; 00081 00082 /* unz_global_info structure contain global data about the ZIPfile 00083 These data comes from the end of central dir */ 00084 typedef struct unz_global_info_s 00085 { 00086 uLong number_entry; /* total number of entries in 00087 the central dir on this disk */ 00088 uLong size_comment; /* size of the global comment of the zipfile */ 00089 } unz_global_info; 00090 00091 00092 /* unz_file_info contain information about a file in the zipfile */ 00093 typedef struct unz_file_info_s 00094 { 00095 uLong version; /* version made by 2 bytes */ 00096 uLong version_needed; /* version needed to extract 2 bytes */ 00097 uLong flag; /* general purpose bit flag 2 bytes */ 00098 uLong compression_method; /* compression method 2 bytes */ 00099 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ 00100 uLong crc; /* crc-32 4 bytes */ 00101 uLong compressed_size; /* compressed size 4 bytes */ 00102 uLong uncompressed_size; /* uncompressed size 4 bytes */ 00103 uLong size_filename; /* filename length 2 bytes */ 00104 uLong size_file_extra; /* extra field length 2 bytes */ 00105 uLong size_file_comment; /* file comment length 2 bytes */ 00106 00107 uLong disk_num_start; /* disk number start 2 bytes */ 00108 uLong internal_fa; /* internal file attributes 2 bytes */ 00109 uLong external_fa; /* external file attributes 4 bytes */ 00110 00111 tm_unz tmu_date; 00112 } unz_file_info; 00113 00114 extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, 00115 const char* fileName2, 00116 int iCaseSensitivity)); 00117 /* 00118 Compare two filename (fileName1,fileName2). 00119 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) 00120 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi 00121 or strcasecmp) 00122 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system 00123 (like 1 on Unix, 2 on Windows) 00124 */ 00125 00126 00127 extern unzFile ZEXPORT unzOpen OF((const char *path)); 00128 /* 00129 Open a Zip file. path contain the full pathname (by example, 00130 on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer 00131 "zlib/zlib111.zip". 00132 If the zipfile cannot be opened (file don't exist or in not valid), the 00133 return value is NULL. 00134 Else, the return value is a unzFile Handle, usable with other function 00135 of this unzip package. 00136 */ 00137 00138 extern int ZEXPORT unzClose OF((unzFile file)); 00139 /* 00140 Close a ZipFile opened with unzipOpen. 00141 If there is files inside the .Zip opened with unzOpenCurrentFile (see later), 00142 these files MUST be closed with unzipCloseCurrentFile before call unzipClose. 00143 return UNZ_OK if there is no problem. */ 00144 00145 extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, 00146 unz_global_info *pglobal_info)); 00147 /* 00148 Write info about the ZipFile in the *pglobal_info structure. 00149 No preparation of the structure is needed 00150 return UNZ_OK if there is no problem. */ 00151 00152 00153 extern int ZEXPORT unzGetGlobalComment OF((unzFile file, 00154 char *szComment, 00155 uLong uSizeBuf)); 00156 /* 00157 Get the global comment string of the ZipFile, in the szComment buffer. 00158 uSizeBuf is the size of the szComment buffer. 00159 return the number of byte copied or an error code <0 00160 */ 00161 00162 00163 /***************************************************************************/ 00164 /* Unzip package allow you browse the directory of the zipfile */ 00165 00166 extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); 00167 /* 00168 Set the current file of the zipfile to the first file. 00169 return UNZ_OK if there is no problem 00170 */ 00171 00172 extern int ZEXPORT unzGoToNextFile OF((unzFile file)); 00173 /* 00174 Set the current file of the zipfile to the next file. 00175 return UNZ_OK if there is no problem 00176 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. 00177 */ 00178 00179 extern int ZEXPORT unzLocateFile OF((unzFile file, 00180 const char *szFileName, 00181 int iCaseSensitivity)); 00182 /* 00183 Try locate the file szFileName in the zipfile. 00184 For the iCaseSensitivity signification, see unzStringFileNameCompare 00185 00186 return value : 00187 UNZ_OK if the file is found. It becomes the current file. 00188 UNZ_END_OF_LIST_OF_FILE if the file is not found 00189 */ 00190 00191 00192 extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, 00193 unz_file_info *pfile_info, 00194 char *szFileName, 00195 uLong fileNameBufferSize, 00196 void *extraField, 00197 uLong extraFieldBufferSize, 00198 char *szComment, 00199 uLong commentBufferSize)); 00200 /* 00201 Get Info about the current file 00202 if pfile_info!=NULL, the *pfile_info structure will contain somes info about 00203 the current file 00204 if szFileName!=NULL, the filemane string will be copied in szFileName 00205 (fileNameBufferSize is the size of the buffer) 00206 if extraField!=NULL, the extra field information will be copied in extraField 00207 (extraFieldBufferSize is the size of the buffer). 00208 This is the Central-header version of the extra field 00209 if szComment!=NULL, the comment string of the file will be copied in szComment 00210 (commentBufferSize is the size of the buffer) 00211 */ 00212 00213 /***************************************************************************/ 00214 /* for reading the content of the current zipfile, you can open it, read data 00215 from it, and close it (you can close it before reading all the file) 00216 */ 00217 00218 extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); 00219 /* 00220 Open for reading data the current file in the zipfile. 00221 If there is no error, the return value is UNZ_OK. 00222 */ 00223 00224 extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); 00225 /* 00226 Close the file in zip opened with unzOpenCurrentFile 00227 Return UNZ_CRCERROR if all the file was read but the CRC is not good 00228 */ 00229 00230 extern int ZEXPORT unzReadCurrentFile OF((unzFile file, 00231 voidp buf, 00232 unsigned len)); 00233 /* 00234 Read bytes from the current file (opened by unzOpenCurrentFile) 00235 buf contain buffer where data must be copied 00236 len the size of buf. 00237 00238 return the number of byte copied if somes bytes are copied 00239 return 0 if the end of file was reached 00240 return <0 with error code if there is an error 00241 (UNZ_ERRNO for IO error, or zLib error for uncompress error) 00242 */ 00243 00244 extern z_off_t ZEXPORT unztell OF((unzFile file)); 00245 /* 00246 Give the current position in uncompressed data 00247 */ 00248 00249 extern int ZEXPORT unzeof OF((unzFile file)); 00250 /* 00251 return 1 if the end of file was reached, 0 elsewhere 00252 */ 00253 00254 extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, voidp buf, 00255 unsigned len)); 00256 /* 00257 Read extra field from the current file (opened by unzOpenCurrentFile) 00258 This is the local-header version of the extra field (sometimes, there is 00259 more info in the local-header version than in the central-header) 00260 00261 if buf==NULL, it return the size of the local extra field 00262 00263 if buf!=NULL, len is the size of the buffer, the extra header is copied in 00264 buf. 00265 the return value is the number of bytes copied in buf, or (if <0) 00266 the error code 00267 */ 00268 00269 #ifdef __cplusplus 00270 } 00271 #endif 00272 00273 #endif /* _unz_H */
1.6.3