summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:20:15 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:20:15 -0700
commitc34c1fcbb19852ca35216ad66276f4f86af3fc22 (patch)
tree4bd0972d6c682e474725eca372f6551d539f8768 /contrib
parent02b6cf579f02ec78c052735020a5d3c5723ed641 (diff)
downloadzlib-1.1.2.tar.gz
zlib-1.1.2.tar.bz2
zlib-1.1.2.zip
zlib 1.1.2v1.1.2
Diffstat (limited to 'contrib')
-rw-r--r--contrib/README.contrib4
-rw-r--r--contrib/asm386/zlibvc.def74
-rw-r--r--contrib/asm386/zlibvc.dsp49
-rw-r--r--contrib/asm386/zlibvc.dsw14
-rw-r--r--contrib/minizip/ChangeLogUnzip38
-rw-r--r--contrib/minizip/Makefile25
-rw-r--r--contrib/minizip/miniunz.c508
-rw-r--r--contrib/minizip/minizip.c302
-rw-r--r--contrib/minizip/readme.txt37
-rw-r--r--contrib/minizip/unzip.c1294
-rw-r--r--contrib/minizip/unzip.def15
-rw-r--r--contrib/minizip/unzip.h275
-rw-r--r--contrib/minizip/zip.c716
-rw-r--r--contrib/minizip/zip.def5
-rw-r--r--contrib/minizip/zip.h150
-rw-r--r--contrib/minizip/zlibvc.def74
-rw-r--r--contrib/minizip/zlibvc.dsp651
-rw-r--r--contrib/minizip/zlibvc.dsw41
18 files changed, 4266 insertions, 6 deletions
diff --git a/contrib/README.contrib b/contrib/README.contrib
index 443eb6b..dfe9031 100644
--- a/contrib/README.contrib
+++ b/contrib/README.contrib
@@ -7,6 +7,10 @@ for help about these, not the zlib authors. Thanks.
7asm386/ by Gilles Vollant <info@winimage.com> 7asm386/ by Gilles Vollant <info@winimage.com>
8 386 asm code replacing longest_match(), for Visual C++ 4.2 and ML 6.11c 8 386 asm code replacing longest_match(), for Visual C++ 4.2 and ML 6.11c
9 9
10minizip/ by Gilles Vollant <info@winimage.com>
11 Mini zip and unzip based on zlib
12 See http://www.winimage.com/zLibDll/unzip.html
13
10iostream/ by Kevin Ruland <kevin@rodin.wustl.edu> 14iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
11 A C++ I/O streams interface to the zlib gz* functions 15 A C++ I/O streams interface to the zlib gz* functions
12 16
diff --git a/contrib/asm386/zlibvc.def b/contrib/asm386/zlibvc.def
new file mode 100644
index 0000000..7e9d60d
--- /dev/null
+++ b/contrib/asm386/zlibvc.def
@@ -0,0 +1,74 @@
1LIBRARY "zlib"
2
3DESCRIPTION '"""zlib data compression library"""'
4
5
6VERSION 1.11
7
8
9HEAPSIZE 1048576,8192
10
11EXPORTS
12 adler32 @1
13 compress @2
14 crc32 @3
15 deflate @4
16 deflateCopy @5
17 deflateEnd @6
18 deflateInit2_ @7
19 deflateInit_ @8
20 deflateParams @9
21 deflateReset @10
22 deflateSetDictionary @11
23 gzclose @12
24 gzdopen @13
25 gzerror @14
26 gzflush @15
27 gzopen @16
28 gzread @17
29 gzwrite @18
30 inflate @19
31 inflateEnd @20
32 inflateInit2_ @21
33 inflateInit_ @22
34 inflateReset @23
35 inflateSetDictionary @24
36 inflateSync @25
37 uncompress @26
38 zlibVersion @27
39 gzprintf @28
40 gzputc @29
41 gzgetc @30
42 gzseek @31
43 gzrewind @32
44 gztell @33
45 gzeof @34
46 gzsetparams @35
47 zError @36
48 inflateSyncPoint @37
49 get_crc_table @38
50 compress2 @39
51 gzputs @40
52 gzgets @41
53
54 unzOpen @61
55 unzClose @62
56 unzGetGlobalInfo @63
57 unzGetCurrentFileInfo @64
58 unzGoToFirstFile @65
59 unzGoToNextFile @66
60 unzOpenCurrentFile @67
61 unzReadCurrentFile @68
62 unztell @70
63 unzeof @71
64 unzCloseCurrentFile @72
65 unzGetGlobalComment @73
66 unzStringFileNameCompare @74
67 unzLocateFile @75
68 unzGetLocalExtrafield @76
69
70 zipOpen @80
71 zipOpenNewFileInZip @81
72 zipWriteInFileInZip @82
73 zipCloseFileInZip @83
74 zipClose @84
diff --git a/contrib/asm386/zlibvc.dsp b/contrib/asm386/zlibvc.dsp
index 98676db..a70d4d4 100644
--- a/contrib/asm386/zlibvc.dsp
+++ b/contrib/asm386/zlibvc.dsp
@@ -47,7 +47,8 @@ CFG=zlibvc - Win32 Release
47# PROP Target_Dir "" 47# PROP Target_Dir ""
48CPP=cl.exe 48CPP=cl.exe
49# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c 49# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
50# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c 50# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c
51# SUBTRACT CPP /YX
51MTL=midl.exe 52MTL=midl.exe
52# ADD BASE MTL /nologo /D "NDEBUG" /win32 53# ADD BASE MTL /nologo /D "NDEBUG" /win32
53# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 54# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -76,7 +77,8 @@ LINK32=link.exe
76# PROP Target_Dir "" 77# PROP Target_Dir ""
77CPP=cl.exe 78CPP=cl.exe
78# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c 79# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
79# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /YX /FD /c 80# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /FD /c
81# SUBTRACT CPP /YX
80MTL=midl.exe 82MTL=midl.exe
81# ADD BASE MTL /nologo /D "_DEBUG" /win32 83# ADD BASE MTL /nologo /D "_DEBUG" /win32
82# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 84# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@@ -109,7 +111,8 @@ MTL=midl.exe
109# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 111# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
110CPP=cl.exe 112CPP=cl.exe
111# ADD BASE CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c 113# ADD BASE CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c
112# ADD CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c 114# ADD CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c
115# SUBTRACT CPP /YX
113RSC=rc.exe 116RSC=rc.exe
114# ADD BASE RSC /l 0x40c /d "NDEBUG" 117# ADD BASE RSC /l 0x40c /d "NDEBUG"
115# ADD RSC /l 0x40c /d "NDEBUG" 118# ADD RSC /l 0x40c /d "NDEBUG"
@@ -138,7 +141,8 @@ LINK32=link.exe
138# PROP Target_Dir "" 141# PROP Target_Dir ""
139CPP=cl.exe 142CPP=cl.exe
140# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c 143# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c
141# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c 144# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c
145# SUBTRACT CPP /YX
142MTL=midl.exe 146MTL=midl.exe
143# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 147# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
144# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 148# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -170,7 +174,8 @@ LINK32=link.exe
170# PROP Target_Dir "" 174# PROP Target_Dir ""
171CPP=cl.exe 175CPP=cl.exe
172# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c 176# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c
173# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c 177# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c
178# SUBTRACT CPP /YX
174MTL=midl.exe 179MTL=midl.exe
175# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 180# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
176# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 181# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -534,6 +539,40 @@ DEP_CPP_UNCOM=\
534# End Source File 539# End Source File
535# Begin Source File 540# Begin Source File
536 541
542SOURCE=.\unzip.c
543
544!IF "$(CFG)" == "zlibvc - Win32 Release"
545
546!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
547
548!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
549
550!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
551
552!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
553
554!ENDIF
555
556# End Source File
557# Begin Source File
558
559SOURCE=.\zip.c
560
561!IF "$(CFG)" == "zlibvc - Win32 Release"
562
563!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
564
565!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
566
567!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
568
569!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
570
571!ENDIF
572
573# End Source File
574# Begin Source File
575
537SOURCE=.\zlib.rc 576SOURCE=.\zlib.rc
538# End Source File 577# End Source File
539# Begin Source File 578# Begin Source File
diff --git a/contrib/asm386/zlibvc.dsw b/contrib/asm386/zlibvc.dsw
index b62e50b..493cd87 100644
--- a/contrib/asm386/zlibvc.dsw
+++ b/contrib/asm386/zlibvc.dsw
@@ -3,7 +3,19 @@ Microsoft Developer Studio Workspace File, Format Version 5.00
3 3
4############################################################################### 4###############################################################################
5 5
6Project: "zlibvc"=".\zlibvc.dsp" - Package Owner=<4> 6Project: "zlibstat"=.\zlibstat.dsp - Package Owner=<4>
7
8Package=<5>
9{{{
10}}}
11
12Package=<4>
13{{{
14}}}
15
16###############################################################################
17
18Project: "zlibvc"=.\zlibvc.dsp - Package Owner=<4>
7 19
8Package=<5> 20Package=<5>
9{{{ 21{{{
diff --git a/contrib/minizip/ChangeLogUnzip b/contrib/minizip/ChangeLogUnzip
new file mode 100644
index 0000000..9987c54
--- /dev/null
+++ b/contrib/minizip/ChangeLogUnzip
@@ -0,0 +1,38 @@
1Change in 0.15: (19 Mar 98)
2- fix memory leak in minizip.c
3
4Change in 0.14: (10 Mar 98)
5- fix bugs in minizip.c sample for zipping big file
6- fix problem in month in date handling
7- fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for
8 comment handling
9
10Change in 0.13: (6 Mar 98)
11- fix bugs in zip.c
12- add real minizip sample
13
14Change in 0.12: (4 Mar 98)
15- add zip.c and zip.h for creates .zip file
16- fix change_file_date in miniunz.c for Unix (Jean-loup Gailly)
17- fix miniunz.c for file without specific record for directory
18
19Change in 0.11: (3 Mar 98)
20- fix bug in unzGetCurrentFileInfo for get extra field and comment
21- enhance miniunz sample, remove the bad unztst.c sample
22
23Change in 0.10: (2 Mar 98)
24- fix bug in unzReadCurrentFile
25- rename unzip* to unz* function and structure
26- remove Windows-like hungary notation variable name
27- modify some structure in unzip.h
28- add somes comment in source
29- remove unzipGetcCurrentFile function
30- replace ZUNZEXPORT by ZEXPORT
31- add unzGetLocalExtrafield for get the local extrafield info
32- add a new sample, miniunz.c
33
34Change in 0.4: (25 Feb 98)
35- suppress the type unzipFileInZip.
36 Only on file in the zipfile can be open at the same time
37- fix somes typo in code
38- added tm_unz structure in unzip_file_info (date/time in readable format)
diff --git a/contrib/minizip/Makefile b/contrib/minizip/Makefile
new file mode 100644
index 0000000..a1dfc16
--- /dev/null
+++ b/contrib/minizip/Makefile
@@ -0,0 +1,25 @@
1CC=cc
2CFLAGS=-O -I../..
3
4UNZ_OBJS = miniunz.o unzip.o ../../libz.a
5ZIP_OBJS = minizip.o zip.o ../../libz.a
6
7.c.o:
8 $(CC) -c $(CFLAGS) $*.c
9
10all: miniunz minizip
11
12miniunz: $(UNZ_OBJS)
13 $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS)
14
15minizip: $(ZIP_OBJS)
16 $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
17
18test: miniunz minizip
19 ./minizip test readme.txt
20 ./miniunz -l test.zip
21 mv readme.txt readme.old
22 ./miniunz test.zip
23
24clean:
25 /bin/rm -f *.o *~ minizip miniunz
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c
new file mode 100644
index 0000000..f3b7832
--- /dev/null
+++ b/contrib/minizip/miniunz.c
@@ -0,0 +1,508 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <time.h>
5#include <errno.h>
6#include <fcntl.h>
7
8#ifdef unix
9# include <unistd.h>
10# include <utime.h>
11#else
12# include <direct.h>
13# include <io.h>
14#endif
15
16#include "unzip.h"
17
18#define CASESENSITIVITY (0)
19#define WRITEBUFFERSIZE (8192)
20
21/*
22 mini unzip, demo of unzip package
23
24 usage :
25 Usage : miniunz [-exvlo] file.zip [file_to_extract]
26
27 list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT
28 if it exists
29*/
30
31
32/* change_file_date : change the date/time of a file
33 filename : the filename of the file where date/time must be modified
34 dosdate : the new date at the MSDos format (4 bytes)
35 tmu_date : the SAME new date at the tm_unz format */
36void change_file_date(filename,dosdate,tmu_date)
37 const char *filename;
38 uLong dosdate;
39 tm_unz tmu_date;
40{
41#ifdef WIN32
42 HANDLE hFile;
43 FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
44
45 hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE,
46 0,NULL,OPEN_EXISTING,0,NULL);
47 GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
48 DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
49 LocalFileTimeToFileTime(&ftLocal,&ftm);
50 SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
51 CloseHandle(hFile);
52#else
53#ifdef unix
54 struct utimbuf ut;
55 struct tm newdate;
56 newdate.tm_sec = tmu_date.tm_sec;
57 newdate.tm_min=tmu_date.tm_min;
58 newdate.tm_hour=tmu_date.tm_hour;
59 newdate.tm_mday=tmu_date.tm_mday;
60 newdate.tm_mon=tmu_date.tm_mon;
61 if (tmu_date.tm_year > 1900)
62 newdate.tm_year=tmu_date.tm_year - 1900;
63 else
64 newdate.tm_year=tmu_date.tm_year ;
65 newdate.tm_isdst=-1;
66
67 ut.actime=ut.modtime=mktime(&newdate);
68 utime(filename,&ut);
69#endif
70#endif
71}
72
73
74/* mymkdir and change_file_date are not 100 % portable
75 As I don't know well Unix, I wait feedback for the unix portion */
76
77int mymkdir(dirname)
78 const char* dirname;
79{
80 int ret=0;
81#ifdef WIN32
82 ret = mkdir(dirname);
83#else
84#ifdef unix
85 ret = mkdir (dirname,0775);
86#endif
87#endif
88 return ret;
89}
90
91int makedir (newdir)
92 char *newdir;
93{
94 char *buffer ;
95 char *p;
96 int len = strlen(newdir);
97
98 if (len <= 0)
99 return 0;
100
101 buffer = (char*)malloc(len+1);
102 strcpy(buffer,newdir);
103
104 if (buffer[len-1] == '/') {
105 buffer[len-1] = '\0';
106 }
107 if (mymkdir(buffer) == 0)
108 {
109 free(buffer);
110 return 1;
111 }
112
113 p = buffer+1;
114 while (1)
115 {
116 char hold;
117
118 while(*p && *p != '\\' && *p != '/')
119 p++;
120 hold = *p;
121 *p = 0;
122 if ((mymkdir(buffer) == -1) && (errno == ENOENT))
123 {
124 printf("couldn't create directory %s\n",buffer);
125 free(buffer);
126 return 0;
127 }
128 if (hold == 0)
129 break;
130 *p++ = hold;
131 }
132 free(buffer);
133 return 1;
134}
135
136void do_banner()
137{
138 printf("MiniUnz 0.15, demo of zLib + Unz package written by Gilles Vollant\n");
139 printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n");
140}
141
142void do_help()
143{
144 printf("Usage : miniunz [-exvlo] file.zip [file_to_extract]\n\n") ;
145}
146
147
148int do_list(uf)
149 unzFile uf;
150{
151 uLong i;
152 unz_global_info gi;
153 int err;
154
155 err = unzGetGlobalInfo (uf,&gi);
156 if (err!=UNZ_OK)
157 printf("error %d with zipfile in unzGetGlobalInfo \n",err);
158 printf(" Length Method Size Ratio Date Time CRC-32 Name\n");
159 printf(" ------ ------ ---- ----- ---- ---- ------ ----\n");
160 for (i=0;i<gi.number_entry;i++)
161 {
162 char filename_inzip[256];
163 unz_file_info file_info;
164 uLong ratio=0;
165 const char *string_method;
166 err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
167 if (err!=UNZ_OK)
168 {
169 printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
170 break;
171 }
172 if (file_info.uncompressed_size>0)
173 ratio = (file_info.compressed_size*100)/file_info.uncompressed_size;
174
175 if (file_info.compression_method==0)
176 string_method="Stored";
177 else
178 if (file_info.compression_method==Z_DEFLATED)
179 {
180 uInt iLevel=(uInt)((file_info.flag & 0x6)/2);
181 if (iLevel==0)
182 string_method="Defl:N";
183 else if (iLevel==1)
184 string_method="Defl:X";
185 else if ((iLevel==2) || (iLevel==3))
186 string_method="Defl:F"; /* 2:fast , 3 : extra fast*/
187 }
188 else
189 string_method="Unkn. ";
190
191 printf("%7lu %6s %7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n",
192 file_info.uncompressed_size,string_method,file_info.compressed_size,
193 ratio,
194 (uLong)file_info.tmu_date.tm_mon + 1,
195 (uLong)file_info.tmu_date.tm_mday,
196 (uLong)file_info.tmu_date.tm_year % 100,
197 (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min,
198 (uLong)file_info.crc,filename_inzip);
199 if ((i+1)<gi.number_entry)
200 {
201 err = unzGoToNextFile(uf);
202 if (err!=UNZ_OK)
203 {
204 printf("error %d with zipfile in unzGoToNextFile\n",err);
205 break;
206 }
207 }
208 }
209
210 return 0;
211}
212
213
214int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite)
215 unzFile uf;
216 const int* popt_extract_without_path;
217 int* popt_overwrite;
218{
219 char filename_inzip[256];
220 char* filename_withoutpath;
221 char* p;
222 int err=UNZ_OK;
223 FILE *fout=NULL;
224 void* buf;
225 uInt size_buf;
226
227 unz_file_info file_info;
228 uLong ratio=0;
229 err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
230
231 if (err!=UNZ_OK)
232 {
233 printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
234 return err;
235 }
236
237 size_buf = WRITEBUFFERSIZE;
238 buf = (void*)malloc(size_buf);
239 if (buf==NULL)
240 {
241 printf("Error allocating memory\n");
242 return UNZ_INTERNALERROR;
243 }
244
245 p = filename_withoutpath = filename_inzip;
246 while ((*p) != '\0')
247 {
248 if (((*p)=='/') || ((*p)=='\\'))
249 filename_withoutpath = p+1;
250 p++;
251 }
252
253 if ((*filename_withoutpath)=='\0')
254 {
255 if ((*popt_extract_without_path)==0)
256 {
257 printf("creating directory: %s\n",filename_inzip);
258 mymkdir(filename_inzip);
259 }
260 }
261 else
262 {
263 const char* write_filename;
264 int skip=0;
265
266 if ((*popt_extract_without_path)==0)
267 write_filename = filename_inzip;
268 else
269 write_filename = filename_withoutpath;
270
271 err = unzOpenCurrentFile(uf);
272 if (err!=UNZ_OK)
273 {
274 printf("error %d with zipfile in unzOpenCurrentFile\n",err);
275 }
276
277 if (((*popt_overwrite)==0) && (err==UNZ_OK))
278 {
279 char rep;
280 FILE* ftestexist;
281 ftestexist = fopen(write_filename,"rb");
282 if (ftestexist!=NULL)
283 {
284 fclose(ftestexist);
285 do
286 {
287 char answer[128];
288 printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
289 scanf("%1s",answer);
290 rep = answer[0] ;
291 if ((rep>='a') && (rep<='z'))
292 rep -= 0x20;
293 }
294 while ((rep!='Y') && (rep!='N') && (rep!='A'));
295 }
296
297 if (rep == 'N')
298 skip = 1;
299
300 if (rep == 'A')
301 *popt_overwrite=1;
302 }
303
304 if ((skip==0) && (err==UNZ_OK))
305 {
306 fout=fopen(write_filename,"wb");
307
308 /* some zipfile don't contain directory alone before file */
309 if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
310 (filename_withoutpath!=(char*)filename_inzip))
311 {
312 char c=*(filename_withoutpath-1);
313 *(filename_withoutpath-1)='\0';
314 makedir(write_filename);
315 *(filename_withoutpath-1)=c;
316 fout=fopen(write_filename,"wb");
317 }
318
319 if (fout==NULL)
320 {
321 printf("error opening %s\n",write_filename);
322 }
323 }
324
325 if (fout!=NULL)
326 {
327 printf(" extracting: %s\n",write_filename);
328
329 do
330 {
331 err = unzReadCurrentFile(uf,buf,size_buf);
332 if (err<0)
333 {
334 printf("error %d with zipfile in unzReadCurrentFile\n",err);
335 break;
336 }
337 if (err>0)
338 if (fwrite(buf,err,1,fout)!=1)
339 {
340 printf("error in writing extracted file\n");
341 err=UNZ_ERRNO;
342 break;
343 }
344 }
345 while (err>0);
346 fclose(fout);
347 if (err==0)
348 change_file_date(write_filename,file_info.dosDate,
349 file_info.tmu_date);
350 }
351
352 if (err==UNZ_OK)
353 {
354 err = unzCloseCurrentFile (uf);
355 if (err!=UNZ_OK)
356 {
357 printf("error %d with zipfile in unzCloseCurrentFile\n",err);
358 }
359 }
360 else
361 unzCloseCurrentFile(uf); /* don't lose the error */
362 }
363
364 free(buf);
365 return err;
366}
367
368
369int do_extract(uf,opt_extract_without_path,opt_overwrite)
370 unzFile uf;
371 int opt_extract_without_path;
372 int opt_overwrite;
373{
374 uLong i;
375 unz_global_info gi;
376 int err;
377 FILE* fout=NULL;
378
379 err = unzGetGlobalInfo (uf,&gi);
380 if (err!=UNZ_OK)
381 printf("error %d with zipfile in unzGetGlobalInfo \n",err);
382
383 for (i=0;i<gi.number_entry;i++)
384 {
385 if (do_extract_currentfile(uf,&opt_extract_without_path,
386 &opt_overwrite) != UNZ_OK)
387 break;
388
389 if ((i+1)<gi.number_entry)
390 {
391 err = unzGoToNextFile(uf);
392 if (err!=UNZ_OK)
393 {
394 printf("error %d with zipfile in unzGoToNextFile\n",err);
395 break;
396 }
397 }
398 }
399
400 return 0;
401}
402
403int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite)
404 unzFile uf;
405 const char* filename;
406 int opt_extract_without_path;
407 int opt_overwrite;
408{
409 int err = UNZ_OK;
410 if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
411 {
412 printf("file %s not found in the zipfile\n",filename);
413 return 2;
414 }
415
416 if (do_extract_currentfile(uf,&opt_extract_without_path,
417 &opt_overwrite) == UNZ_OK)
418 return 0;
419 else
420 return 1;
421}
422
423
424int main(argc,argv)
425 int argc;
426 char *argv[];
427{
428 const char *zipfilename=NULL;
429 const char *filename_to_extract=NULL;
430 int i;
431 int opt_do_list=0;
432 int opt_do_extract=1;
433 int opt_do_extract_withoutpath=0;
434 int opt_overwrite=0;
435 char filename_try[512];
436 unzFile uf=NULL;
437
438 do_banner();
439 if (argc==1)
440 {
441 do_help();
442 exit(0);
443 }
444 else
445 {
446 for (i=1;i<argc;i++)
447 {
448 if ((*argv[i])=='-')
449 {
450 const char *p=argv[i]+1;
451
452 while ((*p)!='\0')
453 {
454 char c=*(p++);;
455 if ((c=='l') || (c=='L'))
456 opt_do_list = 1;
457 if ((c=='v') || (c=='V'))
458 opt_do_list = 1;
459 if ((c=='x') || (c=='X'))
460 opt_do_extract = 1;
461 if ((c=='e') || (c=='E'))
462 opt_do_extract = opt_do_extract_withoutpath = 1;
463 if ((c=='o') || (c=='O'))
464 opt_overwrite=1;
465 }
466 }
467 else
468 {
469 if (zipfilename == NULL)
470 zipfilename = argv[i];
471 else if (filename_to_extract==NULL)
472 filename_to_extract = argv[i] ;
473 }
474 }
475 }
476
477 if (zipfilename!=NULL)
478 {
479 strcpy(filename_try,zipfilename);
480 uf = unzOpen(zipfilename);
481 if (uf==NULL)
482 {
483 strcat(filename_try,".zip");
484 uf = unzOpen(filename_try);
485 }
486 }
487
488 if (uf==NULL)
489 {
490 printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename);
491 exit (1);
492 }
493 printf("%s opened\n",filename_try);
494
495 if (opt_do_list==1)
496 return do_list(uf);
497 else if (opt_do_extract==1)
498 {
499 if (filename_to_extract == NULL)
500 return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite);
501 else
502 return do_extract_onefile(uf,filename_to_extract,
503 opt_do_extract_withoutpath,opt_overwrite);
504 }
505 unzCloseCurrentFile(uf);
506
507 return 0; /* to avoid warning */
508}
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c
new file mode 100644
index 0000000..5e492d2
--- /dev/null
+++ b/contrib/minizip/minizip.c
@@ -0,0 +1,302 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <time.h>
5#include <errno.h>
6#include <fcntl.h>
7
8#ifdef unix
9# include <unistd.h>
10# include <utime.h>
11# include <sys/types.h>
12# include <sys/stat.h>
13#else
14# include <direct.h>
15# include <io.h>
16#endif
17
18#include "zip.h"
19
20
21#define WRITEBUFFERSIZE (16384)
22#define MAXFILENAME (256)
23
24#ifdef WIN32
25uLong filetime(f, tmzip, dt)
26 char *f; /* name of file to get info on */
27 tm_zip *tmzip; /* return value: access, modific. and creation times */
28 uLong *dt; /* dostime */
29{
30 int ret = 0;
31 {
32 FILETIME ftLocal;
33 HANDLE hFind;
34 WIN32_FIND_DATA ff32;
35
36 hFind = FindFirstFile(f,&ff32);
37 if (hFind != INVALID_HANDLE_VALUE)
38 {
39 FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
40 FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
41 FindClose(hFind);
42 ret = 1;
43 }
44 }
45 return ret;
46}
47#else
48#ifdef unix
49uLong filetime(f, tmzip, dt)
50 char *f; /* name of file to get info on */
51 tm_zip *tmzip; /* return value: access, modific. and creation times */
52 uLong *dt; /* dostime */
53{
54 int ret=0;
55 struct stat s; /* results of stat() */
56 struct tm* filedate;
57 time_t tm_t=0;
58
59 if (strcmp(f,"-")!=0)
60 {
61 char name[MAXFILENAME];
62 int len = strlen(f);
63 strcpy(name, f);
64 if (name[len - 1] == '/')
65 name[len - 1] = '\0';
66 /* not all systems allow stat'ing a file with / appended */
67 if (stat(name,&s)==0)
68 {
69 tm_t = s.st_mtime;
70 ret = 1;
71 }
72 }
73 filedate = localtime(&tm_t);
74
75 tmzip->tm_sec = filedate->tm_sec;
76 tmzip->tm_min = filedate->tm_min;
77 tmzip->tm_hour = filedate->tm_hour;
78 tmzip->tm_mday = filedate->tm_mday;
79 tmzip->tm_mon = filedate->tm_mon ;
80 tmzip->tm_year = filedate->tm_year;
81
82 return ret;
83}
84#else
85uLong filetime(f, tmzip, dt)
86 char *f; /* name of file to get info on */
87 tm_zip *tmzip; /* return value: access, modific. and creation times */
88 uLong *dt; /* dostime */
89{
90 return 0;
91}
92#endif
93#endif
94
95
96
97
98int check_exist_file(filename)
99 const char* filename;
100{
101 FILE* ftestexist;
102 int ret = 1;
103 ftestexist = fopen(filename,"rb");
104 if (ftestexist==NULL)
105 ret = 0;
106 else
107 fclose(ftestexist);
108 return ret;
109}
110
111void do_banner()
112{
113 printf("MiniZip 0.15, demo of zLib + Zip package written by Gilles Vollant\n");
114 printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n");
115}
116
117void do_help()
118{
119 printf("Usage : minizip [-o] file.zip [files_to_add]\n\n") ;
120}
121
122int main(argc,argv)
123 int argc;
124 char *argv[];
125{
126 int i;
127 int opt_overwrite=0;
128 int opt_compress_level=Z_DEFAULT_COMPRESSION;
129 int zipfilenamearg = 0;
130 char filename_try[MAXFILENAME];
131 int zipok;
132 int err=0;
133 int size_buf=0;
134 void* buf=NULL,
135
136
137 do_banner();
138 if (argc==1)
139 {
140 do_help();
141 exit(0);
142 return 0;
143 }
144 else
145 {
146 for (i=1;i<argc;i++)
147 {
148 if ((*argv[i])=='-')
149 {
150 const char *p=argv[i]+1;
151
152 while ((*p)!='\0')
153 {
154 char c=*(p++);;
155 if ((c=='o') || (c=='O'))
156 opt_overwrite = 1;
157 if ((c>='0') && (c<='9'))
158 opt_compress_level = c-'0';
159 }
160 }
161 else
162 if (zipfilenamearg == 0)
163 zipfilenamearg = i ;
164 }
165 }
166
167 size_buf = WRITEBUFFERSIZE;
168 buf = (void*)malloc(size_buf);
169 if (buf==NULL)
170 {
171 printf("Error allocating memory\n");
172 return ZIP_INTERNALERROR;
173 }
174
175 if (zipfilenamearg==0)
176 zipok=0;
177 else
178 {
179 int i,len;
180 int dot_found=0;
181
182 zipok = 1 ;
183 strcpy(filename_try,argv[zipfilenamearg]);
184 len=strlen(filename_try);
185 for (i=0;i<len;i++)
186 if (filename_try[i]=='.')
187 dot_found=1;
188
189 if (dot_found==0)
190 strcat(filename_try,".zip");
191
192 if (opt_overwrite==0)
193 if (check_exist_file(filename_try)!=0)
194 {
195 char rep;
196 do
197 {
198 char answer[128];
199 printf("The file %s exist. Overwrite ? [y]es, [n]o : ",filename_try);
200 scanf("%1s",answer);
201 rep = answer[0] ;
202 if ((rep>='a') && (rep<='z'))
203 rep -= 0x20;
204 }
205 while ((rep!='Y') && (rep!='N'));
206 if (rep=='N')
207 zipok = 0;
208 }
209 }
210
211 if (zipok==1)
212 {
213 zipFile zf;
214 int errclose;
215 zf = zipOpen(filename_try,0);
216 if (zf == NULL)
217 {
218 printf("error opening %s\n",filename_try);
219 err= ZIP_ERRNO;
220 }
221 else
222 printf("creating %s\n",filename_try);
223
224 for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++)
225 {
226 if (((*(argv[i]))!='-') && ((*(argv[i]))!='/'))
227 {
228 FILE * fin;
229 int size_read;
230 const char* filenameinzip = argv[i];
231 zip_fileinfo zi;
232
233 zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
234 zi.tmz_date.tm_mday = zi.tmz_date.tm_min = zi.tmz_date.tm_year = 0;
235 zi.dosDate = 0;
236 zi.internal_fa = 0;
237 zi.external_fa = 0;
238 filetime(filenameinzip,&zi.tmz_date,&zi.dosDate);
239
240
241 err = zipOpenNewFileInZip(zf,filenameinzip,&zi,
242 NULL,0,NULL,0,NULL /* comment*/,
243 (opt_compress_level != 0) ? Z_DEFLATED : 0,
244 opt_compress_level);
245
246 if (err != ZIP_OK)
247 printf("error in opening %s in zipfile\n",filenameinzip);
248 else
249 {
250 fin = fopen(filenameinzip,"rb");
251 if (fin==NULL)
252 {
253 err=ZIP_ERRNO;
254 printf("error in opening %s for reading\n",filenameinzip);
255 }
256 }
257
258 if (err == ZIP_OK)
259 do
260 {
261 err = ZIP_OK;
262 size_read = fread(buf,1,size_buf,fin);
263 if (size_read < size_buf)
264 if (feof(fin)==0)
265 {
266 printf("error in reading %s\n",filenameinzip);
267 err = ZIP_ERRNO;
268 }
269
270 if (size_read>0)
271 {
272 err = zipWriteInFileInZip (zf,buf,size_read);
273 if (err<0)
274 {
275 printf("error in writing %s in the zipfile\n",
276 filenameinzip);
277 }
278
279 }
280 } while ((err == ZIP_OK) && (size_read>0));
281
282 fclose(fin);
283 if (err<0)
284 err=ZIP_ERRNO;
285 else
286 {
287 err = zipCloseFileInZip(zf);
288 if (err!=ZIP_OK)
289 printf("error in closing %s in the zipfile\n",
290 filenameinzip);
291 }
292 }
293 }
294 errclose = zipClose(zf,NULL);
295 if (errclose != ZIP_OK)
296 printf("error in closing %s\n",filename_try);
297 }
298
299 free(buf);
300 exit(0);
301 return 0; /* to avoid warning */
302}
diff --git a/contrib/minizip/readme.txt b/contrib/minizip/readme.txt
new file mode 100644
index 0000000..1fc023c
--- /dev/null
+++ b/contrib/minizip/readme.txt
@@ -0,0 +1,37 @@
1
2UnZip 0.15 additionnal library
3
4
5 This unzip package allow extract file from .ZIP file, compatible with
6PKZip 2.04g, WinZip, InfoZip tools and compatible.
7
8 Multi volume ZipFile (span) are not supported, and old compression used by old
9PKZip 1.x are not supported.
10
11See probdesc.zip from PKWare for specification of .ZIP format.
12
13What is Unzip
14 The Zlib library support the deflate compression and the creation of gzip (.gz)
15file. Zlib is free and small.
16 The .Zip format, which can contain several compressed files (.gz can containt
17only one file) is a very popular format. This is why I've written a package for reading file compressed in Zipfile.
18
19Using Unzip package
20
21You need source of Zlib (get zlib111.zip and read zlib.h).
22Get unzlb015.zip and read unzip.h (whith documentation of unzip functions)
23
24The Unzip package is only two file : unzip.h and unzip.c. But it use the Zlib
25 files.
26unztst.c is a simple sample program, which list file in a zipfile and display
27 README.TXT or FILE_ID.DIZ (if these files are found).
28miniunz.c is a mini unzip program.
29
30I'm also currenlyt writing a zipping portion (zip.h, zip.c and test with minizip.c)
31
32Please email me for feedback.
33I hope my source is compatible with Unix system, but I need your help for be sure
34
35Latest revision : Mar 04th, 1998
36
37Check http://www.winimage.com/zLibDll/unzip.html for up to date info.
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c
new file mode 100644
index 0000000..78a8473
--- /dev/null
+++ b/contrib/minizip/unzip.c
@@ -0,0 +1,1294 @@
1/* unzip.c -- IO on .zip files using zlib
2 Version 0.15 beta, Mar 19th, 1998,
3
4 Read unzip.h for more info
5*/
6
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include "zlib.h"
12#include "unzip.h"
13
14#ifdef STDC
15# include <stddef.h>
16# include <string.h>
17# include <stdlib.h>
18#endif
19#ifdef NO_ERRNO_H
20 extern int errno;
21#else
22# include <errno.h>
23#endif
24
25
26#ifndef local
27# define local static
28#endif
29/* compile with -Dlocal if your debugger can't find static symbols */
30
31
32
33#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \
34 !defined(CASESENSITIVITYDEFAULT_NO)
35#define CASESENSITIVITYDEFAULT_NO
36#endif
37
38
39#ifndef UNZ_BUFSIZE
40#define UNZ_BUFSIZE (16384)
41#endif
42
43#ifndef UNZ_MAXFILENAMEINZIP
44#define UNZ_MAXFILENAMEINZIP (256)
45#endif
46
47#ifndef ALLOC
48# define ALLOC(size) (malloc(size))
49#endif
50#ifndef TRYFREE
51# define TRYFREE(p) {if (p) free(p);}
52#endif
53
54#define SIZECENTRALDIRITEM (0x2e)
55#define SIZEZIPLOCALHEADER (0x1e)
56
57
58/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
59
60#ifndef SEEK_CUR
61#define SEEK_CUR 1
62#endif
63
64#ifndef SEEK_END
65#define SEEK_END 2
66#endif
67
68#ifndef SEEK_SET
69#define SEEK_SET 0
70#endif
71
72const char unz_copyright[] =
73 " unzip 0.15 Copyright 1998 Gilles Vollant ";
74
75/* unz_file_info_interntal contain internal info about a file in zipfile*/
76typedef struct unz_file_info_internal_s
77{
78 uLong offset_curfile;/* relative offset of local header 4 bytes */
79} unz_file_info_internal;
80
81
82/* file_in_zip_read_info_s contain internal information about a file in zipfile,
83 when reading and decompress it */
84typedef struct
85{
86 char *read_buffer; /* internal buffer for compressed data */
87 z_stream stream; /* zLib stream structure for inflate */
88
89 uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
90 uLong stream_initialised; /* flag set if stream structure is initialised*/
91
92 uLong offset_local_extrafield;/* offset of the local extra field */
93 uInt size_local_extrafield;/* size of the local extra field */
94 uLong pos_local_extrafield; /* position in the local extra field in read*/
95
96 uLong crc32; /* crc32 of all data uncompressed */
97 uLong crc32_wait; /* crc32 we must obtain after decompress all */
98 uLong rest_read_compressed; /* number of byte to be decompressed */
99 uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
100 FILE* file; /* io structore of the zipfile */
101 uLong compression_method; /* compression method (0==store) */
102 uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
103} file_in_zip_read_info_s;
104
105
106/* unz_s contain internal information about the zipfile
107*/
108typedef struct
109{
110 FILE* file; /* io structore of the zipfile */
111 unz_global_info gi; /* public global information */
112 uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
113 uLong num_file; /* number of the current file in the zipfile*/
114 uLong pos_in_central_dir; /* pos of the current file in the central dir*/
115 uLong current_file_ok; /* flag about the usability of the current file*/
116 uLong central_pos; /* position of the beginning of the central dir*/
117
118 uLong size_central_dir; /* size of the central directory */
119 uLong offset_central_dir; /* offset of start of central directory with
120 respect to the starting disk number */
121
122 unz_file_info cur_file_info; /* public info about the current file in zip*/
123 unz_file_info_internal cur_file_info_internal; /* private info about it*/
124 file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
125 file if we are decompressing it */
126} unz_s;
127
128
129/* ===========================================================================
130 Read a byte from a gz_stream; update next_in and avail_in. Return EOF
131 for end of file.
132 IN assertion: the stream s has been sucessfully opened for reading.
133*/
134
135
136local int unzlocal_getByte(fin,pi)
137 FILE *fin;
138 int *pi;
139{
140 unsigned char c;
141 int err = fread(&c, 1, 1, fin);
142 if (err==1)
143 {
144 *pi = (int)c;
145 return UNZ_OK;
146 }
147 else
148 {
149 if (ferror(fin))
150 return UNZ_ERRNO;
151 else
152 return UNZ_EOF;
153 }
154}
155
156
157/* ===========================================================================
158 Reads a long in LSB order from the given gz_stream. Sets
159*/
160local int unzlocal_getShort (fin,pX)
161 FILE* fin;
162 uLong *pX;
163{
164 uLong x ;
165 int i;
166 int err;
167
168 err = unzlocal_getByte(fin,&i);
169 x = (uLong)i;
170
171 if (err==UNZ_OK)
172 err = unzlocal_getByte(fin,&i);
173 x += ((uLong)i)<<8;
174
175 if (err==UNZ_OK)
176 *pX = x;
177 else
178 *pX = 0;
179 return err;
180}
181
182local int unzlocal_getLong (fin,pX)
183 FILE* fin;
184 uLong *pX;
185{
186 uLong x ;
187 int i;
188 int err;
189
190 err = unzlocal_getByte(fin,&i);
191 x = (uLong)i;
192
193 if (err==UNZ_OK)
194 err = unzlocal_getByte(fin,&i);
195 x += ((uLong)i)<<8;
196
197 if (err==UNZ_OK)
198 err = unzlocal_getByte(fin,&i);
199 x += ((uLong)i)<<16;
200
201 if (err==UNZ_OK)
202 err = unzlocal_getByte(fin,&i);
203 x += ((uLong)i)<<24;
204
205 if (err==UNZ_OK)
206 *pX = x;
207 else
208 *pX = 0;
209 return err;
210}
211
212
213/* My own strcmpi / strcasecmp */
214local int strcmpcasenosensitive_internal (fileName1,fileName2)
215 const char* fileName1;
216 const char* fileName2;
217{
218 for (;;)
219 {
220 char c1=*(fileName1++);
221 char c2=*(fileName2++);
222 if ((c1>='a') && (c1<='z'))
223 c1 -= 0x20;
224 if ((c2>='a') && (c2<='z'))
225 c2 -= 0x20;
226 if (c1=='\0')
227 return ((c2=='\0') ? 0 : -1);
228 if (c2=='\0')
229 return 1;
230 if (c1<c2)
231 return -1;
232 if (c1>c2)
233 return 1;
234 }
235}
236
237
238#ifdef CASESENSITIVITYDEFAULT_NO
239#define CASESENSITIVITYDEFAULTVALUE 2
240#else
241#define CASESENSITIVITYDEFAULTVALUE 1
242#endif
243
244#ifndef STRCMPCASENOSENTIVEFUNCTION
245#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
246#endif
247
248/*
249 Compare two filename (fileName1,fileName2).
250 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
251 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
252 or strcasecmp)
253 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
254 (like 1 on Unix, 2 on Windows)
255
256*/
257extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
258 const char* fileName1;
259 const char* fileName2;
260 int iCaseSensitivity;
261{
262 if (iCaseSensitivity==0)
263 iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
264
265 if (iCaseSensitivity==1)
266 return strcmp(fileName1,fileName2);
267
268 return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
269}
270
271#define BUFREADCOMMENT (0x400)
272
273/*
274 Locate the Central directory of a zipfile (at the end, just before
275 the global comment)
276*/
277local uLong unzlocal_SearchCentralDir(fin)
278 FILE *fin;
279{
280 unsigned char* buf;
281 uLong uSizeFile;
282 uLong uBackRead;
283 uLong uMaxBack=0xffff; /* maximum size of global comment */
284 uLong uPosFound=0;
285
286 if (fseek(fin,0,SEEK_END) != 0)
287 return 0;
288
289
290 uSizeFile = ftell( fin );
291
292 if (uMaxBack>uSizeFile)
293 uMaxBack = uSizeFile;
294
295 buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
296 if (buf==NULL)
297 return 0;
298
299 uBackRead = 4;
300 while (uBackRead<uMaxBack)
301 {
302 uLong uReadSize,uReadPos ;
303 int i;
304 if (uBackRead+BUFREADCOMMENT>uMaxBack)
305 uBackRead = uMaxBack;
306 else
307 uBackRead+=BUFREADCOMMENT;
308 uReadPos = uSizeFile-uBackRead ;
309
310 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
311 (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
312 if (fseek(fin,uReadPos,SEEK_SET)!=0)
313 break;
314
315 if (fread(buf,(uInt)uReadSize,1,fin)!=1)
316 break;
317
318 for (i=0;i<(int)uReadSize-3;i++)
319 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
320 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
321 {
322 uPosFound = uReadPos+i;
323 break;
324 }
325
326 if (uPosFound!=0)
327 break;
328 }
329 TRYFREE(buf);
330 return uPosFound;
331}
332
333/*
334 Open a Zip file. path contain the full pathname (by example,
335 on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer
336 "zlib/zlib109.zip".
337 If the zipfile cannot be opened (file don't exist or in not valid), the
338 return value is NULL.
339 Else, the return value is a unzFile Handle, usable with other function
340 of this unzip package.
341*/
342extern unzFile ZEXPORT unzOpen (path)
343 const char *path;
344{
345 unz_s us;
346 unz_s *s;
347 uLong central_pos,uL;
348 FILE * fin ;
349
350 uLong number_disk; /* number of the current dist, used for
351 spaning ZIP, unsupported, always 0*/
352 uLong number_disk_with_CD; /* number the the disk with central dir, used
353 for spaning ZIP, unsupported, always 0*/
354 uLong number_entry_CD; /* total number of entries in
355 the central dir
356 (same than number_entry on nospan) */
357
358 int err=UNZ_OK;
359
360 if (unz_copyright[0]!=' ')
361 return NULL;
362
363 fin=fopen(path,"rb");
364 if (fin==NULL)
365 return NULL;
366
367 central_pos = unzlocal_SearchCentralDir(fin);
368 if (central_pos==0)
369 err=UNZ_ERRNO;
370
371 if (fseek(fin,central_pos,SEEK_SET)!=0)
372 err=UNZ_ERRNO;
373
374 /* the signature, already checked */
375 if (unzlocal_getLong(fin,&uL)!=UNZ_OK)
376 err=UNZ_ERRNO;
377
378 /* number of this disk */
379 if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK)
380 err=UNZ_ERRNO;
381
382 /* number of the disk with the start of the central directory */
383 if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK)
384 err=UNZ_ERRNO;
385
386 /* total number of entries in the central dir on this disk */
387 if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK)
388 err=UNZ_ERRNO;
389
390 /* total number of entries in the central dir */
391 if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK)
392 err=UNZ_ERRNO;
393
394 if ((number_entry_CD!=us.gi.number_entry) ||
395 (number_disk_with_CD!=0) ||
396 (number_disk!=0))
397 err=UNZ_BADZIPFILE;
398
399 /* size of the central directory */
400 if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)
401 err=UNZ_ERRNO;
402
403 /* offset of start of central directory with respect to the
404 starting disk number */
405 if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)
406 err=UNZ_ERRNO;
407
408 /* zipfile comment length */
409 if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)
410 err=UNZ_ERRNO;
411
412 if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
413 (err==UNZ_OK))
414 err=UNZ_BADZIPFILE;
415
416 if (err!=UNZ_OK)
417 {
418 fclose(fin);
419 return NULL;
420 }
421
422 us.file=fin;
423 us.byte_before_the_zipfile = central_pos -
424 (us.offset_central_dir+us.size_central_dir);
425 us.central_pos = central_pos;
426 us.pfile_in_zip_read = NULL;
427
428
429 s=(unz_s*)ALLOC(sizeof(unz_s));
430 *s=us;
431 unzGoToFirstFile((unzFile)s);
432 return (unzFile)s;
433}
434
435
436/*
437 Close a ZipFile opened with unzipOpen.
438 If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
439 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
440 return UNZ_OK if there is no problem. */
441extern int ZEXPORT unzClose (file)
442 unzFile file;
443{
444 unz_s* s;
445 if (file==NULL)
446 return UNZ_PARAMERROR;
447 s=(unz_s*)file;
448
449 if (s->pfile_in_zip_read!=NULL)
450 unzCloseCurrentFile(file);
451
452 fclose(s->file);
453 TRYFREE(s);
454 return UNZ_OK;
455}
456
457
458/*
459 Write info about the ZipFile in the *pglobal_info structure.
460 No preparation of the structure is needed
461 return UNZ_OK if there is no problem. */
462extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
463 unzFile file;
464 unz_global_info *pglobal_info;
465{
466 unz_s* s;
467 if (file==NULL)
468 return UNZ_PARAMERROR;
469 s=(unz_s*)file;
470 *pglobal_info=s->gi;
471 return UNZ_OK;
472}
473
474
475/*
476 Translate date/time from Dos format to tm_unz (readable more easilty)
477*/
478local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
479 uLong ulDosDate;
480 tm_unz* ptm;
481{
482 uLong uDate;
483 uDate = (uLong)(ulDosDate>>16);
484 ptm->tm_mday = (uInt)(uDate&0x1f) ;
485 ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
486 ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
487
488 ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
489 ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
490 ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
491}
492
493/*
494 Get Info about the current file in the zipfile, with internal only info
495*/
496local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
497 unz_file_info *pfile_info,
498 unz_file_info_internal
499 *pfile_info_internal,
500 char *szFileName,
501 uLong fileNameBufferSize,
502 void *extraField,
503 uLong extraFieldBufferSize,
504 char *szComment,
505 uLong commentBufferSize));
506
507local int unzlocal_GetCurrentFileInfoInternal (file,
508 pfile_info,
509 pfile_info_internal,
510 szFileName, fileNameBufferSize,
511 extraField, extraFieldBufferSize,
512 szComment, commentBufferSize)
513 unzFile file;
514 unz_file_info *pfile_info;
515 unz_file_info_internal *pfile_info_internal;
516 char *szFileName;
517 uLong fileNameBufferSize;
518 void *extraField;
519 uLong extraFieldBufferSize;
520 char *szComment;
521 uLong commentBufferSize;
522{
523 unz_s* s;
524 unz_file_info file_info;
525 unz_file_info_internal file_info_internal;
526 int err=UNZ_OK;
527 uLong uMagic;
528 long lSeek=0;
529
530 if (file==NULL)
531 return UNZ_PARAMERROR;
532 s=(unz_s*)file;
533 if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0)
534 err=UNZ_ERRNO;
535
536
537 /* we check the magic */
538 if (err==UNZ_OK)
539 if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
540 err=UNZ_ERRNO;
541 else if (uMagic!=0x02014b50)
542 err=UNZ_BADZIPFILE;
543
544 if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
545 err=UNZ_ERRNO;
546
547 if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK)
548 err=UNZ_ERRNO;
549
550 if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK)
551 err=UNZ_ERRNO;
552
553 if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK)
554 err=UNZ_ERRNO;
555
556 if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK)
557 err=UNZ_ERRNO;
558
559 unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
560
561 if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK)
562 err=UNZ_ERRNO;
563
564 if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK)
565 err=UNZ_ERRNO;
566
567 if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK)
568 err=UNZ_ERRNO;
569
570 if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK)
571 err=UNZ_ERRNO;
572
573 if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK)
574 err=UNZ_ERRNO;
575
576 if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK)
577 err=UNZ_ERRNO;
578
579 if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK)
580 err=UNZ_ERRNO;
581
582 if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK)
583 err=UNZ_ERRNO;
584
585 if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK)
586 err=UNZ_ERRNO;
587
588 if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK)
589 err=UNZ_ERRNO;
590
591 lSeek+=file_info.size_filename;
592 if ((err==UNZ_OK) && (szFileName!=NULL))
593 {
594 uLong uSizeRead ;
595 if (file_info.size_filename<fileNameBufferSize)
596 {
597 *(szFileName+file_info.size_filename)='\0';
598 uSizeRead = file_info.size_filename;
599 }
600 else
601 uSizeRead = fileNameBufferSize;
602
603 if ((file_info.size_filename>0) && (fileNameBufferSize>0))
604 if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1)
605 err=UNZ_ERRNO;
606 lSeek -= uSizeRead;
607 }
608
609
610 if ((err==UNZ_OK) && (extraField!=NULL))
611 {
612 uLong uSizeRead ;
613 if (file_info.size_file_extra<extraFieldBufferSize)
614 uSizeRead = file_info.size_file_extra;
615 else
616 uSizeRead = extraFieldBufferSize;
617
618 if (lSeek!=0)
619 if (fseek(s->file,lSeek,SEEK_CUR)==0)
620 lSeek=0;
621 else
622 err=UNZ_ERRNO;
623 if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
624 if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
625 err=UNZ_ERRNO;
626 lSeek += file_info.size_file_extra - uSizeRead;
627 }
628 else
629 lSeek+=file_info.size_file_extra;
630
631
632 if ((err==UNZ_OK) && (szComment!=NULL))
633 {
634 uLong uSizeRead ;
635 if (file_info.size_file_comment<commentBufferSize)
636 {
637 *(szComment+file_info.size_file_comment)='\0';
638 uSizeRead = file_info.size_file_comment;
639 }
640 else
641 uSizeRead = commentBufferSize;
642
643 if (lSeek!=0)
644 if (fseek(s->file,lSeek,SEEK_CUR)==0)
645 lSeek=0;
646 else
647 err=UNZ_ERRNO;
648 if ((file_info.size_file_comment>0) && (commentBufferSize>0))
649 if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
650 err=UNZ_ERRNO;
651 lSeek+=file_info.size_file_comment - uSizeRead;
652 }
653 else
654 lSeek+=file_info.size_file_comment;
655
656 if ((err==UNZ_OK) && (pfile_info!=NULL))
657 *pfile_info=file_info;
658
659 if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
660 *pfile_info_internal=file_info_internal;
661
662 return err;
663}
664
665
666
667/*
668 Write info about the ZipFile in the *pglobal_info structure.
669 No preparation of the structure is needed
670 return UNZ_OK if there is no problem.
671*/
672extern int ZEXPORT unzGetCurrentFileInfo (file,
673 pfile_info,
674 szFileName, fileNameBufferSize,
675 extraField, extraFieldBufferSize,
676 szComment, commentBufferSize)
677 unzFile file;
678 unz_file_info *pfile_info;
679 char *szFileName;
680 uLong fileNameBufferSize;
681 void *extraField;
682 uLong extraFieldBufferSize;
683 char *szComment;
684 uLong commentBufferSize;
685{
686 return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
687 szFileName,fileNameBufferSize,
688 extraField,extraFieldBufferSize,
689 szComment,commentBufferSize);
690}
691
692/*
693 Set the current file of the zipfile to the first file.
694 return UNZ_OK if there is no problem
695*/
696extern int ZEXPORT unzGoToFirstFile (file)
697 unzFile file;
698{
699 int err=UNZ_OK;
700 unz_s* s;
701 if (file==NULL)
702 return UNZ_PARAMERROR;
703 s=(unz_s*)file;
704 s->pos_in_central_dir=s->offset_central_dir;
705 s->num_file=0;
706 err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
707 &s->cur_file_info_internal,
708 NULL,0,NULL,0,NULL,0);
709 s->current_file_ok = (err == UNZ_OK);
710 return err;
711}
712
713
714/*
715 Set the current file of the zipfile to the next file.
716 return UNZ_OK if there is no problem
717 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
718*/
719extern int ZEXPORT unzGoToNextFile (file)
720 unzFile file;
721{
722 unz_s* s;
723 int err;
724
725 if (file==NULL)
726 return UNZ_PARAMERROR;
727 s=(unz_s*)file;
728 if (!s->current_file_ok)
729 return UNZ_END_OF_LIST_OF_FILE;
730 if (s->num_file+1==s->gi.number_entry)
731 return UNZ_END_OF_LIST_OF_FILE;
732
733 s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
734 s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
735 s->num_file++;
736 err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
737 &s->cur_file_info_internal,
738 NULL,0,NULL,0,NULL,0);
739 s->current_file_ok = (err == UNZ_OK);
740 return err;
741}
742
743
744/*
745 Try locate the file szFileName in the zipfile.
746 For the iCaseSensitivity signification, see unzipStringFileNameCompare
747
748 return value :
749 UNZ_OK if the file is found. It becomes the current file.
750 UNZ_END_OF_LIST_OF_FILE if the file is not found
751*/
752extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
753 unzFile file;
754 const char *szFileName;
755 int iCaseSensitivity;
756{
757 unz_s* s;
758 int err;
759
760
761 uLong num_fileSaved;
762 uLong pos_in_central_dirSaved;
763
764
765 if (file==NULL)
766 return UNZ_PARAMERROR;
767
768 if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
769 return UNZ_PARAMERROR;
770
771 s=(unz_s*)file;
772 if (!s->current_file_ok)
773 return UNZ_END_OF_LIST_OF_FILE;
774
775 num_fileSaved = s->num_file;
776 pos_in_central_dirSaved = s->pos_in_central_dir;
777
778 err = unzGoToFirstFile(file);
779
780 while (err == UNZ_OK)
781 {
782 char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
783 unzGetCurrentFileInfo(file,NULL,
784 szCurrentFileName,sizeof(szCurrentFileName)-1,
785 NULL,0,NULL,0);
786 if (unzStringFileNameCompare(szCurrentFileName,
787 szFileName,iCaseSensitivity)==0)
788 return UNZ_OK;
789 err = unzGoToNextFile(file);
790 }
791
792 s->num_file = num_fileSaved ;
793 s->pos_in_central_dir = pos_in_central_dirSaved ;
794 return err;
795}
796
797
798/*
799 Read the local header of the current zipfile
800 Check the coherency of the local header and info in the end of central
801 directory about this file
802 store in *piSizeVar the size of extra info in local header
803 (filename and size of extra field data)
804*/
805local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
806 poffset_local_extrafield,
807 psize_local_extrafield)
808 unz_s* s;
809 uInt* piSizeVar;
810 uLong *poffset_local_extrafield;
811 uInt *psize_local_extrafield;
812{
813 uLong uMagic,uData,uFlags;
814 uLong size_filename;
815 uLong size_extra_field;
816 int err=UNZ_OK;
817
818 *piSizeVar = 0;
819 *poffset_local_extrafield = 0;
820 *psize_local_extrafield = 0;
821
822 if (fseek(s->file,s->cur_file_info_internal.offset_curfile +
823 s->byte_before_the_zipfile,SEEK_SET)!=0)
824 return UNZ_ERRNO;
825
826
827 if (err==UNZ_OK)
828 if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
829 err=UNZ_ERRNO;
830 else if (uMagic!=0x04034b50)
831 err=UNZ_BADZIPFILE;
832
833 if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
834 err=UNZ_ERRNO;
835/*
836 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
837 err=UNZ_BADZIPFILE;
838*/
839 if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK)
840 err=UNZ_ERRNO;
841
842 if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
843 err=UNZ_ERRNO;
844 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
845 err=UNZ_BADZIPFILE;
846
847 if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
848 (s->cur_file_info.compression_method!=Z_DEFLATED))
849 err=UNZ_BADZIPFILE;
850
851 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */
852 err=UNZ_ERRNO;
853
854 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */
855 err=UNZ_ERRNO;
856 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
857 ((uFlags & 8)==0))
858 err=UNZ_BADZIPFILE;
859
860 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */
861 err=UNZ_ERRNO;
862 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
863 ((uFlags & 8)==0))
864 err=UNZ_BADZIPFILE;
865
866 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */
867 err=UNZ_ERRNO;
868 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
869 ((uFlags & 8)==0))
870 err=UNZ_BADZIPFILE;
871
872
873 if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK)
874 err=UNZ_ERRNO;
875 else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
876 err=UNZ_BADZIPFILE;
877
878 *piSizeVar += (uInt)size_filename;
879
880 if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK)
881 err=UNZ_ERRNO;
882 *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
883 SIZEZIPLOCALHEADER + size_filename;
884 *psize_local_extrafield = (uInt)size_extra_field;
885
886 *piSizeVar += (uInt)size_extra_field;
887
888 return err;
889}
890
891/*
892 Open for reading data the current file in the zipfile.
893 If there is no error and the file is opened, the return value is UNZ_OK.
894*/
895extern int ZEXPORT unzOpenCurrentFile (file)
896 unzFile file;
897{
898 int err=UNZ_OK;
899 int Store;
900 uInt iSizeVar;
901 unz_s* s;
902 file_in_zip_read_info_s* pfile_in_zip_read_info;
903 uLong offset_local_extrafield; /* offset of the local extra field */
904 uInt size_local_extrafield; /* size of the local extra field */
905
906 if (file==NULL)
907 return UNZ_PARAMERROR;
908 s=(unz_s*)file;
909 if (!s->current_file_ok)
910 return UNZ_PARAMERROR;
911
912 if (s->pfile_in_zip_read != NULL)
913 unzCloseCurrentFile(file);
914
915 if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
916 &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
917 return UNZ_BADZIPFILE;
918
919 pfile_in_zip_read_info = (file_in_zip_read_info_s*)
920 ALLOC(sizeof(file_in_zip_read_info_s));
921 if (pfile_in_zip_read_info==NULL)
922 return UNZ_INTERNALERROR;
923
924 pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
925 pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
926 pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
927 pfile_in_zip_read_info->pos_local_extrafield=0;
928
929 if (pfile_in_zip_read_info->read_buffer==NULL)
930 {
931 TRYFREE(pfile_in_zip_read_info);
932 return UNZ_INTERNALERROR;
933 }
934
935 pfile_in_zip_read_info->stream_initialised=0;
936
937 if ((s->cur_file_info.compression_method!=0) &&
938 (s->cur_file_info.compression_method!=Z_DEFLATED))
939 err=UNZ_BADZIPFILE;
940 Store = s->cur_file_info.compression_method==0;
941
942 pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
943 pfile_in_zip_read_info->crc32=0;
944 pfile_in_zip_read_info->compression_method =
945 s->cur_file_info.compression_method;
946 pfile_in_zip_read_info->file=s->file;
947 pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
948
949 pfile_in_zip_read_info->stream.total_out = 0;
950
951 if (!Store)
952 {
953 pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
954 pfile_in_zip_read_info->stream.zfree = (free_func)0;
955 pfile_in_zip_read_info->stream.opaque = (voidpf)0;
956
957 err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
958 if (err == Z_OK)
959 pfile_in_zip_read_info->stream_initialised=1;
960 /* windowBits is passed < 0 to tell that there is no zlib header.
961 * Note that in this case inflate *requires* an extra "dummy" byte
962 * after the compressed stream in order to complete decompression and
963 * return Z_STREAM_END.
964 * In unzip, i don't wait absolutely Z_STREAM_END because I known the
965 * size of both compressed and uncompressed data
966 */
967 }
968 pfile_in_zip_read_info->rest_read_compressed =
969 s->cur_file_info.compressed_size ;
970 pfile_in_zip_read_info->rest_read_uncompressed =
971 s->cur_file_info.uncompressed_size ;
972
973
974 pfile_in_zip_read_info->pos_in_zipfile =
975 s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
976 iSizeVar;
977
978 pfile_in_zip_read_info->stream.avail_in = (uInt)0;
979
980
981 s->pfile_in_zip_read = pfile_in_zip_read_info;
982 return UNZ_OK;
983}
984
985
986/*
987 Read bytes from the current file.
988 buf contain buffer where data must be copied
989 len the size of buf.
990
991 return the number of byte copied if somes bytes are copied
992 return 0 if the end of file was reached
993 return <0 with error code if there is an error
994 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
995*/
996extern int ZEXPORT unzReadCurrentFile (file, buf, len)
997 unzFile file;
998 voidp buf;
999 unsigned len;
1000{
1001 int err=UNZ_OK;
1002 uInt iRead = 0;
1003 unz_s* s;
1004 file_in_zip_read_info_s* pfile_in_zip_read_info;
1005 if (file==NULL)
1006 return UNZ_PARAMERROR;
1007 s=(unz_s*)file;
1008 pfile_in_zip_read_info=s->pfile_in_zip_read;
1009
1010 if (pfile_in_zip_read_info==NULL)
1011 return UNZ_PARAMERROR;
1012
1013
1014 if ((pfile_in_zip_read_info->read_buffer == NULL))
1015 return UNZ_END_OF_LIST_OF_FILE;
1016 if (len==0)
1017 return 0;
1018
1019 pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1020
1021 pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1022
1023 if (len>pfile_in_zip_read_info->rest_read_uncompressed)
1024 pfile_in_zip_read_info->stream.avail_out =
1025 (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
1026
1027 while (pfile_in_zip_read_info->stream.avail_out>0)
1028 {
1029 if ((pfile_in_zip_read_info->stream.avail_in==0) &&
1030 (pfile_in_zip_read_info->rest_read_compressed>0))
1031 {
1032 uInt uReadThis = UNZ_BUFSIZE;
1033 if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
1034 uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
1035 if (uReadThis == 0)
1036 return UNZ_EOF;
1037 if (fseek(pfile_in_zip_read_info->file,
1038 pfile_in_zip_read_info->pos_in_zipfile +
1039 pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)
1040 return UNZ_ERRNO;
1041 if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,
1042 pfile_in_zip_read_info->file)!=1)
1043 return UNZ_ERRNO;
1044 pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
1045
1046 pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
1047
1048 pfile_in_zip_read_info->stream.next_in =
1049 (Bytef*)pfile_in_zip_read_info->read_buffer;
1050 pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
1051 }
1052
1053 if (pfile_in_zip_read_info->compression_method==0)
1054 {
1055 uInt uDoCopy,i ;
1056 if (pfile_in_zip_read_info->stream.avail_out <
1057 pfile_in_zip_read_info->stream.avail_in)
1058 uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
1059 else
1060 uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
1061
1062 for (i=0;i<uDoCopy;i++)
1063 *(pfile_in_zip_read_info->stream.next_out+i) =
1064 *(pfile_in_zip_read_info->stream.next_in+i);
1065
1066 pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
1067 pfile_in_zip_read_info->stream.next_out,
1068 uDoCopy);
1069 pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
1070 pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
1071 pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
1072 pfile_in_zip_read_info->stream.next_out += uDoCopy;
1073 pfile_in_zip_read_info->stream.next_in += uDoCopy;
1074 pfile_in_zip_read_info->stream.total_out += uDoCopy;
1075 iRead += uDoCopy;
1076 }
1077 else
1078 {
1079 uLong uTotalOutBefore,uTotalOutAfter;
1080 const Bytef *bufBefore;
1081 uLong uOutThis;
1082 int flush=Z_SYNC_FLUSH;
1083
1084 uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
1085 bufBefore = pfile_in_zip_read_info->stream.next_out;
1086
1087 /*
1088 if ((pfile_in_zip_read_info->rest_read_uncompressed ==
1089 pfile_in_zip_read_info->stream.avail_out) &&
1090 (pfile_in_zip_read_info->rest_read_compressed == 0))
1091 flush = Z_FINISH;
1092 */
1093 err=inflate(&pfile_in_zip_read_info->stream,flush);
1094
1095 uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
1096 uOutThis = uTotalOutAfter-uTotalOutBefore;
1097
1098 pfile_in_zip_read_info->crc32 =
1099 crc32(pfile_in_zip_read_info->crc32,bufBefore,
1100 (uInt)(uOutThis));
1101
1102 pfile_in_zip_read_info->rest_read_uncompressed -=
1103 uOutThis;
1104
1105 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
1106
1107 if (err==Z_STREAM_END)
1108 return (iRead==0) ? UNZ_EOF : iRead;
1109 if (err!=Z_OK)
1110 break;
1111 }
1112 }
1113
1114 if (err==Z_OK)
1115 return iRead;
1116 return err;
1117}
1118
1119
1120/*
1121 Give the current position in uncompressed data
1122*/
1123extern z_off_t ZEXPORT unztell (file)
1124 unzFile file;
1125{
1126 unz_s* s;
1127 file_in_zip_read_info_s* pfile_in_zip_read_info;
1128 if (file==NULL)
1129 return UNZ_PARAMERROR;
1130 s=(unz_s*)file;
1131 pfile_in_zip_read_info=s->pfile_in_zip_read;
1132
1133 if (pfile_in_zip_read_info==NULL)
1134 return UNZ_PARAMERROR;
1135
1136 return (z_off_t)pfile_in_zip_read_info->stream.total_out;
1137}
1138
1139
1140/*
1141 return 1 if the end of file was reached, 0 elsewhere
1142*/
1143extern int ZEXPORT unzeof (file)
1144 unzFile file;
1145{
1146 unz_s* s;
1147 file_in_zip_read_info_s* pfile_in_zip_read_info;
1148 if (file==NULL)
1149 return UNZ_PARAMERROR;
1150 s=(unz_s*)file;
1151 pfile_in_zip_read_info=s->pfile_in_zip_read;
1152
1153 if (pfile_in_zip_read_info==NULL)
1154 return UNZ_PARAMERROR;
1155
1156 if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
1157 return 1;
1158 else
1159 return 0;
1160}
1161
1162
1163
1164/*
1165 Read extra field from the current file (opened by unzOpenCurrentFile)
1166 This is the local-header version of the extra field (sometimes, there is
1167 more info in the local-header version than in the central-header)
1168
1169 if buf==NULL, it return the size of the local extra field that can be read
1170
1171 if buf!=NULL, len is the size of the buffer, the extra header is copied in
1172 buf.
1173 the return value is the number of bytes copied in buf, or (if <0)
1174 the error code
1175*/
1176extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
1177 unzFile file;
1178 voidp buf;
1179 unsigned len;
1180{
1181 unz_s* s;
1182 file_in_zip_read_info_s* pfile_in_zip_read_info;
1183 uInt read_now;
1184 uLong size_to_read;
1185
1186 if (file==NULL)
1187 return UNZ_PARAMERROR;
1188 s=(unz_s*)file;
1189 pfile_in_zip_read_info=s->pfile_in_zip_read;
1190
1191 if (pfile_in_zip_read_info==NULL)
1192 return UNZ_PARAMERROR;
1193
1194 size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
1195 pfile_in_zip_read_info->pos_local_extrafield);
1196
1197 if (buf==NULL)
1198 return (int)size_to_read;
1199
1200 if (len>size_to_read)
1201 read_now = (uInt)size_to_read;
1202 else
1203 read_now = (uInt)len ;
1204
1205 if (read_now==0)
1206 return 0;
1207
1208 if (fseek(pfile_in_zip_read_info->file,
1209 pfile_in_zip_read_info->offset_local_extrafield +
1210 pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)
1211 return UNZ_ERRNO;
1212
1213 if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1)
1214 return UNZ_ERRNO;
1215
1216 return (int)read_now;
1217}
1218
1219/*
1220 Close the file in zip opened with unzipOpenCurrentFile
1221 Return UNZ_CRCERROR if all the file was read but the CRC is not good
1222*/
1223extern int ZEXPORT unzCloseCurrentFile (file)
1224 unzFile file;
1225{
1226 int err=UNZ_OK;
1227
1228 unz_s* s;
1229 file_in_zip_read_info_s* pfile_in_zip_read_info;
1230 if (file==NULL)
1231 return UNZ_PARAMERROR;
1232 s=(unz_s*)file;
1233 pfile_in_zip_read_info=s->pfile_in_zip_read;
1234
1235 if (pfile_in_zip_read_info==NULL)
1236 return UNZ_PARAMERROR;
1237
1238
1239 if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
1240 {
1241 if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
1242 err=UNZ_CRCERROR;
1243 }
1244
1245
1246 TRYFREE(pfile_in_zip_read_info->read_buffer);
1247 pfile_in_zip_read_info->read_buffer = NULL;
1248 if (pfile_in_zip_read_info->stream_initialised)
1249 inflateEnd(&pfile_in_zip_read_info->stream);
1250
1251 pfile_in_zip_read_info->stream_initialised = 0;
1252 TRYFREE(pfile_in_zip_read_info);
1253
1254 s->pfile_in_zip_read=NULL;
1255
1256 return err;
1257}
1258
1259
1260/*
1261 Get the global comment string of the ZipFile, in the szComment buffer.
1262 uSizeBuf is the size of the szComment buffer.
1263 return the number of byte copied or an error code <0
1264*/
1265extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
1266 unzFile file;
1267 char *szComment;
1268 uLong uSizeBuf;
1269{
1270 int err=UNZ_OK;
1271 unz_s* s;
1272 uLong uReadThis ;
1273 if (file==NULL)
1274 return UNZ_PARAMERROR;
1275 s=(unz_s*)file;
1276
1277 uReadThis = uSizeBuf;
1278 if (uReadThis>s->gi.size_comment)
1279 uReadThis = s->gi.size_comment;
1280
1281 if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0)
1282 return UNZ_ERRNO;
1283
1284 if (uReadThis>0)
1285 {
1286 *szComment='\0';
1287 if (fread(szComment,(uInt)uReadThis,1,s->file)!=1)
1288 return UNZ_ERRNO;
1289 }
1290
1291 if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
1292 *(szComment+s->gi.size_comment)='\0';
1293 return (int)uReadThis;
1294}
diff --git a/contrib/minizip/unzip.def b/contrib/minizip/unzip.def
new file mode 100644
index 0000000..f6ede89
--- /dev/null
+++ b/contrib/minizip/unzip.def
@@ -0,0 +1,15 @@
1 unzOpen @61
2 unzClose @62
3 unzGetGlobalInfo @63
4 unzGetCurrentFileInfo @64
5 unzGoToFirstFile @65
6 unzGoToNextFile @66
7 unzOpenCurrentFile @67
8 unzReadCurrentFile @68
9 unztell @70
10 unzeof @71
11 unzCloseCurrentFile @72
12 unzGetGlobalComment @73
13 unzStringFileNameCompare @74
14 unzLocateFile @75
15 unzGetLocalExtrafield @76
diff --git a/contrib/minizip/unzip.h b/contrib/minizip/unzip.h
new file mode 100644
index 0000000..76692cb
--- /dev/null
+++ b/contrib/minizip/unzip.h
@@ -0,0 +1,275 @@
1/* unzip.h -- IO for uncompress .zip files using zlib
2 Version 0.15 beta, Mar 19th, 1998,
3
4 Copyright (C) 1998 Gilles Vollant
5
6 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
7 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 supported
10
11 THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
12 CAN CHANGE IN FUTURE VERSION !!
13 I WAIT FEEDBACK at mail info@winimage.com
14 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
15
16 Condition of use and distribution are the same than zlib :
17
18 This software is provided 'as-is', without any express or implied
19 warranty. In no event will the authors be held liable for any damages
20 arising from the use of this software.
21
22 Permission is granted to anyone to use this software for any purpose,
23 including commercial applications, and to alter it and redistribute it
24 freely, subject to the following restrictions:
25
26 1. The origin of this software must not be misrepresented; you must not
27 claim that you wrote the original software. If you use this software
28 in a product, an acknowledgment in the product documentation would be
29 appreciated but is not required.
30 2. Altered source versions must be plainly marked as such, and must not be
31 misrepresented as being the original software.
32 3. This notice may not be removed or altered from any source distribution.
33
34
35*/
36/* for more info about .ZIP format, see
37 ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
38 PkWare has also a specification at :
39 ftp://ftp.pkware.com/probdesc.zip */
40
41#ifndef _unz_H
42#define _unz_H
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#ifndef _ZLIB_H
49#include "zlib.h"
50#endif
51
52#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
53/* like the STRICT of WIN32, we define a pointer that cannot be converted
54 from (void*) without cast */
55typedef struct TagunzFile__ { int unused; } unzFile__;
56typedef unzFile__ *unzFile;
57#else
58typedef voidp unzFile;
59#endif
60
61
62#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)
70
71/* tm_unz contain date/time info */
72typedef struct tm_unz_s
73{
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;
81
82/* unz_global_info structure contain global data about the ZIPfile
83 These data comes from the end of central dir */
84typedef struct unz_global_info_s
85{
86 uLong number_entry; /* total number of entries in
87 the central dir on this disk */
88 uLong size_comment; /* size of the global comment of the zipfile */
89} unz_global_info;
90
91
92/* unz_file_info contain information about a file in the zipfile */
93typedef struct unz_file_info_s
94{
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 */
106
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 */
110
111 tm_unz tmu_date;
112} unz_file_info;
113
114extern 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 strcmpi
121 or strcasecmp)
122 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
123 (like 1 on Unix, 2 on Windows)
124*/
125
126
127extern 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 computer
131 "zlib/zlib111.zip".
132 If the zipfile cannot be opened (file don't exist or in not valid), the
133 return value is NULL.
134 Else, the return value is a unzFile Handle, usable with other function
135 of this unzip package.
136*/
137
138extern 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. */
144
145extern 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 needed
150 return UNZ_OK if there is no problem. */
151
152
153extern 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 <0
160*/
161
162
163/***************************************************************************/
164/* Unzip package allow you browse the directory of the zipfile */
165
166extern 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 problem
170*/
171
172extern 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 problem
176 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
177*/
178
179extern 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 unzStringFileNameCompare
185
186 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 found
189*/
190
191
192extern 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 file
202 if pfile_info!=NULL, the *pfile_info structure will contain somes info about
203 the current file
204 if szFileName!=NULL, the filemane string will be copied in szFileName
205 (fileNameBufferSize is the size of the buffer)
206 if extraField!=NULL, the extra field information will be copied in extraField
207 (extraFieldBufferSize is the size of the buffer).
208 This is the Central-header version of the extra field
209 if szComment!=NULL, the comment string of the file will be copied in szComment
210 (commentBufferSize is the size of the buffer)
211*/
212
213/***************************************************************************/
214/* for reading the content of the current zipfile, you can open it, read data
215 from it, and close it (you can close it before reading all the file)
216 */
217
218extern 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*/
223
224extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
225/*
226 Close the file in zip opened with unzOpenCurrentFile
227 Return UNZ_CRCERROR if all the file was read but the CRC is not good
228*/
229
230
231extern 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 copied
237 len the size of buf.
238
239 return the number of byte copied if somes bytes are copied
240 return 0 if the end of file was reached
241 return <0 with error code if there is an error
242 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
243*/
244
245extern z_off_t ZEXPORT unztell OF((unzFile file));
246/*
247 Give the current position in uncompressed data
248*/
249
250extern int ZEXPORT unzeof OF((unzFile file));
251/*
252 return 1 if the end of file was reached, 0 elsewhere
253*/
254
255extern 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 is
261 more info in the local-header version than in the central-header)
262
263 if buf==NULL, it return the size of the local extra field
264
265 if buf!=NULL, len is the size of the buffer, the extra header is copied in
266 buf.
267 the return value is the number of bytes copied in buf, or (if <0)
268 the error code
269*/
270
271#ifdef __cplusplus
272}
273#endif
274
275#endif /* _unz_H */
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c
new file mode 100644
index 0000000..ddb2334
--- /dev/null
+++ b/contrib/minizip/zip.c
@@ -0,0 +1,716 @@
1/* zip.c -- IO on .zip files using zlib
2 Version 0.15 beta, Mar 19th, 1998,
3
4 Read zip.h for more info
5*/
6
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include "zlib.h"
12#include "zip.h"
13
14#ifdef STDC
15# include <stddef.h>
16# include <string.h>
17# include <stdlib.h>
18#endif
19#ifdef NO_ERRNO_H
20 extern int errno;
21#else
22# include <errno.h>
23#endif
24
25
26#ifndef local
27# define local static
28#endif
29/* compile with -Dlocal if your debugger can't find static symbols */
30
31#ifndef VERSIONMADEBY
32# define VERSIONMADEBY (0x0) /* platform depedent */
33#endif
34
35#ifndef Z_BUFSIZE
36#define Z_BUFSIZE (16384)
37#endif
38
39#ifndef Z_MAXFILENAMEINZIP
40#define Z_MAXFILENAMEINZIP (256)
41#endif
42
43#ifndef ALLOC
44# define ALLOC(size) (malloc(size))
45#endif
46#ifndef TRYFREE
47# define TRYFREE(p) {if (p) free(p);}
48#endif
49
50/*
51#define SIZECENTRALDIRITEM (0x2e)
52#define SIZEZIPLOCALHEADER (0x1e)
53*/
54
55/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
56
57#ifndef SEEK_CUR
58#define SEEK_CUR 1
59#endif
60
61#ifndef SEEK_END
62#define SEEK_END 2
63#endif
64
65#ifndef SEEK_SET
66#define SEEK_SET 0
67#endif
68
69const char zip_copyright[] =
70 " zip 0.15 Copyright 1998 Gilles Vollant ";
71
72
73#define SIZEDATA_INDATABLOCK (4096-(4*4))
74
75#define LOCALHEADERMAGIC (0x04034b50)
76#define CENTRALHEADERMAGIC (0x02014b50)
77#define ENDHEADERMAGIC (0x06054b50)
78
79#define FLAG_LOCALHEADER_OFFSET (0x06)
80#define CRC_LOCALHEADER_OFFSET (0x0e)
81
82#define SIZECENTRALHEADER (0x2e) /* 46 */
83
84typedef struct linkedlist_datablock_internal_s
85{
86 struct linkedlist_datablock_internal_s* next_datablock;
87 uLong avail_in_this_block;
88 uLong filled_in_this_block;
89 uLong unused; /* for future use and alignement */
90 unsigned char data[SIZEDATA_INDATABLOCK];
91} linkedlist_datablock_internal;
92
93typedef struct linkedlist_data_s
94{
95 linkedlist_datablock_internal* first_block;
96 linkedlist_datablock_internal* last_block;
97} linkedlist_data;
98
99
100typedef struct
101{
102 z_stream stream; /* zLib stream structure for inflate */
103 int stream_initialised; /* 1 is stream is initialised */
104 uInt pos_in_buffered_data; /* last written byte in buffered_data */
105
106 uLong pos_local_header; /* offset of the local header of the file
107 currenty writing */
108 char* central_header; /* central header data for the current file */
109 uLong size_centralheader; /* size of the central header for cur file */
110 uLong flag; /* flag of the file currently writing */
111
112 int method; /* compression method of file currenty wr.*/
113 Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/
114 uLong dosDate;
115 uLong crc32;
116} curfile_info;
117
118typedef struct
119{
120 FILE * filezip;
121 linkedlist_data central_dir;/* datablock with central dir in construction*/
122 int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/
123 curfile_info ci; /* info on the file curretly writing */
124
125 uLong begin_pos; /* position of the beginning of the zipfile */
126 uLong number_entry;
127} zip_internal;
128
129local linkedlist_datablock_internal* allocate_new_datablock()
130{
131 linkedlist_datablock_internal* ldi;
132 ldi = (linkedlist_datablock_internal*)
133 ALLOC(sizeof(linkedlist_datablock_internal));
134 if (ldi!=NULL)
135 {
136 ldi->next_datablock = NULL ;
137 ldi->filled_in_this_block = 0 ;
138 ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ;
139 }
140 return ldi;
141}
142
143local void free_datablock(ldi)
144 linkedlist_datablock_internal* ldi;
145{
146 while (ldi!=NULL)
147 {
148 linkedlist_datablock_internal* ldinext = ldi->next_datablock;
149 TRYFREE(ldi);
150 ldi = ldinext;
151 }
152}
153
154local void init_linkedlist(ll)
155 linkedlist_data* ll;
156{
157 ll->first_block = ll->last_block = NULL;
158}
159
160local void free_linkedlist(ll)
161 linkedlist_data* ll;
162{
163 free_datablock(ll->first_block);
164 ll->first_block = ll->last_block = NULL;
165}
166
167
168local int add_data_in_datablock(ll,buf,len)
169 linkedlist_data* ll;
170 const void* buf;
171 uLong len;
172{
173 linkedlist_datablock_internal* ldi;
174 const unsigned char* from_copy;
175
176 if (ll==NULL)
177 return ZIP_INTERNALERROR;
178
179 if (ll->last_block == NULL)
180 {
181 ll->first_block = ll->last_block = allocate_new_datablock();
182 if (ll->first_block == NULL)
183 return ZIP_INTERNALERROR;
184 }
185
186 ldi = ll->last_block;
187 from_copy = (unsigned char*)buf;
188
189 while (len>0)
190 {
191 uInt copy_this;
192 uInt i;
193 unsigned char* to_copy;
194
195 if (ldi->avail_in_this_block==0)
196 {
197 ldi->next_datablock = allocate_new_datablock();
198 if (ldi->next_datablock == NULL)
199 return ZIP_INTERNALERROR;
200 ldi = ldi->next_datablock ;
201 ll->last_block = ldi;
202 }
203
204 if (ldi->avail_in_this_block < len)
205 copy_this = (uInt)ldi->avail_in_this_block;
206 else
207 copy_this = (uInt)len;
208
209 to_copy = &(ldi->data[ldi->filled_in_this_block]);
210
211 for (i=0;i<copy_this;i++)
212 *(to_copy+i)=*(from_copy+i);
213
214 ldi->filled_in_this_block += copy_this;
215 ldi->avail_in_this_block -= copy_this;
216 from_copy += copy_this ;
217 len -= copy_this;
218 }
219 return ZIP_OK;
220}
221
222
223local int write_datablock(fout,ll)
224 FILE * fout;
225 linkedlist_data* ll;
226{
227 linkedlist_datablock_internal* ldi;
228 ldi = ll->first_block;
229 while (ldi!=NULL)
230 {
231 if (ldi->filled_in_this_block > 0)
232 if (fwrite(ldi->data,(uInt)ldi->filled_in_this_block,1,fout)!=1)
233 return ZIP_ERRNO;
234 ldi = ldi->next_datablock;
235 }
236 return ZIP_OK;
237}
238
239/****************************************************************************/
240
241/* ===========================================================================
242 Outputs a long in LSB order to the given file
243 nbByte == 1, 2 or 4 (byte, short or long)
244*/
245local int ziplocal_putValue (file, x, nbByte)
246 FILE *file;
247 uLong x;
248 int nbByte;
249{
250 unsigned char buf[4];
251 int n;
252 for (n = 0; n < nbByte; n++) {
253 buf[n] = (unsigned char)(x & 0xff);
254 x >>= 8;
255 }
256 if (fwrite(buf,nbByte,1,file)!=1)
257 return ZIP_ERRNO;
258 else
259 return ZIP_OK;
260}
261
262
263local void ziplocal_putValue_inmemory (dest, x, nbByte)
264 void* dest;
265 uLong x;
266 int nbByte;
267{
268 unsigned char* buf=(unsigned char*)dest;
269 int n;
270 for (n = 0; n < nbByte; n++) {
271 buf[n] = (unsigned char)(x & 0xff);
272 x >>= 8;
273 }
274}
275/****************************************************************************/
276
277
278local uLong ziplocal_TmzDateToDosDate(ptm,dosDate)
279 tm_zip* ptm;
280 uLong dosDate;
281{
282 uLong year = (uLong)ptm->tm_year;
283 if (year>1980)
284 year-=1980;
285 else if (year>80)
286 year-=80;
287 return
288 (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) |
289 ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
290}
291
292
293/****************************************************************************/
294
295extern zipFile ZEXPORT zipOpen (pathname, append)
296 const char *pathname;
297 int append;
298{
299 zip_internal ziinit;
300 zip_internal* zi;
301
302 ziinit.filezip = fopen(pathname,(append == 0) ? "wb" : "ab");
303 if (ziinit.filezip == NULL)
304 return NULL;
305 ziinit.begin_pos = ftell(ziinit.filezip);
306 ziinit.in_opened_file_inzip = 0;
307 ziinit.ci.stream_initialised = 0;
308 ziinit.number_entry = 0;
309 init_linkedlist(&(ziinit.central_dir));
310
311
312 zi = (zip_internal*)ALLOC(sizeof(zip_internal));
313 if (zi==NULL)
314 {
315 fclose(ziinit.filezip);
316 return NULL;
317 }
318
319 *zi = ziinit;
320 return (zipFile)zi;
321}
322
323extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
324 extrafield_local, size_extrafield_local,
325 extrafield_global, size_extrafield_global,
326 comment, method, level)
327 zipFile file;
328 const char* filename;
329 const zip_fileinfo* zipfi;
330 const void* extrafield_local;
331 uInt size_extrafield_local;
332 const void* extrafield_global;
333 uInt size_extrafield_global;
334 const char* comment;
335 int method;
336 int level;
337{
338 zip_internal* zi;
339 uInt size_filename;
340 uInt size_comment;
341 uInt i;
342 int err = ZIP_OK;
343
344 if (file == NULL)
345 return ZIP_PARAMERROR;
346 if ((method!=0) && (method!=Z_DEFLATED))
347 return ZIP_PARAMERROR;
348
349 zi = (zip_internal*)file;
350
351 if (zi->in_opened_file_inzip == 1)
352 {
353 err = zipCloseFileInZip (file);
354 if (err != ZIP_OK)
355 return err;
356 }
357
358
359 if (filename==NULL)
360 filename="-";
361
362 if (comment==NULL)
363 size_comment = 0;
364 else
365 size_comment = strlen(comment);
366
367 size_filename = strlen(filename);
368
369 if (zipfi == NULL)
370 zi->ci.dosDate = 0;
371 else
372 {
373 if (zipfi->dosDate != 0)
374 zi->ci.dosDate = zipfi->dosDate;
375 else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate);
376 }
377
378 zi->ci.flag = 0;
379 if ((level==8) || (level==9))
380 zi->ci.flag |= 2;
381 if ((level==2))
382 zi->ci.flag |= 4;
383 if ((level==1))
384 zi->ci.flag |= 6;
385
386 zi->ci.crc32 = 0;
387 zi->ci.method = method;
388 zi->ci.stream_initialised = 0;
389 zi->ci.pos_in_buffered_data = 0;
390 zi->ci.pos_local_header = ftell(zi->filezip);
391 zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename +
392 size_extrafield_global + size_comment;
393 zi->ci.central_header = (char*)ALLOC(zi->ci.size_centralheader);
394
395 ziplocal_putValue_inmemory(zi->ci.central_header,CENTRALHEADERMAGIC,4);
396 /* version info */
397 ziplocal_putValue_inmemory(zi->ci.central_header+4,VERSIONMADEBY,2);
398 ziplocal_putValue_inmemory(zi->ci.central_header+6,20,2);
399 ziplocal_putValue_inmemory(zi->ci.central_header+8,zi->ci.flag,2);
400 ziplocal_putValue_inmemory(zi->ci.central_header+10,zi->ci.method,2);
401 ziplocal_putValue_inmemory(zi->ci.central_header+12,zi->ci.dosDate,4);
402 ziplocal_putValue_inmemory(zi->ci.central_header+16,0,4); /*crc*/
403 ziplocal_putValue_inmemory(zi->ci.central_header+20,0,4); /*compr size*/
404 ziplocal_putValue_inmemory(zi->ci.central_header+24,0,4); /*uncompr size*/
405 ziplocal_putValue_inmemory(zi->ci.central_header+28,size_filename,2);
406 ziplocal_putValue_inmemory(zi->ci.central_header+30,size_extrafield_global,2);
407 ziplocal_putValue_inmemory(zi->ci.central_header+32,size_comment,2);
408 ziplocal_putValue_inmemory(zi->ci.central_header+34,0,2); /*disk nm start*/
409
410 if (zipfi==NULL)
411 ziplocal_putValue_inmemory(zi->ci.central_header+36,0,2);
412 else
413 ziplocal_putValue_inmemory(zi->ci.central_header+36,zipfi->internal_fa,2);
414
415 if (zipfi==NULL)
416 ziplocal_putValue_inmemory(zi->ci.central_header+38,0,4);
417 else
418 ziplocal_putValue_inmemory(zi->ci.central_header+38,zipfi->external_fa,4);
419
420 ziplocal_putValue_inmemory(zi->ci.central_header+42,zi->ci.pos_local_header,4);
421
422 for (i=0;i<size_filename;i++)
423 *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);
424
425 for (i=0;i<size_extrafield_global;i++)
426 *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) =
427 *(((const char*)extrafield_global)+i);
428
429 for (i=0;i<size_comment;i++)
430 *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+
431 size_extrafield_global+i) = *(filename+i);
432 if (zi->ci.central_header == NULL)
433 return ZIP_INTERNALERROR;
434
435 /* write the local header */
436 err = ziplocal_putValue(zi->filezip,LOCALHEADERMAGIC,4);
437
438 if (err==ZIP_OK)
439 err = ziplocal_putValue(zi->filezip,20,2);/* version needed to extract */
440 if (err==ZIP_OK)
441 err = ziplocal_putValue(zi->filezip,zi->ci.flag,2);
442
443 if (err==ZIP_OK)
444 err = ziplocal_putValue(zi->filezip,zi->ci.method,2);
445
446 if (err==ZIP_OK)
447 err = ziplocal_putValue(zi->filezip,zi->ci.dosDate,4);
448
449 if (err==ZIP_OK)
450 err = ziplocal_putValue(zi->filezip,0,4); /* crc 32, unknown */
451 if (err==ZIP_OK)
452 err = ziplocal_putValue(zi->filezip,0,4); /* compressed size, unknown */
453 if (err==ZIP_OK)
454 err = ziplocal_putValue(zi->filezip,0,4); /* uncompressed size, unknown */
455
456 if (err==ZIP_OK)
457 err = ziplocal_putValue(zi->filezip,(uLong)size_filename,2);
458
459 if (err==ZIP_OK)
460 err = ziplocal_putValue(zi->filezip,(uLong)size_extrafield_local,2);
461
462 if ((err==ZIP_OK) && (size_filename>0))
463 if (fwrite(filename,(uInt)size_filename,1,zi->filezip)!=1)
464 err = ZIP_ERRNO;
465
466 if ((err==ZIP_OK) && (size_extrafield_local>0))
467 if (fwrite(extrafield_local,(uInt)size_extrafield_local,1,zi->filezip)
468 !=1)
469 err = ZIP_ERRNO;
470
471 zi->ci.stream.avail_in = (uInt)0;
472 zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
473 zi->ci.stream.next_out = zi->ci.buffered_data;
474 zi->ci.stream.total_in = 0;
475 zi->ci.stream.total_out = 0;
476
477 if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED))
478 {
479 zi->ci.stream.zalloc = (alloc_func)0;
480 zi->ci.stream.zfree = (free_func)0;
481 zi->ci.stream.opaque = (voidpf)0;
482
483 err = deflateInit2(&zi->ci.stream, level,
484 Z_DEFLATED, -MAX_WBITS, /*DEF_MEM_LEVEL*/8, 0);
485
486 if (err==Z_OK)
487 zi->ci.stream_initialised = 1;
488 }
489
490
491 if (err==Z_OK)
492 zi->in_opened_file_inzip = 1;
493 return err;
494}
495
496extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
497 zipFile file;
498 const voidp buf;
499 unsigned len;
500{
501 zip_internal* zi;
502 int err=ZIP_OK;
503
504 if (file == NULL)
505 return ZIP_PARAMERROR;
506 zi = (zip_internal*)file;
507
508 if (zi->in_opened_file_inzip == 0)
509 return ZIP_PARAMERROR;
510
511 zi->ci.stream.next_in = buf;
512 zi->ci.stream.avail_in = len;
513 zi->ci.crc32 = crc32(zi->ci.crc32,buf,len);
514
515 while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
516 {
517 if (zi->ci.stream.avail_out == 0)
518 {
519 if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip)
520 !=1)
521 err = ZIP_ERRNO;
522 zi->ci.pos_in_buffered_data = 0;
523 zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
524 zi->ci.stream.next_out = zi->ci.buffered_data;
525 }
526
527 if (zi->ci.method == Z_DEFLATED)
528 {
529 uLong uTotalOutBefore = zi->ci.stream.total_out;
530 err=deflate(&zi->ci.stream, Z_NO_FLUSH);
531 zi->ci.pos_in_buffered_data += zi->ci.stream.total_out - uTotalOutBefore ;
532
533 }
534 else
535 {
536 uInt copy_this,i;
537 if (zi->ci.stream.avail_in < zi->ci.stream.avail_out)
538 copy_this = zi->ci.stream.avail_in;
539 else
540 copy_this = zi->ci.stream.avail_out;
541 for (i=0;i<copy_this;i++)
542 *(((char*)zi->ci.stream.next_out)+i) =
543 *(((const char*)zi->ci.stream.next_in)+i);
544 {
545 zi->ci.stream.avail_in -= copy_this;
546 zi->ci.stream.avail_out-= copy_this;
547 zi->ci.stream.next_in+= copy_this;
548 zi->ci.stream.next_out+= copy_this;
549 zi->ci.stream.total_in+= copy_this;
550 zi->ci.stream.total_out+= copy_this;
551 zi->ci.pos_in_buffered_data += copy_this;
552 }
553 }
554 }
555
556 return 0;
557}
558
559extern int ZEXPORT zipCloseFileInZip (file)
560 zipFile file;
561{
562 zip_internal* zi;
563 int err=ZIP_OK;
564
565 if (file == NULL)
566 return ZIP_PARAMERROR;
567 zi = (zip_internal*)file;
568
569 if (zi->in_opened_file_inzip == 0)
570 return ZIP_PARAMERROR;
571 zi->ci.stream.avail_in = 0;
572
573 if (zi->ci.method == Z_DEFLATED)
574 while (err==ZIP_OK)
575 {
576 uLong uTotalOutBefore;
577 if (zi->ci.stream.avail_out == 0)
578 {
579 if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip)
580 !=1)
581 err = ZIP_ERRNO;
582 zi->ci.pos_in_buffered_data = 0;
583 zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
584 zi->ci.stream.next_out = zi->ci.buffered_data;
585 }
586 uTotalOutBefore = zi->ci.stream.total_out;
587 err=deflate(&zi->ci.stream, Z_FINISH);
588 zi->ci.pos_in_buffered_data += zi->ci.stream.total_out - uTotalOutBefore ;
589 }
590
591 if (err==Z_STREAM_END)
592 err=ZIP_OK; /* this is normal */
593
594 if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK))
595 if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip)
596 !=1)
597 err = ZIP_ERRNO;
598
599 if ((zi->ci.method == Z_DEFLATED) && (err==ZIP_OK))
600 {
601 err=deflateEnd(&zi->ci.stream);
602 zi->ci.stream_initialised = 0;
603 }
604
605 ziplocal_putValue_inmemory(zi->ci.central_header+16,zi->ci.crc32,4); /*crc*/
606 ziplocal_putValue_inmemory(zi->ci.central_header+20,
607 zi->ci.stream.total_out,4); /*compr size*/
608 ziplocal_putValue_inmemory(zi->ci.central_header+24,
609 zi->ci.stream.total_in,4); /*uncompr size*/
610
611 if (err==ZIP_OK)
612 err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header,
613 (uLong)zi->ci.size_centralheader);
614 free(zi->ci.central_header);
615
616 if (err==ZIP_OK)
617 {
618 long cur_pos_inzip = ftell(zi->filezip);
619 if (fseek(zi->filezip,
620 zi->ci.pos_local_header + 14,SEEK_SET)!=0)
621 err = ZIP_ERRNO;
622
623 if (err==ZIP_OK)
624 err = ziplocal_putValue(zi->filezip,zi->ci.crc32,4); /* crc 32, unknown */
625
626 if (err==ZIP_OK) /* compressed size, unknown */
627 err = ziplocal_putValue(zi->filezip,zi->ci.stream.total_out,4);
628
629 if (err==ZIP_OK) /* uncompressed size, unknown */
630 err = ziplocal_putValue(zi->filezip,zi->ci.stream.total_in,4);
631
632 if (fseek(zi->filezip,
633 cur_pos_inzip,SEEK_SET)!=0)
634 err = ZIP_ERRNO;
635 }
636
637 zi->number_entry ++;
638 zi->in_opened_file_inzip = 0;
639
640 return err;
641}
642
643extern int ZEXPORT zipClose (file, global_comment)
644 zipFile file;
645 const char* global_comment;
646{
647 zip_internal* zi;
648 int err = 0;
649 uLong size_centraldir = 0;
650 uLong centraldir_pos_inzip ;
651 uInt size_global_comment;
652 if (file == NULL)
653 return ZIP_PARAMERROR;
654 zi = (zip_internal*)file;
655
656 if (zi->in_opened_file_inzip == 1)
657 {
658 err = zipCloseFileInZip (file);
659 }
660
661 if (global_comment==NULL)
662 size_global_comment = 0;
663 else
664 size_global_comment = strlen(global_comment);
665
666
667 centraldir_pos_inzip = ftell(zi->filezip);
668 if (err==ZIP_OK)
669 {
670 linkedlist_datablock_internal* ldi = zi->central_dir.first_block ;
671 while (ldi!=NULL)
672 {
673 if ((err==ZIP_OK) && (ldi->filled_in_this_block>0))
674 if (fwrite(ldi->data,(uInt)ldi->filled_in_this_block,
675 1,zi->filezip) !=1 )
676 err = ZIP_ERRNO;
677
678 size_centraldir += ldi->filled_in_this_block;
679 ldi = ldi->next_datablock;
680 }
681 }
682 free_datablock(zi->central_dir.first_block);
683
684 if (err==ZIP_OK) /* Magic End */
685 err = ziplocal_putValue(zi->filezip,ENDHEADERMAGIC,4);
686
687 if (err==ZIP_OK) /* number of this disk */
688 err = ziplocal_putValue(zi->filezip,0,2);
689
690 if (err==ZIP_OK) /* number of the disk with the start of the central directory */
691 err = ziplocal_putValue(zi->filezip,0,2);
692
693 if (err==ZIP_OK) /* total number of entries in the central dir on this disk */
694 err = ziplocal_putValue(zi->filezip,zi->number_entry,2);
695
696 if (err==ZIP_OK) /* total number of entries in the central dir */
697 err = ziplocal_putValue(zi->filezip,zi->number_entry,2);
698
699 if (err==ZIP_OK) /* size of the central directory */
700 err = ziplocal_putValue(zi->filezip,size_centraldir,4);
701
702 if (err==ZIP_OK) /* offset of start of central directory with respect to the
703 starting disk number */
704 err = ziplocal_putValue(zi->filezip,centraldir_pos_inzip ,4);
705
706 if (err==ZIP_OK) /* zipfile comment length */
707 err = ziplocal_putValue(zi->filezip,(uLong)size_global_comment,2);
708
709 if ((err==ZIP_OK) && (size_global_comment>0))
710 if (fwrite(global_comment,(uInt)size_global_comment,1,zi->filezip) !=1 )
711 err = ZIP_ERRNO;
712 fclose(zi->filezip);
713 TRYFREE(zi);
714
715 return err;
716}
diff --git a/contrib/minizip/zip.def b/contrib/minizip/zip.def
new file mode 100644
index 0000000..5d5079f
--- /dev/null
+++ b/contrib/minizip/zip.def
@@ -0,0 +1,5 @@
1 zipOpen @80
2 zipOpenNewFileInZip @81
3 zipWriteInFileInZip @82
4 zipCloseFileInZip @83
5 zipClose @84
diff --git a/contrib/minizip/zip.h b/contrib/minizip/zip.h
new file mode 100644
index 0000000..678260b
--- /dev/null
+++ b/contrib/minizip/zip.h
@@ -0,0 +1,150 @@
1/* zip.h -- IO for compress .zip files using zlib
2 Version 0.15 alpha, Mar 19th, 1998,
3
4 Copyright (C) 1998 Gilles Vollant
5
6 This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
7 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 supported
10
11 For uncompress .zip file, look at unzip.h
12
13 THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
14 CAN CHANGE IN FUTURE VERSION !!
15 I WAIT FEEDBACK at mail info@winimage.com
16 Visit also http://www.winimage.com/zLibDll/zip.htm for evolution
17
18 Condition of use and distribution are the same than zlib :
19
20 This software is provided 'as-is', without any express or implied
21 warranty. In no event will the authors be held liable for any damages
22 arising from the use of this software.
23
24 Permission is granted to anyone to use this software for any purpose,
25 including commercial applications, and to alter it and redistribute it
26 freely, subject to the following restrictions:
27
28 1. The origin of this software must not be misrepresented; you must not
29 claim that you wrote the original software. If you use this software
30 in a product, an acknowledgment in the product documentation would be
31 appreciated but is not required.
32 2. Altered source versions must be plainly marked as such, and must not be
33 misrepresented as being the original software.
34 3. This notice may not be removed or altered from any source distribution.
35
36
37*/
38
39/* for more info about .ZIP format, see
40 ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
41 PkWare has also a specification at :
42 ftp://ftp.pkware.com/probdesc.zip
43*/
44
45#ifndef _zip_H
46#define _zip_H
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52#ifndef _ZLIB_H
53#include "zlib.h"
54#endif
55
56#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
57/* like the STRICT of WIN32, we define a pointer that cannot be converted
58 from (void*) without cast */
59typedef struct TagzipFile__ { int unused; } zipFile__;
60typedef zipFile__ *zipFile;
61#else
62typedef voidp zipFile;
63#endif
64
65#define ZIP_OK (0)
66#define ZIP_ERRNO (Z_ERRNO)
67#define ZIP_PARAMERROR (-102)
68#define ZIP_INTERNALERROR (-104)
69
70/* tm_zip contain date/time info */
71typedef struct tm_zip_s
72{
73 uInt tm_sec; /* seconds after the minute - [0,59] */
74 uInt tm_min; /* minutes after the hour - [0,59] */
75 uInt tm_hour; /* hours since midnight - [0,23] */
76 uInt tm_mday; /* day of the month - [1,31] */
77 uInt tm_mon; /* months since January - [0,11] */
78 uInt tm_year; /* years - [1980..2044] */
79} tm_zip;
80
81typedef struct
82{
83 tm_zip tmz_date; /* date in understandable format */
84 uLong dosDate; /* if dos_date == 0, tmu_date is used */
85/* uLong flag; */ /* general purpose bit flag 2 bytes */
86
87 uLong internal_fa; /* internal file attributes 2 bytes */
88 uLong external_fa; /* external file attributes 4 bytes */
89} zip_fileinfo;
90
91extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
92/*
93 Create a zipfile.
94 pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on
95 an Unix computer "zlib/zlib111.zip".
96 if the file pathname exist and append=1, the zip will be created at the end
97 of the file. (useful if the file contain a self extractor code)
98 If the zipfile cannot be opened, the return value is NULL.
99 Else, the return value is a zipFile Handle, usable with other function
100 of this zip package.
101
102
103*/
104
105extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
106 const char* filename,
107 const zip_fileinfo* zipfi,
108 const void* extrafield_local,
109 uInt size_extrafield_local,
110 const void* extrafield_global,
111 uInt size_extrafield_global,
112 const char* comment,
113 int method,
114 int level));
115/*
116 Open a file in the ZIP for writing.
117 filename : the filename in zip (if NULL, '-' without quote will be used
118 *zipfi contain supplemental information
119 if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
120 contains the extrafield data the the local header
121 if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
122 contains the extrafield data the the local header
123 if comment != NULL, comment contain the comment string
124 method contain the compression method (0 for store, Z_DEFLATED for deflate)
125 level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
126*/
127
128extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
129 const voidp buf,
130 unsigned len));
131/*
132 Write data in the zipfile
133*/
134
135extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
136/*
137 Close the current file in the zipfile
138*/
139
140extern int ZEXPORT zipClose OF((zipFile file,
141 const char* global_comment));
142/*
143 Close the zipfile
144*/
145
146#ifdef __cplusplus
147}
148#endif
149
150#endif /* _zip_H */
diff --git a/contrib/minizip/zlibvc.def b/contrib/minizip/zlibvc.def
new file mode 100644
index 0000000..7e9d60d
--- /dev/null
+++ b/contrib/minizip/zlibvc.def
@@ -0,0 +1,74 @@
1LIBRARY "zlib"
2
3DESCRIPTION '"""zlib data compression library"""'
4
5
6VERSION 1.11
7
8
9HEAPSIZE 1048576,8192
10
11EXPORTS
12 adler32 @1
13 compress @2
14 crc32 @3
15 deflate @4
16 deflateCopy @5
17 deflateEnd @6
18 deflateInit2_ @7
19 deflateInit_ @8
20 deflateParams @9
21 deflateReset @10
22 deflateSetDictionary @11
23 gzclose @12
24 gzdopen @13
25 gzerror @14
26 gzflush @15
27 gzopen @16
28 gzread @17
29 gzwrite @18
30 inflate @19
31 inflateEnd @20
32 inflateInit2_ @21
33 inflateInit_ @22
34 inflateReset @23
35 inflateSetDictionary @24
36 inflateSync @25
37 uncompress @26
38 zlibVersion @27
39 gzprintf @28
40 gzputc @29
41 gzgetc @30
42 gzseek @31
43 gzrewind @32
44 gztell @33
45 gzeof @34
46 gzsetparams @35
47 zError @36
48 inflateSyncPoint @37
49 get_crc_table @38
50 compress2 @39
51 gzputs @40
52 gzgets @41
53
54 unzOpen @61
55 unzClose @62
56 unzGetGlobalInfo @63
57 unzGetCurrentFileInfo @64
58 unzGoToFirstFile @65
59 unzGoToNextFile @66
60 unzOpenCurrentFile @67
61 unzReadCurrentFile @68
62 unztell @70
63 unzeof @71
64 unzCloseCurrentFile @72
65 unzGetGlobalComment @73
66 unzStringFileNameCompare @74
67 unzLocateFile @75
68 unzGetLocalExtrafield @76
69
70 zipOpen @80
71 zipOpenNewFileInZip @81
72 zipWriteInFileInZip @82
73 zipCloseFileInZip @83
74 zipClose @84
diff --git a/contrib/minizip/zlibvc.dsp b/contrib/minizip/zlibvc.dsp
new file mode 100644
index 0000000..a70d4d4
--- /dev/null
+++ b/contrib/minizip/zlibvc.dsp
@@ -0,0 +1,651 @@
1# Microsoft Developer Studio Project File - Name="zlibvc" - Package Owner=<4>
2# Microsoft Developer Studio Generated Build File, Format Version 5.00
3# ** DO NOT EDIT **
4
5# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6# TARGTYPE "Win32 (ALPHA) Dynamic-Link Library" 0x0602
7
8CFG=zlibvc - Win32 Release
9!MESSAGE This is not a valid makefile. To build this project using NMAKE,
10!MESSAGE use the Export Makefile command and run
11!MESSAGE
12!MESSAGE NMAKE /f "zlibvc.mak".
13!MESSAGE
14!MESSAGE You can specify a configuration when running NMAKE
15!MESSAGE by defining the macro CFG on the command line. For example:
16!MESSAGE
17!MESSAGE NMAKE /f "zlibvc.mak" CFG="zlibvc - Win32 Release"
18!MESSAGE
19!MESSAGE Possible choices for configuration are:
20!MESSAGE
21!MESSAGE "zlibvc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
22!MESSAGE "zlibvc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
23!MESSAGE "zlibvc - Win32 ReleaseAxp" (based on\
24 "Win32 (ALPHA) Dynamic-Link Library")
25!MESSAGE "zlibvc - Win32 ReleaseWithoutAsm" (based on\
26 "Win32 (x86) Dynamic-Link Library")
27!MESSAGE "zlibvc - Win32 ReleaseWithoutCrtdll" (based on\
28 "Win32 (x86) Dynamic-Link Library")
29!MESSAGE
30
31# Begin Project
32# PROP Scc_ProjName ""
33# PROP Scc_LocalPath ""
34
35!IF "$(CFG)" == "zlibvc - Win32 Release"
36
37# PROP BASE Use_MFC 0
38# PROP BASE Use_Debug_Libraries 0
39# PROP BASE Output_Dir ".\Release"
40# PROP BASE Intermediate_Dir ".\Release"
41# PROP BASE Target_Dir ""
42# PROP Use_MFC 0
43# PROP Use_Debug_Libraries 0
44# PROP Output_Dir ".\Release"
45# PROP Intermediate_Dir ".\Release"
46# PROP Ignore_Export_Lib 0
47# PROP Target_Dir ""
48CPP=cl.exe
49# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
50# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c
51# SUBTRACT CPP /YX
52MTL=midl.exe
53# ADD BASE MTL /nologo /D "NDEBUG" /win32
54# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
55RSC=rc.exe
56# ADD BASE RSC /l 0x40c /d "NDEBUG"
57# ADD RSC /l 0x40c /d "NDEBUG"
58BSC32=bscmake.exe
59# ADD BASE BSC32 /nologo
60# ADD BSC32 /nologo
61LINK32=link.exe
62# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
63# ADD LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll"
64# SUBTRACT LINK32 /pdb:none
65
66!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
67
68# PROP BASE Use_MFC 0
69# PROP BASE Use_Debug_Libraries 1
70# PROP BASE Output_Dir ".\Debug"
71# PROP BASE Intermediate_Dir ".\Debug"
72# PROP BASE Target_Dir ""
73# PROP Use_MFC 0
74# PROP Use_Debug_Libraries 1
75# PROP Output_Dir ".\Debug"
76# PROP Intermediate_Dir ".\Debug"
77# PROP Target_Dir ""
78CPP=cl.exe
79# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
80# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /FD /c
81# SUBTRACT CPP /YX
82MTL=midl.exe
83# ADD BASE MTL /nologo /D "_DEBUG" /win32
84# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
85RSC=rc.exe
86# ADD BASE RSC /l 0x40c /d "_DEBUG"
87# ADD RSC /l 0x40c /d "_DEBUG"
88BSC32=bscmake.exe
89# ADD BASE BSC32 /nologo
90# ADD BSC32 /nologo
91LINK32=link.exe
92# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
93# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:".\Debug\zlib.dll"
94
95!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
96
97# PROP BASE Use_MFC 0
98# PROP BASE Use_Debug_Libraries 0
99# PROP BASE Output_Dir "zlibvc__"
100# PROP BASE Intermediate_Dir "zlibvc__"
101# PROP BASE Ignore_Export_Lib 0
102# PROP BASE Target_Dir ""
103# PROP Use_MFC 0
104# PROP Use_Debug_Libraries 0
105# PROP Output_Dir "zlibvc__"
106# PROP Intermediate_Dir "zlibvc__"
107# PROP Ignore_Export_Lib 0
108# PROP Target_Dir ""
109MTL=midl.exe
110# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
111# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
112CPP=cl.exe
113# ADD BASE CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c
114# ADD CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c
115# SUBTRACT CPP /YX
116RSC=rc.exe
117# ADD BASE RSC /l 0x40c /d "NDEBUG"
118# ADD RSC /l 0x40c /d "NDEBUG"
119BSC32=bscmake.exe
120# ADD BASE BSC32 /nologo
121# ADD BSC32 /nologo
122LINK32=link.exe
123# ADD BASE LINK32 crtdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /map /machine:ALPHA /nodefaultlib /out:".\Release\zlib.dll"
124# SUBTRACT BASE LINK32 /pdb:none
125# ADD LINK32 crtdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /map /machine:ALPHA /nodefaultlib /out:"zlibvc__\zlib.dll"
126# SUBTRACT LINK32 /pdb:none
127
128!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
129
130# PROP BASE Use_MFC 0
131# PROP BASE Use_Debug_Libraries 0
132# PROP BASE Output_Dir "zlibvc_0"
133# PROP BASE Intermediate_Dir "zlibvc_0"
134# PROP BASE Ignore_Export_Lib 0
135# PROP BASE Target_Dir ""
136# PROP Use_MFC 0
137# PROP Use_Debug_Libraries 0
138# PROP Output_Dir "zlibvc_0"
139# PROP Intermediate_Dir "zlibvc_0"
140# PROP Ignore_Export_Lib 0
141# PROP Target_Dir ""
142CPP=cl.exe
143# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c
144# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c
145# SUBTRACT CPP /YX
146MTL=midl.exe
147# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
148# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
149RSC=rc.exe
150# ADD BASE RSC /l 0x40c /d "NDEBUG"
151# ADD RSC /l 0x40c /d "NDEBUG"
152BSC32=bscmake.exe
153# ADD BASE BSC32 /nologo
154# ADD BSC32 /nologo
155LINK32=link.exe
156# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll"
157# SUBTRACT BASE LINK32 /pdb:none
158# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\zlibvc_0\zlib.dll"
159# SUBTRACT LINK32 /pdb:none
160
161!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
162
163# PROP BASE Use_MFC 0
164# PROP BASE Use_Debug_Libraries 0
165# PROP BASE Output_Dir "zlibvc_1"
166# PROP BASE Intermediate_Dir "zlibvc_1"
167# PROP BASE Ignore_Export_Lib 0
168# PROP BASE Target_Dir ""
169# PROP Use_MFC 0
170# PROP Use_Debug_Libraries 0
171# PROP Output_Dir "zlibvc_1"
172# PROP Intermediate_Dir "zlibvc_1"
173# PROP Ignore_Export_Lib 0
174# PROP Target_Dir ""
175CPP=cl.exe
176# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c
177# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c
178# SUBTRACT CPP /YX
179MTL=midl.exe
180# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
181# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
182RSC=rc.exe
183# ADD BASE RSC /l 0x40c /d "NDEBUG"
184# ADD RSC /l 0x40c /d "NDEBUG"
185BSC32=bscmake.exe
186# ADD BASE BSC32 /nologo
187# ADD BSC32 /nologo
188LINK32=link.exe
189# ADD BASE LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll"
190# SUBTRACT BASE LINK32 /pdb:none
191# ADD LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\zlibvc_1\zlib.dll"
192# SUBTRACT LINK32 /pdb:none
193
194!ENDIF
195
196# Begin Target
197
198# Name "zlibvc - Win32 Release"
199# Name "zlibvc - Win32 Debug"
200# Name "zlibvc - Win32 ReleaseAxp"
201# Name "zlibvc - Win32 ReleaseWithoutAsm"
202# Name "zlibvc - Win32 ReleaseWithoutCrtdll"
203# Begin Group "Source Files"
204
205# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
206# Begin Source File
207
208SOURCE=.\adler32.c
209
210!IF "$(CFG)" == "zlibvc - Win32 Release"
211
212!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
213
214!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
215
216DEP_CPP_ADLER=\
217 ".\zconf.h"\
218 ".\zlib.h"\
219
220
221!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
222
223!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
224
225!ENDIF
226
227# End Source File
228# Begin Source File
229
230SOURCE=.\compress.c
231
232!IF "$(CFG)" == "zlibvc - Win32 Release"
233
234!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
235
236!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
237
238DEP_CPP_COMPR=\
239 ".\zconf.h"\
240 ".\zlib.h"\
241
242
243!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
244
245!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
246
247!ENDIF
248
249# End Source File
250# Begin Source File
251
252SOURCE=.\crc32.c
253
254!IF "$(CFG)" == "zlibvc - Win32 Release"
255
256!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
257
258!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
259
260DEP_CPP_CRC32=\
261 ".\zconf.h"\
262 ".\zlib.h"\
263
264
265!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
266
267!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
268
269!ENDIF
270
271# End Source File
272# Begin Source File
273
274SOURCE=.\deflate.c
275
276!IF "$(CFG)" == "zlibvc - Win32 Release"
277
278!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
279
280!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
281
282DEP_CPP_DEFLA=\
283 ".\deflate.h"\
284 ".\zconf.h"\
285 ".\zlib.h"\
286 ".\zutil.h"\
287
288
289!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
290
291!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
292
293!ENDIF
294
295# End Source File
296# Begin Source File
297
298SOURCE=.\gvmat32c.c
299
300!IF "$(CFG)" == "zlibvc - Win32 Release"
301
302!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
303
304!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
305
306!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
307
308!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
309
310!ENDIF
311
312# End Source File
313# Begin Source File
314
315SOURCE=.\gzio.c
316
317!IF "$(CFG)" == "zlibvc - Win32 Release"
318
319!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
320
321!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
322
323DEP_CPP_GZIO_=\
324 ".\zconf.h"\
325 ".\zlib.h"\
326 ".\zutil.h"\
327
328
329!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
330
331!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
332
333!ENDIF
334
335# End Source File
336# Begin Source File
337
338SOURCE=.\infblock.c
339
340!IF "$(CFG)" == "zlibvc - Win32 Release"
341
342!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
343
344!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
345
346DEP_CPP_INFBL=\
347 ".\infblock.h"\
348 ".\infcodes.h"\
349 ".\inftrees.h"\
350 ".\infutil.h"\
351 ".\zconf.h"\
352 ".\zlib.h"\
353 ".\zutil.h"\
354
355
356!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
357
358!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
359
360!ENDIF
361
362# End Source File
363# Begin Source File
364
365SOURCE=.\infcodes.c
366
367!IF "$(CFG)" == "zlibvc - Win32 Release"
368
369!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
370
371!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
372
373DEP_CPP_INFCO=\
374 ".\infblock.h"\
375 ".\infcodes.h"\
376 ".\inffast.h"\
377 ".\inftrees.h"\
378 ".\infutil.h"\
379 ".\zconf.h"\
380 ".\zlib.h"\
381 ".\zutil.h"\
382
383
384!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
385
386!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
387
388!ENDIF
389
390# End Source File
391# Begin Source File
392
393SOURCE=.\inffast.c
394
395!IF "$(CFG)" == "zlibvc - Win32 Release"
396
397!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
398
399!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
400
401DEP_CPP_INFFA=\
402 ".\infblock.h"\
403 ".\infcodes.h"\
404 ".\inffast.h"\
405 ".\inftrees.h"\
406 ".\infutil.h"\
407 ".\zconf.h"\
408 ".\zlib.h"\
409 ".\zutil.h"\
410
411
412!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
413
414!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
415
416!ENDIF
417
418# End Source File
419# Begin Source File
420
421SOURCE=.\inflate.c
422
423!IF "$(CFG)" == "zlibvc - Win32 Release"
424
425!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
426
427!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
428
429DEP_CPP_INFLA=\
430 ".\infblock.h"\
431 ".\zconf.h"\
432 ".\zlib.h"\
433 ".\zutil.h"\
434
435
436!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
437
438!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
439
440!ENDIF
441
442# End Source File
443# Begin Source File
444
445SOURCE=.\inftrees.c
446
447!IF "$(CFG)" == "zlibvc - Win32 Release"
448
449!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
450
451!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
452
453DEP_CPP_INFTR=\
454 ".\inftrees.h"\
455 ".\zconf.h"\
456 ".\zlib.h"\
457 ".\zutil.h"\
458
459
460!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
461
462!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
463
464!ENDIF
465
466# End Source File
467# Begin Source File
468
469SOURCE=.\infutil.c
470
471!IF "$(CFG)" == "zlibvc - Win32 Release"
472
473!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
474
475!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
476
477DEP_CPP_INFUT=\
478 ".\infblock.h"\
479 ".\infcodes.h"\
480 ".\inftrees.h"\
481 ".\infutil.h"\
482 ".\zconf.h"\
483 ".\zlib.h"\
484 ".\zutil.h"\
485
486
487!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
488
489!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
490
491!ENDIF
492
493# End Source File
494# Begin Source File
495
496SOURCE=.\trees.c
497
498!IF "$(CFG)" == "zlibvc - Win32 Release"
499
500!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
501
502!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
503
504DEP_CPP_TREES=\
505 ".\deflate.h"\
506 ".\zconf.h"\
507 ".\zlib.h"\
508 ".\zutil.h"\
509
510
511!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
512
513!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
514
515!ENDIF
516
517# End Source File
518# Begin Source File
519
520SOURCE=.\uncompr.c
521
522!IF "$(CFG)" == "zlibvc - Win32 Release"
523
524!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
525
526!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
527
528DEP_CPP_UNCOM=\
529 ".\zconf.h"\
530 ".\zlib.h"\
531
532
533!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
534
535!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
536
537!ENDIF
538
539# End Source File
540# Begin Source File
541
542SOURCE=.\unzip.c
543
544!IF "$(CFG)" == "zlibvc - Win32 Release"
545
546!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
547
548!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
549
550!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
551
552!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
553
554!ENDIF
555
556# End Source File
557# Begin Source File
558
559SOURCE=.\zip.c
560
561!IF "$(CFG)" == "zlibvc - Win32 Release"
562
563!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
564
565!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
566
567!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
568
569!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
570
571!ENDIF
572
573# End Source File
574# Begin Source File
575
576SOURCE=.\zlib.rc
577# End Source File
578# Begin Source File
579
580SOURCE=.\zlibvc.def
581# End Source File
582# Begin Source File
583
584SOURCE=.\zutil.c
585
586!IF "$(CFG)" == "zlibvc - Win32 Release"
587
588!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
589
590!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp"
591
592DEP_CPP_ZUTIL=\
593 ".\zconf.h"\
594 ".\zlib.h"\
595 ".\zutil.h"\
596
597
598!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm"
599
600!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll"
601
602!ENDIF
603
604# End Source File
605# End Group
606# Begin Group "Header Files"
607
608# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
609# Begin Source File
610
611SOURCE=.\deflate.h
612# End Source File
613# Begin Source File
614
615SOURCE=.\infblock.h
616# End Source File
617# Begin Source File
618
619SOURCE=.\infcodes.h
620# End Source File
621# Begin Source File
622
623SOURCE=.\inffast.h
624# End Source File
625# Begin Source File
626
627SOURCE=.\inftrees.h
628# End Source File
629# Begin Source File
630
631SOURCE=.\infutil.h
632# End Source File
633# Begin Source File
634
635SOURCE=.\zconf.h
636# End Source File
637# Begin Source File
638
639SOURCE=.\zlib.h
640# End Source File
641# Begin Source File
642
643SOURCE=.\zutil.h
644# End Source File
645# End Group
646# Begin Group "Resource Files"
647
648# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
649# End Group
650# End Target
651# End Project
diff --git a/contrib/minizip/zlibvc.dsw b/contrib/minizip/zlibvc.dsw
new file mode 100644
index 0000000..493cd87
--- /dev/null
+++ b/contrib/minizip/zlibvc.dsw
@@ -0,0 +1,41 @@
1Microsoft Developer Studio Workspace File, Format Version 5.00
2# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3
4###############################################################################
5
6Project: "zlibstat"=.\zlibstat.dsp - Package Owner=<4>
7
8Package=<5>
9{{{
10}}}
11
12Package=<4>
13{{{
14}}}
15
16###############################################################################
17
18Project: "zlibvc"=.\zlibvc.dsp - Package Owner=<4>
19
20Package=<5>
21{{{
22}}}
23
24Package=<4>
25{{{
26}}}
27
28###############################################################################
29
30Global:
31
32Package=<5>
33{{{
34}}}
35
36Package=<3>
37{{{
38}}}
39
40###############################################################################
41