summaryrefslogtreecommitdiff
path: root/contrib/minizip
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/minizip')
-rw-r--r--contrib/minizip/ChangeLogUnzip9
-rw-r--r--contrib/minizip/Makefile4
-rw-r--r--contrib/minizip/crypt.h104
-rw-r--r--contrib/minizip/ioapi.c177
-rw-r--r--contrib/minizip/ioapi.h75
-rw-r--r--contrib/minizip/iowin32.c271
-rw-r--r--contrib/minizip/iowin32.h19
-rw-r--r--contrib/minizip/miniunz.c609
-rw-r--r--contrib/minizip/minizip.c230
-rw-r--r--contrib/minizip/readme.txt37
-rw-r--r--contrib/minizip/unzip.c1845
-rw-r--r--contrib/minizip/unzip.def15
-rw-r--r--contrib/minizip/unzip.h191
-rw-r--r--contrib/minizip/zip.c662
-rw-r--r--contrib/minizip/zip.def5
-rw-r--r--contrib/minizip/zip.h161
-rw-r--r--contrib/minizip/zlibvc.def74
-rw-r--r--contrib/minizip/zlibvc.dsp651
-rw-r--r--contrib/minizip/zlibvc.dsw41
19 files changed, 2987 insertions, 2193 deletions
diff --git a/contrib/minizip/ChangeLogUnzip b/contrib/minizip/ChangeLogUnzip
index 9987c54..18316fc 100644
--- a/contrib/minizip/ChangeLogUnzip
+++ b/contrib/minizip/ChangeLogUnzip
@@ -1,3 +1,12 @@
1Change in 0.21: (10 Mar 03)
2- bug fixes
3
4Change in 0.17: (27 Jan 02)
5- bug fixes
6
7Change in 0.16: (19 Jan 02)
8- Support of ioapi for virtualize zip file access
9
1Change in 0.15: (19 Mar 98) 10Change in 0.15: (19 Mar 98)
2- fix memory leak in minizip.c 11- fix memory leak in minizip.c
3 12
diff --git a/contrib/minizip/Makefile b/contrib/minizip/Makefile
index a1dfc16..84eaad2 100644
--- a/contrib/minizip/Makefile
+++ b/contrib/minizip/Makefile
@@ -1,8 +1,8 @@
1CC=cc 1CC=cc
2CFLAGS=-O -I../.. 2CFLAGS=-O -I../..
3 3
4UNZ_OBJS = miniunz.o unzip.o ../../libz.a 4UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a
5ZIP_OBJS = minizip.o zip.o ../../libz.a 5ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
6 6
7.c.o: 7.c.o:
8 $(CC) -c $(CFLAGS) $*.c 8 $(CC) -c $(CFLAGS) $*.c
diff --git a/contrib/minizip/crypt.h b/contrib/minizip/crypt.h
new file mode 100644
index 0000000..e5bc627
--- /dev/null
+++ b/contrib/minizip/crypt.h
@@ -0,0 +1,104 @@
1
2#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
3
4/***********************************************************************
5 * Return the next byte in the pseudo-random sequence
6 */
7static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
8{
9 unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
10 * unpredictable manner on 16-bit systems; not a problem
11 * with any known compiler so far, though */
12
13 temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
14 return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
15}
16
17/***********************************************************************
18 * Update the encryption keys with the next byte of plain text
19 */
20static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
21{
22 (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
23 (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
24 (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
25 {
26 register int keyshift = (int)((*(pkeys+1)) >> 24);
27 (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
28 }
29 return c;
30}
31
32
33/***********************************************************************
34 * Initialize the encryption keys and the random header according to
35 * the given password.
36 */
37static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
38{
39 *(pkeys+0) = 305419896L;
40 *(pkeys+1) = 591751049L;
41 *(pkeys+2) = 878082192L;
42 while (*passwd != '\0') {
43 update_keys(pkeys,pcrc_32_tab,(int)*passwd);
44 passwd++;
45 }
46}
47
48#define zdecode(pkeys,pcrc_32_tab,c) \
49 (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
50
51#define zencode(pkeys,pcrc_32_tab,c,t) \
52 (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
53
54#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
55
56#define RAND_HEAD_LEN 12
57 /* "last resort" source for second part of crypt seed pattern */
58# ifndef ZCR_SEED2
59# define ZCR_SEED2 (unsigned long)3141592654L /* use PI as default pattern */
60# endif
61
62static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
63 const char *passwd; /* password string */
64 unsigned char *buf; /* where to write header */
65 int bufSize;
66 unsigned long* pkeys;
67 const unsigned long* pcrc_32_tab;
68 unsigned long crcForCrypting;
69{
70 int n; /* index in random header */
71 int t; /* temporary */
72 int c; /* random byte */
73 unsigned char header[RAND_HEAD_LEN-2]; /* random header */
74 static unsigned calls = 0; /* ensure different random header each time */
75
76 if (bufSize<RAND_HEAD_LEN)
77 return 0;
78
79 /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
80 * output of rand() to get less predictability, since rand() is
81 * often poorly implemented.
82 */
83 if (++calls == 1)
84 {
85 srand((unsigned)(time(NULL) ^ ZCR_SEED2));
86 }
87 init_keys(passwd, pkeys, pcrc_32_tab);
88 for (n = 0; n < RAND_HEAD_LEN-2; n++)
89 {
90 c = (rand() >> 7) & 0xff;
91 header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
92 }
93 /* Encrypt random header (last two bytes is high word of crc) */
94 init_keys(passwd, pkeys, pcrc_32_tab);
95 for (n = 0; n < RAND_HEAD_LEN-2; n++)
96 {
97 buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
98 }
99 buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
100 buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
101 return n;
102}
103
104#endif
diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c
new file mode 100644
index 0000000..d35d5f5
--- /dev/null
+++ b/contrib/minizip/ioapi.c
@@ -0,0 +1,177 @@
1/* ioapi.c -- IO base function header for compress/uncompress .zip
2 files using zlib + zip or unzip API
3
4 Version 0.21, March 10th, 2003
5
6 Copyright (C) 1998-2003 Gilles Vollant
7*/
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12
13#include "zlib.h"
14#include "ioapi.h"
15
16
17
18/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
19
20#ifndef SEEK_CUR
21#define SEEK_CUR 1
22#endif
23
24#ifndef SEEK_END
25#define SEEK_END 2
26#endif
27
28#ifndef SEEK_SET
29#define SEEK_SET 0
30#endif
31
32voidpf ZCALLBACK fopen_file_func OF((
33 voidpf opaque,
34 const char* filename,
35 int mode));
36
37uLong ZCALLBACK fread_file_func OF((
38 voidpf opaque,
39 voidpf stream,
40 void* buf,
41 uLong size));
42
43uLong ZCALLBACK fwrite_file_func OF((
44 voidpf opaque,
45 voidpf stream,
46 const void* buf,
47 uLong size));
48
49long ZCALLBACK ftell_file_func OF((
50 voidpf opaque,
51 voidpf stream));
52
53long ZCALLBACK fseek_file_func OF((
54 voidpf opaque,
55 voidpf stream,
56 uLong offset,
57 int origin));
58
59int ZCALLBACK fclose_file_func OF((
60 voidpf opaque,
61 voidpf stream));
62
63int ZCALLBACK ferror_file_func OF((
64 voidpf opaque,
65 voidpf stream));
66
67
68voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
69 voidpf opaque;
70 const char* filename;
71 int mode;
72{
73 FILE* file = NULL;
74 const char* mode_fopen = NULL;
75 if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
76 mode_fopen = "rb";
77 else
78 if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
79 mode_fopen = "r+b";
80 else
81 if (mode & ZLIB_FILEFUNC_MODE_CREATE)
82 mode_fopen = "wb";
83
84 if ((filename!=NULL) && (mode_fopen != NULL))
85 file = fopen(filename, mode_fopen);
86 return file;
87}
88
89
90uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
91 voidpf opaque;
92 voidpf stream;
93 void* buf;
94 uLong size;
95{
96 uLong ret;
97 ret = fread(buf, 1, (size_t)size, (FILE *)stream);
98 return ret;
99}
100
101
102uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
103 voidpf opaque;
104 voidpf stream;
105 const void* buf;
106 uLong size;
107{
108 uLong ret;
109 ret = fwrite(buf, 1, (size_t)size, (FILE *)stream);
110 return ret;
111}
112
113long ZCALLBACK ftell_file_func (opaque, stream)
114 voidpf opaque;
115 voidpf stream;
116{
117 long ret;
118 ret = ftell((FILE *)stream);
119 return ret;
120}
121
122long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
123 voidpf opaque;
124 voidpf stream;
125 uLong offset;
126 int origin;
127{
128 int fseek_origin=0;
129 long ret;
130 switch (origin)
131 {
132 case ZLIB_FILEFUNC_SEEK_CUR :
133 fseek_origin = SEEK_CUR;
134 break;
135 case ZLIB_FILEFUNC_SEEK_END :
136 fseek_origin = SEEK_END;
137 break;
138 case ZLIB_FILEFUNC_SEEK_SET :
139 fseek_origin = SEEK_SET;
140 break;
141 default: return -1;
142 }
143 ret = 0;
144 fseek((FILE *)stream, offset, fseek_origin);
145 return ret;
146}
147
148int ZCALLBACK fclose_file_func (opaque, stream)
149 voidpf opaque;
150 voidpf stream;
151{
152 int ret;
153 ret = fclose((FILE *)stream);
154 return ret;
155}
156
157int ZCALLBACK ferror_file_func (opaque, stream)
158 voidpf opaque;
159 voidpf stream;
160{
161 int ret;
162 ret = ferror((FILE *)stream);
163 return ret;
164}
165
166void fill_fopen_filefunc (pzlib_filefunc_def)
167 zlib_filefunc_def* pzlib_filefunc_def;
168{
169 pzlib_filefunc_def->zopen_file = fopen_file_func;
170 pzlib_filefunc_def->zread_file = fread_file_func;
171 pzlib_filefunc_def->zwrite_file = fwrite_file_func;
172 pzlib_filefunc_def->ztell_file = ftell_file_func;
173 pzlib_filefunc_def->zseek_file = fseek_file_func;
174 pzlib_filefunc_def->zclose_file = fclose_file_func;
175 pzlib_filefunc_def->zerror_file = ferror_file_func;
176 pzlib_filefunc_def->opaque = NULL;
177}
diff --git a/contrib/minizip/ioapi.h b/contrib/minizip/ioapi.h
new file mode 100644
index 0000000..f30fe7a
--- /dev/null
+++ b/contrib/minizip/ioapi.h
@@ -0,0 +1,75 @@
1/* ioapi.h -- IO base function header for compress/uncompress .zip
2 files using zlib + zip or unzip API
3
4 Version 0.21, March 10th, 2003
5
6 Copyright (C) 1998-2003 Gilles Vollant
7*/
8
9#ifndef _ZLIBIOAPI_H
10#define _ZLIBIOAPI_H
11
12
13#define ZLIB_FILEFUNC_SEEK_CUR (1)
14#define ZLIB_FILEFUNC_SEEK_END (2)
15#define ZLIB_FILEFUNC_SEEK_SET (0)
16
17#define ZLIB_FILEFUNC_MODE_READ (1)
18#define ZLIB_FILEFUNC_MODE_WRITE (2)
19#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
20
21#define ZLIB_FILEFUNC_MODE_EXISTING (4)
22#define ZLIB_FILEFUNC_MODE_CREATE (8)
23
24
25#ifndef ZCALLBACK
26
27#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
28#define ZCALLBACK CALLBACK
29#else
30#define ZCALLBACK
31#endif
32#endif
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
39typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
40typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
41typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
42typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
43typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
44typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
45
46typedef struct zlib_filefunc_def_s
47{
48 open_file_func zopen_file;
49 read_file_func zread_file;
50 write_file_func zwrite_file;
51 tell_file_func ztell_file;
52 seek_file_func zseek_file;
53 close_file_func zclose_file;
54 testerror_file_func zerror_file;
55 voidpf opaque;
56} zlib_filefunc_def;
57
58
59
60void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
61
62#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
63#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
64#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
65#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
66#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
67#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
68
69
70#ifdef __cplusplus
71}
72#endif
73
74#endif
75
diff --git a/contrib/minizip/iowin32.c b/contrib/minizip/iowin32.c
new file mode 100644
index 0000000..f1f5546
--- /dev/null
+++ b/contrib/minizip/iowin32.c
@@ -0,0 +1,271 @@
1/* iowin32.c -- IO base function header for compress/uncompress .zip
2 files using zlib + zip or unzip API
3 This IO API version uses the Win32 API (for Microsoft Windows)
4
5 Version 0.21, March 10th, 2003
6
7 Copyright (C) 1998-2003 Gilles Vollant
8*/
9
10#include <windows.h>
11#include <stdlib.h>
12
13#include "zlib.h"
14#include "ioapi.h"
15#include "iowin32.h"
16
17#ifndef INVALID_HANDLE_VALUE
18#define INVALID_HANDLE_VALUE (0xFFFFFFFF)
19#endif
20
21#ifndef INVALID_SET_FILE_POINTER
22#define INVALID_SET_FILE_POINTER ((DWORD)-1)
23#endif
24
25voidpf ZCALLBACK win32_open_file_func OF((
26 voidpf opaque,
27 const char* filename,
28 int mode));
29
30uLong ZCALLBACK win32_read_file_func OF((
31 voidpf opaque,
32 voidpf stream,
33 void* buf,
34 uLong size));
35
36uLong ZCALLBACK win32_write_file_func OF((
37 voidpf opaque,
38 voidpf stream,
39 const void* buf,
40 uLong size));
41
42long ZCALLBACK win32_tell_file_func OF((
43 voidpf opaque,
44 voidpf stream));
45
46long ZCALLBACK win32_seek_file_func OF((
47 voidpf opaque,
48 voidpf stream,
49 uLong offset,
50 int origin));
51
52long ZCALLBACK win32_close_file_func OF((
53 voidpf opaque,
54 voidpf stream));
55
56int ZCALLBACK win32_error_file_func OF((
57 voidpf opaque,
58 voidpf stream));
59
60typedef struct
61{
62 HANDLE hf;
63 int error;
64} WIN32FILE_IOWIN;
65
66voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode)
67 voidpf opaque;
68 const char* filename;
69 int mode;
70{
71 const char* mode_fopen = NULL;
72 DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
73 HANDLE hFile = 0;
74 voidpf ret=NULL;
75
76 dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0;
77
78 if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
79 {
80 dwDesiredAccess = GENERIC_READ;
81 dwCreationDisposition = OPEN_EXISTING;
82 dwShareMode = FILE_SHARE_READ;
83 }
84 else
85 if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
86 {
87 dwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
88 dwCreationDisposition = OPEN_EXISTING;
89 }
90 else
91 if (mode & ZLIB_FILEFUNC_MODE_CREATE)
92 {
93 dwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
94 dwCreationDisposition = CREATE_ALWAYS;
95 }
96
97 if ((filename!=NULL) && (dwDesiredAccess != 0))
98 hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL,
99 dwCreationDisposition, dwFlagsAndAttributes, NULL);
100
101 if (hFile == INVALID_HANDLE_VALUE)
102 hFile = NULL;
103
104 if (hFile != NULL)
105 {
106 WIN32FILE_IOWIN w32fiow;
107 w32fiow.hf = hFile;
108 w32fiow.error = 0;
109 ret = malloc(sizeof(WIN32FILE_IOWIN));
110 if (ret==NULL)
111 CloseHandle(hFile);
112 else *((WIN32FILE_IOWIN*)ret) = w32fiow;
113 }
114 return ret;
115}
116
117
118uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size)
119 voidpf opaque;
120 voidpf stream;
121 void* buf;
122 uLong size;
123{
124 uLong ret=0;
125 HANDLE hFile = NULL;
126 if (stream!=NULL)
127 hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
128 if (hFile != NULL)
129 if (!ReadFile(hFile, buf, size, &ret, NULL))
130 {
131 DWORD dwErr = GetLastError();
132 if (dwErr == ERROR_HANDLE_EOF)
133 dwErr = 0;
134 ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
135 }
136
137 return ret;
138}
139
140
141uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size)
142 voidpf opaque;
143 voidpf stream;
144 const void* buf;
145 uLong size;
146{
147 uLong ret=0;
148 HANDLE hFile = NULL;
149 if (stream!=NULL)
150 hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
151
152 if (hFile !=NULL)
153 if (!WriteFile(hFile, buf, size, &ret, NULL))
154 {
155 DWORD dwErr = GetLastError();
156 if (dwErr == ERROR_HANDLE_EOF)
157 dwErr = 0;
158 ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
159 }
160
161 return ret;
162}
163
164long ZCALLBACK win32_tell_file_func (opaque, stream)
165 voidpf opaque;
166 voidpf stream;
167{
168 long ret=-1;
169 HANDLE hFile = NULL;
170 if (stream!=NULL)
171 hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
172 if (hFile != NULL)
173 {
174 DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
175 if (dwSet == INVALID_SET_FILE_POINTER)
176 {
177 DWORD dwErr = GetLastError();
178 ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
179 ret = -1;
180 }
181 else
182 ret=(long)dwSet;
183 }
184 return ret;
185}
186
187long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin)
188 voidpf opaque;
189 voidpf stream;
190 uLong offset;
191 int origin;
192{
193 DWORD dwMoveMethod=0xFFFFFFFF;
194 HANDLE hFile = NULL;
195
196 long ret=-1;
197 if (stream!=NULL)
198 hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
199 switch (origin)
200 {
201 case ZLIB_FILEFUNC_SEEK_CUR :
202 dwMoveMethod = FILE_CURRENT;
203 break;
204 case ZLIB_FILEFUNC_SEEK_END :
205 dwMoveMethod = FILE_END;
206 break;
207 case ZLIB_FILEFUNC_SEEK_SET :
208 dwMoveMethod = FILE_BEGIN;
209 break;
210 default: return -1;
211 }
212
213 if (hFile != NULL)
214 {
215 DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod);
216 if (dwSet == INVALID_SET_FILE_POINTER)
217 {
218 DWORD dwErr = GetLastError();
219 ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
220 ret = -1;
221 }
222 else
223 ret=0;
224 }
225 return ret;
226}
227
228long ZCALLBACK win32_close_file_func (opaque, stream)
229 voidpf opaque;
230 voidpf stream;
231{
232 long ret=-1;
233
234 if (stream!=NULL)
235 {
236 HANDLE hFile;
237 hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
238 if (hFile != NULL)
239 {
240 CloseHandle(hFile);
241 ret=0;
242 }
243 free(stream);
244 }
245 return ret;
246}
247
248int ZCALLBACK win32_error_file_func (opaque, stream)
249 voidpf opaque;
250 voidpf stream;
251{
252 int ret=-1;
253 if (stream!=NULL)
254 {
255 ret = ((WIN32FILE_IOWIN*)stream) -> error;
256 }
257 return ret;
258}
259
260void fill_win32_filefunc (pzlib_filefunc_def)
261 zlib_filefunc_def* pzlib_filefunc_def;
262{
263 pzlib_filefunc_def->zopen_file = win32_open_file_func;
264 pzlib_filefunc_def->zread_file = win32_read_file_func;
265 pzlib_filefunc_def->zwrite_file = win32_write_file_func;
266 pzlib_filefunc_def->ztell_file = win32_tell_file_func;
267 pzlib_filefunc_def->zseek_file = win32_seek_file_func;
268 pzlib_filefunc_def->zclose_file = win32_close_file_func;
269 pzlib_filefunc_def->zerror_file = win32_error_file_func;
270 pzlib_filefunc_def->opaque=NULL;
271}
diff --git a/contrib/minizip/iowin32.h b/contrib/minizip/iowin32.h
new file mode 100644
index 0000000..d2f5e37
--- /dev/null
+++ b/contrib/minizip/iowin32.h
@@ -0,0 +1,19 @@
1/* iowin32.h -- IO base function header for compress/uncompress .zip
2 files using zlib + zip or unzip API
3 This IO API version uses the Win32 API (for Microsoft Windows)
4
5 Version 0.21, March 10th, 2003
6
7 Copyright (C) 1998-2003 Gilles Vollant
8*/
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
15
16
17#ifdef __cplusplus
18}
19#endif
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c
index f3b7832..938d4ef 100644
--- a/contrib/minizip/miniunz.c
+++ b/contrib/minizip/miniunz.c
@@ -17,7 +17,12 @@
17 17
18#define CASESENSITIVITY (0) 18#define CASESENSITIVITY (0)
19#define WRITEBUFFERSIZE (8192) 19#define WRITEBUFFERSIZE (8192)
20#define MAXFILENAME (256)
20 21
22#ifdef WIN32
23#define USEWIN32IOAPI
24#include "iowin32.h"
25#endif
21/* 26/*
22 mini unzip, demo of unzip package 27 mini unzip, demo of unzip package
23 28
@@ -34,9 +39,9 @@
34 dosdate : the new date at the MSDos format (4 bytes) 39 dosdate : the new date at the MSDos format (4 bytes)
35 tmu_date : the SAME new date at the tm_unz format */ 40 tmu_date : the SAME new date at the tm_unz format */
36void change_file_date(filename,dosdate,tmu_date) 41void change_file_date(filename,dosdate,tmu_date)
37 const char *filename; 42 const char *filename;
38 uLong dosdate; 43 uLong dosdate;
39 tm_unz tmu_date; 44 tm_unz tmu_date;
40{ 45{
41#ifdef WIN32 46#ifdef WIN32
42 HANDLE hFile; 47 HANDLE hFile;
@@ -75,17 +80,17 @@ void change_file_date(filename,dosdate,tmu_date)
75 As I don't know well Unix, I wait feedback for the unix portion */ 80 As I don't know well Unix, I wait feedback for the unix portion */
76 81
77int mymkdir(dirname) 82int mymkdir(dirname)
78 const char* dirname; 83 const char* dirname;
79{ 84{
80 int ret=0; 85 int ret=0;
81#ifdef WIN32 86#ifdef WIN32
82 ret = mkdir(dirname); 87 ret = mkdir(dirname);
83#else 88#else
84#ifdef unix 89#ifdef unix
85 ret = mkdir (dirname,0775); 90 ret = mkdir (dirname,0775);
86#endif 91#endif
87#endif 92#endif
88 return ret; 93 return ret;
89} 94}
90 95
91int makedir (newdir) 96int makedir (newdir)
@@ -93,14 +98,14 @@ int makedir (newdir)
93{ 98{
94 char *buffer ; 99 char *buffer ;
95 char *p; 100 char *p;
96 int len = strlen(newdir); 101 int len = (int)strlen(newdir);
97 102
98 if (len <= 0) 103 if (len <= 0)
99 return 0; 104 return 0;
100 105
101 buffer = (char*)malloc(len+1); 106 buffer = (char*)malloc(len+1);
102 strcpy(buffer,newdir); 107 strcpy(buffer,newdir);
103 108
104 if (buffer[len-1] == '/') { 109 if (buffer[len-1] == '/') {
105 buffer[len-1] = '\0'; 110 buffer[len-1] = '\0';
106 } 111 }
@@ -135,104 +140,105 @@ int makedir (newdir)
135 140
136void do_banner() 141void do_banner()
137{ 142{
138 printf("MiniUnz 0.15, demo of zLib + Unz package written by Gilles Vollant\n"); 143 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"); 144 printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
140} 145}
141 146
142void do_help() 147void do_help()
143{ 148{
144 printf("Usage : miniunz [-exvlo] file.zip [file_to_extract]\n\n") ; 149 printf("Usage : miniunz [-exvlo] file.zip [file_to_extract]\n\n") ;
145} 150}
146 151
147 152
148int do_list(uf) 153int do_list(uf)
149 unzFile uf; 154 unzFile uf;
150{ 155{
151 uLong i; 156 uLong i;
152 unz_global_info gi; 157 unz_global_info gi;
153 int err; 158 int err;
154 159
155 err = unzGetGlobalInfo (uf,&gi); 160 err = unzGetGlobalInfo (uf,&gi);
156 if (err!=UNZ_OK) 161 if (err!=UNZ_OK)
157 printf("error %d with zipfile in unzGetGlobalInfo \n",err); 162 printf("error %d with zipfile in unzGetGlobalInfo \n",err);
158 printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); 163 printf(" Length Method Size Ratio Date Time CRC-32 Name\n");
159 printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); 164 printf(" ------ ------ ---- ----- ---- ---- ------ ----\n");
160 for (i=0;i<gi.number_entry;i++) 165 for (i=0;i<gi.number_entry;i++)
161 { 166 {
162 char filename_inzip[256]; 167 char filename_inzip[256];
163 unz_file_info file_info; 168 unz_file_info file_info;
164 uLong ratio=0; 169 uLong ratio=0;
165 const char *string_method; 170 const char *string_method;
166 err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); 171 err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
167 if (err!=UNZ_OK) 172 if (err!=UNZ_OK)
168 { 173 {
169 printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); 174 printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
170 break; 175 break;
171 } 176 }
172 if (file_info.uncompressed_size>0) 177 if (file_info.uncompressed_size>0)
173 ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; 178 ratio = (file_info.compressed_size*100)/file_info.uncompressed_size;
174 179
175 if (file_info.compression_method==0) 180 if (file_info.compression_method==0)
176 string_method="Stored"; 181 string_method="Stored";
177 else 182 else
178 if (file_info.compression_method==Z_DEFLATED) 183 if (file_info.compression_method==Z_DEFLATED)
179 { 184 {
180 uInt iLevel=(uInt)((file_info.flag & 0x6)/2); 185 uInt iLevel=(uInt)((file_info.flag & 0x6)/2);
181 if (iLevel==0) 186 if (iLevel==0)
182 string_method="Defl:N"; 187 string_method="Defl:N";
183 else if (iLevel==1) 188 else if (iLevel==1)
184 string_method="Defl:X"; 189 string_method="Defl:X";
185 else if ((iLevel==2) || (iLevel==3)) 190 else if ((iLevel==2) || (iLevel==3))
186 string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ 191 string_method="Defl:F"; /* 2:fast , 3 : extra fast*/
187 } 192 }
188 else 193 else
189 string_method="Unkn. "; 194 string_method="Unkn. ";
190 195
191 printf("%7lu %6s %7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", 196 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, 197 file_info.uncompressed_size,string_method,file_info.compressed_size,
193 ratio, 198 ratio,
194 (uLong)file_info.tmu_date.tm_mon + 1, 199 (uLong)file_info.tmu_date.tm_mon + 1,
195 (uLong)file_info.tmu_date.tm_mday, 200 (uLong)file_info.tmu_date.tm_mday,
196 (uLong)file_info.tmu_date.tm_year % 100, 201 (uLong)file_info.tmu_date.tm_year % 100,
197 (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, 202 (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min,
198 (uLong)file_info.crc,filename_inzip); 203 (uLong)file_info.crc,filename_inzip);
199 if ((i+1)<gi.number_entry) 204 if ((i+1)<gi.number_entry)
200 { 205 {
201 err = unzGoToNextFile(uf); 206 err = unzGoToNextFile(uf);
202 if (err!=UNZ_OK) 207 if (err!=UNZ_OK)
203 { 208 {
204 printf("error %d with zipfile in unzGoToNextFile\n",err); 209 printf("error %d with zipfile in unzGoToNextFile\n",err);
205 break; 210 break;
206 } 211 }
207 } 212 }
208 } 213 }
209 214
210 return 0; 215 return 0;
211} 216}
212 217
213 218
214int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite) 219int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
215 unzFile uf; 220 unzFile uf;
216 const int* popt_extract_without_path; 221 const int* popt_extract_without_path;
217 int* popt_overwrite; 222 int* popt_overwrite;
223 const char* password;
218{ 224{
219 char filename_inzip[256]; 225 char filename_inzip[256];
220 char* filename_withoutpath; 226 char* filename_withoutpath;
221 char* p; 227 char* p;
222 int err=UNZ_OK; 228 int err=UNZ_OK;
223 FILE *fout=NULL; 229 FILE *fout=NULL;
224 void* buf; 230 void* buf;
225 uInt size_buf; 231 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 232
231 if (err!=UNZ_OK) 233 unz_file_info file_info;
232 { 234 uLong ratio=0;
233 printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); 235 err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
234 return err; 236
235 } 237 if (err!=UNZ_OK)
238 {
239 printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
240 return err;
241 }
236 242
237 size_buf = WRITEBUFFERSIZE; 243 size_buf = WRITEBUFFERSIZE;
238 buf = (void*)malloc(size_buf); 244 buf = (void*)malloc(size_buf);
@@ -242,71 +248,71 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite)
242 return UNZ_INTERNALERROR; 248 return UNZ_INTERNALERROR;
243 } 249 }
244 250
245 p = filename_withoutpath = filename_inzip; 251 p = filename_withoutpath = filename_inzip;
246 while ((*p) != '\0') 252 while ((*p) != '\0')
247 { 253 {
248 if (((*p)=='/') || ((*p)=='\\')) 254 if (((*p)=='/') || ((*p)=='\\'))
249 filename_withoutpath = p+1; 255 filename_withoutpath = p+1;
250 p++; 256 p++;
251 } 257 }
252 258
253 if ((*filename_withoutpath)=='\0') 259 if ((*filename_withoutpath)=='\0')
254 { 260 {
255 if ((*popt_extract_without_path)==0) 261 if ((*popt_extract_without_path)==0)
256 { 262 {
257 printf("creating directory: %s\n",filename_inzip); 263 printf("creating directory: %s\n",filename_inzip);
258 mymkdir(filename_inzip); 264 mymkdir(filename_inzip);
259 } 265 }
260 } 266 }
261 else 267 else
262 { 268 {
263 const char* write_filename; 269 const char* write_filename;
264 int skip=0; 270 int skip=0;
265 271
266 if ((*popt_extract_without_path)==0) 272 if ((*popt_extract_without_path)==0)
267 write_filename = filename_inzip; 273 write_filename = filename_inzip;
268 else 274 else
269 write_filename = filename_withoutpath; 275 write_filename = filename_withoutpath;
270 276
271 err = unzOpenCurrentFile(uf); 277 err = unzOpenCurrentFilePassword(uf,password);
272 if (err!=UNZ_OK) 278 if (err!=UNZ_OK)
273 { 279 {
274 printf("error %d with zipfile in unzOpenCurrentFile\n",err); 280 printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err);
275 } 281 }
276 282
277 if (((*popt_overwrite)==0) && (err==UNZ_OK)) 283 if (((*popt_overwrite)==0) && (err==UNZ_OK))
278 { 284 {
279 char rep; 285 char rep=0;
280 FILE* ftestexist; 286 FILE* ftestexist;
281 ftestexist = fopen(write_filename,"rb"); 287 ftestexist = fopen(write_filename,"rb");
282 if (ftestexist!=NULL) 288 if (ftestexist!=NULL)
283 { 289 {
284 fclose(ftestexist); 290 fclose(ftestexist);
285 do 291 do
286 { 292 {
287 char answer[128]; 293 char answer[128];
288 printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename); 294 printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
289 scanf("%1s",answer); 295 scanf("%1s",answer);
290 rep = answer[0] ; 296 rep = answer[0] ;
291 if ((rep>='a') && (rep<='z')) 297 if ((rep>='a') && (rep<='z'))
292 rep -= 0x20; 298 rep -= 0x20;
293 } 299 }
294 while ((rep!='Y') && (rep!='N') && (rep!='A')); 300 while ((rep!='Y') && (rep!='N') && (rep!='A'));
295 } 301 }
296 302
297 if (rep == 'N') 303 if (rep == 'N')
298 skip = 1; 304 skip = 1;
299 305
300 if (rep == 'A') 306 if (rep == 'A')
301 *popt_overwrite=1; 307 *popt_overwrite=1;
302 } 308 }
303 309
304 if ((skip==0) && (err==UNZ_OK)) 310 if ((skip==0) && (err==UNZ_OK))
305 { 311 {
306 fout=fopen(write_filename,"wb"); 312 fout=fopen(write_filename,"wb");
307 313
308 /* some zipfile don't contain directory alone before file */ 314 /* some zipfile don't contain directory alone before file */
309 if ((fout==NULL) && ((*popt_extract_without_path)==0) && 315 if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
310 (filename_withoutpath!=(char*)filename_inzip)) 316 (filename_withoutpath!=(char*)filename_inzip))
311 { 317 {
312 char c=*(filename_withoutpath-1); 318 char c=*(filename_withoutpath-1);
@@ -316,95 +322,100 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite)
316 fout=fopen(write_filename,"wb"); 322 fout=fopen(write_filename,"wb");
317 } 323 }
318 324
319 if (fout==NULL) 325 if (fout==NULL)
320 { 326 {
321 printf("error opening %s\n",write_filename); 327 printf("error opening %s\n",write_filename);
322 } 328 }
323 } 329 }
324 330
325 if (fout!=NULL) 331 if (fout!=NULL)
326 { 332 {
327 printf(" extracting: %s\n",write_filename); 333 printf(" extracting: %s\n",write_filename);
328 334
329 do 335 do
330 { 336 {
331 err = unzReadCurrentFile(uf,buf,size_buf); 337 err = unzReadCurrentFile(uf,buf,size_buf);
332 if (err<0) 338 if (err<0)
333 { 339 {
334 printf("error %d with zipfile in unzReadCurrentFile\n",err); 340 printf("error %d with zipfile in unzReadCurrentFile\n",err);
335 break; 341 break;
336 } 342 }
337 if (err>0) 343 if (err>0)
338 if (fwrite(buf,err,1,fout)!=1) 344 if (fwrite(buf,err,1,fout)!=1)
339 { 345 {
340 printf("error in writing extracted file\n"); 346 printf("error in writing extracted file\n");
341 err=UNZ_ERRNO; 347 err=UNZ_ERRNO;
342 break; 348 break;
343 } 349 }
344 } 350 }
345 while (err>0); 351 while (err>0);
346 fclose(fout); 352 if (fout)
347 if (err==0) 353 fclose(fout);
348 change_file_date(write_filename,file_info.dosDate, 354
349 file_info.tmu_date); 355 if (err==0)
350 } 356 change_file_date(write_filename,file_info.dosDate,
357 file_info.tmu_date);
358 }
351 359
352 if (err==UNZ_OK) 360 if (err==UNZ_OK)
353 { 361 {
354 err = unzCloseCurrentFile (uf); 362 err = unzCloseCurrentFile (uf);
355 if (err!=UNZ_OK) 363 if (err!=UNZ_OK)
356 { 364 {
357 printf("error %d with zipfile in unzCloseCurrentFile\n",err); 365 printf("error %d with zipfile in unzCloseCurrentFile\n",err);
358 } 366 }
359 } 367 }
360 else 368 else
361 unzCloseCurrentFile(uf); /* don't lose the error */ 369 unzCloseCurrentFile(uf); /* don't lose the error */
362 } 370 }
363 371
364 free(buf); 372 free(buf);
365 return err; 373 return err;
366} 374}
367 375
368 376
369int do_extract(uf,opt_extract_without_path,opt_overwrite) 377int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
370 unzFile uf; 378 unzFile uf;
371 int opt_extract_without_path; 379 int opt_extract_without_path;
372 int opt_overwrite; 380 int opt_overwrite;
381 const char* password;
373{ 382{
374 uLong i; 383 uLong i;
375 unz_global_info gi; 384 unz_global_info gi;
376 int err; 385 int err;
377 FILE* fout=NULL; 386 FILE* fout=NULL;
378 387
379 err = unzGetGlobalInfo (uf,&gi); 388 err = unzGetGlobalInfo (uf,&gi);
380 if (err!=UNZ_OK) 389 if (err!=UNZ_OK)
381 printf("error %d with zipfile in unzGetGlobalInfo \n",err); 390 printf("error %d with zipfile in unzGetGlobalInfo \n",err);
382 391
383 for (i=0;i<gi.number_entry;i++) 392 for (i=0;i<gi.number_entry;i++)
384 { 393 {
385 if (do_extract_currentfile(uf,&opt_extract_without_path, 394 if (do_extract_currentfile(uf,&opt_extract_without_path,
386 &opt_overwrite) != UNZ_OK) 395 &opt_overwrite,
396 password) != UNZ_OK)
387 break; 397 break;
388 398
389 if ((i+1)<gi.number_entry) 399 if ((i+1)<gi.number_entry)
390 { 400 {
391 err = unzGoToNextFile(uf); 401 err = unzGoToNextFile(uf);
392 if (err!=UNZ_OK) 402 if (err!=UNZ_OK)
393 { 403 {
394 printf("error %d with zipfile in unzGoToNextFile\n",err); 404 printf("error %d with zipfile in unzGoToNextFile\n",err);
395 break; 405 break;
396 } 406 }
397 } 407 }
398 } 408 }
399 409
400 return 0; 410 return 0;
401} 411}
402 412
403int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite) 413int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
404 unzFile uf; 414 unzFile uf;
405 const char* filename; 415 const char* filename;
406 int opt_extract_without_path; 416 int opt_extract_without_path;
407 int opt_overwrite; 417 int opt_overwrite;
418 const char* password;
408{ 419{
409 int err = UNZ_OK; 420 int err = UNZ_OK;
410 if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) 421 if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
@@ -414,7 +425,8 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite)
414 } 425 }
415 426
416 if (do_extract_currentfile(uf,&opt_extract_without_path, 427 if (do_extract_currentfile(uf,&opt_extract_without_path,
417 &opt_overwrite) == UNZ_OK) 428 &opt_overwrite,
429 password) == UNZ_OK)
418 return 0; 430 return 0;
419 else 431 else
420 return 1; 432 return 1;
@@ -422,87 +434,110 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite)
422 434
423 435
424int main(argc,argv) 436int main(argc,argv)
425 int argc; 437 int argc;
426 char *argv[]; 438 char *argv[];
427{ 439{
428 const char *zipfilename=NULL; 440 const char *zipfilename=NULL;
429 const char *filename_to_extract=NULL; 441 const char *filename_to_extract=NULL;
430 int i; 442 const char *password=NULL;
431 int opt_do_list=0; 443 char filename_try[MAXFILENAME+16] = "";
432 int opt_do_extract=1; 444 int i;
433 int opt_do_extract_withoutpath=0; 445 int opt_do_list=0;
434 int opt_overwrite=0; 446 int opt_do_extract=1;
435 char filename_try[512]; 447 int opt_do_extract_withoutpath=0;
436 unzFile uf=NULL; 448 int opt_overwrite=0;
437 449 unzFile uf=NULL;
438 do_banner(); 450
439 if (argc==1) 451 do_banner();
440 { 452 if (argc==1)
441 do_help(); 453 {
442 exit(0); 454 do_help();
443 } 455 return 0;
444 else 456 }
445 { 457 else
446 for (i=1;i<argc;i++) 458 {
447 { 459 for (i=1;i<argc;i++)
448 if ((*argv[i])=='-') 460 {
449 { 461 if ((*argv[i])=='-')
450 const char *p=argv[i]+1; 462 {
451 463 const char *p=argv[i]+1;
452 while ((*p)!='\0') 464
453 { 465 while ((*p)!='\0')
454 char c=*(p++);; 466 {
455 if ((c=='l') || (c=='L')) 467 char c=*(p++);;
456 opt_do_list = 1; 468 if ((c=='l') || (c=='L'))
457 if ((c=='v') || (c=='V')) 469 opt_do_list = 1;
458 opt_do_list = 1; 470 if ((c=='v') || (c=='V'))
459 if ((c=='x') || (c=='X')) 471 opt_do_list = 1;
460 opt_do_extract = 1; 472 if ((c=='x') || (c=='X'))
461 if ((c=='e') || (c=='E')) 473 opt_do_extract = 1;
462 opt_do_extract = opt_do_extract_withoutpath = 1; 474 if ((c=='e') || (c=='E'))
463 if ((c=='o') || (c=='O')) 475 opt_do_extract = opt_do_extract_withoutpath = 1;
464 opt_overwrite=1; 476 if ((c=='o') || (c=='O'))
465 } 477 opt_overwrite=1;
466 } 478 if (((c=='p') || (c=='P')) && (i+1<argc))
467 else 479 {
480 password=argv[i+1];
481 i++;
482 }
483 }
484 }
485 else
468 { 486 {
469 if (zipfilename == NULL) 487 if (zipfilename == NULL)
470 zipfilename = argv[i]; 488 zipfilename = argv[i];
471 else if (filename_to_extract==NULL) 489 else if (filename_to_extract==NULL)
472 filename_to_extract = argv[i] ; 490 filename_to_extract = argv[i] ;
473 } 491 }
474 } 492 }
475 } 493 }
476 494
477 if (zipfilename!=NULL) 495 if (zipfilename!=NULL)
478 { 496 {
479 strcpy(filename_try,zipfilename); 497
480 uf = unzOpen(zipfilename); 498 #ifdef USEWIN32IOAPI
481 if (uf==NULL) 499 zlib_filefunc_def ffunc;
482 { 500 #endif
483 strcat(filename_try,".zip"); 501
484 uf = unzOpen(filename_try); 502 strncpy(filename_try, zipfilename,MAXFILENAME-1);
485 } 503 /* strncpy doesnt append the trailing NULL, of the string is too long. */
486 } 504 filename_try[ MAXFILENAME ] = '\0';
487 505
488 if (uf==NULL) 506 #ifdef USEWIN32IOAPI
489 { 507 fill_win32_filefunc(&ffunc);
490 printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename); 508 uf = unzOpen2(zipfilename,&ffunc);
491 exit (1); 509 #else
492 } 510 uf = unzOpen(zipfilename);
511 #endif
512 if (uf==NULL)
513 {
514 strcat(filename_try,".zip");
515 #ifdef USEWIN32IOAPI
516 uf = unzOpen2(filename_try,&ffunc);
517 #else
518 uf = unzOpen(filename_try);
519 #endif
520 }
521 }
522
523 if (uf==NULL)
524 {
525 printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename);
526 return 1;
527 }
493 printf("%s opened\n",filename_try); 528 printf("%s opened\n",filename_try);
494 529
495 if (opt_do_list==1) 530 if (opt_do_list==1)
496 return do_list(uf); 531 return do_list(uf);
497 else if (opt_do_extract==1) 532 else if (opt_do_extract==1)
498 { 533 {
499 if (filename_to_extract == NULL) 534 if (filename_to_extract == NULL)
500 return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite); 535 return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,password);
501 else 536 else
502 return do_extract_onefile(uf,filename_to_extract, 537 return do_extract_onefile(uf,filename_to_extract,
503 opt_do_extract_withoutpath,opt_overwrite); 538 opt_do_extract_withoutpath,opt_overwrite,password);
504 } 539 }
505 unzCloseCurrentFile(uf); 540 unzCloseCurrentFile(uf);
506 541
507 return 0; /* to avoid warning */ 542 return 0;
508} 543}
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c
index 5e492d2..5792a1e 100644
--- a/contrib/minizip/minizip.c
+++ b/contrib/minizip/minizip.c
@@ -17,6 +17,12 @@
17 17
18#include "zip.h" 18#include "zip.h"
19 19
20#ifdef WIN32
21#define USEWIN32IOAPI
22#include "iowin32.h"
23#endif
24
25
20 26
21#define WRITEBUFFERSIZE (16384) 27#define WRITEBUFFERSIZE (16384)
22#define MAXFILENAME (256) 28#define MAXFILENAME (256)
@@ -55,12 +61,16 @@ uLong filetime(f, tmzip, dt)
55 struct stat s; /* results of stat() */ 61 struct stat s; /* results of stat() */
56 struct tm* filedate; 62 struct tm* filedate;
57 time_t tm_t=0; 63 time_t tm_t=0;
58 64
59 if (strcmp(f,"-")!=0) 65 if (strcmp(f,"-")!=0)
60 { 66 {
61 char name[MAXFILENAME]; 67 char name[MAXFILENAME+1];
62 int len = strlen(f); 68 int len = strlen(f);
63 strcpy(name, f); 69
70 strncpy(name, f,MAXFILENAME-1);
71 /* strncpy doesnt append the trailing NULL, of the string is too long. */
72 name[ MAXFILENAME ] = '\0';
73
64 if (name[len - 1] == '/') 74 if (name[len - 1] == '/')
65 name[len - 1] = '\0'; 75 name[len - 1] = '\0';
66 /* not all systems allow stat'ing a file with / appended */ 76 /* not all systems allow stat'ing a file with / appended */
@@ -98,10 +108,10 @@ uLong filetime(f, tmzip, dt)
98int check_exist_file(filename) 108int check_exist_file(filename)
99 const char* filename; 109 const char* filename;
100{ 110{
101 FILE* ftestexist; 111 FILE* ftestexist;
102 int ret = 1; 112 int ret = 1;
103 ftestexist = fopen(filename,"rb"); 113 ftestexist = fopen(filename,"rb");
104 if (ftestexist==NULL) 114 if (ftestexist==NULL)
105 ret = 0; 115 ret = 0;
106 else 116 else
107 fclose(ftestexist); 117 fclose(ftestexist);
@@ -110,59 +120,107 @@ int check_exist_file(filename)
110 120
111void do_banner() 121void do_banner()
112{ 122{
113 printf("MiniZip 0.15, demo of zLib + Zip package written by Gilles Vollant\n"); 123 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"); 124 printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
115} 125}
116 126
117void do_help() 127void do_help()
118{ 128{
119 printf("Usage : minizip [-o] file.zip [files_to_add]\n\n") ; 129 printf("Usage : minizip [-o] file.zip [files_to_add]\n\n") ;
130}
131
132/* calculate the CRC32 of a file,
133 because to encrypt a file, we need known the CRC32 of the file before */
134int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
135{
136 unsigned long calculate_crc=0;
137 int err=ZIP_OK;
138 FILE * fin = fopen(filenameinzip,"rb");
139 unsigned long size_read = 0;
140 unsigned long total_read = 0;
141 if (fin==NULL)
142 {
143 err = ZIP_ERRNO;
144 }
145
146 if (err == ZIP_OK)
147 do
148 {
149 err = ZIP_OK;
150 size_read = (int)fread(buf,1,size_buf,fin);
151 if (size_read < size_buf)
152 if (feof(fin)==0)
153 {
154 printf("error in reading %s\n",filenameinzip);
155 err = ZIP_ERRNO;
156 }
157
158 if (size_read>0)
159 calculate_crc = crc32(calculate_crc,buf,size_read);
160 total_read += size_read;
161
162 } while ((err == ZIP_OK) && (size_read>0));
163
164 if (fin)
165 fclose(fin);
166
167 *result_crc=calculate_crc;
168 printf("file %s crc %x\n",filenameinzip,calculate_crc);
169 return err;
120} 170}
121 171
122int main(argc,argv) 172int main(argc,argv)
123 int argc; 173 int argc;
124 char *argv[]; 174 char *argv[];
125{ 175{
126 int i; 176 int i;
127 int opt_overwrite=0; 177 int opt_overwrite=0;
128 int opt_compress_level=Z_DEFAULT_COMPRESSION; 178 int opt_compress_level=Z_DEFAULT_COMPRESSION;
129 int zipfilenamearg = 0; 179 int zipfilenamearg = 0;
130 char filename_try[MAXFILENAME]; 180 char filename_try[MAXFILENAME+16];
131 int zipok; 181 int zipok;
132 int err=0; 182 int err=0;
133 int size_buf=0; 183 int size_buf=0;
134 void* buf=NULL, 184 void* buf=NULL;
185 const char* password=NULL;
135 186
136 187
137 do_banner(); 188 do_banner();
138 if (argc==1) 189 if (argc==1)
139 { 190 {
140 do_help(); 191 do_help();
141 exit(0);
142 return 0; 192 return 0;
143 } 193 }
144 else 194 else
145 { 195 {
146 for (i=1;i<argc;i++) 196 for (i=1;i<argc;i++)
147 { 197 {
148 if ((*argv[i])=='-') 198 if ((*argv[i])=='-')
149 { 199 {
150 const char *p=argv[i]+1; 200 const char *p=argv[i]+1;
151 201
152 while ((*p)!='\0') 202 while ((*p)!='\0')
153 { 203 {
154 char c=*(p++);; 204 char c=*(p++);;
155 if ((c=='o') || (c=='O')) 205 if ((c=='o') || (c=='O'))
156 opt_overwrite = 1; 206 opt_overwrite = 1;
207 if ((c=='a') || (c=='A'))
208 opt_overwrite = 2;
157 if ((c>='0') && (c<='9')) 209 if ((c>='0') && (c<='9'))
158 opt_compress_level = c-'0'; 210 opt_compress_level = c-'0';
159 } 211
160 } 212 if (((c=='p') || (c=='P')) && (i+1<argc))
161 else 213 {
162 if (zipfilenamearg == 0) 214 password=argv[i+1];
215 i++;
216 }
217 }
218 }
219 else
220 if (zipfilenamearg == 0)
163 zipfilenamearg = i ; 221 zipfilenamearg = i ;
164 } 222 }
165 } 223 }
166 224
167 size_buf = WRITEBUFFERSIZE; 225 size_buf = WRITEBUFFERSIZE;
168 buf = (void*)malloc(size_buf); 226 buf = (void*)malloc(size_buf);
@@ -172,16 +230,19 @@ int main(argc,argv)
172 return ZIP_INTERNALERROR; 230 return ZIP_INTERNALERROR;
173 } 231 }
174 232
175 if (zipfilenamearg==0) 233 if (zipfilenamearg==0)
176 zipok=0; 234 zipok=0;
177 else 235 else
178 { 236 {
179 int i,len; 237 int i,len;
180 int dot_found=0; 238 int dot_found=0;
181 239
182 zipok = 1 ; 240 zipok = 1 ;
183 strcpy(filename_try,argv[zipfilenamearg]); 241 strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
184 len=strlen(filename_try); 242 /* strncpy doesnt append the trailing NULL, of the string is too long. */
243 filename_try[ MAXFILENAME ] = '\0';
244
245 len=(int)strlen(filename_try);
185 for (i=0;i<len;i++) 246 for (i=0;i<len;i++)
186 if (filename_try[i]=='.') 247 if (filename_try[i]=='.')
187 dot_found=1; 248 dot_found=1;
@@ -189,36 +250,52 @@ int main(argc,argv)
189 if (dot_found==0) 250 if (dot_found==0)
190 strcat(filename_try,".zip"); 251 strcat(filename_try,".zip");
191 252
253 if (opt_overwrite==2)
254 {
255 /* if the file don't exist, we not append file */
256 if (check_exist_file(filename_try)==0)
257 opt_overwrite=1;
258 }
259 else
192 if (opt_overwrite==0) 260 if (opt_overwrite==0)
193 if (check_exist_file(filename_try)!=0) 261 if (check_exist_file(filename_try)!=0)
194 { 262 {
195 char rep; 263 char rep=0;
196 do 264 do
197 { 265 {
198 char answer[128]; 266 char answer[128];
199 printf("The file %s exist. Overwrite ? [y]es, [n]o : ",filename_try); 267 printf("The file %s exist. Overwrite ? [y]es, [n]o, [a]ppend : ",filename_try);
200 scanf("%1s",answer); 268 scanf("%1s",answer);
201 rep = answer[0] ; 269 rep = answer[0] ;
202 if ((rep>='a') && (rep<='z')) 270 if ((rep>='a') && (rep<='z'))
203 rep -= 0x20; 271 rep -= 0x20;
204 } 272 }
205 while ((rep!='Y') && (rep!='N')); 273 while ((rep!='Y') && (rep!='N') && (rep!='A'));
206 if (rep=='N') 274 if (rep=='N')
207 zipok = 0; 275 zipok = 0;
208 } 276 if (rep=='A')
277 opt_overwrite = 2;
278 }
209 } 279 }
210 280
211 if (zipok==1) 281 if (zipok==1)
212 { 282 {
213 zipFile zf; 283 zipFile zf;
214 int errclose; 284 int errclose;
215 zf = zipOpen(filename_try,0); 285 #ifdef USEWIN32IOAPI
286 zlib_filefunc_def ffunc;
287 fill_win32_filefunc(&ffunc);
288 zf = zipOpen2(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc);
289 #else
290 zf = zipOpen(filename_try,(opt_overwrite==2) ? 2 : 0);
291 #endif
292
216 if (zf == NULL) 293 if (zf == NULL)
217 { 294 {
218 printf("error opening %s\n",filename_try); 295 printf("error opening %s\n",filename_try);
219 err= ZIP_ERRNO; 296 err= ZIP_ERRNO;
220 } 297 }
221 else 298 else
222 printf("creating %s\n",filename_try); 299 printf("creating %s\n",filename_try);
223 300
224 for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++) 301 for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++)
@@ -229,19 +306,31 @@ int main(argc,argv)
229 int size_read; 306 int size_read;
230 const char* filenameinzip = argv[i]; 307 const char* filenameinzip = argv[i];
231 zip_fileinfo zi; 308 zip_fileinfo zi;
309 unsigned long crcFile=0;
232 310
233 zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = 311 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; 312 zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
235 zi.dosDate = 0; 313 zi.dosDate = 0;
236 zi.internal_fa = 0; 314 zi.internal_fa = 0;
237 zi.external_fa = 0; 315 zi.external_fa = 0;
238 filetime(filenameinzip,&zi.tmz_date,&zi.dosDate); 316 filetime(filenameinzip,&zi.tmz_date,&zi.dosDate);
239 317
240 318/*
241 err = zipOpenNewFileInZip(zf,filenameinzip,&zi, 319 err = zipOpenNewFileInZip(zf,filenameinzip,&zi,
242 NULL,0,NULL,0,NULL /* comment*/, 320 NULL,0,NULL,0,NULL / * comment * /,
243 (opt_compress_level != 0) ? Z_DEFLATED : 0, 321 (opt_compress_level != 0) ? Z_DEFLATED : 0,
244 opt_compress_level); 322 opt_compress_level);
323*/
324 if ((password != NULL) && (err==ZIP_OK))
325 err = getFileCrc(filenameinzip,buf,size_buf,&crcFile);
326
327 err = zipOpenNewFileInZip3(zf,filenameinzip,&zi,
328 NULL,0,NULL,0,NULL /* comment*/,
329 (opt_compress_level != 0) ? Z_DEFLATED : 0,
330 opt_compress_level,0,
331 /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */
332 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
333 password,crcFile);
245 334
246 if (err != ZIP_OK) 335 if (err != ZIP_OK)
247 printf("error in opening %s in zipfile\n",filenameinzip); 336 printf("error in opening %s in zipfile\n",filenameinzip);
@@ -259,7 +348,7 @@ int main(argc,argv)
259 do 348 do
260 { 349 {
261 err = ZIP_OK; 350 err = ZIP_OK;
262 size_read = fread(buf,1,size_buf,fin); 351 size_read = (int)fread(buf,1,size_buf,fin);
263 if (size_read < size_buf) 352 if (size_read < size_buf)
264 if (feof(fin)==0) 353 if (feof(fin)==0)
265 { 354 {
@@ -275,15 +364,17 @@ int main(argc,argv)
275 printf("error in writing %s in the zipfile\n", 364 printf("error in writing %s in the zipfile\n",
276 filenameinzip); 365 filenameinzip);
277 } 366 }
278 367
279 } 368 }
280 } while ((err == ZIP_OK) && (size_read>0)); 369 } while ((err == ZIP_OK) && (size_read>0));
281 370
282 fclose(fin); 371 if (fin)
372 fclose(fin);
373
283 if (err<0) 374 if (err<0)
284 err=ZIP_ERRNO; 375 err=ZIP_ERRNO;
285 else 376 else
286 { 377 {
287 err = zipCloseFileInZip(zf); 378 err = zipCloseFileInZip(zf);
288 if (err!=ZIP_OK) 379 if (err!=ZIP_OK)
289 printf("error in closing %s in the zipfile\n", 380 printf("error in closing %s in the zipfile\n",
@@ -297,6 +388,5 @@ int main(argc,argv)
297 } 388 }
298 389
299 free(buf); 390 free(buf);
300 exit(0); 391 return 0;
301 return 0; /* to avoid warning */
302} 392}
diff --git a/contrib/minizip/readme.txt b/contrib/minizip/readme.txt
deleted file mode 100644
index 1fc023c..0000000
--- a/contrib/minizip/readme.txt
+++ /dev/null
@@ -1,37 +0,0 @@
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
index ff71a47..7244523 100644
--- a/contrib/minizip/unzip.c
+++ b/contrib/minizip/unzip.c
@@ -1,9 +1,39 @@
1/* unzip.c -- IO on .zip files using zlib 1/* unzip.c -- IO for uncompress .zip files using zlib
2 Version 0.15 beta, Mar 19th, 1998, 2 Version 0.21 with encryption, March 10th, 2003
3
4 Copyright (C) 1998-2003 Gilles Vollant
3 5
4 Read unzip.h for more info 6 Read unzip.h for more info
5*/ 7*/
6 8
9/* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
10compatibility with older software. The following is from the original crypt.c. Code
11woven in by Terry Thorsen 1/2003.
12*/
13/*
14 Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
15
16 See the accompanying file LICENSE, version 2000-Apr-09 or later
17 (the contents of which are also included in zip.h) for terms of use.
18 If, for some reason, all these files are missing, the Info-ZIP license
19 also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
20*/
21/*
22 crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h]
23
24 The encryption/decryption parts of this source code (as opposed to the
25 non-echoing password parts) were originally written in Europe. The
26 whole source package can be freely distributed, including from the USA.
27 (Prior to January 2000, re-export from the US was a violation of US law.)
28 */
29
30/*
31 This encryption code is a direct transcription of the algorithm from
32 Roger Schlafly, described by Phil Katz in the file appnote.txt. This
33 file (appnote.txt) is distributed with the PKZIP program (even in the
34 version without encryption capabilities).
35 */
36
7 37
8#include <stdio.h> 38#include <stdio.h>
9#include <stdlib.h> 39#include <stdlib.h>
@@ -55,22 +85,10 @@
55#define SIZEZIPLOCALHEADER (0x1e) 85#define SIZEZIPLOCALHEADER (0x1e)
56 86
57 87
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 88
68#ifndef SEEK_SET
69#define SEEK_SET 0
70#endif
71 89
72const char unz_copyright[] = 90const char unz_copyright[] =
73 " unzip 0.15 Copyright 1998 Gilles Vollant "; 91 " unzip 0.21 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll";
74 92
75/* unz_file_info_interntal contain internal info about a file in zipfile*/ 93/* unz_file_info_interntal contain internal info about a file in zipfile*/
76typedef struct unz_file_info_internal_s 94typedef struct unz_file_info_internal_s
@@ -83,23 +101,25 @@ typedef struct unz_file_info_internal_s
83 when reading and decompress it */ 101 when reading and decompress it */
84typedef struct 102typedef struct
85{ 103{
86 char *read_buffer; /* internal buffer for compressed data */ 104 char *read_buffer; /* internal buffer for compressed data */
87 z_stream stream; /* zLib stream structure for inflate */ 105 z_stream stream; /* zLib stream structure for inflate */
88 106
89 uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ 107 uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
90 uLong stream_initialised; /* flag set if stream structure is initialised*/ 108 uLong stream_initialised; /* flag set if stream structure is initialised*/
91 109
92 uLong offset_local_extrafield;/* offset of the local extra field */ 110 uLong offset_local_extrafield;/* offset of the local extra field */
93 uInt size_local_extrafield;/* size of the local extra field */ 111 uInt size_local_extrafield;/* size of the local extra field */
94 uLong pos_local_extrafield; /* position in the local extra field in read*/ 112 uLong pos_local_extrafield; /* position in the local extra field in read*/
95 113
96 uLong crc32; /* crc32 of all data uncompressed */ 114 uLong crc32; /* crc32 of all data uncompressed */
97 uLong crc32_wait; /* crc32 we must obtain after decompress all */ 115 uLong crc32_wait; /* crc32 we must obtain after decompress all */
98 uLong rest_read_compressed; /* number of byte to be decompressed */ 116 uLong rest_read_compressed; /* number of byte to be decompressed */
99 uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ 117 uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
100 FILE* file; /* io structore of the zipfile */ 118 zlib_filefunc_def z_filefunc;
101 uLong compression_method; /* compression method (0==store) */ 119 voidpf filestream; /* io structore of the zipfile */
102 uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ 120 uLong compression_method; /* compression method (0==store) */
121 uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
122 int raw;
103} file_in_zip_read_info_s; 123} file_in_zip_read_info_s;
104 124
105 125
@@ -107,25 +127,35 @@ typedef struct
107*/ 127*/
108typedef struct 128typedef struct
109{ 129{
110 FILE* file; /* io structore of the zipfile */ 130 zlib_filefunc_def z_filefunc;
111 unz_global_info gi; /* public global information */ 131 voidpf filestream; /* io structore of the zipfile */
112 uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ 132 unz_global_info gi; /* public global information */
113 uLong num_file; /* number of the current file in the zipfile*/ 133 uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
114 uLong pos_in_central_dir; /* pos of the current file in the central dir*/ 134 uLong num_file; /* number of the current file in the zipfile*/
115 uLong current_file_ok; /* flag about the usability of the current file*/ 135 uLong pos_in_central_dir; /* pos of the current file in the central dir*/
116 uLong central_pos; /* position of the beginning of the central dir*/ 136 uLong current_file_ok; /* flag about the usability of the current file*/
117 137 uLong central_pos; /* position of the beginning of the central dir*/
118 uLong size_central_dir; /* size of the central directory */ 138
119 uLong offset_central_dir; /* offset of start of central directory with 139 uLong size_central_dir; /* size of the central directory */
120 respect to the starting disk number */ 140 uLong offset_central_dir; /* offset of start of central directory with
121 141 respect to the starting disk number */
122 unz_file_info cur_file_info; /* public info about the current file in zip*/ 142
123 unz_file_info_internal cur_file_info_internal; /* private info about it*/ 143 unz_file_info cur_file_info; /* public info about the current file in zip*/
144 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 145 file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
125 file if we are decompressing it */ 146 file if we are decompressing it */
147 int encrypted;
148 #ifndef NOUNCRPYT
149 unsigned long keys[3]; /* keys defining the pseudo-random sequence */
150 const unsigned long* pcrc_32_tab;
151 #endif
126} unz_s; 152} unz_s;
127 153
128 154
155#ifndef NOUNCRPYT
156#include "crypt.h"
157#endif
158
129/* =========================================================================== 159/* ===========================================================================
130 Read a byte from a gz_stream; update next_in and avail_in. Return EOF 160 Read a byte from a gz_stream; update next_in and avail_in. Return EOF
131 for end of file. 161 for end of file.
@@ -133,12 +163,18 @@ typedef struct
133*/ 163*/
134 164
135 165
136local int unzlocal_getByte(fin,pi) 166local int unzlocal_getByte OF((
137 FILE *fin; 167 const zlib_filefunc_def* pzlib_filefunc_def,
138 int *pi; 168 voidpf filestream,
169 int *pi));
170
171local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi)
172 const zlib_filefunc_def* pzlib_filefunc_def;
173 voidpf filestream;
174 int *pi;
139{ 175{
140 unsigned char c; 176 unsigned char c;
141 int err = fread(&c, 1, 1, fin); 177 int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
142 if (err==1) 178 if (err==1)
143 { 179 {
144 *pi = (int)c; 180 *pi = (int)c;
@@ -146,7 +182,7 @@ local int unzlocal_getByte(fin,pi)
146 } 182 }
147 else 183 else
148 { 184 {
149 if (ferror(fin)) 185 if (ZERROR(*pzlib_filefunc_def,filestream))
150 return UNZ_ERRNO; 186 return UNZ_ERRNO;
151 else 187 else
152 return UNZ_EOF; 188 return UNZ_EOF;
@@ -155,23 +191,29 @@ local int unzlocal_getByte(fin,pi)
155 191
156 192
157/* =========================================================================== 193/* ===========================================================================
158 Reads a long in LSB order from the given gz_stream. Sets 194 Reads a long in LSB order from the given gz_stream. Sets
159*/ 195*/
160local int unzlocal_getShort (fin,pX) 196local int unzlocal_getShort OF((
161 FILE* fin; 197 const zlib_filefunc_def* pzlib_filefunc_def,
198 voidpf filestream,
199 uLong *pX));
200
201local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
202 const zlib_filefunc_def* pzlib_filefunc_def;
203 voidpf filestream;
162 uLong *pX; 204 uLong *pX;
163{ 205{
164 uLong x ; 206 uLong x ;
165 int i; 207 int i;
166 int err; 208 int err;
167 209
168 err = unzlocal_getByte(fin,&i); 210 err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
169 x = (uLong)i; 211 x = (uLong)i;
170 212
171 if (err==UNZ_OK) 213 if (err==UNZ_OK)
172 err = unzlocal_getByte(fin,&i); 214 err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
173 x += ((uLong)i)<<8; 215 x += ((uLong)i)<<8;
174 216
175 if (err==UNZ_OK) 217 if (err==UNZ_OK)
176 *pX = x; 218 *pX = x;
177 else 219 else
@@ -179,29 +221,35 @@ local int unzlocal_getShort (fin,pX)
179 return err; 221 return err;
180} 222}
181 223
182local int unzlocal_getLong (fin,pX) 224local int unzlocal_getLong OF((
183 FILE* fin; 225 const zlib_filefunc_def* pzlib_filefunc_def,
226 voidpf filestream,
227 uLong *pX));
228
229local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
230 const zlib_filefunc_def* pzlib_filefunc_def;
231 voidpf filestream;
184 uLong *pX; 232 uLong *pX;
185{ 233{
186 uLong x ; 234 uLong x ;
187 int i; 235 int i;
188 int err; 236 int err;
189 237
190 err = unzlocal_getByte(fin,&i); 238 err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
191 x = (uLong)i; 239 x = (uLong)i;
192 240
193 if (err==UNZ_OK) 241 if (err==UNZ_OK)
194 err = unzlocal_getByte(fin,&i); 242 err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
195 x += ((uLong)i)<<8; 243 x += ((uLong)i)<<8;
196 244
197 if (err==UNZ_OK) 245 if (err==UNZ_OK)
198 err = unzlocal_getByte(fin,&i); 246 err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
199 x += ((uLong)i)<<16; 247 x += ((uLong)i)<<16;
200 248
201 if (err==UNZ_OK) 249 if (err==UNZ_OK)
202 err = unzlocal_getByte(fin,&i); 250 err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
203 x += ((uLong)i)<<24; 251 x += ((uLong)i)<<24;
204 252
205 if (err==UNZ_OK) 253 if (err==UNZ_OK)
206 *pX = x; 254 *pX = x;
207 else 255 else
@@ -212,26 +260,26 @@ local int unzlocal_getLong (fin,pX)
212 260
213/* My own strcmpi / strcasecmp */ 261/* My own strcmpi / strcasecmp */
214local int strcmpcasenosensitive_internal (fileName1,fileName2) 262local int strcmpcasenosensitive_internal (fileName1,fileName2)
215 const char* fileName1; 263 const char* fileName1;
216 const char* fileName2; 264 const char* fileName2;
217{ 265{
218 for (;;) 266 for (;;)
219 { 267 {
220 char c1=*(fileName1++); 268 char c1=*(fileName1++);
221 char c2=*(fileName2++); 269 char c2=*(fileName2++);
222 if ((c1>='a') && (c1<='z')) 270 if ((c1>='a') && (c1<='z'))
223 c1 -= 0x20; 271 c1 -= 0x20;
224 if ((c2>='a') && (c2<='z')) 272 if ((c2>='a') && (c2<='z'))
225 c2 -= 0x20; 273 c2 -= 0x20;
226 if (c1=='\0') 274 if (c1=='\0')
227 return ((c2=='\0') ? 0 : -1); 275 return ((c2=='\0') ? 0 : -1);
228 if (c2=='\0') 276 if (c2=='\0')
229 return 1; 277 return 1;
230 if (c1<c2) 278 if (c1<c2)
231 return -1; 279 return -1;
232 if (c1>c2) 280 if (c1>c2)
233 return 1; 281 return 1;
234 } 282 }
235} 283}
236 284
237 285
@@ -245,7 +293,7 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2)
245#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal 293#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
246#endif 294#endif
247 295
248/* 296/*
249 Compare two filename (fileName1,fileName2). 297 Compare two filename (fileName1,fileName2).
250 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) 298 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
251 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi 299 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
@@ -255,203 +303,225 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2)
255 303
256*/ 304*/
257extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) 305extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
258 const char* fileName1; 306 const char* fileName1;
259 const char* fileName2; 307 const char* fileName2;
260 int iCaseSensitivity; 308 int iCaseSensitivity;
261{ 309{
262 if (iCaseSensitivity==0) 310 if (iCaseSensitivity==0)
263 iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; 311 iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
264 312
265 if (iCaseSensitivity==1) 313 if (iCaseSensitivity==1)
266 return strcmp(fileName1,fileName2); 314 return strcmp(fileName1,fileName2);
267 315
268 return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); 316 return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
269} 317}
270 318
319#ifndef BUFREADCOMMENT
271#define BUFREADCOMMENT (0x400) 320#define BUFREADCOMMENT (0x400)
321#endif
272 322
273/* 323/*
274 Locate the Central directory of a zipfile (at the end, just before 324 Locate the Central directory of a zipfile (at the end, just before
275 the global comment) 325 the global comment)
276*/ 326*/
277local uLong unzlocal_SearchCentralDir(fin) 327local uLong unzlocal_SearchCentralDir OF((
278 FILE *fin; 328 const zlib_filefunc_def* pzlib_filefunc_def,
329 voidpf filestream));
330
331local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
332 const zlib_filefunc_def* pzlib_filefunc_def;
333 voidpf filestream;
279{ 334{
280 unsigned char* buf; 335 unsigned char* buf;
281 uLong uSizeFile; 336 uLong uSizeFile;
282 uLong uBackRead; 337 uLong uBackRead;
283 uLong uMaxBack=0xffff; /* maximum size of global comment */ 338 uLong uMaxBack=0xffff; /* maximum size of global comment */
284 uLong uPosFound=0; 339 uLong uPosFound=0;
285 340
286 if (fseek(fin,0,SEEK_END) != 0) 341 if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
287 return 0; 342 return 0;
288 343
289 344
290 uSizeFile = ftell( fin ); 345 uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
291 346
292 if (uMaxBack>uSizeFile) 347 if (uMaxBack>uSizeFile)
293 uMaxBack = uSizeFile; 348 uMaxBack = uSizeFile;
294 349
295 buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); 350 buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
296 if (buf==NULL) 351 if (buf==NULL)
297 return 0; 352 return 0;
298 353
299 uBackRead = 4; 354 uBackRead = 4;
300 while (uBackRead<uMaxBack) 355 while (uBackRead<uMaxBack)
301 { 356 {
302 uLong uReadSize,uReadPos ; 357 uLong uReadSize,uReadPos ;
303 int i; 358 int i;
304 if (uBackRead+BUFREADCOMMENT>uMaxBack) 359 if (uBackRead+BUFREADCOMMENT>uMaxBack)
305 uBackRead = uMaxBack; 360 uBackRead = uMaxBack;
306 else 361 else
307 uBackRead+=BUFREADCOMMENT; 362 uBackRead+=BUFREADCOMMENT;
308 uReadPos = uSizeFile-uBackRead ; 363 uReadPos = uSizeFile-uBackRead ;
309 364
310 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? 365 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
311 (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); 366 (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
312 if (fseek(fin,uReadPos,SEEK_SET)!=0) 367 if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
313 break; 368 break;
314 369
315 if (fread(buf,(uInt)uReadSize,1,fin)!=1) 370 if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
316 break; 371 break;
317 372
318 for (i=(int)uReadSize-3; (i--)>0;) 373 for (i=(int)uReadSize-3; (i--)>0;)
319 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && 374 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
320 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) 375 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
321 { 376 {
322 uPosFound = uReadPos+i; 377 uPosFound = uReadPos+i;
323 break; 378 break;
324 } 379 }
325 380
326 if (uPosFound!=0) 381 if (uPosFound!=0)
327 break; 382 break;
328 } 383 }
329 TRYFREE(buf); 384 TRYFREE(buf);
330 return uPosFound; 385 return uPosFound;
331} 386}
332 387
333/* 388/*
334 Open a Zip file. path contain the full pathname (by example, 389 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 390 on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
336 "zlib/zlib109.zip". 391 "zlib/zlib114.zip".
337 If the zipfile cannot be opened (file don't exist or in not valid), the 392 If the zipfile cannot be opened (file doesn't exist or in not valid), the
338 return value is NULL. 393 return value is NULL.
339 Else, the return value is a unzFile Handle, usable with other function 394 Else, the return value is a unzFile Handle, usable with other function
340 of this unzip package. 395 of this unzip package.
341*/ 396*/
342extern unzFile ZEXPORT unzOpen (path) 397extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
343 const char *path; 398 const char *path;
399 zlib_filefunc_def* pzlib_filefunc_def;
344{ 400{
345 unz_s us; 401 unz_s us;
346 unz_s *s; 402 unz_s *s;
347 uLong central_pos,uL; 403 uLong central_pos,uL;
348 FILE * fin ;
349 404
350 uLong number_disk; /* number of the current dist, used for 405 uLong number_disk; /* number of the current dist, used for
351 spaning ZIP, unsupported, always 0*/ 406 spaning ZIP, unsupported, always 0*/
352 uLong number_disk_with_CD; /* number the the disk with central dir, used 407 uLong number_disk_with_CD; /* number the the disk with central dir, used
353 for spaning ZIP, unsupported, always 0*/ 408 for spaning ZIP, unsupported, always 0*/
354 uLong number_entry_CD; /* total number of entries in 409 uLong number_entry_CD; /* total number of entries in
355 the central dir 410 the central dir
356 (same than number_entry on nospan) */ 411 (same than number_entry on nospan) */
357 412
358 int err=UNZ_OK; 413 int err=UNZ_OK;
359 414
360 if (unz_copyright[0]!=' ') 415 if (unz_copyright[0]!=' ')
361 return NULL; 416 return NULL;
362 417
363 fin=fopen(path,"rb"); 418 if (pzlib_filefunc_def==NULL)
364 if (fin==NULL) 419 fill_fopen_filefunc(&us.z_filefunc);
365 return NULL; 420 else
366 421 us.z_filefunc = *pzlib_filefunc_def;
367 central_pos = unzlocal_SearchCentralDir(fin); 422
368 if (central_pos==0) 423 us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque,
369 err=UNZ_ERRNO; 424 path,
370 425 ZLIB_FILEFUNC_MODE_READ |
371 if (fseek(fin,central_pos,SEEK_SET)!=0) 426 ZLIB_FILEFUNC_MODE_EXISTING);
372 err=UNZ_ERRNO; 427 if (us.filestream==NULL)
373 428 return NULL;
374 /* the signature, already checked */ 429
375 if (unzlocal_getLong(fin,&uL)!=UNZ_OK) 430 central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream);
376 err=UNZ_ERRNO; 431 if (central_pos==0)
377 432 err=UNZ_ERRNO;
378 /* number of this disk */ 433
379 if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) 434 if (ZSEEK(us.z_filefunc, us.filestream,
380 err=UNZ_ERRNO; 435 central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
381 436 err=UNZ_ERRNO;
382 /* number of the disk with the start of the central directory */ 437
383 if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) 438 /* the signature, already checked */
384 err=UNZ_ERRNO; 439 if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
385 440 err=UNZ_ERRNO;
386 /* total number of entries in the central dir on this disk */ 441
387 if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) 442 /* number of this disk */
388 err=UNZ_ERRNO; 443 if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
389 444 err=UNZ_ERRNO;
390 /* total number of entries in the central dir */ 445
391 if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) 446 /* number of the disk with the start of the central directory */
392 err=UNZ_ERRNO; 447 if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
393 448 err=UNZ_ERRNO;
394 if ((number_entry_CD!=us.gi.number_entry) || 449
395 (number_disk_with_CD!=0) || 450 /* total number of entries in the central dir on this disk */
396 (number_disk!=0)) 451 if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
397 err=UNZ_BADZIPFILE; 452 err=UNZ_ERRNO;
398 453
399 /* size of the central directory */ 454 /* total number of entries in the central dir */
400 if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) 455 if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
401 err=UNZ_ERRNO; 456 err=UNZ_ERRNO;
402 457
403 /* offset of start of central directory with respect to the 458 if ((number_entry_CD!=us.gi.number_entry) ||
404 starting disk number */ 459 (number_disk_with_CD!=0) ||
405 if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) 460 (number_disk!=0))
406 err=UNZ_ERRNO; 461 err=UNZ_BADZIPFILE;
407 462
408 /* zipfile comment length */ 463 /* size of the central directory */
409 if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) 464 if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
410 err=UNZ_ERRNO; 465 err=UNZ_ERRNO;
411 466
412 if ((central_pos<us.offset_central_dir+us.size_central_dir) && 467 /* offset of start of central directory with respect to the
413 (err==UNZ_OK)) 468 starting disk number */
414 err=UNZ_BADZIPFILE; 469 if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
415 470 err=UNZ_ERRNO;
416 if (err!=UNZ_OK) 471
417 { 472 /* zipfile comment length */
418 fclose(fin); 473 if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
419 return NULL; 474 err=UNZ_ERRNO;
420 } 475
421 476 if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
422 us.file=fin; 477 (err==UNZ_OK))
423 us.byte_before_the_zipfile = central_pos - 478 err=UNZ_BADZIPFILE;
424 (us.offset_central_dir+us.size_central_dir); 479
425 us.central_pos = central_pos; 480 if (err!=UNZ_OK)
481 {
482 ZCLOSE(us.z_filefunc, us.filestream);
483 return NULL;
484 }
485
486 us.byte_before_the_zipfile = central_pos -
487 (us.offset_central_dir+us.size_central_dir);
488 us.central_pos = central_pos;
426 us.pfile_in_zip_read = NULL; 489 us.pfile_in_zip_read = NULL;
427 490 us.encrypted = 0;
428 491
429 s=(unz_s*)ALLOC(sizeof(unz_s)); 492
430 *s=us; 493 s=(unz_s*)ALLOC(sizeof(unz_s));
431 unzGoToFirstFile((unzFile)s); 494 *s=us;
432 return (unzFile)s; 495 unzGoToFirstFile((unzFile)s);
496 return (unzFile)s;
433} 497}
434 498
435 499
500extern unzFile ZEXPORT unzOpen (path)
501 const char *path;
502{
503 return unzOpen2(path, NULL);
504}
505
436/* 506/*
437 Close a ZipFile opened with unzipOpen. 507 Close a ZipFile opened with unzipOpen.
438 If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), 508 If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
439 these files MUST be closed with unzipCloseCurrentFile before call unzipClose. 509 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
440 return UNZ_OK if there is no problem. */ 510 return UNZ_OK if there is no problem. */
441extern int ZEXPORT unzClose (file) 511extern int ZEXPORT unzClose (file)
442 unzFile file; 512 unzFile file;
443{ 513{
444 unz_s* s; 514 unz_s* s;
445 if (file==NULL) 515 if (file==NULL)
446 return UNZ_PARAMERROR; 516 return UNZ_PARAMERROR;
447 s=(unz_s*)file; 517 s=(unz_s*)file;
448 518
449 if (s->pfile_in_zip_read!=NULL) 519 if (s->pfile_in_zip_read!=NULL)
450 unzCloseCurrentFile(file); 520 unzCloseCurrentFile(file);
451 521
452 fclose(s->file); 522 ZCLOSE(s->z_filefunc, s->filestream);
453 TRYFREE(s); 523 TRYFREE(s);
454 return UNZ_OK; 524 return UNZ_OK;
455} 525}
456 526
457 527
@@ -460,15 +530,15 @@ extern int ZEXPORT unzClose (file)
460 No preparation of the structure is needed 530 No preparation of the structure is needed
461 return UNZ_OK if there is no problem. */ 531 return UNZ_OK if there is no problem. */
462extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) 532extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
463 unzFile file; 533 unzFile file;
464 unz_global_info *pglobal_info; 534 unz_global_info *pglobal_info;
465{ 535{
466 unz_s* s; 536 unz_s* s;
467 if (file==NULL) 537 if (file==NULL)
468 return UNZ_PARAMERROR; 538 return UNZ_PARAMERROR;
469 s=(unz_s*)file; 539 s=(unz_s*)file;
470 *pglobal_info=s->gi; 540 *pglobal_info=s->gi;
471 return UNZ_OK; 541 return UNZ_OK;
472} 542}
473 543
474 544
@@ -495,14 +565,14 @@ local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
495*/ 565*/
496local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, 566local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
497 unz_file_info *pfile_info, 567 unz_file_info *pfile_info,
498 unz_file_info_internal 568 unz_file_info_internal
499 *pfile_info_internal, 569 *pfile_info_internal,
500 char *szFileName, 570 char *szFileName,
501 uLong fileNameBufferSize, 571 uLong fileNameBufferSize,
502 void *extraField, 572 void *extraField,
503 uLong extraFieldBufferSize, 573 uLong extraFieldBufferSize,
504 char *szComment, 574 char *szComment,
505 uLong commentBufferSize)); 575 uLong commentBufferSize));
506 576
507local int unzlocal_GetCurrentFileInfoInternal (file, 577local int unzlocal_GetCurrentFileInfoInternal (file,
508 pfile_info, 578 pfile_info,
@@ -510,156 +580,158 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
510 szFileName, fileNameBufferSize, 580 szFileName, fileNameBufferSize,
511 extraField, extraFieldBufferSize, 581 extraField, extraFieldBufferSize,
512 szComment, commentBufferSize) 582 szComment, commentBufferSize)
513 unzFile file; 583 unzFile file;
514 unz_file_info *pfile_info; 584 unz_file_info *pfile_info;
515 unz_file_info_internal *pfile_info_internal; 585 unz_file_info_internal *pfile_info_internal;
516 char *szFileName; 586 char *szFileName;
517 uLong fileNameBufferSize; 587 uLong fileNameBufferSize;
518 void *extraField; 588 void *extraField;
519 uLong extraFieldBufferSize; 589 uLong extraFieldBufferSize;
520 char *szComment; 590 char *szComment;
521 uLong commentBufferSize; 591 uLong commentBufferSize;
522{ 592{
523 unz_s* s; 593 unz_s* s;
524 unz_file_info file_info; 594 unz_file_info file_info;
525 unz_file_info_internal file_info_internal; 595 unz_file_info_internal file_info_internal;
526 int err=UNZ_OK; 596 int err=UNZ_OK;
527 uLong uMagic; 597 uLong uMagic;
528 long lSeek=0; 598 long lSeek=0;
529 599
530 if (file==NULL) 600 if (file==NULL)
531 return UNZ_PARAMERROR; 601 return UNZ_PARAMERROR;
532 s=(unz_s*)file; 602 s=(unz_s*)file;
533 if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) 603 if (ZSEEK(s->z_filefunc, s->filestream,
534 err=UNZ_ERRNO; 604 s->pos_in_central_dir+s->byte_before_the_zipfile,
605 ZLIB_FILEFUNC_SEEK_SET)!=0)
606 err=UNZ_ERRNO;
535 607
536 608
537 /* we check the magic */ 609 /* we check the magic */
538 if (err==UNZ_OK) 610 if (err==UNZ_OK)
539 if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) 611 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
540 err=UNZ_ERRNO; 612 err=UNZ_ERRNO;
541 else if (uMagic!=0x02014b50) 613 else if (uMagic!=0x02014b50)
542 err=UNZ_BADZIPFILE; 614 err=UNZ_BADZIPFILE;
543 615
544 if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) 616 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
545 err=UNZ_ERRNO; 617 err=UNZ_ERRNO;
546 618
547 if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) 619 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
548 err=UNZ_ERRNO; 620 err=UNZ_ERRNO;
549 621
550 if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) 622 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
551 err=UNZ_ERRNO; 623 err=UNZ_ERRNO;
552 624
553 if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) 625 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
554 err=UNZ_ERRNO; 626 err=UNZ_ERRNO;
555 627
556 if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) 628 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
557 err=UNZ_ERRNO; 629 err=UNZ_ERRNO;
558 630
559 unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); 631 unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
560 632
561 if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) 633 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
562 err=UNZ_ERRNO; 634 err=UNZ_ERRNO;
563 635
564 if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) 636 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
565 err=UNZ_ERRNO; 637 err=UNZ_ERRNO;
566 638
567 if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) 639 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
568 err=UNZ_ERRNO; 640 err=UNZ_ERRNO;
569 641
570 if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) 642 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
571 err=UNZ_ERRNO; 643 err=UNZ_ERRNO;
572 644
573 if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) 645 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
574 err=UNZ_ERRNO; 646 err=UNZ_ERRNO;
575 647
576 if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) 648 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
577 err=UNZ_ERRNO; 649 err=UNZ_ERRNO;
578 650
579 if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) 651 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
580 err=UNZ_ERRNO; 652 err=UNZ_ERRNO;
581 653
582 if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) 654 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
583 err=UNZ_ERRNO; 655 err=UNZ_ERRNO;
584 656
585 if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) 657 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
586 err=UNZ_ERRNO; 658 err=UNZ_ERRNO;
587 659
588 if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) 660 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
589 err=UNZ_ERRNO; 661 err=UNZ_ERRNO;
590 662
591 lSeek+=file_info.size_filename; 663 lSeek+=file_info.size_filename;
592 if ((err==UNZ_OK) && (szFileName!=NULL)) 664 if ((err==UNZ_OK) && (szFileName!=NULL))
593 { 665 {
594 uLong uSizeRead ; 666 uLong uSizeRead ;
595 if (file_info.size_filename<fileNameBufferSize) 667 if (file_info.size_filename<fileNameBufferSize)
596 { 668 {
597 *(szFileName+file_info.size_filename)='\0'; 669 *(szFileName+file_info.size_filename)='\0';
598 uSizeRead = file_info.size_filename; 670 uSizeRead = file_info.size_filename;
599 } 671 }
600 else 672 else
601 uSizeRead = fileNameBufferSize; 673 uSizeRead = fileNameBufferSize;
602 674
603 if ((file_info.size_filename>0) && (fileNameBufferSize>0)) 675 if ((file_info.size_filename>0) && (fileNameBufferSize>0))
604 if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) 676 if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
605 err=UNZ_ERRNO; 677 err=UNZ_ERRNO;
606 lSeek -= uSizeRead; 678 lSeek -= uSizeRead;
607 } 679 }
608 680
609 681
610 if ((err==UNZ_OK) && (extraField!=NULL)) 682 if ((err==UNZ_OK) && (extraField!=NULL))
611 { 683 {
612 uLong uSizeRead ; 684 uLong uSizeRead ;
613 if (file_info.size_file_extra<extraFieldBufferSize) 685 if (file_info.size_file_extra<extraFieldBufferSize)
614 uSizeRead = file_info.size_file_extra; 686 uSizeRead = file_info.size_file_extra;
615 else 687 else
616 uSizeRead = extraFieldBufferSize; 688 uSizeRead = extraFieldBufferSize;
617 689
618 if (lSeek!=0) 690 if (lSeek!=0)
619 if (fseek(s->file,lSeek,SEEK_CUR)==0) 691 if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
620 lSeek=0; 692 lSeek=0;
621 else 693 else
622 err=UNZ_ERRNO; 694 err=UNZ_ERRNO;
623 if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) 695 if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
624 if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) 696 if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead)
625 err=UNZ_ERRNO; 697 err=UNZ_ERRNO;
626 lSeek += file_info.size_file_extra - uSizeRead; 698 lSeek += file_info.size_file_extra - uSizeRead;
627 } 699 }
628 else 700 else
629 lSeek+=file_info.size_file_extra; 701 lSeek+=file_info.size_file_extra;
630 702
631 703
632 if ((err==UNZ_OK) && (szComment!=NULL)) 704 if ((err==UNZ_OK) && (szComment!=NULL))
633 { 705 {
634 uLong uSizeRead ; 706 uLong uSizeRead ;
635 if (file_info.size_file_comment<commentBufferSize) 707 if (file_info.size_file_comment<commentBufferSize)
636 { 708 {
637 *(szComment+file_info.size_file_comment)='\0'; 709 *(szComment+file_info.size_file_comment)='\0';
638 uSizeRead = file_info.size_file_comment; 710 uSizeRead = file_info.size_file_comment;
639 } 711 }
640 else 712 else
641 uSizeRead = commentBufferSize; 713 uSizeRead = commentBufferSize;
642 714
643 if (lSeek!=0) 715 if (lSeek!=0)
644 if (fseek(s->file,lSeek,SEEK_CUR)==0) 716 if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
645 lSeek=0; 717 lSeek=0;
646 else 718 else
647 err=UNZ_ERRNO; 719 err=UNZ_ERRNO;
648 if ((file_info.size_file_comment>0) && (commentBufferSize>0)) 720 if ((file_info.size_file_comment>0) && (commentBufferSize>0))
649 if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) 721 if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
650 err=UNZ_ERRNO; 722 err=UNZ_ERRNO;
651 lSeek+=file_info.size_file_comment - uSizeRead; 723 lSeek+=file_info.size_file_comment - uSizeRead;
652 } 724 }
653 else 725 else
654 lSeek+=file_info.size_file_comment; 726 lSeek+=file_info.size_file_comment;
655 727
656 if ((err==UNZ_OK) && (pfile_info!=NULL)) 728 if ((err==UNZ_OK) && (pfile_info!=NULL))
657 *pfile_info=file_info; 729 *pfile_info=file_info;
658 730
659 if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) 731 if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
660 *pfile_info_internal=file_info_internal; 732 *pfile_info_internal=file_info_internal;
661 733
662 return err; 734 return err;
663} 735}
664 736
665 737
@@ -670,23 +742,23 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
670 return UNZ_OK if there is no problem. 742 return UNZ_OK if there is no problem.
671*/ 743*/
672extern int ZEXPORT unzGetCurrentFileInfo (file, 744extern int ZEXPORT unzGetCurrentFileInfo (file,
673 pfile_info, 745 pfile_info,
674 szFileName, fileNameBufferSize, 746 szFileName, fileNameBufferSize,
675 extraField, extraFieldBufferSize, 747 extraField, extraFieldBufferSize,
676 szComment, commentBufferSize) 748 szComment, commentBufferSize)
677 unzFile file; 749 unzFile file;
678 unz_file_info *pfile_info; 750 unz_file_info *pfile_info;
679 char *szFileName; 751 char *szFileName;
680 uLong fileNameBufferSize; 752 uLong fileNameBufferSize;
681 void *extraField; 753 void *extraField;
682 uLong extraFieldBufferSize; 754 uLong extraFieldBufferSize;
683 char *szComment; 755 char *szComment;
684 uLong commentBufferSize; 756 uLong commentBufferSize;
685{ 757{
686 return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, 758 return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
687 szFileName,fileNameBufferSize, 759 szFileName,fileNameBufferSize,
688 extraField,extraFieldBufferSize, 760 extraField,extraFieldBufferSize,
689 szComment,commentBufferSize); 761 szComment,commentBufferSize);
690} 762}
691 763
692/* 764/*
@@ -694,50 +766,49 @@ extern int ZEXPORT unzGetCurrentFileInfo (file,
694 return UNZ_OK if there is no problem 766 return UNZ_OK if there is no problem
695*/ 767*/
696extern int ZEXPORT unzGoToFirstFile (file) 768extern int ZEXPORT unzGoToFirstFile (file)
697 unzFile file; 769 unzFile file;
698{ 770{
699 int err=UNZ_OK; 771 int err=UNZ_OK;
700 unz_s* s; 772 unz_s* s;
701 if (file==NULL) 773 if (file==NULL)
702 return UNZ_PARAMERROR; 774 return UNZ_PARAMERROR;
703 s=(unz_s*)file; 775 s=(unz_s*)file;
704 s->pos_in_central_dir=s->offset_central_dir; 776 s->pos_in_central_dir=s->offset_central_dir;
705 s->num_file=0; 777 s->num_file=0;
706 err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, 778 err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
707 &s->cur_file_info_internal, 779 &s->cur_file_info_internal,
708 NULL,0,NULL,0,NULL,0); 780 NULL,0,NULL,0,NULL,0);
709 s->current_file_ok = (err == UNZ_OK); 781 s->current_file_ok = (err == UNZ_OK);
710 return err; 782 return err;
711} 783}
712 784
713
714/* 785/*
715 Set the current file of the zipfile to the next file. 786 Set the current file of the zipfile to the next file.
716 return UNZ_OK if there is no problem 787 return UNZ_OK if there is no problem
717 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. 788 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
718*/ 789*/
719extern int ZEXPORT unzGoToNextFile (file) 790extern int ZEXPORT unzGoToNextFile (file)
720 unzFile file; 791 unzFile file;
721{ 792{
722 unz_s* s; 793 unz_s* s;
723 int err; 794 int err;
724 795
725 if (file==NULL) 796 if (file==NULL)
726 return UNZ_PARAMERROR; 797 return UNZ_PARAMERROR;
727 s=(unz_s*)file; 798 s=(unz_s*)file;
728 if (!s->current_file_ok) 799 if (!s->current_file_ok)
729 return UNZ_END_OF_LIST_OF_FILE; 800 return UNZ_END_OF_LIST_OF_FILE;
730 if (s->num_file+1==s->gi.number_entry) 801 if (s->num_file+1==s->gi.number_entry)
731 return UNZ_END_OF_LIST_OF_FILE; 802 return UNZ_END_OF_LIST_OF_FILE;
732 803
733 s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + 804 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 ; 805 s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
735 s->num_file++; 806 s->num_file++;
736 err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, 807 err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
737 &s->cur_file_info_internal, 808 &s->cur_file_info_internal,
738 NULL,0,NULL,0,NULL,0); 809 NULL,0,NULL,0,NULL,0);
739 s->current_file_ok = (err == UNZ_OK); 810 s->current_file_ok = (err == UNZ_OK);
740 return err; 811 return err;
741} 812}
742 813
743 814
@@ -750,52 +821,117 @@ extern int ZEXPORT unzGoToNextFile (file)
750 UNZ_END_OF_LIST_OF_FILE if the file is not found 821 UNZ_END_OF_LIST_OF_FILE if the file is not found
751*/ 822*/
752extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) 823extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
753 unzFile file; 824 unzFile file;
754 const char *szFileName; 825 const char *szFileName;
755 int iCaseSensitivity; 826 int iCaseSensitivity;
756{ 827{
757 unz_s* s; 828 unz_s* s;
758 int err; 829 int err;
759 830
760
761 uLong num_fileSaved;
762 uLong pos_in_central_dirSaved;
763 831
832 uLong num_fileSaved;
833 uLong pos_in_central_dirSaved;
764 834
765 if (file==NULL) 835
766 return UNZ_PARAMERROR; 836 if (file==NULL)
837 return UNZ_PARAMERROR;
767 838
768 if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) 839 if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
769 return UNZ_PARAMERROR; 840 return UNZ_PARAMERROR;
770 841
771 s=(unz_s*)file; 842 s=(unz_s*)file;
772 if (!s->current_file_ok) 843 if (!s->current_file_ok)
773 return UNZ_END_OF_LIST_OF_FILE; 844 return UNZ_END_OF_LIST_OF_FILE;
774 845
775 num_fileSaved = s->num_file; 846 num_fileSaved = s->num_file;
776 pos_in_central_dirSaved = s->pos_in_central_dir; 847 pos_in_central_dirSaved = s->pos_in_central_dir;
777 848
778 err = unzGoToFirstFile(file); 849 err = unzGoToFirstFile(file);
779 850
780 while (err == UNZ_OK) 851 while (err == UNZ_OK)
781 { 852 {
782 char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; 853 char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
783 unzGetCurrentFileInfo(file,NULL, 854 unzGetCurrentFileInfo(file,NULL,
784 szCurrentFileName,sizeof(szCurrentFileName)-1, 855 szCurrentFileName,sizeof(szCurrentFileName)-1,
785 NULL,0,NULL,0); 856 NULL,0,NULL,0);
786 if (unzStringFileNameCompare(szCurrentFileName, 857 if (unzStringFileNameCompare(szCurrentFileName,
787 szFileName,iCaseSensitivity)==0) 858 szFileName,iCaseSensitivity)==0)
788 return UNZ_OK; 859 return UNZ_OK;
789 err = unzGoToNextFile(file); 860 err = unzGoToNextFile(file);
790 } 861 }
791 862
792 s->num_file = num_fileSaved ; 863 s->num_file = num_fileSaved ;
793 s->pos_in_central_dir = pos_in_central_dirSaved ; 864 s->pos_in_central_dir = pos_in_central_dirSaved ;
794 return err; 865 return err;
795} 866}
796 867
797 868
798/* 869/*
870///////////////////////////////////////////
871// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
872// I need random access
873//
874// Further optimization could be realized by adding an ability
875// to cache the directory in memory. The goal being a single
876// comprehensive file read to put the file I need in a memory.
877*/
878
879/*
880typedef struct unz_file_pos_s
881{
882 uLong pos_in_zip_directory; // offset in file
883 uLong num_of_file; // # of file
884} unz_file_pos;
885*/
886
887extern int ZEXPORT unzGetFilePos(file, file_pos)
888 unzFile file;
889 unz_file_pos* file_pos;
890{
891 unz_s* s;
892
893 if (file==NULL || file_pos==NULL)
894 return UNZ_PARAMERROR;
895 s=(unz_s*)file;
896 if (!s->current_file_ok)
897 return UNZ_END_OF_LIST_OF_FILE;
898
899 file_pos->pos_in_zip_directory = s->pos_in_central_dir;
900 file_pos->num_of_file = s->num_file;
901
902 return UNZ_OK;
903}
904
905extern int ZEXPORT unzGoToFilePos(file, file_pos)
906 unzFile file;
907 unz_file_pos* file_pos;
908{
909 unz_s* s;
910 int err;
911
912 if (file==NULL || file_pos==NULL)
913 return UNZ_PARAMERROR;
914 s=(unz_s*)file;
915
916 /* jump to the right spot */
917 s->pos_in_central_dir = file_pos->pos_in_zip_directory;
918 s->num_file = file_pos->num_of_file;
919
920 /* set the current file */
921 err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
922 &s->cur_file_info_internal,
923 NULL,0,NULL,0,NULL,0);
924 /* return results */
925 s->current_file_ok = (err == UNZ_OK);
926 return err;
927}
928
929/*
930// Unzip Helper Functions - should be here?
931///////////////////////////////////////////
932*/
933
934/*
799 Read the local header of the current zipfile 935 Read the local header of the current zipfile
800 Check the coherency of the local header and info in the end of central 936 Check the coherency of the local header and info in the end of central
801 directory about this file 937 directory about this file
@@ -803,185 +939,256 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
803 (filename and size of extra field data) 939 (filename and size of extra field data)
804*/ 940*/
805local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, 941local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
806 poffset_local_extrafield, 942 poffset_local_extrafield,
807 psize_local_extrafield) 943 psize_local_extrafield)
808 unz_s* s; 944 unz_s* s;
809 uInt* piSizeVar; 945 uInt* piSizeVar;
810 uLong *poffset_local_extrafield; 946 uLong *poffset_local_extrafield;
811 uInt *psize_local_extrafield; 947 uInt *psize_local_extrafield;
812{ 948{
813 uLong uMagic,uData,uFlags; 949 uLong uMagic,uData,uFlags;
814 uLong size_filename; 950 uLong size_filename;
815 uLong size_extra_field; 951 uLong size_extra_field;
816 int err=UNZ_OK; 952 int err=UNZ_OK;
817 953
818 *piSizeVar = 0; 954 *piSizeVar = 0;
819 *poffset_local_extrafield = 0; 955 *poffset_local_extrafield = 0;
820 *psize_local_extrafield = 0; 956 *psize_local_extrafield = 0;
821 957
822 if (fseek(s->file,s->cur_file_info_internal.offset_curfile + 958 if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
823 s->byte_before_the_zipfile,SEEK_SET)!=0) 959 s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
824 return UNZ_ERRNO; 960 return UNZ_ERRNO;
825 961
826 962
827 if (err==UNZ_OK) 963 if (err==UNZ_OK)
828 if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) 964 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
829 err=UNZ_ERRNO; 965 err=UNZ_ERRNO;
830 else if (uMagic!=0x04034b50) 966 else if (uMagic!=0x04034b50)
831 err=UNZ_BADZIPFILE; 967 err=UNZ_BADZIPFILE;
832 968
833 if (unzlocal_getShort(s->file,&uData) != UNZ_OK) 969 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
834 err=UNZ_ERRNO; 970 err=UNZ_ERRNO;
835/* 971/*
836 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) 972 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
837 err=UNZ_BADZIPFILE; 973 err=UNZ_BADZIPFILE;
838*/ 974*/
839 if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) 975 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
840 err=UNZ_ERRNO; 976 err=UNZ_ERRNO;
841 977
842 if (unzlocal_getShort(s->file,&uData) != UNZ_OK) 978 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
843 err=UNZ_ERRNO; 979 err=UNZ_ERRNO;
844 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) 980 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
845 err=UNZ_BADZIPFILE; 981 err=UNZ_BADZIPFILE;
846 982
847 if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && 983 if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
848 (s->cur_file_info.compression_method!=Z_DEFLATED)) 984 (s->cur_file_info.compression_method!=Z_DEFLATED))
849 err=UNZ_BADZIPFILE; 985 err=UNZ_BADZIPFILE;
850 986
851 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ 987 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
852 err=UNZ_ERRNO; 988 err=UNZ_ERRNO;
853 989
854 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ 990 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
855 err=UNZ_ERRNO; 991 err=UNZ_ERRNO;
856 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && 992 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
857 ((uFlags & 8)==0)) 993 ((uFlags & 8)==0))
858 err=UNZ_BADZIPFILE; 994 err=UNZ_BADZIPFILE;
859 995
860 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ 996 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
861 err=UNZ_ERRNO; 997 err=UNZ_ERRNO;
862 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && 998 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
863 ((uFlags & 8)==0)) 999 ((uFlags & 8)==0))
864 err=UNZ_BADZIPFILE; 1000 err=UNZ_BADZIPFILE;
865 1001
866 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ 1002 if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
867 err=UNZ_ERRNO; 1003 err=UNZ_ERRNO;
868 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && 1004 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
869 ((uFlags & 8)==0)) 1005 ((uFlags & 8)==0))
870 err=UNZ_BADZIPFILE; 1006 err=UNZ_BADZIPFILE;
871 1007
872 1008
873 if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) 1009 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
874 err=UNZ_ERRNO; 1010 err=UNZ_ERRNO;
875 else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) 1011 else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
876 err=UNZ_BADZIPFILE; 1012 err=UNZ_BADZIPFILE;
877 1013
878 *piSizeVar += (uInt)size_filename; 1014 *piSizeVar += (uInt)size_filename;
879 1015
880 if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) 1016 if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
881 err=UNZ_ERRNO; 1017 err=UNZ_ERRNO;
882 *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + 1018 *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
883 SIZEZIPLOCALHEADER + size_filename; 1019 SIZEZIPLOCALHEADER + size_filename;
884 *psize_local_extrafield = (uInt)size_extra_field; 1020 *psize_local_extrafield = (uInt)size_extra_field;
885 1021
886 *piSizeVar += (uInt)size_extra_field; 1022 *piSizeVar += (uInt)size_extra_field;
887 1023
888 return err; 1024 return err;
889} 1025}
890 1026
891/* 1027/*
892 Open for reading data the current file in the zipfile. 1028 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. 1029 If there is no error and the file is opened, the return value is UNZ_OK.
894*/ 1030*/
895extern int ZEXPORT unzOpenCurrentFile (file) 1031extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
896 unzFile file; 1032 unzFile file;
1033 int* method;
1034 int* level;
1035 int raw;
1036 const char* password;
897{ 1037{
898 int err=UNZ_OK; 1038 int err=UNZ_OK;
899 int Store; 1039 uInt iSizeVar;
900 uInt iSizeVar; 1040 unz_s* s;
901 unz_s* s; 1041 file_in_zip_read_info_s* pfile_in_zip_read_info;
902 file_in_zip_read_info_s* pfile_in_zip_read_info; 1042 uLong offset_local_extrafield; /* offset of the local extra field */
903 uLong offset_local_extrafield; /* offset of the local extra field */ 1043 uInt size_local_extrafield; /* size of the local extra field */
904 uInt size_local_extrafield; /* size of the local extra field */ 1044 #ifndef NOUNCRPYT
905 1045 char source[12];
906 if (file==NULL) 1046 #else
907 return UNZ_PARAMERROR; 1047 if (password != NULL)
908 s=(unz_s*)file; 1048 return UNZ_PARAMERROR;
909 if (!s->current_file_ok) 1049 #endif
910 return UNZ_PARAMERROR; 1050
1051 if (file==NULL)
1052 return UNZ_PARAMERROR;
1053 s=(unz_s*)file;
1054 if (!s->current_file_ok)
1055 return UNZ_PARAMERROR;
911 1056
912 if (s->pfile_in_zip_read != NULL) 1057 if (s->pfile_in_zip_read != NULL)
913 unzCloseCurrentFile(file); 1058 unzCloseCurrentFile(file);
914 1059
915 if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, 1060 if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
916 &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) 1061 &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
917 return UNZ_BADZIPFILE; 1062 return UNZ_BADZIPFILE;
918 1063
919 pfile_in_zip_read_info = (file_in_zip_read_info_s*) 1064 pfile_in_zip_read_info = (file_in_zip_read_info_s*)
920 ALLOC(sizeof(file_in_zip_read_info_s)); 1065 ALLOC(sizeof(file_in_zip_read_info_s));
921 if (pfile_in_zip_read_info==NULL) 1066 if (pfile_in_zip_read_info==NULL)
922 return UNZ_INTERNALERROR; 1067 return UNZ_INTERNALERROR;
923 1068
924 pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); 1069 pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
925 pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; 1070 pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
926 pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; 1071 pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
927 pfile_in_zip_read_info->pos_local_extrafield=0; 1072 pfile_in_zip_read_info->pos_local_extrafield=0;
928 1073 pfile_in_zip_read_info->raw=raw;
929 if (pfile_in_zip_read_info->read_buffer==NULL) 1074
930 { 1075 if (pfile_in_zip_read_info->read_buffer==NULL)
931 TRYFREE(pfile_in_zip_read_info); 1076 {
932 return UNZ_INTERNALERROR; 1077 TRYFREE(pfile_in_zip_read_info);
933 } 1078 return UNZ_INTERNALERROR;
934 1079 }
935 pfile_in_zip_read_info->stream_initialised=0; 1080
936 1081 pfile_in_zip_read_info->stream_initialised=0;
937 if ((s->cur_file_info.compression_method!=0) && 1082
1083 if (method!=NULL)
1084 *method = (int)s->cur_file_info.compression_method;
1085
1086 if (level!=NULL)
1087 {
1088 *level = 6;
1089 switch (s->cur_file_info.flag & 0x06)
1090 {
1091 case 6 : *level = 1; break;
1092 case 4 : *level = 2; break;
1093 case 2 : *level = 9; break;
1094 }
1095 }
1096
1097 if ((s->cur_file_info.compression_method!=0) &&
938 (s->cur_file_info.compression_method!=Z_DEFLATED)) 1098 (s->cur_file_info.compression_method!=Z_DEFLATED))
939 err=UNZ_BADZIPFILE; 1099 err=UNZ_BADZIPFILE;
940 Store = s->cur_file_info.compression_method==0;
941 1100
942 pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; 1101 pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
943 pfile_in_zip_read_info->crc32=0; 1102 pfile_in_zip_read_info->crc32=0;
944 pfile_in_zip_read_info->compression_method = 1103 pfile_in_zip_read_info->compression_method =
945 s->cur_file_info.compression_method; 1104 s->cur_file_info.compression_method;
946 pfile_in_zip_read_info->file=s->file; 1105 pfile_in_zip_read_info->filestream=s->filestream;
947 pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; 1106 pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
1107 pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
948 1108
949 pfile_in_zip_read_info->stream.total_out = 0; 1109 pfile_in_zip_read_info->stream.total_out = 0;
950 1110
951 if (!Store) 1111 if ((s->cur_file_info.compression_method==Z_DEFLATED) &&
952 { 1112 (!raw))
953 pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; 1113 {
954 pfile_in_zip_read_info->stream.zfree = (free_func)0; 1114 pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
955 pfile_in_zip_read_info->stream.opaque = (voidpf)0; 1115 pfile_in_zip_read_info->stream.zfree = (free_func)0;
956 1116 pfile_in_zip_read_info->stream.opaque = (voidpf)0;
957 err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); 1117
958 if (err == Z_OK) 1118 err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
959 pfile_in_zip_read_info->stream_initialised=1; 1119 if (err == Z_OK)
1120 pfile_in_zip_read_info->stream_initialised=1;
1121 else
1122 return err;
960 /* windowBits is passed < 0 to tell that there is no zlib header. 1123 /* windowBits is passed < 0 to tell that there is no zlib header.
961 * Note that in this case inflate *requires* an extra "dummy" byte 1124 * Note that in this case inflate *requires* an extra "dummy" byte
962 * after the compressed stream in order to complete decompression and 1125 * after the compressed stream in order to complete decompression and
963 * return Z_STREAM_END. 1126 * return Z_STREAM_END.
964 * In unzip, i don't wait absolutely Z_STREAM_END because I known the 1127 * In unzip, i don't wait absolutely Z_STREAM_END because I known the
965 * size of both compressed and uncompressed data 1128 * size of both compressed and uncompressed data
966 */ 1129 */
967 } 1130 }
968 pfile_in_zip_read_info->rest_read_compressed = 1131 pfile_in_zip_read_info->rest_read_compressed =
969 s->cur_file_info.compressed_size ; 1132 s->cur_file_info.compressed_size ;
970 pfile_in_zip_read_info->rest_read_uncompressed = 1133 pfile_in_zip_read_info->rest_read_uncompressed =
971 s->cur_file_info.uncompressed_size ; 1134 s->cur_file_info.uncompressed_size ;
972 1135
973 1136
974 pfile_in_zip_read_info->pos_in_zipfile = 1137 pfile_in_zip_read_info->pos_in_zipfile =
975 s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + 1138 s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
976 iSizeVar; 1139 iSizeVar;
977 1140
978 pfile_in_zip_read_info->stream.avail_in = (uInt)0; 1141 pfile_in_zip_read_info->stream.avail_in = (uInt)0;
1142
1143 s->pfile_in_zip_read = pfile_in_zip_read_info;
1144
1145 #ifndef NOUNCRPYT
1146 if (password != NULL)
1147 {
1148 int i;
1149 s->pcrc_32_tab = get_crc_table();
1150 init_keys(password,s->keys,s->pcrc_32_tab);
1151 if (ZSEEK(s->z_filefunc, s->filestream,
1152 s->pfile_in_zip_read->pos_in_zipfile +
1153 s->pfile_in_zip_read->byte_before_the_zipfile,
1154 SEEK_SET)!=0)
1155 return UNZ_INTERNALERROR;
1156 if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12)
1157 return UNZ_INTERNALERROR;
1158
1159 for (i = 0; i<12; i++)
1160 zdecode(s->keys,s->pcrc_32_tab,source[i]);
1161
1162 s->pfile_in_zip_read->pos_in_zipfile+=12;
1163 s->encrypted=1;
1164 }
1165 #endif
979 1166
980 1167
981 s->pfile_in_zip_read = pfile_in_zip_read_info;
982 return UNZ_OK; 1168 return UNZ_OK;
983} 1169}
984 1170
1171extern int ZEXPORT unzOpenCurrentFile (file)
1172 unzFile file;
1173{
1174 return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
1175}
1176
1177extern int ZEXPORT unzOpenCurrentFilePassword (file, password)
1178 unzFile file;
1179 const char* password;
1180{
1181 return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
1182}
1183
1184extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
1185 unzFile file;
1186 int* method;
1187 int* level;
1188 int raw;
1189{
1190 return unzOpenCurrentFile3(file, method, level, raw, NULL);
1191}
985 1192
986/* 1193/*
987 Read bytes from the current file. 1194 Read bytes from the current file.
@@ -994,126 +1201,149 @@ extern int ZEXPORT unzOpenCurrentFile (file)
994 (UNZ_ERRNO for IO error, or zLib error for uncompress error) 1201 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
995*/ 1202*/
996extern int ZEXPORT unzReadCurrentFile (file, buf, len) 1203extern int ZEXPORT unzReadCurrentFile (file, buf, len)
997 unzFile file; 1204 unzFile file;
998 voidp buf; 1205 voidp buf;
999 unsigned len; 1206 unsigned len;
1000{ 1207{
1001 int err=UNZ_OK; 1208 int err=UNZ_OK;
1002 uInt iRead = 0; 1209 uInt iRead = 0;
1003 unz_s* s; 1210 unz_s* s;
1004 file_in_zip_read_info_s* pfile_in_zip_read_info; 1211 file_in_zip_read_info_s* pfile_in_zip_read_info;
1005 if (file==NULL) 1212 if (file==NULL)
1006 return UNZ_PARAMERROR; 1213 return UNZ_PARAMERROR;
1007 s=(unz_s*)file; 1214 s=(unz_s*)file;
1008 pfile_in_zip_read_info=s->pfile_in_zip_read; 1215 pfile_in_zip_read_info=s->pfile_in_zip_read;
1009 1216
1010 if (pfile_in_zip_read_info==NULL) 1217 if (pfile_in_zip_read_info==NULL)
1011 return UNZ_PARAMERROR; 1218 return UNZ_PARAMERROR;
1219
1012 1220
1221 if ((pfile_in_zip_read_info->read_buffer == NULL))
1222 return UNZ_END_OF_LIST_OF_FILE;
1223 if (len==0)
1224 return 0;
1013 1225
1014 if ((pfile_in_zip_read_info->read_buffer == NULL)) 1226 pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1015 return UNZ_END_OF_LIST_OF_FILE;
1016 if (len==0)
1017 return 0;
1018 1227
1019 pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; 1228 pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1020 1229
1021 pfile_in_zip_read_info->stream.avail_out = (uInt)len; 1230 if (len>pfile_in_zip_read_info->rest_read_uncompressed)
1022 1231 pfile_in_zip_read_info->stream.avail_out =
1023 if (len>pfile_in_zip_read_info->rest_read_uncompressed) 1232 (uInt)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 1233
1027 while (pfile_in_zip_read_info->stream.avail_out>0) 1234 while (pfile_in_zip_read_info->stream.avail_out>0)
1028 { 1235 {
1029 if ((pfile_in_zip_read_info->stream.avail_in==0) && 1236 if ((pfile_in_zip_read_info->stream.avail_in==0) &&
1030 (pfile_in_zip_read_info->rest_read_compressed>0)) 1237 (pfile_in_zip_read_info->rest_read_compressed>0))
1031 { 1238 {
1032 uInt uReadThis = UNZ_BUFSIZE; 1239 uInt uReadThis = UNZ_BUFSIZE;
1033 if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) 1240 if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
1034 uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; 1241 uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
1035 if (uReadThis == 0) 1242 if (uReadThis == 0)
1036 return UNZ_EOF; 1243 return UNZ_EOF;
1037 if (fseek(pfile_in_zip_read_info->file, 1244 if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
1038 pfile_in_zip_read_info->pos_in_zipfile + 1245 pfile_in_zip_read_info->filestream,
1039 pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) 1246 pfile_in_zip_read_info->pos_in_zipfile +
1040 return UNZ_ERRNO; 1247 pfile_in_zip_read_info->byte_before_the_zipfile,
1041 if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, 1248 ZLIB_FILEFUNC_SEEK_SET)!=0)
1042 pfile_in_zip_read_info->file)!=1) 1249 return UNZ_ERRNO;
1043 return UNZ_ERRNO; 1250 if (ZREAD(pfile_in_zip_read_info->z_filefunc,
1044 pfile_in_zip_read_info->pos_in_zipfile += uReadThis; 1251 pfile_in_zip_read_info->filestream,
1045 1252 pfile_in_zip_read_info->read_buffer,
1046 pfile_in_zip_read_info->rest_read_compressed-=uReadThis; 1253 uReadThis)!=uReadThis)
1047 1254 return UNZ_ERRNO;
1048 pfile_in_zip_read_info->stream.next_in = 1255
1256
1257 #ifndef NOUNCRPYT
1258 if(s->encrypted)
1259 {
1260 uInt i;
1261 for(i=0;i<uReadThis;i++)
1262 pfile_in_zip_read_info->read_buffer[i] =
1263 zdecode(s->keys,s->pcrc_32_tab,
1264 pfile_in_zip_read_info->read_buffer[i]);
1265 }
1266 #endif
1267
1268
1269 pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
1270
1271 pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
1272
1273 pfile_in_zip_read_info->stream.next_in =
1049 (Bytef*)pfile_in_zip_read_info->read_buffer; 1274 (Bytef*)pfile_in_zip_read_info->read_buffer;
1050 pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; 1275 pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
1051 } 1276 }
1052 1277
1053 if (pfile_in_zip_read_info->compression_method==0) 1278 if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
1054 { 1279 {
1055 uInt uDoCopy,i ; 1280 uInt uDoCopy,i ;
1056 if (pfile_in_zip_read_info->stream.avail_out < 1281
1282 if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
1283 (pfile_in_zip_read_info->rest_read_compressed == 0))
1284 return (iRead==0) ? UNZ_EOF : iRead;
1285
1286 if (pfile_in_zip_read_info->stream.avail_out <
1057 pfile_in_zip_read_info->stream.avail_in) 1287 pfile_in_zip_read_info->stream.avail_in)
1058 uDoCopy = pfile_in_zip_read_info->stream.avail_out ; 1288 uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
1059 else 1289 else
1060 uDoCopy = pfile_in_zip_read_info->stream.avail_in ; 1290 uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
1061 1291
1062 for (i=0;i<uDoCopy;i++) 1292 for (i=0;i<uDoCopy;i++)
1063 *(pfile_in_zip_read_info->stream.next_out+i) = 1293 *(pfile_in_zip_read_info->stream.next_out+i) =
1064 *(pfile_in_zip_read_info->stream.next_in+i); 1294 *(pfile_in_zip_read_info->stream.next_in+i);
1065 1295
1066 pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, 1296 pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
1067 pfile_in_zip_read_info->stream.next_out, 1297 pfile_in_zip_read_info->stream.next_out,
1068 uDoCopy); 1298 uDoCopy);
1069 pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; 1299 pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
1070 pfile_in_zip_read_info->stream.avail_in -= uDoCopy; 1300 pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
1071 pfile_in_zip_read_info->stream.avail_out -= uDoCopy; 1301 pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
1072 pfile_in_zip_read_info->stream.next_out += uDoCopy; 1302 pfile_in_zip_read_info->stream.next_out += uDoCopy;
1073 pfile_in_zip_read_info->stream.next_in += uDoCopy; 1303 pfile_in_zip_read_info->stream.next_in += uDoCopy;
1074 pfile_in_zip_read_info->stream.total_out += uDoCopy; 1304 pfile_in_zip_read_info->stream.total_out += uDoCopy;
1075 iRead += uDoCopy; 1305 iRead += uDoCopy;
1076 } 1306 }
1077 else 1307 else
1078 { 1308 {
1079 uLong uTotalOutBefore,uTotalOutAfter; 1309 uLong uTotalOutBefore,uTotalOutAfter;
1080 const Bytef *bufBefore; 1310 const Bytef *bufBefore;
1081 uLong uOutThis; 1311 uLong uOutThis;
1082 int flush=Z_SYNC_FLUSH; 1312 int flush=Z_SYNC_FLUSH;
1083 1313
1084 uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; 1314 uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
1085 bufBefore = pfile_in_zip_read_info->stream.next_out; 1315 bufBefore = pfile_in_zip_read_info->stream.next_out;
1086 1316
1087 /* 1317 /*
1088 if ((pfile_in_zip_read_info->rest_read_uncompressed == 1318 if ((pfile_in_zip_read_info->rest_read_uncompressed ==
1089 pfile_in_zip_read_info->stream.avail_out) && 1319 pfile_in_zip_read_info->stream.avail_out) &&
1090 (pfile_in_zip_read_info->rest_read_compressed == 0)) 1320 (pfile_in_zip_read_info->rest_read_compressed == 0))
1091 flush = Z_FINISH; 1321 flush = Z_FINISH;
1092 */ 1322 */
1093 err=inflate(&pfile_in_zip_read_info->stream,flush); 1323 err=inflate(&pfile_in_zip_read_info->stream,flush);
1094 1324
1095 uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; 1325 uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
1096 uOutThis = uTotalOutAfter-uTotalOutBefore; 1326 uOutThis = uTotalOutAfter-uTotalOutBefore;
1097 1327
1098 pfile_in_zip_read_info->crc32 = 1328 pfile_in_zip_read_info->crc32 =
1099 crc32(pfile_in_zip_read_info->crc32,bufBefore, 1329 crc32(pfile_in_zip_read_info->crc32,bufBefore,
1100 (uInt)(uOutThis)); 1330 (uInt)(uOutThis));
1101 1331
1102 pfile_in_zip_read_info->rest_read_uncompressed -= 1332 pfile_in_zip_read_info->rest_read_uncompressed -=
1103 uOutThis; 1333 uOutThis;
1104 1334
1105 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); 1335 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
1106 1336
1107 if (err==Z_STREAM_END) 1337 if (err==Z_STREAM_END)
1108 return (iRead==0) ? UNZ_EOF : iRead; 1338 return (iRead==0) ? UNZ_EOF : iRead;
1109 if (err!=Z_OK) 1339 if (err!=Z_OK)
1110 break; 1340 break;
1111 } 1341 }
1112 } 1342 }
1113 1343
1114 if (err==Z_OK) 1344 if (err==Z_OK)
1115 return iRead; 1345 return iRead;
1116 return err; 1346 return err;
1117} 1347}
1118 1348
1119 1349
@@ -1121,42 +1351,42 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
1121 Give the current position in uncompressed data 1351 Give the current position in uncompressed data
1122*/ 1352*/
1123extern z_off_t ZEXPORT unztell (file) 1353extern z_off_t ZEXPORT unztell (file)
1124 unzFile file; 1354 unzFile file;
1125{ 1355{
1126 unz_s* s; 1356 unz_s* s;
1127 file_in_zip_read_info_s* pfile_in_zip_read_info; 1357 file_in_zip_read_info_s* pfile_in_zip_read_info;
1128 if (file==NULL) 1358 if (file==NULL)
1129 return UNZ_PARAMERROR; 1359 return UNZ_PARAMERROR;
1130 s=(unz_s*)file; 1360 s=(unz_s*)file;
1131 pfile_in_zip_read_info=s->pfile_in_zip_read; 1361 pfile_in_zip_read_info=s->pfile_in_zip_read;
1132 1362
1133 if (pfile_in_zip_read_info==NULL) 1363 if (pfile_in_zip_read_info==NULL)
1134 return UNZ_PARAMERROR; 1364 return UNZ_PARAMERROR;
1135 1365
1136 return (z_off_t)pfile_in_zip_read_info->stream.total_out; 1366 return (z_off_t)pfile_in_zip_read_info->stream.total_out;
1137} 1367}
1138 1368
1139 1369
1140/* 1370/*
1141 return 1 if the end of file was reached, 0 elsewhere 1371 return 1 if the end of file was reached, 0 elsewhere
1142*/ 1372*/
1143extern int ZEXPORT unzeof (file) 1373extern int ZEXPORT unzeof (file)
1144 unzFile file; 1374 unzFile file;
1145{ 1375{
1146 unz_s* s; 1376 unz_s* s;
1147 file_in_zip_read_info_s* pfile_in_zip_read_info; 1377 file_in_zip_read_info_s* pfile_in_zip_read_info;
1148 if (file==NULL) 1378 if (file==NULL)
1149 return UNZ_PARAMERROR; 1379 return UNZ_PARAMERROR;
1150 s=(unz_s*)file; 1380 s=(unz_s*)file;
1151 pfile_in_zip_read_info=s->pfile_in_zip_read; 1381 pfile_in_zip_read_info=s->pfile_in_zip_read;
1152 1382
1153 if (pfile_in_zip_read_info==NULL) 1383 if (pfile_in_zip_read_info==NULL)
1154 return UNZ_PARAMERROR; 1384 return UNZ_PARAMERROR;
1155 1385
1156 if (pfile_in_zip_read_info->rest_read_uncompressed == 0) 1386 if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
1157 return 1; 1387 return 1;
1158 else 1388 else
1159 return 0; 1389 return 0;
1160} 1390}
1161 1391
1162 1392
@@ -1169,51 +1399,55 @@ extern int ZEXPORT unzeof (file)
1169 if buf==NULL, it return the size of the local extra field that can be read 1399 if buf==NULL, it return the size of the local extra field that can be read
1170 1400
1171 if buf!=NULL, len is the size of the buffer, the extra header is copied in 1401 if buf!=NULL, len is the size of the buffer, the extra header is copied in
1172 buf. 1402 buf.
1173 the return value is the number of bytes copied in buf, or (if <0) 1403 the return value is the number of bytes copied in buf, or (if <0)
1174 the error code 1404 the error code
1175*/ 1405*/
1176extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) 1406extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
1177 unzFile file; 1407 unzFile file;
1178 voidp buf; 1408 voidp buf;
1179 unsigned len; 1409 unsigned len;
1180{ 1410{
1181 unz_s* s; 1411 unz_s* s;
1182 file_in_zip_read_info_s* pfile_in_zip_read_info; 1412 file_in_zip_read_info_s* pfile_in_zip_read_info;
1183 uInt read_now; 1413 uInt read_now;
1184 uLong size_to_read; 1414 uLong size_to_read;
1185 1415
1186 if (file==NULL) 1416 if (file==NULL)
1187 return UNZ_PARAMERROR; 1417 return UNZ_PARAMERROR;
1188 s=(unz_s*)file; 1418 s=(unz_s*)file;
1189 pfile_in_zip_read_info=s->pfile_in_zip_read; 1419 pfile_in_zip_read_info=s->pfile_in_zip_read;
1190 1420
1191 if (pfile_in_zip_read_info==NULL) 1421 if (pfile_in_zip_read_info==NULL)
1192 return UNZ_PARAMERROR; 1422 return UNZ_PARAMERROR;
1193 1423
1194 size_to_read = (pfile_in_zip_read_info->size_local_extrafield - 1424 size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
1195 pfile_in_zip_read_info->pos_local_extrafield); 1425 pfile_in_zip_read_info->pos_local_extrafield);
1426
1427 if (buf==NULL)
1428 return (int)size_to_read;
1429
1430 if (len>size_to_read)
1431 read_now = (uInt)size_to_read;
1432 else
1433 read_now = (uInt)len ;
1196 1434
1197 if (buf==NULL) 1435 if (read_now==0)
1198 return (int)size_to_read; 1436 return 0;
1199
1200 if (len>size_to_read)
1201 read_now = (uInt)size_to_read;
1202 else
1203 read_now = (uInt)len ;
1204 1437
1205 if (read_now==0) 1438 if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
1206 return 0; 1439 pfile_in_zip_read_info->filestream,
1207 1440 pfile_in_zip_read_info->offset_local_extrafield +
1208 if (fseek(pfile_in_zip_read_info->file, 1441 pfile_in_zip_read_info->pos_local_extrafield,
1209 pfile_in_zip_read_info->offset_local_extrafield + 1442 ZLIB_FILEFUNC_SEEK_SET)!=0)
1210 pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) 1443 return UNZ_ERRNO;
1211 return UNZ_ERRNO;
1212 1444
1213 if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) 1445 if (ZREAD(pfile_in_zip_read_info->z_filefunc,
1214 return UNZ_ERRNO; 1446 pfile_in_zip_read_info->filestream,
1447 buf,size_to_read)!=size_to_read)
1448 return UNZ_ERRNO;
1215 1449
1216 return (int)read_now; 1450 return (int)read_now;
1217} 1451}
1218 1452
1219/* 1453/*
@@ -1221,39 +1455,40 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
1221 Return UNZ_CRCERROR if all the file was read but the CRC is not good 1455 Return UNZ_CRCERROR if all the file was read but the CRC is not good
1222*/ 1456*/
1223extern int ZEXPORT unzCloseCurrentFile (file) 1457extern int ZEXPORT unzCloseCurrentFile (file)
1224 unzFile file; 1458 unzFile file;
1225{ 1459{
1226 int err=UNZ_OK; 1460 int err=UNZ_OK;
1227 1461
1228 unz_s* s; 1462 unz_s* s;
1229 file_in_zip_read_info_s* pfile_in_zip_read_info; 1463 file_in_zip_read_info_s* pfile_in_zip_read_info;
1230 if (file==NULL) 1464 if (file==NULL)
1231 return UNZ_PARAMERROR; 1465 return UNZ_PARAMERROR;
1232 s=(unz_s*)file; 1466 s=(unz_s*)file;
1233 pfile_in_zip_read_info=s->pfile_in_zip_read; 1467 pfile_in_zip_read_info=s->pfile_in_zip_read;
1234 1468
1235 if (pfile_in_zip_read_info==NULL) 1469 if (pfile_in_zip_read_info==NULL)
1236 return UNZ_PARAMERROR; 1470 return UNZ_PARAMERROR;
1237 1471
1238 1472
1239 if (pfile_in_zip_read_info->rest_read_uncompressed == 0) 1473 if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
1240 { 1474 (!pfile_in_zip_read_info->raw))
1241 if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) 1475 {
1242 err=UNZ_CRCERROR; 1476 if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
1243 } 1477 err=UNZ_CRCERROR;
1478 }
1244 1479
1245 1480
1246 TRYFREE(pfile_in_zip_read_info->read_buffer); 1481 TRYFREE(pfile_in_zip_read_info->read_buffer);
1247 pfile_in_zip_read_info->read_buffer = NULL; 1482 pfile_in_zip_read_info->read_buffer = NULL;
1248 if (pfile_in_zip_read_info->stream_initialised) 1483 if (pfile_in_zip_read_info->stream_initialised)
1249 inflateEnd(&pfile_in_zip_read_info->stream); 1484 inflateEnd(&pfile_in_zip_read_info->stream);
1250 1485
1251 pfile_in_zip_read_info->stream_initialised = 0; 1486 pfile_in_zip_read_info->stream_initialised = 0;
1252 TRYFREE(pfile_in_zip_read_info); 1487 TRYFREE(pfile_in_zip_read_info);
1253 1488
1254 s->pfile_in_zip_read=NULL; 1489 s->pfile_in_zip_read=NULL;
1255 1490
1256 return err; 1491 return err;
1257} 1492}
1258 1493
1259 1494
@@ -1263,32 +1498,32 @@ extern int ZEXPORT unzCloseCurrentFile (file)
1263 return the number of byte copied or an error code <0 1498 return the number of byte copied or an error code <0
1264*/ 1499*/
1265extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) 1500extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
1266 unzFile file; 1501 unzFile file;
1267 char *szComment; 1502 char *szComment;
1268 uLong uSizeBuf; 1503 uLong uSizeBuf;
1269{ 1504{
1270 int err=UNZ_OK; 1505 int err=UNZ_OK;
1271 unz_s* s; 1506 unz_s* s;
1272 uLong uReadThis ; 1507 uLong uReadThis ;
1273 if (file==NULL) 1508 if (file==NULL)
1274 return UNZ_PARAMERROR; 1509 return UNZ_PARAMERROR;
1275 s=(unz_s*)file; 1510 s=(unz_s*)file;
1276 1511
1277 uReadThis = uSizeBuf; 1512 uReadThis = uSizeBuf;
1278 if (uReadThis>s->gi.size_comment) 1513 if (uReadThis>s->gi.size_comment)
1279 uReadThis = s->gi.size_comment; 1514 uReadThis = s->gi.size_comment;
1280 1515
1281 if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) 1516 if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
1282 return UNZ_ERRNO; 1517 return UNZ_ERRNO;
1283 1518
1284 if (uReadThis>0) 1519 if (uReadThis>0)
1285 { 1520 {
1286 *szComment='\0'; 1521 *szComment='\0';
1287 if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) 1522 if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
1288 return UNZ_ERRNO; 1523 return UNZ_ERRNO;
1289 } 1524 }
1290 1525
1291 if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) 1526 if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
1292 *(szComment+s->gi.size_comment)='\0'; 1527 *(szComment+s->gi.size_comment)='\0';
1293 return (int)uReadThis; 1528 return (int)uReadThis;
1294} 1529}
diff --git a/contrib/minizip/unzip.def b/contrib/minizip/unzip.def
deleted file mode 100644
index f6ede89..0000000
--- a/contrib/minizip/unzip.def
+++ /dev/null
@@ -1,15 +0,0 @@
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
index 76692cb..67ca851 100644
--- a/contrib/minizip/unzip.h
+++ b/contrib/minizip/unzip.h
@@ -1,15 +1,14 @@
1/* unzip.h -- IO for uncompress .zip files using zlib 1/* unzip.h -- IO for uncompress .zip files using zlib
2 Version 0.15 beta, Mar 19th, 1998, 2 Version 0.21, March 10th, 2003
3 3
4 Copyright (C) 1998 Gilles Vollant 4 Copyright (C) 1998-2003 Gilles Vollant
5 5
6 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g 6 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
7 WinZip, InfoZip tools and compatible. 7 WinZip, InfoZip tools and compatible.
8 Encryption and multi volume ZipFile (span) are not supported. 8 Encryption and multi volume ZipFile (span) are not supported.
9 Old compressions used by old PKZip 1.x are not supported 9 Old compressions used by old PKZip 1.x are not supported
10 10
11 THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE 11
12 CAN CHANGE IN FUTURE VERSION !!
13 I WAIT FEEDBACK at mail info@winimage.com 12 I WAIT FEEDBACK at mail info@winimage.com
14 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution 13 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
15 14
@@ -33,10 +32,13 @@
33 32
34 33
35*/ 34*/
36/* for more info about .ZIP format, see 35
37 ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip 36/* for more info about .ZIP format, see
37 http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
38 http://www.info-zip.org/pub/infozip/doc/
38 PkWare has also a specification at : 39 PkWare has also a specification at :
39 ftp://ftp.pkware.com/probdesc.zip */ 40 ftp://ftp.pkware.com/probdesc.zip
41*/
40 42
41#ifndef _unz_H 43#ifndef _unz_H
42#define _unz_H 44#define _unz_H
@@ -49,43 +51,47 @@ extern "C" {
49#include "zlib.h" 51#include "zlib.h"
50#endif 52#endif
51 53
54#ifndef _ZLIBIOAPI_H
55#include "ioapi.h"
56#endif
57
52#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) 58#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
53/* like the STRICT of WIN32, we define a pointer that cannot be converted 59/* like the STRICT of WIN32, we define a pointer that cannot be converted
54 from (void*) without cast */ 60 from (void*) without cast */
55typedef struct TagunzFile__ { int unused; } unzFile__; 61typedef struct TagunzFile__ { int unused; } unzFile__;
56typedef unzFile__ *unzFile; 62typedef unzFile__ *unzFile;
57#else 63#else
58typedef voidp unzFile; 64typedef voidp unzFile;
59#endif 65#endif
60 66
61 67
62#define UNZ_OK (0) 68#define UNZ_OK (0)
63#define UNZ_END_OF_LIST_OF_FILE (-100) 69#define UNZ_END_OF_LIST_OF_FILE (-100)
64#define UNZ_ERRNO (Z_ERRNO) 70#define UNZ_ERRNO (Z_ERRNO)
65#define UNZ_EOF (0) 71#define UNZ_EOF (0)
66#define UNZ_PARAMERROR (-102) 72#define UNZ_PARAMERROR (-102)
67#define UNZ_BADZIPFILE (-103) 73#define UNZ_BADZIPFILE (-103)
68#define UNZ_INTERNALERROR (-104) 74#define UNZ_INTERNALERROR (-104)
69#define UNZ_CRCERROR (-105) 75#define UNZ_CRCERROR (-105)
70 76
71/* tm_unz contain date/time info */ 77/* tm_unz contain date/time info */
72typedef struct tm_unz_s 78typedef struct tm_unz_s
73{ 79{
74 uInt tm_sec; /* seconds after the minute - [0,59] */ 80 uInt tm_sec; /* seconds after the minute - [0,59] */
75 uInt tm_min; /* minutes after the hour - [0,59] */ 81 uInt tm_min; /* minutes after the hour - [0,59] */
76 uInt tm_hour; /* hours since midnight - [0,23] */ 82 uInt tm_hour; /* hours since midnight - [0,23] */
77 uInt tm_mday; /* day of the month - [1,31] */ 83 uInt tm_mday; /* day of the month - [1,31] */
78 uInt tm_mon; /* months since January - [0,11] */ 84 uInt tm_mon; /* months since January - [0,11] */
79 uInt tm_year; /* years - [1980..2044] */ 85 uInt tm_year; /* years - [1980..2044] */
80} tm_unz; 86} tm_unz;
81 87
82/* unz_global_info structure contain global data about the ZIPfile 88/* unz_global_info structure contain global data about the ZIPfile
83 These data comes from the end of central dir */ 89 These data comes from the end of central dir */
84typedef struct unz_global_info_s 90typedef struct unz_global_info_s
85{ 91{
86 uLong number_entry; /* total number of entries in 92 uLong number_entry; /* total number of entries in
87 the central dir on this disk */ 93 the central dir on this disk */
88 uLong size_comment; /* size of the global comment of the zipfile */ 94 uLong size_comment; /* size of the global comment of the zipfile */
89} unz_global_info; 95} unz_global_info;
90 96
91 97
@@ -98,8 +104,8 @@ typedef struct unz_file_info_s
98 uLong compression_method; /* compression method 2 bytes */ 104 uLong compression_method; /* compression method 2 bytes */
99 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ 105 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
100 uLong crc; /* crc-32 4 bytes */ 106 uLong crc; /* crc-32 4 bytes */
101 uLong compressed_size; /* compressed size 4 bytes */ 107 uLong compressed_size; /* compressed size 4 bytes */
102 uLong uncompressed_size; /* uncompressed size 4 bytes */ 108 uLong uncompressed_size; /* uncompressed size 4 bytes */
103 uLong size_filename; /* filename length 2 bytes */ 109 uLong size_filename; /* filename length 2 bytes */
104 uLong size_file_extra; /* extra field length 2 bytes */ 110 uLong size_file_extra; /* extra field length 2 bytes */
105 uLong size_file_comment; /* file comment length 2 bytes */ 111 uLong size_file_comment; /* file comment length 2 bytes */
@@ -112,27 +118,34 @@ typedef struct unz_file_info_s
112} unz_file_info; 118} unz_file_info;
113 119
114extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, 120extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
115 const char* fileName2, 121 const char* fileName2,
116 int iCaseSensitivity)); 122 int iCaseSensitivity));
117/* 123/*
118 Compare two filename (fileName1,fileName2). 124 Compare two filename (fileName1,fileName2).
119 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) 125 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
120 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi 126 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
121 or strcasecmp) 127 or strcasecmp)
122 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system 128 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
123 (like 1 on Unix, 2 on Windows) 129 (like 1 on Unix, 2 on Windows)
124*/ 130*/
125 131
126 132
127extern unzFile ZEXPORT unzOpen OF((const char *path)); 133extern unzFile ZEXPORT unzOpen OF((const char *path));
128/* 134/*
129 Open a Zip file. path contain the full pathname (by example, 135 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 136 on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
131 "zlib/zlib111.zip". 137 "zlib/zlib113.zip".
132 If the zipfile cannot be opened (file don't exist or in not valid), the 138 If the zipfile cannot be opened (file don't exist or in not valid), the
133 return value is NULL. 139 return value is NULL.
134 Else, the return value is a unzFile Handle, usable with other function 140 Else, the return value is a unzFile Handle, usable with other function
135 of this unzip package. 141 of this unzip package.
142*/
143
144extern unzFile ZEXPORT unzOpen2 OF((const char *path,
145 zlib_filefunc_def* pzlib_filefunc_def));
146/*
147 Open a Zip file, like unzOpen, but provide a set of file low level API
148 for read/write the zip file (see ioapi.h)
136*/ 149*/
137 150
138extern int ZEXPORT unzClose OF((unzFile file)); 151extern int ZEXPORT unzClose OF((unzFile file));
@@ -143,7 +156,7 @@ extern int ZEXPORT unzClose OF((unzFile file));
143 return UNZ_OK if there is no problem. */ 156 return UNZ_OK if there is no problem. */
144 157
145extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, 158extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
146 unz_global_info *pglobal_info)); 159 unz_global_info *pglobal_info));
147/* 160/*
148 Write info about the ZipFile in the *pglobal_info structure. 161 Write info about the ZipFile in the *pglobal_info structure.
149 No preparation of the structure is needed 162 No preparation of the structure is needed
@@ -151,8 +164,8 @@ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
151 164
152 165
153extern int ZEXPORT unzGetGlobalComment OF((unzFile file, 166extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
154 char *szComment, 167 char *szComment,
155 uLong uSizeBuf)); 168 uLong uSizeBuf));
156/* 169/*
157 Get the global comment string of the ZipFile, in the szComment buffer. 170 Get the global comment string of the ZipFile, in the szComment buffer.
158 uSizeBuf is the size of the szComment buffer. 171 uSizeBuf is the size of the szComment buffer.
@@ -176,9 +189,9 @@ extern int ZEXPORT unzGoToNextFile OF((unzFile file));
176 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. 189 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
177*/ 190*/
178 191
179extern int ZEXPORT unzLocateFile OF((unzFile file, 192extern int ZEXPORT unzLocateFile OF((unzFile file,
180 const char *szFileName, 193 const char *szFileName,
181 int iCaseSensitivity)); 194 int iCaseSensitivity));
182/* 195/*
183 Try locate the file szFileName in the zipfile. 196 Try locate the file szFileName in the zipfile.
184 For the iCaseSensitivity signification, see unzStringFileNameCompare 197 For the iCaseSensitivity signification, see unzStringFileNameCompare
@@ -189,25 +202,44 @@ extern int ZEXPORT unzLocateFile OF((unzFile file,
189*/ 202*/
190 203
191 204
205/* ****************************************** */
206/* Ryan supplied functions */
207/* unz_file_info contain information about a file in the zipfile */
208typedef struct unz_file_pos_s
209{
210 uLong pos_in_zip_directory; /* offset in zip file directory */
211 uLong num_of_file; /* # of file */
212} unz_file_pos;
213
214extern int ZEXPORT unzGetFilePos(
215 unzFile file,
216 unz_file_pos* file_pos);
217
218extern int ZEXPORT unzGoToFilePos(
219 unzFile file,
220 unz_file_pos* file_pos);
221
222/* ****************************************** */
223
192extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, 224extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
193 unz_file_info *pfile_info, 225 unz_file_info *pfile_info,
194 char *szFileName, 226 char *szFileName,
195 uLong fileNameBufferSize, 227 uLong fileNameBufferSize,
196 void *extraField, 228 void *extraField,
197 uLong extraFieldBufferSize, 229 uLong extraFieldBufferSize,
198 char *szComment, 230 char *szComment,
199 uLong commentBufferSize)); 231 uLong commentBufferSize));
200/* 232/*
201 Get Info about the current file 233 Get Info about the current file
202 if pfile_info!=NULL, the *pfile_info structure will contain somes info about 234 if pfile_info!=NULL, the *pfile_info structure will contain somes info about
203 the current file 235 the current file
204 if szFileName!=NULL, the filemane string will be copied in szFileName 236 if szFileName!=NULL, the filemane string will be copied in szFileName
205 (fileNameBufferSize is the size of the buffer) 237 (fileNameBufferSize is the size of the buffer)
206 if extraField!=NULL, the extra field information will be copied in extraField 238 if extraField!=NULL, the extra field information will be copied in extraField
207 (extraFieldBufferSize is the size of the buffer). 239 (extraFieldBufferSize is the size of the buffer).
208 This is the Central-header version of the extra field 240 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 241 if szComment!=NULL, the comment string of the file will be copied in szComment
210 (commentBufferSize is the size of the buffer) 242 (commentBufferSize is the size of the buffer)
211*/ 243*/
212 244
213/***************************************************************************/ 245/***************************************************************************/
@@ -221,16 +253,51 @@ extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
221 If there is no error, the return value is UNZ_OK. 253 If there is no error, the return value is UNZ_OK.
222*/ 254*/
223 255
256extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
257 const char* password));
258/*
259 Open for reading data the current file in the zipfile.
260 password is a crypting password
261 If there is no error, the return value is UNZ_OK.
262*/
263
264extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
265 int* method,
266 int* level,
267 int raw));
268/*
269 Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
270 if raw==1
271 *method will receive method of compression, *level will receive level of
272 compression
273 note : you can set level parameter as NULL (if you did not want known level,
274 but you CANNOT set method parameter as NULL
275*/
276
277extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
278 int* method,
279 int* level,
280 int raw,
281 const char* password));
282/*
283 Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
284 if raw==1
285 *method will receive method of compression, *level will receive level of
286 compression
287 note : you can set level parameter as NULL (if you did not want known level,
288 but you CANNOT set method parameter as NULL
289*/
290
291
224extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); 292extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
225/* 293/*
226 Close the file in zip opened with unzOpenCurrentFile 294 Close the file in zip opened with unzOpenCurrentFile
227 Return UNZ_CRCERROR if all the file was read but the CRC is not good 295 Return UNZ_CRCERROR if all the file was read but the CRC is not good
228*/ 296*/
229 297
230 298extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
231extern int ZEXPORT unzReadCurrentFile OF((unzFile file, 299 voidp buf,
232 voidp buf, 300 unsigned len));
233 unsigned len));
234/* 301/*
235 Read bytes from the current file (opened by unzOpenCurrentFile) 302 Read bytes from the current file (opened by unzOpenCurrentFile)
236 buf contain buffer where data must be copied 303 buf contain buffer where data must be copied
@@ -249,12 +316,12 @@ extern z_off_t ZEXPORT unztell OF((unzFile file));
249 316
250extern int ZEXPORT unzeof OF((unzFile file)); 317extern int ZEXPORT unzeof OF((unzFile file));
251/* 318/*
252 return 1 if the end of file was reached, 0 elsewhere 319 return 1 if the end of file was reached, 0 elsewhere
253*/ 320*/
254 321
255extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, 322extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
256 voidp buf, 323 voidp buf,
257 unsigned len)); 324 unsigned len));
258/* 325/*
259 Read extra field from the current file (opened by unzOpenCurrentFile) 326 Read extra field from the current file (opened by unzOpenCurrentFile)
260 This is the local-header version of the extra field (sometimes, there is 327 This is the local-header version of the extra field (sometimes, there is
@@ -263,9 +330,9 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
263 if buf==NULL, it return the size of the local extra field 330 if buf==NULL, it return the size of the local extra field
264 331
265 if buf!=NULL, len is the size of the buffer, the extra header is copied in 332 if buf!=NULL, len is the size of the buffer, the extra header is copied in
266 buf. 333 buf.
267 the return value is the number of bytes copied in buf, or (if <0) 334 the return value is the number of bytes copied in buf, or (if <0)
268 the error code 335 the error code
269*/ 336*/
270 337
271#ifdef __cplusplus 338#ifdef __cplusplus
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c
index 0cae64a..29c17d8 100644
--- a/contrib/minizip/zip.c
+++ b/contrib/minizip/zip.c
@@ -1,5 +1,5 @@
1/* zip.c -- IO on .zip files using zlib 1/* zip.c -- IO on .zip files using zlib
2 Version 0.15 beta, Mar 19th, 1998, 2 Version 0.21, March 10th, 2003
3 3
4 Read zip.h for more info 4 Read zip.h for more info
5*/ 5*/
@@ -8,6 +8,7 @@
8#include <stdio.h> 8#include <stdio.h>
9#include <stdlib.h> 9#include <stdlib.h>
10#include <string.h> 10#include <string.h>
11#include <time.h>
11#include "zlib.h" 12#include "zlib.h"
12#include "zip.h" 13#include "zip.h"
13 14
@@ -66,8 +67,15 @@
66#define SEEK_SET 0 67#define SEEK_SET 0
67#endif 68#endif
68 69
70#ifndef DEF_MEM_LEVEL
71#if MAX_MEM_LEVEL >= 8
72# define DEF_MEM_LEVEL 8
73#else
74# define DEF_MEM_LEVEL MAX_MEM_LEVEL
75#endif
76#endif
69const char zip_copyright[] = 77const char zip_copyright[] =
70 " zip 0.15 Copyright 1998 Gilles Vollant "; 78 " zip 0.21 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll";
71 79
72 80
73#define SIZEDATA_INDATABLOCK (4096-(4*4)) 81#define SIZEDATA_INDATABLOCK (4096-(4*4))
@@ -99,33 +107,49 @@ typedef struct linkedlist_data_s
99 107
100typedef struct 108typedef struct
101{ 109{
102 z_stream stream; /* zLib stream structure for inflate */ 110 z_stream stream; /* zLib stream structure for inflate */
103 int stream_initialised; /* 1 is stream is initialised */ 111 int stream_initialised; /* 1 is stream is initialised */
104 uInt pos_in_buffered_data; /* last written byte in buffered_data */ 112 uInt pos_in_buffered_data; /* last written byte in buffered_data */
105 113
106 uLong pos_local_header; /* offset of the local header of the file 114 uLong pos_local_header; /* offset of the local header of the file
107 currenty writing */ 115 currenty writing */
108 char* central_header; /* central header data for the current file */ 116 char* central_header; /* central header data for the current file */
109 uLong size_centralheader; /* size of the central header for cur file */ 117 uLong size_centralheader; /* size of the central header for cur file */
110 uLong flag; /* flag of the file currently writing */ 118 uLong flag; /* flag of the file currently writing */
111 119
112 int method; /* compression method of file currenty wr.*/ 120 int method; /* compression method of file currenty wr.*/
121 int raw; /* 1 for directly writing raw data */
113 Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ 122 Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/
114 uLong dosDate; 123 uLong dosDate;
115 uLong crc32; 124 uLong crc32;
125 int encrypt;
126#ifndef NOCRPYT
127 unsigned long keys[3]; /* keys defining the pseudo-random sequence */
128 const unsigned long* pcrc_32_tab;
129 int crypt_header_size;
130#endif
116} curfile_info; 131} curfile_info;
117 132
118typedef struct 133typedef struct
119{ 134{
120 FILE * filezip; 135 zlib_filefunc_def z_filefunc;
136 voidpf filestream; /* io structore of the zipfile */
121 linkedlist_data central_dir;/* datablock with central dir in construction*/ 137 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.*/ 138 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 */ 139 curfile_info ci; /* info on the file curretly writing */
124 140
125 uLong begin_pos; /* position of the beginning of the zipfile */ 141 uLong begin_pos; /* position of the beginning of the zipfile */
142 uLong add_position_when_writting_offset;
126 uLong number_entry; 143 uLong number_entry;
127} zip_internal; 144} zip_internal;
128 145
146
147
148#ifndef NOCRPYT
149#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED
150#include "crypt.h"
151#endif
152
129local linkedlist_datablock_internal* allocate_new_datablock() 153local linkedlist_datablock_internal* allocate_new_datablock()
130{ 154{
131 linkedlist_datablock_internal* ldi; 155 linkedlist_datablock_internal* ldi;
@@ -166,7 +190,7 @@ local void free_linkedlist(ll)
166 190
167 191
168local int add_data_in_datablock(ll,buf,len) 192local int add_data_in_datablock(ll,buf,len)
169 linkedlist_data* ll; 193 linkedlist_data* ll;
170 const void* buf; 194 const void* buf;
171 uLong len; 195 uLong len;
172{ 196{
@@ -220,32 +244,20 @@ local int add_data_in_datablock(ll,buf,len)
220} 244}
221 245
222 246
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 247
239/****************************************************************************/ 248/****************************************************************************/
240 249
250#ifndef NO_ADDFILEINEXISTINGZIP
241/* =========================================================================== 251/* ===========================================================================
242 Outputs a long in LSB order to the given file 252 Inputs a long in LSB order to the given file
243 nbByte == 1, 2 or 4 (byte, short or long) 253 nbByte == 1, 2 or 4 (byte, short or long)
244*/ 254*/
245 255
246local int ziplocal_putValue OF((FILE *file, uLong x, int nbByte)); 256local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def,
247local int ziplocal_putValue (file, x, nbByte) 257 voidpf filestream, uLong x, int nbByte));
248 FILE *file; 258local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte)
259 const zlib_filefunc_def* pzlib_filefunc_def;
260 voidpf filestream;
249 uLong x; 261 uLong x;
250 int nbByte; 262 int nbByte;
251{ 263{
@@ -255,7 +267,7 @@ local int ziplocal_putValue (file, x, nbByte)
255 buf[n] = (unsigned char)(x & 0xff); 267 buf[n] = (unsigned char)(x & 0xff);
256 x >>= 8; 268 x >>= 8;
257 } 269 }
258 if (fwrite(buf,nbByte,1,file)!=1) 270 if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte)
259 return ZIP_ERRNO; 271 return ZIP_ERRNO;
260 else 272 else
261 return ZIP_OK; 273 return ZIP_OK;
@@ -278,7 +290,7 @@ local void ziplocal_putValue_inmemory (dest, x, nbByte)
278 290
279 291
280local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) 292local uLong ziplocal_TmzDateToDosDate(ptm,dosDate)
281 tm_zip* ptm; 293 const tm_zip* ptm;
282 uLong dosDate; 294 uLong dosDate;
283{ 295{
284 uLong year = (uLong)ptm->tm_year; 296 uLong year = (uLong)ptm->tm_year;
@@ -294,38 +306,348 @@ local uLong ziplocal_TmzDateToDosDate(ptm,dosDate)
294 306
295/****************************************************************************/ 307/****************************************************************************/
296 308
297extern zipFile ZEXPORT zipOpen (pathname, append) 309local int ziplocal_getByte OF((
310 const zlib_filefunc_def* pzlib_filefunc_def,
311 voidpf filestream,
312 int *pi));
313
314local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi)
315 const zlib_filefunc_def* pzlib_filefunc_def;
316 voidpf filestream;
317 int *pi;
318{
319 unsigned char c;
320 int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
321 if (err==1)
322 {
323 *pi = (int)c;
324 return ZIP_OK;
325 }
326 else
327 {
328 if (ZERROR(*pzlib_filefunc_def,filestream))
329 return ZIP_ERRNO;
330 else
331 return ZIP_EOF;
332 }
333}
334
335
336/* ===========================================================================
337 Reads a long in LSB order from the given gz_stream. Sets
338*/
339local int ziplocal_getShort OF((
340 const zlib_filefunc_def* pzlib_filefunc_def,
341 voidpf filestream,
342 uLong *pX));
343
344local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX)
345 const zlib_filefunc_def* pzlib_filefunc_def;
346 voidpf filestream;
347 uLong *pX;
348{
349 uLong x ;
350 int i;
351 int err;
352
353 err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
354 x = (uLong)i;
355
356 if (err==ZIP_OK)
357 err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
358 x += ((uLong)i)<<8;
359
360 if (err==ZIP_OK)
361 *pX = x;
362 else
363 *pX = 0;
364 return err;
365}
366
367local int ziplocal_getLong OF((
368 const zlib_filefunc_def* pzlib_filefunc_def,
369 voidpf filestream,
370 uLong *pX));
371
372local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX)
373 const zlib_filefunc_def* pzlib_filefunc_def;
374 voidpf filestream;
375 uLong *pX;
376{
377 uLong x ;
378 int i;
379 int err;
380
381 err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
382 x = (uLong)i;
383
384 if (err==ZIP_OK)
385 err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
386 x += ((uLong)i)<<8;
387
388 if (err==ZIP_OK)
389 err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
390 x += ((uLong)i)<<16;
391
392 if (err==ZIP_OK)
393 err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
394 x += ((uLong)i)<<24;
395
396 if (err==ZIP_OK)
397 *pX = x;
398 else
399 *pX = 0;
400 return err;
401}
402
403#ifndef BUFREADCOMMENT
404#define BUFREADCOMMENT (0x400)
405#endif
406/*
407 Locate the Central directory of a zipfile (at the end, just before
408 the global comment)
409*/
410local uLong ziplocal_SearchCentralDir OF((
411 const zlib_filefunc_def* pzlib_filefunc_def,
412 voidpf filestream));
413
414local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream)
415 const zlib_filefunc_def* pzlib_filefunc_def;
416 voidpf filestream;
417{
418 unsigned char* buf;
419 uLong uSizeFile;
420 uLong uBackRead;
421 uLong uMaxBack=0xffff; /* maximum size of global comment */
422 uLong uPosFound=0;
423
424 if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
425 return 0;
426
427
428 uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
429
430 if (uMaxBack>uSizeFile)
431 uMaxBack = uSizeFile;
432
433 buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
434 if (buf==NULL)
435 return 0;
436
437 uBackRead = 4;
438 while (uBackRead<uMaxBack)
439 {
440 uLong uReadSize,uReadPos ;
441 int i;
442 if (uBackRead+BUFREADCOMMENT>uMaxBack)
443 uBackRead = uMaxBack;
444 else
445 uBackRead+=BUFREADCOMMENT;
446 uReadPos = uSizeFile-uBackRead ;
447
448 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
449 (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
450 if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
451 break;
452
453 if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
454 break;
455
456 for (i=(int)uReadSize-3; (i--)>0;)
457 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
458 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
459 {
460 uPosFound = uReadPos+i;
461 break;
462 }
463
464 if (uPosFound!=0)
465 break;
466 }
467 TRYFREE(buf);
468 return uPosFound;
469}
470#endif /* !NO_ADDFILEINEXISTINGZIP*/
471
472/************************************************************/
473extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def)
298 const char *pathname; 474 const char *pathname;
299 int append; 475 int append;
476 zipcharpc* globalcomment;
477 zlib_filefunc_def* pzlib_filefunc_def;
300{ 478{
301 zip_internal ziinit; 479 zip_internal ziinit;
302 zip_internal* zi; 480 zip_internal* zi;
481 int err=ZIP_OK;
482
303 483
304 ziinit.filezip = fopen(pathname,(append == 0) ? "wb" : "ab"); 484 if (pzlib_filefunc_def==NULL)
305 if (ziinit.filezip == NULL) 485 fill_fopen_filefunc(&ziinit.z_filefunc);
486 else
487 ziinit.z_filefunc = *pzlib_filefunc_def;
488
489 ziinit.filestream = (*(ziinit.z_filefunc.zopen_file))
490 (ziinit.z_filefunc.opaque,
491 pathname,
492 (append == APPEND_STATUS_CREATE) ?
493 (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) :
494 (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING));
495
496 if (ziinit.filestream == NULL)
306 return NULL; 497 return NULL;
307 ziinit.begin_pos = ftell(ziinit.filezip); 498 ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream);
308 ziinit.in_opened_file_inzip = 0; 499 ziinit.in_opened_file_inzip = 0;
309 ziinit.ci.stream_initialised = 0; 500 ziinit.ci.stream_initialised = 0;
310 ziinit.number_entry = 0; 501 ziinit.number_entry = 0;
502 ziinit.add_position_when_writting_offset = 0;
311 init_linkedlist(&(ziinit.central_dir)); 503 init_linkedlist(&(ziinit.central_dir));
312 504
313 505
314 zi = (zip_internal*)ALLOC(sizeof(zip_internal)); 506 zi = (zip_internal*)ALLOC(sizeof(zip_internal));
315 if (zi==NULL) 507 if (zi==NULL)
316 { 508 {
317 fclose(ziinit.filezip); 509 ZCLOSE(ziinit.z_filefunc,ziinit.filestream);
318 return NULL; 510 return NULL;
319 } 511 }
320 512
321 *zi = ziinit; 513 /* now we add file in a zipfile */
322 return (zipFile)zi; 514 #ifndef NO_ADDFILEINEXISTINGZIP
515 if (append == APPEND_STATUS_ADDINZIP)
516 {
517 uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
518
519 uLong size_central_dir; /* size of the central directory */
520 uLong offset_central_dir; /* offset of start of central directory */
521 uLong central_pos,uL;
522
523 uLong number_disk; /* number of the current dist, used for
524 spaning ZIP, unsupported, always 0*/
525 uLong number_disk_with_CD; /* number the the disk with central dir, used
526 for spaning ZIP, unsupported, always 0*/
527 uLong number_entry;
528 uLong number_entry_CD; /* total number of entries in
529 the central dir
530 (same than number_entry on nospan) */
531 uLong size_comment;
532
533 central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream);
534 if (central_pos==0)
535 err=ZIP_ERRNO;
536
537 if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,
538 central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
539 err=ZIP_ERRNO;
540
541 /* the signature, already checked */
542 if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK)
543 err=ZIP_ERRNO;
544
545 /* number of this disk */
546 if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK)
547 err=ZIP_ERRNO;
548
549 /* number of the disk with the start of the central directory */
550 if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK)
551 err=ZIP_ERRNO;
552
553 /* total number of entries in the central dir on this disk */
554 if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK)
555 err=ZIP_ERRNO;
556
557 /* total number of entries in the central dir */
558 if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK)
559 err=ZIP_ERRNO;
560
561 if ((number_entry_CD!=number_entry) ||
562 (number_disk_with_CD!=0) ||
563 (number_disk!=0))
564 err=ZIP_BADZIPFILE;
565
566 /* size of the central directory */
567 if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK)
568 err=ZIP_ERRNO;
569
570 /* offset of start of central directory with respect to the
571 starting disk number */
572 if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK)
573 err=ZIP_ERRNO;
574
575 /* zipfile comment length */
576 if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK)
577 err=ZIP_ERRNO;
578
579 if ((central_pos<offset_central_dir+size_central_dir) &&
580 (err==ZIP_OK))
581 err=ZIP_BADZIPFILE;
582
583 if (err!=ZIP_OK)
584 {
585 ZCLOSE(ziinit.z_filefunc, ziinit.filestream);
586 return NULL;
587 }
588
589 byte_before_the_zipfile = central_pos -
590 (offset_central_dir+size_central_dir);
591 ziinit.add_position_when_writting_offset = byte_before_the_zipfile ;
592
593 {
594 uLong size_central_dir_to_read = size_central_dir;
595 size_t buf_size = SIZEDATA_INDATABLOCK;
596 void* buf_read = (void*)ALLOC(buf_size);
597 if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,
598 offset_central_dir + byte_before_the_zipfile,
599 ZLIB_FILEFUNC_SEEK_SET) != 0)
600 err=ZIP_ERRNO;
601
602 while ((size_central_dir_to_read>0) && (err==ZIP_OK))
603 {
604 uLong read_this = SIZEDATA_INDATABLOCK;
605 if (read_this > size_central_dir_to_read)
606 read_this = size_central_dir_to_read;
607 if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this)
608 err=ZIP_ERRNO;
609
610 if (err==ZIP_OK)
611 err = add_data_in_datablock(&ziinit.central_dir,buf_read,
612 (uLong)read_this);
613 size_central_dir_to_read-=read_this;
614 }
615 TRYFREE(buf_read);
616 }
617 ziinit.begin_pos = byte_before_the_zipfile;
618 ziinit.number_entry = number_entry_CD;
619
620 if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,
621 offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
622 err=ZIP_ERRNO;
623 }
624 #endif /* !NO_ADDFILEINEXISTINGZIP*/
625
626 if (err != ZIP_OK)
627 {
628 TRYFREE(zi);
629 return NULL;
630 }
631 else
632 {
633 *zi = ziinit;
634 return (zipFile)zi;
635 }
323} 636}
324 637
325extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, 638extern zipFile ZEXPORT zipOpen (pathname, append)
326 extrafield_local, size_extrafield_local, 639 const char *pathname;
327 extrafield_global, size_extrafield_global, 640 int append;
328 comment, method, level) 641{
642 return zipOpen2(pathname,append,NULL,NULL);
643}
644
645extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
646 extrafield_local, size_extrafield_local,
647 extrafield_global, size_extrafield_global,
648 comment, method, level, raw,
649 windowBits, memLevel, strategy,
650 password, crcForCrypting)
329 zipFile file; 651 zipFile file;
330 const char* filename; 652 const char* filename;
331 const zip_fileinfo* zipfi; 653 const zip_fileinfo* zipfi;
@@ -336,6 +658,12 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
336 const char* comment; 658 const char* comment;
337 int method; 659 int method;
338 int level; 660 int level;
661 int raw;
662 int windowBits;
663 int memLevel;
664 int strategy;
665 const char* password;
666 uLong crcForCrypting;
339{ 667{
340 zip_internal* zi; 668 zip_internal* zi;
341 uInt size_filename; 669 uInt size_filename;
@@ -343,6 +671,11 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
343 uInt i; 671 uInt i;
344 int err = ZIP_OK; 672 int err = ZIP_OK;
345 673
674 #ifdef NOCRPYT
675 if (password != NULL)
676 return ZIP_PARAMERROR;
677 #endif
678
346 if (file == NULL) 679 if (file == NULL)
347 return ZIP_PARAMERROR; 680 return ZIP_PARAMERROR;
348 if ((method!=0) && (method!=Z_DEFLATED)) 681 if ((method!=0) && (method!=Z_DEFLATED))
@@ -384,13 +717,17 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
384 zi->ci.flag |= 4; 717 zi->ci.flag |= 4;
385 if ((level==1)) 718 if ((level==1))
386 zi->ci.flag |= 6; 719 zi->ci.flag |= 6;
720 if (password != NULL)
721 zi->ci.flag |= 1;
387 722
388 zi->ci.crc32 = 0; 723 zi->ci.crc32 = 0;
389 zi->ci.method = method; 724 zi->ci.method = method;
725 zi->ci.encrypt = 0;
390 zi->ci.stream_initialised = 0; 726 zi->ci.stream_initialised = 0;
391 zi->ci.pos_in_buffered_data = 0; 727 zi->ci.pos_in_buffered_data = 0;
392 zi->ci.pos_local_header = ftell(zi->filezip); 728 zi->ci.raw = raw;
393 zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + 729 zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ;
730 zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename +
394 size_extrafield_global + size_comment; 731 size_extrafield_global + size_comment;
395 zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); 732 zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader);
396 733
@@ -410,16 +747,16 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
410 ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ 747 ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/
411 748
412 if (zipfi==NULL) 749 if (zipfi==NULL)
413 ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); 750 ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2);
414 else 751 else
415 ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); 752 ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2);
416 753
417 if (zipfi==NULL) 754 if (zipfi==NULL)
418 ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); 755 ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4);
419 else 756 else
420 ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); 757 ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4);
421 758
422 ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header,4); 759 ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4);
423 760
424 for (i=0;i<size_filename;i++) 761 for (i=0;i<size_filename;i++)
425 *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i); 762 *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);
@@ -430,44 +767,44 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
430 767
431 for (i=0;i<size_comment;i++) 768 for (i=0;i<size_comment;i++)
432 *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+ 769 *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+
433 size_extrafield_global+i) = *(filename+i); 770 size_extrafield_global+i) = *(comment+i);
434 if (zi->ci.central_header == NULL) 771 if (zi->ci.central_header == NULL)
435 return ZIP_INTERNALERROR; 772 return ZIP_INTERNALERROR;
436 773
437 /* write the local header */ 774 /* write the local header */
438 err = ziplocal_putValue(zi->filezip,(uLong)LOCALHEADERMAGIC,4); 775 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4);
439 776
440 if (err==ZIP_OK) 777 if (err==ZIP_OK)
441 err = ziplocal_putValue(zi->filezip,(uLong)20,2);/* version needed to extract */ 778 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */
442 if (err==ZIP_OK) 779 if (err==ZIP_OK)
443 err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.flag,2); 780 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2);
444 781
445 if (err==ZIP_OK) 782 if (err==ZIP_OK)
446 err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.method,2); 783 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2);
447 784
448 if (err==ZIP_OK) 785 if (err==ZIP_OK)
449 err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.dosDate,4); 786 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4);
450 787
451 if (err==ZIP_OK) 788 if (err==ZIP_OK)
452 err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* crc 32, unknown */ 789 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */
453 if (err==ZIP_OK) 790 if (err==ZIP_OK)
454 err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* compressed size, unknown */ 791 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */
455 if (err==ZIP_OK) 792 if (err==ZIP_OK)
456 err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* uncompressed size, unknown */ 793 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */
457 794
458 if (err==ZIP_OK) 795 if (err==ZIP_OK)
459 err = ziplocal_putValue(zi->filezip,(uLong)size_filename,2); 796 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2);
460 797
461 if (err==ZIP_OK) 798 if (err==ZIP_OK)
462 err = ziplocal_putValue(zi->filezip,(uLong)size_extrafield_local,2); 799 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2);
463 800
464 if ((err==ZIP_OK) && (size_filename>0)) 801 if ((err==ZIP_OK) && (size_filename>0))
465 if (fwrite(filename,(uInt)size_filename,1,zi->filezip)!=1) 802 if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename)
466 err = ZIP_ERRNO; 803 err = ZIP_ERRNO;
467 804
468 if ((err==ZIP_OK) && (size_extrafield_local>0)) 805 if ((err==ZIP_OK) && (size_extrafield_local>0))
469 if (fwrite(extrafield_local,(uInt)size_extrafield_local,1,zi->filezip) 806 if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local)
470 !=1) 807 !=size_extrafield_local)
471 err = ZIP_ERRNO; 808 err = ZIP_ERRNO;
472 809
473 zi->ci.stream.avail_in = (uInt)0; 810 zi->ci.stream.avail_in = (uInt)0;
@@ -476,17 +813,38 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
476 zi->ci.stream.total_in = 0; 813 zi->ci.stream.total_in = 0;
477 zi->ci.stream.total_out = 0; 814 zi->ci.stream.total_out = 0;
478 815
479 if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED)) 816 if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
480 { 817 {
481 zi->ci.stream.zalloc = (alloc_func)0; 818 zi->ci.stream.zalloc = (alloc_func)0;
482 zi->ci.stream.zfree = (free_func)0; 819 zi->ci.stream.zfree = (free_func)0;
483 zi->ci.stream.opaque = (voidpf)0; 820 zi->ci.stream.opaque = (voidpf)0;
484 821
822 if (windowBits>0)
823 windowBits = -windowBits;
824
485 err = deflateInit2(&zi->ci.stream, level, 825 err = deflateInit2(&zi->ci.stream, level,
486 Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, 0); 826 Z_DEFLATED, windowBits, memLevel, strategy);
487 827
488 if (err==Z_OK) 828 if (err==Z_OK)
489 zi->ci.stream_initialised = 1; 829 zi->ci.stream_initialised = 1;
830
831 #ifndef NOCRPYT
832 zi->ci.crypt_header_size = 0;
833 if ((err==Z_OK) && (password != NULL))
834 {
835 unsigned char bufHead[RAND_HEAD_LEN];
836 unsigned int sizeHead;
837 zi->ci.encrypt = 1;
838 zi->ci.pcrc_32_tab = get_crc_table();
839 /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/
840
841 sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting);
842 zi->ci.crypt_header_size = sizeHead;
843
844 if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead)
845 err = ZIP_ERRNO;
846 }
847 #endif
490 } 848 }
491 849
492 850
@@ -495,9 +853,74 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
495 return err; 853 return err;
496} 854}
497 855
856extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi,
857 extrafield_local, size_extrafield_local,
858 extrafield_global, size_extrafield_global,
859 comment, method, level, raw)
860 zipFile file;
861 const char* filename;
862 const zip_fileinfo* zipfi;
863 const void* extrafield_local;
864 uInt size_extrafield_local;
865 const void* extrafield_global;
866 uInt size_extrafield_global;
867 const char* comment;
868 int method;
869 int level;
870 int raw;
871{
872 return zipOpenNewFileInZip3 (file, filename, zipfi,
873 extrafield_local, size_extrafield_local,
874 extrafield_global, size_extrafield_global,
875 comment, method, level, raw,
876 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
877 NULL, 0);
878}
879
880extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
881 extrafield_local, size_extrafield_local,
882 extrafield_global, size_extrafield_global,
883 comment, method, level)
884 zipFile file;
885 const char* filename;
886 const zip_fileinfo* zipfi;
887 const void* extrafield_local;
888 uInt size_extrafield_local;
889 const void* extrafield_global;
890 uInt size_extrafield_global;
891 const char* comment;
892 int method;
893 int level;
894{
895 return zipOpenNewFileInZip2 (file, filename, zipfi,
896 extrafield_local, size_extrafield_local,
897 extrafield_global, size_extrafield_global,
898 comment, method, level, 0);
899}
900
901local int zipFlushWriteBuffer(zi)
902 zip_internal* zi;
903{
904 int err=ZIP_OK;
905
906 if (zi->ci.encrypt != 0)
907 {
908 uInt i;
909 int t;
910 for (i=0;i<zi->ci.pos_in_buffered_data;i++)
911 zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab,
912 zi->ci.buffered_data[i],t);
913 }
914 if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data)
915 !=zi->ci.pos_in_buffered_data)
916 err = ZIP_ERRNO;
917 zi->ci.pos_in_buffered_data = 0;
918 return err;
919}
920
498extern int ZEXPORT zipWriteInFileInZip (file, buf, len) 921extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
499 zipFile file; 922 zipFile file;
500 const voidp buf; 923 const void* buf;
501 unsigned len; 924 unsigned len;
502{ 925{
503 zip_internal* zi; 926 zip_internal* zi;
@@ -510,7 +933,7 @@ extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
510 if (zi->in_opened_file_inzip == 0) 933 if (zi->in_opened_file_inzip == 0)
511 return ZIP_PARAMERROR; 934 return ZIP_PARAMERROR;
512 935
513 zi->ci.stream.next_in = buf; 936 zi->ci.stream.next_in = (void*)buf;
514 zi->ci.stream.avail_in = len; 937 zi->ci.stream.avail_in = len;
515 zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); 938 zi->ci.crc32 = crc32(zi->ci.crc32,buf,len);
516 939
@@ -518,15 +941,17 @@ extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
518 { 941 {
519 if (zi->ci.stream.avail_out == 0) 942 if (zi->ci.stream.avail_out == 0)
520 { 943 {
521 if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) 944 if (zipFlushWriteBuffer(zi) == ZIP_ERRNO)
522 !=1)
523 err = ZIP_ERRNO; 945 err = ZIP_ERRNO;
524 zi->ci.pos_in_buffered_data = 0;
525 zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; 946 zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
526 zi->ci.stream.next_out = zi->ci.buffered_data; 947 zi->ci.stream.next_out = zi->ci.buffered_data;
527 } 948 }
528 949
529 if (zi->ci.method == Z_DEFLATED) 950
951 if(err != ZIP_OK)
952 break;
953
954 if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
530 { 955 {
531 uLong uTotalOutBefore = zi->ci.stream.total_out; 956 uLong uTotalOutBefore = zi->ci.stream.total_out;
532 err=deflate(&zi->ci.stream, Z_NO_FLUSH); 957 err=deflate(&zi->ci.stream, Z_NO_FLUSH);
@@ -555,33 +980,34 @@ extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
555 } 980 }
556 } 981 }
557 982
558 return 0; 983 return err;
559} 984}
560 985
561extern int ZEXPORT zipCloseFileInZip (file) 986extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32)
562 zipFile file; 987 zipFile file;
988 uLong uncompressed_size;
989 uLong crc32;
563{ 990{
564 zip_internal* zi; 991 zip_internal* zi;
992 uLong compressed_size;
565 int err=ZIP_OK; 993 int err=ZIP_OK;
566 994
567 if (file == NULL) 995 if (file == NULL)
568 return ZIP_PARAMERROR; 996 return ZIP_PARAMERROR;
569 zi = (zip_internal*)file; 997 zi = (zip_internal*)file;
570 998
571 if (zi->in_opened_file_inzip == 0) 999 if (zi->in_opened_file_inzip == 0)
572 return ZIP_PARAMERROR; 1000 return ZIP_PARAMERROR;
573 zi->ci.stream.avail_in = 0; 1001 zi->ci.stream.avail_in = 0;
574 1002
575 if (zi->ci.method == Z_DEFLATED) 1003 if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
576 while (err==ZIP_OK) 1004 while (err==ZIP_OK)
577 { 1005 {
578 uLong uTotalOutBefore; 1006 uLong uTotalOutBefore;
579 if (zi->ci.stream.avail_out == 0) 1007 if (zi->ci.stream.avail_out == 0)
580 { 1008 {
581 if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) 1009 if (zipFlushWriteBuffer(zi) == ZIP_ERRNO)
582 !=1)
583 err = ZIP_ERRNO; 1010 err = ZIP_ERRNO;
584 zi->ci.pos_in_buffered_data = 0;
585 zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; 1011 zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
586 zi->ci.stream.next_out = zi->ci.buffered_data; 1012 zi->ci.stream.next_out = zi->ci.buffered_data;
587 } 1013 }
@@ -594,21 +1020,32 @@ extern int ZEXPORT zipCloseFileInZip (file)
594 err=ZIP_OK; /* this is normal */ 1020 err=ZIP_OK; /* this is normal */
595 1021
596 if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) 1022 if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK))
597 if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) 1023 if (zipFlushWriteBuffer(zi)==ZIP_ERRNO)
598 !=1)
599 err = ZIP_ERRNO; 1024 err = ZIP_ERRNO;
600 1025
601 if ((zi->ci.method == Z_DEFLATED) && (err==ZIP_OK)) 1026 if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
602 { 1027 {
603 err=deflateEnd(&zi->ci.stream); 1028 err=deflateEnd(&zi->ci.stream);
604 zi->ci.stream_initialised = 0; 1029 zi->ci.stream_initialised = 0;
605 } 1030 }
606 1031
607 ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)zi->ci.crc32,4); /*crc*/ 1032 if (!zi->ci.raw)
1033 {
1034 crc32 = (uLong)zi->ci.crc32;
1035 uncompressed_size = (uLong)zi->ci.stream.total_in;
1036 }
1037 compressed_size = (uLong)zi->ci.stream.total_out;
1038 #ifndef NOCRPYT
1039 compressed_size += zi->ci.crypt_header_size;
1040 #endif
1041
1042 ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/
608 ziplocal_putValue_inmemory(zi->ci.central_header+20, 1043 ziplocal_putValue_inmemory(zi->ci.central_header+20,
609 (uLong)zi->ci.stream.total_out,4); /*compr size*/ 1044 compressed_size,4); /*compr size*/
1045 if (zi->ci.stream.data_type == Z_ASCII)
1046 ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2);
610 ziplocal_putValue_inmemory(zi->ci.central_header+24, 1047 ziplocal_putValue_inmemory(zi->ci.central_header+24,
611 (uLong)zi->ci.stream.total_in,4); /*uncompr size*/ 1048 uncompressed_size,4); /*uncompr size*/
612 1049
613 if (err==ZIP_OK) 1050 if (err==ZIP_OK)
614 err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, 1051 err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header,
@@ -617,23 +1054,23 @@ extern int ZEXPORT zipCloseFileInZip (file)
617 1054
618 if (err==ZIP_OK) 1055 if (err==ZIP_OK)
619 { 1056 {
620 long cur_pos_inzip = ftell(zi->filezip); 1057 long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream);
621 if (fseek(zi->filezip, 1058 if (ZSEEK(zi->z_filefunc,zi->filestream,
622 zi->ci.pos_local_header + 14,SEEK_SET)!=0) 1059 zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0)
623 err = ZIP_ERRNO; 1060 err = ZIP_ERRNO;
624 1061
625 if (err==ZIP_OK) 1062 if (err==ZIP_OK)
626 err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.crc32,4); /* crc 32, unknown */ 1063 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */
627 1064
628 if (err==ZIP_OK) /* compressed size, unknown */ 1065 if (err==ZIP_OK) /* compressed size, unknown */
629 err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_out,4); 1066 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4);
630 1067
631 if (err==ZIP_OK) /* uncompressed size, unknown */ 1068 if (err==ZIP_OK) /* uncompressed size, unknown */
632 err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_in,4); 1069 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4);
633 1070
634 if (fseek(zi->filezip, 1071 if (ZSEEK(zi->z_filefunc,zi->filestream,
635 cur_pos_inzip,SEEK_SET)!=0) 1072 cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0)
636 err = ZIP_ERRNO; 1073 err = ZIP_ERRNO;
637 } 1074 }
638 1075
639 zi->number_entry ++; 1076 zi->number_entry ++;
@@ -642,6 +1079,12 @@ extern int ZEXPORT zipCloseFileInZip (file)
642 return err; 1079 return err;
643} 1080}
644 1081
1082extern int ZEXPORT zipCloseFileInZip (file)
1083 zipFile file;
1084{
1085 return zipCloseFileInZipRaw (file,0,0);
1086}
1087
645extern int ZEXPORT zipClose (file, global_comment) 1088extern int ZEXPORT zipClose (file, global_comment)
646 zipFile file; 1089 zipFile file;
647 const char* global_comment; 1090 const char* global_comment;
@@ -666,15 +1109,16 @@ extern int ZEXPORT zipClose (file, global_comment)
666 size_global_comment = strlen(global_comment); 1109 size_global_comment = strlen(global_comment);
667 1110
668 1111
669 centraldir_pos_inzip = ftell(zi->filezip); 1112 centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream);
670 if (err==ZIP_OK) 1113 if (err==ZIP_OK)
671 { 1114 {
672 linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; 1115 linkedlist_datablock_internal* ldi = zi->central_dir.first_block ;
673 while (ldi!=NULL) 1116 while (ldi!=NULL)
674 { 1117 {
675 if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) 1118 if ((err==ZIP_OK) && (ldi->filled_in_this_block>0))
676 if (fwrite(ldi->data,(uInt)ldi->filled_in_this_block, 1119 if (ZWRITE(zi->z_filefunc,zi->filestream,
677 1,zi->filezip) !=1 ) 1120 ldi->data,ldi->filled_in_this_block)
1121 !=ldi->filled_in_this_block )
678 err = ZIP_ERRNO; 1122 err = ZIP_ERRNO;
679 1123
680 size_centraldir += ldi->filled_in_this_block; 1124 size_centraldir += ldi->filled_in_this_block;
@@ -684,34 +1128,40 @@ extern int ZEXPORT zipClose (file, global_comment)
684 free_datablock(zi->central_dir.first_block); 1128 free_datablock(zi->central_dir.first_block);
685 1129
686 if (err==ZIP_OK) /* Magic End */ 1130 if (err==ZIP_OK) /* Magic End */
687 err = ziplocal_putValue(zi->filezip,(uLong)ENDHEADERMAGIC,4); 1131 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4);
688 1132
689 if (err==ZIP_OK) /* number of this disk */ 1133 if (err==ZIP_OK) /* number of this disk */
690 err = ziplocal_putValue(zi->filezip,(uLong)0,2); 1134 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);
691 1135
692 if (err==ZIP_OK) /* number of the disk with the start of the central directory */ 1136 if (err==ZIP_OK) /* number of the disk with the start of the central directory */
693 err = ziplocal_putValue(zi->filezip,(uLong)0,2); 1137 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);
694 1138
695 if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ 1139 if (err==ZIP_OK) /* total number of entries in the central dir on this disk */
696 err = ziplocal_putValue(zi->filezip,(uLong)zi->number_entry,2); 1140 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
697 1141
698 if (err==ZIP_OK) /* total number of entries in the central dir */ 1142 if (err==ZIP_OK) /* total number of entries in the central dir */
699 err = ziplocal_putValue(zi->filezip,(uLong)zi->number_entry,2); 1143 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
700 1144
701 if (err==ZIP_OK) /* size of the central directory */ 1145 if (err==ZIP_OK) /* size of the central directory */
702 err = ziplocal_putValue(zi->filezip,(uLong)size_centraldir,4); 1146 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4);
703 1147
704 if (err==ZIP_OK) /* offset of start of central directory with respect to the 1148 if (err==ZIP_OK) /* offset of start of central directory with respect to the
705 starting disk number */ 1149 starting disk number */
706 err = ziplocal_putValue(zi->filezip,(uLong)centraldir_pos_inzip ,4); 1150 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,
1151 (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4);
707 1152
708 if (err==ZIP_OK) /* zipfile comment length */ 1153 if (err==ZIP_OK) /* zipfile comment length */
709 err = ziplocal_putValue(zi->filezip,(uLong)size_global_comment,2); 1154 err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2);
710 1155
711 if ((err==ZIP_OK) && (size_global_comment>0)) 1156 if ((err==ZIP_OK) && (size_global_comment>0))
712 if (fwrite(global_comment,(uInt)size_global_comment,1,zi->filezip) !=1 ) 1157 if (ZWRITE(zi->z_filefunc,zi->filestream,
1158 global_comment,size_global_comment) != size_global_comment)
713 err = ZIP_ERRNO; 1159 err = ZIP_ERRNO;
714 fclose(zi->filezip); 1160
1161 if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0)
1162 if (err == ZIP_OK)
1163 err = ZIP_ERRNO;
1164
715 TRYFREE(zi); 1165 TRYFREE(zi);
716 1166
717 return err; 1167 return err;
diff --git a/contrib/minizip/zip.def b/contrib/minizip/zip.def
deleted file mode 100644
index 5d5079f..0000000
--- a/contrib/minizip/zip.def
+++ /dev/null
@@ -1,5 +0,0 @@
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
index 678260b..4bc6aa4 100644
--- a/contrib/minizip/zip.h
+++ b/contrib/minizip/zip.h
@@ -1,7 +1,7 @@
1/* zip.h -- IO for compress .zip files using zlib 1/* zip.h -- IO for compress .zip files using zlib
2 Version 0.15 alpha, Mar 19th, 1998, 2 Version 0.21, March 10th, 2003
3 3
4 Copyright (C) 1998 Gilles Vollant 4 Copyright (C) 1998-2003 Gilles Vollant
5 5
6 This unzip package allow creates .ZIP file, compatible with PKZip 2.04g 6 This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
7 WinZip, InfoZip tools and compatible. 7 WinZip, InfoZip tools and compatible.
@@ -10,10 +10,9 @@
10 10
11 For uncompress .zip file, look at unzip.h 11 For uncompress .zip file, look at unzip.h
12 12
13 THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE 13
14 CAN CHANGE IN FUTURE VERSION !!
15 I WAIT FEEDBACK at mail info@winimage.com 14 I WAIT FEEDBACK at mail info@winimage.com
16 Visit also http://www.winimage.com/zLibDll/zip.htm for evolution 15 Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
17 16
18 Condition of use and distribution are the same than zlib : 17 Condition of use and distribution are the same than zlib :
19 18
@@ -36,8 +35,9 @@
36 35
37*/ 36*/
38 37
39/* for more info about .ZIP format, see 38/* for more info about .ZIP format, see
40 ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip 39 http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
40 http://www.info-zip.org/pub/infozip/doc/
41 PkWare has also a specification at : 41 PkWare has also a specification at :
42 ftp://ftp.pkware.com/probdesc.zip 42 ftp://ftp.pkware.com/probdesc.zip
43*/ 43*/
@@ -53,34 +53,49 @@ extern "C" {
53#include "zlib.h" 53#include "zlib.h"
54#endif 54#endif
55 55
56#ifndef _ZLIBIOAPI_H
57#include "ioapi.h"
58#endif
59
56#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) 60#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
57/* like the STRICT of WIN32, we define a pointer that cannot be converted 61/* like the STRICT of WIN32, we define a pointer that cannot be converted
58 from (void*) without cast */ 62 from (void*) without cast */
59typedef struct TagzipFile__ { int unused; } zipFile__; 63typedef struct TagzipFile__ { int unused; } zipFile__;
60typedef zipFile__ *zipFile; 64typedef zipFile__ *zipFile;
61#else 65#else
62typedef voidp zipFile; 66typedef voidp zipFile;
63#endif 67#endif
64 68
65#define ZIP_OK (0) 69#define ZIP_OK (0)
66#define ZIP_ERRNO (Z_ERRNO) 70#define ZIP_EOF (0)
71#define ZIP_ERRNO (Z_ERRNO)
67#define ZIP_PARAMERROR (-102) 72#define ZIP_PARAMERROR (-102)
73#define ZIP_BADZIPFILE (-103)
68#define ZIP_INTERNALERROR (-104) 74#define ZIP_INTERNALERROR (-104)
69 75
76#ifndef DEF_MEM_LEVEL
77# if MAX_MEM_LEVEL >= 8
78# define DEF_MEM_LEVEL 8
79# else
80# define DEF_MEM_LEVEL MAX_MEM_LEVEL
81# endif
82#endif
83/* default memLevel */
84
70/* tm_zip contain date/time info */ 85/* tm_zip contain date/time info */
71typedef struct tm_zip_s 86typedef struct tm_zip_s
72{ 87{
73 uInt tm_sec; /* seconds after the minute - [0,59] */ 88 uInt tm_sec; /* seconds after the minute - [0,59] */
74 uInt tm_min; /* minutes after the hour - [0,59] */ 89 uInt tm_min; /* minutes after the hour - [0,59] */
75 uInt tm_hour; /* hours since midnight - [0,23] */ 90 uInt tm_hour; /* hours since midnight - [0,23] */
76 uInt tm_mday; /* day of the month - [1,31] */ 91 uInt tm_mday; /* day of the month - [1,31] */
77 uInt tm_mon; /* months since January - [0,11] */ 92 uInt tm_mon; /* months since January - [0,11] */
78 uInt tm_year; /* years - [1980..2044] */ 93 uInt tm_year; /* years - [1980..2044] */
79} tm_zip; 94} tm_zip;
80 95
81typedef struct 96typedef struct
82{ 97{
83 tm_zip tmz_date; /* date in understandable format */ 98 tm_zip tmz_date; /* date in understandable format */
84 uLong dosDate; /* if dos_date == 0, tmu_date is used */ 99 uLong dosDate; /* if dos_date == 0, tmu_date is used */
85/* uLong flag; */ /* general purpose bit flag 2 bytes */ 100/* uLong flag; */ /* general purpose bit flag 2 bytes */
86 101
@@ -88,30 +103,48 @@ typedef struct
88 uLong external_fa; /* external file attributes 4 bytes */ 103 uLong external_fa; /* external file attributes 4 bytes */
89} zip_fileinfo; 104} zip_fileinfo;
90 105
106typedef const char* zipcharpc;
107
108
109#define APPEND_STATUS_CREATE (0)
110#define APPEND_STATUS_CREATEAFTER (1)
111#define APPEND_STATUS_ADDINZIP (2)
112
91extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); 113extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
92/* 114/*
93 Create a zipfile. 115 Create a zipfile.
94 pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on 116 pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
95 an Unix computer "zlib/zlib111.zip". 117 an Unix computer "zlib/zlib113.zip".
96 if the file pathname exist and append=1, the zip will be created at the end 118 if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
97 of the file. (useful if the file contain a self extractor code) 119 will be created at the end of the file.
98 If the zipfile cannot be opened, the return value is NULL. 120 (useful if the file contain a self extractor code)
121 if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
122 add files in existing zip (be sure you don't add file that doesn't exist)
123 If the zipfile cannot be opened, the return value is NULL.
99 Else, the return value is a zipFile Handle, usable with other function 124 Else, the return value is a zipFile Handle, usable with other function
100 of this zip package. 125 of this zip package.
101 126*/
102 127
128/* Note : there is no delete function into a zipfile.
129 If you want delete file into a zipfile, you must open a zipfile, and create another
130 Of couse, you can use RAW reading and writing to copy the file you did not want delte
103*/ 131*/
104 132
133extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
134 int append,
135 zipcharpc* globalcomment,
136 zlib_filefunc_def* pzlib_filefunc_def));
137
105extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, 138extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
106 const char* filename, 139 const char* filename,
107 const zip_fileinfo* zipfi, 140 const zip_fileinfo* zipfi,
108 const void* extrafield_local, 141 const void* extrafield_local,
109 uInt size_extrafield_local, 142 uInt size_extrafield_local,
110 const void* extrafield_global, 143 const void* extrafield_global,
111 uInt size_extrafield_global, 144 uInt size_extrafield_global,
112 const char* comment, 145 const char* comment,
113 int method, 146 int method,
114 int level)); 147 int level));
115/* 148/*
116 Open a file in the ZIP for writing. 149 Open a file in the ZIP for writing.
117 filename : the filename in zip (if NULL, '-' without quote will be used 150 filename : the filename in zip (if NULL, '-' without quote will be used
@@ -125,9 +158,51 @@ extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
125 level contain the level of compression (can be Z_DEFAULT_COMPRESSION) 158 level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
126*/ 159*/
127 160
161
162extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
163 const char* filename,
164 const zip_fileinfo* zipfi,
165 const void* extrafield_local,
166 uInt size_extrafield_local,
167 const void* extrafield_global,
168 uInt size_extrafield_global,
169 const char* comment,
170 int method,
171 int level,
172 int raw));
173
174/*
175 Same than zipOpenNewFileInZip, except if raw=1, we write raw file
176 */
177
178extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
179 const char* filename,
180 const zip_fileinfo* zipfi,
181 const void* extrafield_local,
182 uInt size_extrafield_local,
183 const void* extrafield_global,
184 uInt size_extrafield_global,
185 const char* comment,
186 int method,
187 int level,
188 int raw,
189 int windowBits,
190 int memLevel,
191 int strategy,
192 const char* password,
193 uLong crcForCtypting));
194
195/*
196 Same than zipOpenNewFileInZip2, except
197 windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
198 password : crypting password (NULL for no crypting)
199 crcForCtypting : crc of file to compress (needed for crypting)
200 */
201
202
128extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, 203extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
129 const voidp buf, 204 const void* buf,
130 unsigned len)); 205 unsigned len));
131/* 206/*
132 Write data in the zipfile 207 Write data in the zipfile
133*/ 208*/
@@ -137,8 +212,18 @@ extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
137 Close the current file in the zipfile 212 Close the current file in the zipfile
138*/ 213*/
139 214
215
216extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
217 uLong uncompressed_size,
218 uLong crc32));
219/*
220 Close the current file in the zipfile, for fiel opened with
221 parameter raw=1 in zipOpenNewFileInZip2
222 uncompressed_size and crc32 are value for the uncompressed size
223*/
224
140extern int ZEXPORT zipClose OF((zipFile file, 225extern int ZEXPORT zipClose OF((zipFile file,
141 const char* global_comment)); 226 const char* global_comment));
142/* 227/*
143 Close the zipfile 228 Close the zipfile
144*/ 229*/
diff --git a/contrib/minizip/zlibvc.def b/contrib/minizip/zlibvc.def
deleted file mode 100644
index 7e9d60d..0000000
--- a/contrib/minizip/zlibvc.def
+++ /dev/null
@@ -1,74 +0,0 @@
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
deleted file mode 100644
index a70d4d4..0000000
--- a/contrib/minizip/zlibvc.dsp
+++ /dev/null
@@ -1,651 +0,0 @@
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
deleted file mode 100644
index 493cd87..0000000
--- a/contrib/minizip/zlibvc.dsw
+++ /dev/null
@@ -1,41 +0,0 @@
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