Mercurial > vba-clojure
view src/common/unzip.h @ 185:c8ec477beeac
added world directory for practice worldbuilding.
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Thu, 22 Mar 2012 07:02:50 -0500 |
parents | f9f4f1b99eed |
children |
line wrap: on
line source
1 /* unzip.h -- IO for uncompress .zip files using zlib2 Version 0.15 beta, Mar 19th, 1998,4 Copyright (C) 1998 Gilles Vollant6 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g7 WinZip, InfoZip tools and compatible.8 Encryption and multi volume ZipFile (span) are not supported.9 Old compressions used by old PKZip 1.x are not supported11 THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE12 CAN CHANGE IN FUTURE VERSION !!13 I WAIT FEEDBACK at mail info@winimage.com14 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution16 Condition of use and distribution are the same than zlib :18 This software is provided 'as-is', without any express or implied19 warranty. In no event will the authors be held liable for any damages20 arising from the use of this software.22 Permission is granted to anyone to use this software for any purpose,23 including commercial applications, and to alter it and redistribute it24 freely, subject to the following restrictions:26 1. The origin of this software must not be misrepresented; you must not27 claim that you wrote the original software. If you use this software28 in a product, an acknowledgment in the product documentation would be29 appreciated but is not required.30 2. Altered source versions must be plainly marked as such, and must not be31 misrepresented as being the original software.32 3. This notice may not be removed or altered from any source distribution.35 */36 /* for more info about .ZIP format, see37 ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip38 PkWare has also a specification at :39 ftp://ftp.pkware.com/probdesc.zip */41 #ifndef _unz_H42 #define _unz_H44 #ifdef __cplusplus45 extern "C" {46 #endif48 #ifndef _ZLIB_H49 #include "zlib.h"50 #endif52 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)53 /* like the STRICT of WIN32, we define a pointer that cannot be converted54 from (void*) without cast */55 typedef struct TagunzFile__ { int unused; } unzFile__;56 typedef unzFile__ *unzFile;57 #else58 typedef voidp unzFile;59 #endif62 #define UNZ_OK (0)63 #define UNZ_END_OF_LIST_OF_FILE (-100)64 #define UNZ_ERRNO (Z_ERRNO)65 #define UNZ_EOF (0)66 #define UNZ_PARAMERROR (-102)67 #define UNZ_BADZIPFILE (-103)68 #define UNZ_INTERNALERROR (-104)69 #define UNZ_CRCERROR (-105)71 /* tm_unz contain date/time info */72 typedef struct tm_unz_s73 {74 uInt tm_sec; /* seconds after the minute - [0,59] */75 uInt tm_min; /* minutes after the hour - [0,59] */76 uInt tm_hour; /* hours since midnight - [0,23] */77 uInt tm_mday; /* day of the month - [1,31] */78 uInt tm_mon; /* months since January - [0,11] */79 uInt tm_year; /* years - [1980..2044] */80 } tm_unz;82 /* unz_global_info structure contain global data about the ZIPfile83 These data comes from the end of central dir */84 typedef struct unz_global_info_s85 {86 uLong number_entry; /* total number of entries in87 the central dir on this disk */88 uLong size_comment; /* size of the global comment of the zipfile */89 } unz_global_info;92 /* unz_file_info contain information about a file in the zipfile */93 typedef struct unz_file_info_s94 {95 uLong version; /* version made by 2 bytes */96 uLong version_needed; /* version needed to extract 2 bytes */97 uLong flag; /* general purpose bit flag 2 bytes */98 uLong compression_method; /* compression method 2 bytes */99 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */100 uLong crc; /* crc-32 4 bytes */101 uLong compressed_size; /* compressed size 4 bytes */102 uLong uncompressed_size; /* uncompressed size 4 bytes */103 uLong size_filename; /* filename length 2 bytes */104 uLong size_file_extra; /* extra field length 2 bytes */105 uLong size_file_comment; /* file comment length 2 bytes */107 uLong disk_num_start; /* disk number start 2 bytes */108 uLong internal_fa; /* internal file attributes 2 bytes */109 uLong external_fa; /* external file attributes 4 bytes */111 tm_unz tmu_date;112 } unz_file_info;114 extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,115 const char* fileName2,116 int iCaseSensitivity));117 /*118 Compare two filename (fileName1,fileName2).119 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)120 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi121 or strcasecmp)122 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system123 (like 1 on Unix, 2 on Windows)124 */127 extern unzFile ZEXPORT unzOpen OF((const char *path));128 /*129 Open a Zip file. path contain the full pathname (by example,130 on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer131 "zlib/zlib111.zip".132 If the zipfile cannot be opened (file don't exist or in not valid), the133 return value is NULL.134 Else, the return value is a unzFile Handle, usable with other function135 of this unzip package.136 */138 extern int ZEXPORT unzClose OF((unzFile file));139 /*140 Close a ZipFile opened with unzipOpen.141 If there is files inside the .Zip opened with unzOpenCurrentFile (see later),142 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.143 return UNZ_OK if there is no problem. */145 extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,146 unz_global_info *pglobal_info));147 /*148 Write info about the ZipFile in the *pglobal_info structure.149 No preparation of the structure is needed150 return UNZ_OK if there is no problem. */153 extern int ZEXPORT unzGetGlobalComment OF((unzFile file,154 char *szComment,155 uLong uSizeBuf));156 /*157 Get the global comment string of the ZipFile, in the szComment buffer.158 uSizeBuf is the size of the szComment buffer.159 return the number of byte copied or an error code <0160 */163 /***************************************************************************/164 /* Unzip package allow you browse the directory of the zipfile */166 extern int ZEXPORT unzGoToFirstFile OF((unzFile file));167 /*168 Set the current file of the zipfile to the first file.169 return UNZ_OK if there is no problem170 */172 extern int ZEXPORT unzGoToNextFile OF((unzFile file));173 /*174 Set the current file of the zipfile to the next file.175 return UNZ_OK if there is no problem176 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.177 */179 extern int ZEXPORT unzLocateFile OF((unzFile file,180 const char *szFileName,181 int iCaseSensitivity));182 /*183 Try locate the file szFileName in the zipfile.184 For the iCaseSensitivity signification, see unzStringFileNameCompare186 return value :187 UNZ_OK if the file is found. It becomes the current file.188 UNZ_END_OF_LIST_OF_FILE if the file is not found189 */192 extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,193 unz_file_info *pfile_info,194 char *szFileName,195 uLong fileNameBufferSize,196 void *extraField,197 uLong extraFieldBufferSize,198 char *szComment,199 uLong commentBufferSize));200 /*201 Get Info about the current file202 if pfile_info!=NULL, the *pfile_info structure will contain somes info about203 the current file204 if szFileName!=NULL, the filemane string will be copied in szFileName205 (fileNameBufferSize is the size of the buffer)206 if extraField!=NULL, the extra field information will be copied in extraField207 (extraFieldBufferSize is the size of the buffer).208 This is the Central-header version of the extra field209 if szComment!=NULL, the comment string of the file will be copied in szComment210 (commentBufferSize is the size of the buffer)211 */213 /***************************************************************************/214 /* for reading the content of the current zipfile, you can open it, read data215 from it, and close it (you can close it before reading all the file)216 */218 extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));219 /*220 Open for reading data the current file in the zipfile.221 If there is no error, the return value is UNZ_OK.222 */224 extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));225 /*226 Close the file in zip opened with unzOpenCurrentFile227 Return UNZ_CRCERROR if all the file was read but the CRC is not good228 */231 extern int ZEXPORT unzReadCurrentFile OF((unzFile file,232 voidp buf,233 unsigned len));234 /*235 Read bytes from the current file (opened by unzOpenCurrentFile)236 buf contain buffer where data must be copied237 len the size of buf.239 return the number of byte copied if somes bytes are copied240 return 0 if the end of file was reached241 return <0 with error code if there is an error242 (UNZ_ERRNO for IO error, or zLib error for uncompress error)243 */245 extern z_off_t ZEXPORT unztell OF((unzFile file));246 /*247 Give the current position in uncompressed data248 */250 extern int ZEXPORT unzeof OF((unzFile file));251 /*252 return 1 if the end of file was reached, 0 elsewhere253 */255 extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,256 voidp buf,257 unsigned len));258 /*259 Read extra field from the current file (opened by unzOpenCurrentFile)260 This is the local-header version of the extra field (sometimes, there is261 more info in the local-header version than in the central-header)263 if buf==NULL, it return the size of the local extra field265 if buf!=NULL, len is the size of the buffer, the extra header is copied in266 buf.267 the return value is the number of bytes copied in buf, or (if <0)268 the error code269 */271 #ifdef __cplusplus272 }273 #endif275 #endif /* _unz_H */