00001 /* zip.h -- IO for compress .zip files using zlib 00002 Version 1.01, May 8th, 2004 00003 00004 Copyright (C) 1998-2004 Gilles Vollant 00005 Converted to more modern C/C++ by the Pentagram team. 00006 00007 This unzip package allow creates .ZIP file, compatible with PKZip 2.04g 00008 WinZip, InfoZip tools and compatible. 00009 Encryption and multi volume ZipFile (span) are not supported. 00010 Old compressions used by old PKZip 1.x are not supported 00011 00012 For uncompress .zip file, look at unzip.h 00013 00014 00015 I WAIT FEEDBACK at mail info@winimage.com 00016 Visit also http://www.winimage.com/zLibDll/unzip.html for evolution 00017 00018 Condition of use and distribution are the same than zlib : 00019 00020 This software is provided 'as-is', without any express or implied 00021 warranty. In no event will the authors be held liable for any damages 00022 arising from the use of this software. 00023 00024 Permission is granted to anyone to use this software for any purpose, 00025 including commercial applications, and to alter it and redistribute it 00026 freely, subject to the following restrictions: 00027 00028 1. The origin of this software must not be misrepresented; you must not 00029 claim that you wrote the original software. If you use this software 00030 in a product, an acknowledgment in the product documentation would be 00031 appreciated but is not required. 00032 2. Altered source versions must be plainly marked as such, and must not be 00033 misrepresented as being the original software. 00034 3. This notice may not be removed or altered from any source distribution. 00035 00036 00037 */ 00038 00039 /* for more info about .ZIP format, see 00040 http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip 00041 http://www.info-zip.org/pub/infozip/doc/ 00042 PkWare has also a specification at : 00043 ftp://ftp.pkware.com/probdesc.zip 00044 */ 00045 00046 #ifndef _zip_H 00047 #define _zip_H 00048 00049 #ifndef _ZLIB_H 00050 #include "zlib.h" 00051 #endif 00052 00053 #ifndef _ZLIBIOAPI_H 00054 #include "ioapi.h" 00055 #endif 00056 00057 namespace PentZip { 00058 00059 #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) 00060 /* like the STRICT of WIN32, we define a pointer that cannot be converted 00061 from (void*) without cast */ 00062 typedef struct TagzipFile__ { int unused; } zipFile__; 00063 typedef zipFile__ *zipFile; 00064 #else 00065 typedef voidp zipFile; 00066 #endif 00067 00068 #define ZIP_OK (0) 00069 #define ZIP_EOF (0) 00070 #define ZIP_ERRNO (Z_ERRNO) 00071 #define ZIP_PARAMERROR (-102) 00072 #define ZIP_BADZIPFILE (-103) 00073 #define ZIP_INTERNALERROR (-104) 00074 00075 #ifndef DEF_MEM_LEVEL 00076 # if MAX_MEM_LEVEL >= 8 00077 # define DEF_MEM_LEVEL 8 00078 # else 00079 # define DEF_MEM_LEVEL MAX_MEM_LEVEL 00080 # endif 00081 #endif 00082 /* default memLevel */ 00083 00084 /* tm_zip contain date/time info */ 00085 typedef struct tm_zip_s 00086 { 00087 uInt tm_sec; /* seconds after the minute - [0,59] */ 00088 uInt tm_min; /* minutes after the hour - [0,59] */ 00089 uInt tm_hour; /* hours since midnight - [0,23] */ 00090 uInt tm_mday; /* day of the month - [1,31] */ 00091 uInt tm_mon; /* months since January - [0,11] */ 00092 uInt tm_year; /* years - [1980..2044] */ 00093 } tm_zip; 00094 00095 typedef struct 00096 { 00097 tm_zip tmz_date; /* date in understandable format */ 00098 uLong dosDate; /* if dos_date == 0, tmu_date is used */ 00099 /* uLong flag; */ /* general purpose bit flag 2 bytes */ 00100 00101 uLong internal_fa; /* internal file attributes 2 bytes */ 00102 uLong external_fa; /* external file attributes 4 bytes */ 00103 } zip_fileinfo; 00104 00105 typedef const char* zipcharpc; 00106 00107 00108 #define APPEND_STATUS_CREATE (0) 00109 #define APPEND_STATUS_CREATEAFTER (1) 00110 #define APPEND_STATUS_ADDINZIP (2) 00111 00112 extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); 00113 /* 00114 Create a zipfile. 00115 pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on 00116 an Unix computer "zlib/zlib113.zip". 00117 if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip 00118 will be created at the end of the file. 00119 (useful if the file contain a self extractor code) 00120 if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will 00121 add files in existing zip (be sure you don't add file that doesn't exist) 00122 If the zipfile cannot be opened, the return value is NULL. 00123 Else, the return value is a zipFile Handle, usable with other function 00124 of this zip package. 00125 */ 00126 00127 /* Note : there is no delete function into a zipfile. 00128 If you want delete file into a zipfile, you must open a zipfile, and create another 00129 Of couse, you can use RAW reading and writing to copy the file you did not want delte 00130 */ 00131 00132 extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, 00133 int append, 00134 zipcharpc* globalcomment, 00135 zlib_filefunc_def* pzlib_filefunc_def)); 00136 00137 extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, 00138 const char* filename, 00139 const zip_fileinfo* zipfi, 00140 const void* extrafield_local, 00141 uInt size_extrafield_local, 00142 const void* extrafield_global, 00143 uInt size_extrafield_global, 00144 const char* comment, 00145 int method, 00146 int level)); 00147 /* 00148 Open a file in the ZIP for writing. 00149 filename : the filename in zip (if NULL, '-' without quote will be used 00150 *zipfi contain supplemental information 00151 if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local 00152 contains the extrafield data the the local header 00153 if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global 00154 contains the extrafield data the the local header 00155 if comment != NULL, comment contain the comment string 00156 method contain the compression method (0 for store, Z_DEFLATED for deflate) 00157 level contain the level of compression (can be Z_DEFAULT_COMPRESSION) 00158 */ 00159 00160 00161 extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, 00162 const char* filename, 00163 const zip_fileinfo* zipfi, 00164 const void* extrafield_local, 00165 uInt size_extrafield_local, 00166 const void* extrafield_global, 00167 uInt size_extrafield_global, 00168 const char* comment, 00169 int method, 00170 int level, 00171 int raw)); 00172 00173 /* 00174 Same than zipOpenNewFileInZip, except if raw=1, we write raw file 00175 */ 00176 00177 extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, 00178 const char* filename, 00179 const zip_fileinfo* zipfi, 00180 const void* extrafield_local, 00181 uInt size_extrafield_local, 00182 const void* extrafield_global, 00183 uInt size_extrafield_global, 00184 const char* comment, 00185 int method, 00186 int level, 00187 int raw, 00188 int windowBits, 00189 int memLevel, 00190 int strategy, 00191 const char* password, 00192 uLong crcForCtypting)); 00193 00194 /* 00195 Same than zipOpenNewFileInZip2, except 00196 windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 00197 password : crypting password (NULL for no crypting) 00198 crcForCtypting : crc of file to compress (needed for crypting) 00199 */ 00200 00201 00202 extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, 00203 const void* buf, 00204 unsigned len)); 00205 /* 00206 Write data in the zipfile 00207 */ 00208 00209 extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); 00210 /* 00211 Close the current file in the zipfile 00212 */ 00213 00214 extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, 00215 uLong uncompressed_size, 00216 uLong crc32)); 00217 /* 00218 Close the current file in the zipfile, for fiel opened with 00219 parameter raw=1 in zipOpenNewFileInZip2 00220 uncompressed_size and crc32 are value for the uncompressed size 00221 */ 00222 00223 extern int ZEXPORT zipClose OF((zipFile file, 00224 const char* global_comment)); 00225 /* 00226 Close the zipfile 00227 */ 00228 00229 } 00230 00231 #endif /* _zip_H */