summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:17:33 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:17:33 -0700
commit7850e4e406dce1f7a819297eeb151d1ca18e7cd9 (patch)
treed4befddacae46b06c4924193904de533099610b4 /contrib
parentebd3c2c0e734fc99a1360014ea52ed04fe6aade4 (diff)
downloadzlib-1.0.7.tar.gz
zlib-1.0.7.tar.bz2
zlib-1.0.7.zip
zlib 1.0.7v1.0.7
Diffstat (limited to '')
-rw-r--r--contrib/README.contrib21
-rw-r--r--contrib/asm386/gvmat32.asm464
-rw-r--r--contrib/asm386/gvmat32c.c229
-rw-r--r--contrib/asm386/mkgvmt32.bat1
-rw-r--r--contrib/asm386/zlibvc.mak781
-rw-r--r--contrib/iostream/test.cpp24
-rw-r--r--contrib/iostream/zfstream.cpp329
-rw-r--r--contrib/iostream/zfstream.h142
-rw-r--r--contrib/iostream2/zstream.h307
-rw-r--r--contrib/iostream2/zstream_test.cpp25
-rw-r--r--contrib/untgz/Makefile14
-rw-r--r--contrib/untgz/makefile.w3263
-rw-r--r--contrib/untgz/untgz.c478
-rw-r--r--contrib/visual-basic.txt57
14 files changed, 2935 insertions, 0 deletions
diff --git a/contrib/README.contrib b/contrib/README.contrib
new file mode 100644
index 0000000..87eb1e3
--- /dev/null
+++ b/contrib/README.contrib
@@ -0,0 +1,21 @@
1All files under this contrib directory are UNSUPPORTED. There were
2provided by users of zlib and were not tested by the authors of zlib.
3Use at your own risk. Please contact the authors of the contributions
4for help about these, not the zlib authors. Thanks.
5
6
7asm386/ by Gilles Vollant <info@winimage.com>
8 386 asm code replacing longest_match(). This code may be slower
9 than the C code if you have a good compiler.
10
11iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
12 A C++ I/O streams interface to the zlib gz* functions
13
14iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
15 Another C++ I/O streams interface
16
17untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
18 A very simple tar.gz file extractor using zlib
19
20visual-basic.txt by Carlos Rios <c_rios@sonda.cl>
21 How to use compress(), uncompress() and the gz* functions from VB.
diff --git a/contrib/asm386/gvmat32.asm b/contrib/asm386/gvmat32.asm
new file mode 100644
index 0000000..b175871
--- /dev/null
+++ b/contrib/asm386/gvmat32.asm
@@ -0,0 +1,464 @@
1;
2; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86
3; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant.
4; File written by Gilles Vollant, by modifiying the longest_match
5; from Jean-loup Gailly in deflate.c
6; It need wmask == 0x7fff
7; (assembly code is faster with a fixed wmask)
8;
9; For Visual C++ 4.2 and ML 6.11c (version in directory \MASM611C of Win95 DDK)
10; I compile with : "ml /coff /Zi /c gvmat32.asm"
11;
12; uInt longest_match_gvasm(IPos cur_match,int* match_start_ptr,uInt scan_end,
13; uInt scan_start,ush* prev,uch* window,int best_len,
14; IPos limit,uInt chain_length,uch* scanrp,
15; uInt nice_match);
16
17;uInt longest_match(s, cur_match)
18; deflate_state *s;
19; IPos cur_match; /* current match */
20
21 NbStack equ 76
22 cur_match equ dword ptr[esp+NbStack-0]
23 str_s equ dword ptr[esp+NbStack-4]
24 ; 5 dword on top (ret,ebp,esi,edi,ebx)
25 adrret equ dword ptr[esp+NbStack-8]
26 pushebp equ dword ptr[esp+NbStack-12]
27 pushedi equ dword ptr[esp+NbStack-16]
28 pushesi equ dword ptr[esp+NbStack-20]
29 pushebx equ dword ptr[esp+NbStack-24]
30
31 chain_length equ dword ptr [esp+NbStack-28]
32 limit equ dword ptr [esp+NbStack-32]
33 best_len equ dword ptr [esp+NbStack-36]
34 window equ dword ptr [esp+NbStack-40]
35 prev equ dword ptr [esp+NbStack-44]
36 scan_start equ word ptr [esp+NbStack-48]
37 scan_end equ word ptr [esp+NbStack-52]
38 match_start_ptr equ dword ptr [esp+NbStack-56]
39 nice_match equ dword ptr [esp+NbStack-60]
40 scanrp equ dword ptr [esp+NbStack-64]
41
42 windowlen equ dword ptr [esp+NbStack-68]
43 match_start equ dword ptr [esp+NbStack-72]
44 strend equ dword ptr [esp+NbStack-76]
45 NbStackAdd equ (76-24)
46
47 .386p
48
49 name gvmatch
50 .MODEL FLAT
51
52
53@lmtype TYPEDEF PROTO C :PTR , :SDWORD
54longest_match_c PROTO @lmtype
55
56 dep_max_chain_length equ 70h
57 dep_window equ 2ch
58 dep_strstart equ 60h
59 dep_prev_length equ 6ch
60 dep_nice_match equ 84h
61 dep_w_size equ 20h
62 dep_prev equ 34h
63 dep_w_mask equ 28h
64 dep_good_match equ 80h
65 dep_match_start equ 64h
66 dep_lookahead equ 68h
67
68
69_TEXT segment
70 public _longest_match_asm7fff
71
72 MAX_MATCH equ 258
73 MIN_MATCH equ 3
74 MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1)
75
76; initialize or check the variables used in match.asm.
77
78
79; -----------------------------------------------------------------------
80; Set match_start to the longest match starting at the given string and
81; return its length. Matches shorter or equal to prev_length are discarded,
82; in which case the result is equal to prev_length and match_start is
83; garbage.
84; IN assertions: cur_match is the head of the hash chain for the current
85; string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
86
87; int longest_match(cur_match)
88
89_longest_match_asm7fff proc near
90
91
92
93 ; return address
94
95 mov eax,[esp+4]
96 mov bx,[eax+dep_w_mask]
97 cmp bx,7fffh
98 jnz longest_match_c
99
100 push ebp
101 push edi
102 push esi
103 push ebx
104
105 sub esp,NbStackAdd
106
107 ;//mov ebp,str_s
108 mov ebp,eax
109
110 mov eax,[ebp+dep_max_chain_length]
111 mov ebx,[ebp+dep_prev_length]
112 cmp [ebp+dep_good_match],ebx ; if prev_length>=good_match chain_length >>= 2
113 ja noshr
114 shr eax,2
115noshr:
116 mov edi,[ebp+dep_nice_match]
117 mov chain_length,eax
118 mov edx,[ebp+dep_lookahead]
119 cmp edx,edi
120;if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
121 jae nolookaheadnicematch
122 mov edi,edx
123nolookaheadnicematch:
124 mov best_len,ebx
125
126
127 mov esi,[ebp+dep_window]
128 mov ecx,[ebp+dep_strstart]
129 mov window,esi
130
131 mov nice_match,edi
132 add esi,ecx
133 mov scanrp,esi
134 mov ax,word ptr [esi]
135 mov bx,word ptr [esi+ebx-1]
136 add esi,MAX_MATCH-1
137 mov scan_start,ax
138 mov strend,esi
139 mov scan_end,bx
140
141; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
142; s->strstart - (IPos)MAX_DIST(s) : NIL;
143
144 mov esi,[ebp+dep_w_size]
145 sub esi,MIN_LOOKAHEAD
146 ; here esi = MAX_DIST(s)
147 sub ecx,esi
148 ja nodist
149 xor ecx,ecx
150nodist:
151 mov limit,ecx
152
153
154
155
156 mov eax,[ebp+dep_prev]
157 mov prev,eax
158
159 mov ebx,dword ptr [ebp+dep_match_start]
160 mov bp,scan_start
161 mov edx,cur_match
162 mov match_start,ebx
163
164 mov bx,scan_end
165 mov eax,window
166 mov edi,eax
167 add edi,best_len
168 mov esi,prev
169 dec edi
170 mov windowlen,edi
171
172 jmp beginloop2
173 align 4
174
175; here, in the loop
176;;;; eax = chain_length
177; edx = dx = cur_match
178; ecx = limit
179; bx = scan_end
180; bp = scan_start
181; edi = windowlen (window + best_len)
182; esi = prev
183
184
185;// here; eax <=16
186normalbeg0add16:
187 add chain_length,16
188 jz exitloop
189normalbeg0:
190 cmp word ptr[edi+edx-0],bx
191 je normalbeg2
192 and edx,7fffh
193 mov dx,word ptr[esi+edx*2]
194 cmp ecx,edx
195 jnb exitloop
196 dec chain_length
197 jnz normalbeg0
198;jnbexitloopshort1:
199 jmp exitloop
200
201contloop3:
202 mov edi,windowlen
203
204; cur_match = prev[cur_match & wmask]
205 and edx,7fffh
206 mov dx,word ptr[esi+edx*2]
207; if cur_match > limit, go to exitloop
208 cmp ecx,edx
209jnbexitloopshort1:
210 jnb exitloop
211; if --chain_length != 0, go to exitloop
212
213beginloop2:
214 sub chain_length,16+1
215 jna normalbeg0add16
216
217do16:
218 cmp word ptr[edi+edx],bx
219 je normalbeg2dc0
220
221maccn MACRO lab
222 and edx,7fffh
223 mov dx,word ptr[esi+edx*2]
224 cmp ecx,edx
225 jnb exitloop
226 cmp word ptr[edi+edx-0],bx
227 je lab
228 ENDM
229
230rcontloop0:
231 maccn normalbeg2dc1
232
233rcontloop1:
234 maccn normalbeg2dc2
235
236rcontloop2:
237 maccn normalbeg2dc3
238
239rcontloop3:
240 maccn normalbeg2dc4
241
242rcontloop4:
243 maccn normalbeg2dc5
244
245rcontloop5:
246 maccn normalbeg2dc6
247
248rcontloop6:
249 maccn normalbeg2dc7
250
251rcontloop7:
252 maccn normalbeg2dc8
253
254rcontloop8:
255 maccn normalbeg2dc9
256
257rcontloop9:
258 maccn normalbeg2dc10
259
260rcontloop10:
261 maccn normalbeg2dc11
262
263rcontloop11:
264 maccn short normalbeg2dc12
265
266rcontloop12:
267 maccn short normalbeg2dc13
268
269rcontloop13:
270 maccn short normalbeg2dc14
271
272rcontloop14:
273 maccn short normalbeg2dc15
274
275rcontloop15:
276 and edx,7fffh
277 mov dx,word ptr[esi+edx*2]
278 cmp ecx,edx
279 jnb short exitloopshort
280
281 sub chain_length,16
282 ja do16
283 jmp normalbeg0add16
284
285;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
286
287exitloopshort:
288 jmp exitloop
289
290normbeg MACRO rcontlab,valsub
291 cmp bp,word ptr[eax+edx]
292 jne rcontlab
293 add chain_length,16-valsub
294 jmp iseq
295 ENDM
296
297normalbeg2dc12:
298 normbeg rcontloop12,12
299
300normalbeg2dc13:
301 normbeg rcontloop13,13
302
303normalbeg2dc14:
304 normbeg rcontloop14,14
305
306normalbeg2dc15:
307 normbeg rcontloop15,15
308
309normalbeg2dc11:
310 normbeg rcontloop11,11
311
312normalbeg2dc10:
313 normbeg rcontloop10,10
314
315
316normalbeg2dc9:
317 normbeg rcontloop9,9
318
319normalbeg2dc8:
320 normbeg rcontloop8,8
321
322normalbeg2dc7:
323 normbeg rcontloop7,7
324
325normalbeg2dc5:
326 normbeg rcontloop5,5
327
328
329
330
331
332normalbeg2dc6:
333 normbeg rcontloop6,6
334
335normalbeg2dc4:
336 normbeg rcontloop4,4
337
338normalbeg2dc3:
339 normbeg rcontloop3,3
340
341normalbeg2dc2:
342 normbeg rcontloop2,2
343
344normalbeg2dc1:
345 normbeg rcontloop1,1
346
347normalbeg2dc0:
348 normbeg rcontloop0,0
349
350
351; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end
352
353normalbeg2:
354
355 ; 10 nop here take 10% time
356 mov edi,window
357 ;mov chain_length,eax ; now, we need eax...
358
359 cmp bp,word ptr[edi+edx]
360 jne contloop3 ; if *(ushf*)match != scan_start, continue
361
362iseq:
363
364 mov edi,eax
365 mov esi,scanrp ; esi = scan
366 add edi,edx ; edi = window + cur_match = match
367
368
369 mov eax,[esi+3] ; compare manually dword at match+3
370 xor eax,[edi+3] ; and scan +3
371
372 jz begincompare ; if equal, go to long compare
373
374 ; we will determine the unmatch byte and calculate len (in esi)
375 or al,al
376 je eq1rr
377 mov esi,3
378 jmp trfinval
379eq1rr:
380 or ax,ax
381 je eq1
382
383 mov esi,4
384 jmp trfinval
385eq1:
386 shl eax,8
387 jz eq11
388 mov esi,5
389 jmp trfinval
390eq11:
391 mov esi,6
392 jmp trfinval
393
394begincompare:
395 ; here we now scan and match begin same
396 add edi,6
397 add esi,6
398 mov ecx,(MAX_MATCH-(2+4))/4 ;//; scan for at most MAX_MATCH bytes
399 repe cmpsd ;//; loop until mismatch
400
401 je trfin ; go to trfin if not unmatch
402 ; we determine the unmatch byte
403 sub esi,4
404 mov eax,[edi-4]
405 xor eax,[esi]
406 or al,al
407
408 jnz trfin
409 inc esi
410
411 or ax,ax
412 jnz trfin
413 inc esi
414
415 shl eax,8
416 jnz trfin
417 inc esi
418
419trfin:
420 sub esi,scanrp ; esi = len
421trfinval:
422 cmp esi,best_len ; if len <= best_len, go contloop2
423 jbe contloop2
424
425 mov best_len,esi ; len become best_len
426
427 mov match_start,edx
428 cmp esi,nice_match ;//; if esi >= nice_match, exit
429 mov ecx,scanrp
430 jae exitloop
431 add esi,window
432 add ecx,best_len
433 dec esi
434 mov windowlen,esi
435 mov bx,[ecx-1]
436
437
438; now we restore eax, ecx and esi, for the big loop :
439contloop2:
440 mov esi,prev
441 mov ecx,limit
442 ;mov eax,chain_length
443 mov eax,window
444 jmp contloop3
445
446exitloop:
447 mov ebx,match_start
448 mov ebp,str_s
449 mov dword ptr [ebp+dep_match_start],ebx
450 mov eax,best_len
451 add esp,NbStackAdd
452
453
454 pop ebx
455 pop esi
456 pop edi
457 pop ebp
458 ret
459
460_longest_match_asm7fff endp
461
462_TEXT ends
463end
464 \ No newline at end of file
diff --git a/contrib/asm386/gvmat32c.c b/contrib/asm386/gvmat32c.c
new file mode 100644
index 0000000..43d530b
--- /dev/null
+++ b/contrib/asm386/gvmat32c.c
@@ -0,0 +1,229 @@
1/* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86
2 * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant.
3 * File written by Gilles Vollant, by modifiying the longest_match
4 * from Jean-loup Gailly in deflate.c
5 * it prepare all parameters and call the assembly longest_match_gvasm
6 * longest_match execute standard C code is wmask != 0x7fff
7 * (assembly code is faster with a fixed wmask)
8 *
9 */
10//#pragma optimize("agt",on)
11
12#include "deflate.h"
13
14#undef FAR
15#include <windows.h>
16
17#ifdef ASMV
18
19#define NIL 0
20
21static unsigned int tot=0;
22static unsigned int totl0=0;
23static unsigned int totl0p0=0;
24static unsigned int ba0=0;
25static unsigned int ba1=0;
26static unsigned int cpta=0;
27static unsigned int cptb=0;
28
29#define UNALIGNED_OK
30#define gvshow(a,b,c,d)
31/*
32void gvshow(int chain_length,int len,int limit,ushf* prev)
33{
34static int ival=0;
35char sz[80];
36unsigned long i;
37int prev0=*prev;
38 ival++;
39 //wsprintf(sz,"call %u, len=%u, chain_length=%u\n",ival,len,chain_length);
40 //OutputDebugString(sz);
41 tot++;
42 if (limit==NIL)
43 totl0++;
44 if ((limit==NIL) && (prev0==0))
45 totl0p0++;
46 for (i=limit+1;i<32768;i++)
47 {
48 ush va=*(prev+i);
49 if (ba0>4000000000)
50 {
51 ba0+=10;
52 }
53 ba0++;
54 if ((va>limit) || (va==0))
55 continue;
56 ba1++;
57 }
58}
59*/
60
61
62/* if your C compiler don't add underline before function name,
63 define ADD_UNDERLINE_ASMFUNC */
64#ifdef ADD_UNDERLINE_ASMFUNC
65#define longest_match_asm7fff _longest_match_asm7fff
66#endif
67void match_init()
68{
69}
70
71uInt longest_match_c(
72 deflate_state *s,
73 IPos cur_match); /* current match */
74
75
76uInt longest_match_asm7fff(
77 deflate_state *s,
78 IPos cur_match); /* current match */
79
80uInt longest_match(
81 deflate_state *s,
82 IPos cur_match) /* current match */
83{
84 if (s->w_mask == 0x7fff)
85 return longest_match_asm7fff(s,cur_match);
86 return longest_match_c(s,cur_match);
87}
88
89
90
91uInt longest_match_c(s, cur_match)
92 deflate_state *s;
93 IPos cur_match; /* current match */
94{
95 unsigned chain_length = s->max_chain_length;/* max hash chain length */
96 register Bytef *scan = s->window + s->strstart; /* current string */
97 register Bytef *match; /* matched string */
98 register int len; /* length of current match */
99 int best_len = s->prev_length; /* best match length so far */
100 int nice_match = s->nice_match; /* stop if match long enough */
101 IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
102 s->strstart - (IPos)MAX_DIST(s) : NIL;
103 /* Stop when cur_match becomes <= limit. To simplify the code,
104 * we prevent matches with the string of window index 0.
105 */
106 Posf *prev = s->prev;
107 uInt wmask = s->w_mask;
108
109#ifdef UNALIGNED_OK
110 /* Compare two bytes at a time. Note: this is not always beneficial.
111 * Try with and without -DUNALIGNED_OK to check.
112 */
113 register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
114 register ush scan_start = *(ushf*)scan;
115 register ush scan_end = *(ushf*)(scan+best_len-1);
116#else
117 register Bytef *strend = s->window + s->strstart + MAX_MATCH;
118 register Byte scan_end1 = scan[best_len-1];
119 register Byte scan_end = scan[best_len];
120#endif
121
122 /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
123 * It is easy to get rid of this optimization if necessary.
124 */
125 Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
126
127 /* Do not waste too much time if we already have a good match: */
128 if (s->prev_length >= s->good_match) {
129 chain_length >>= 2;
130 }
131 /* Do not look for matches beyond the end of the input. This is necessary
132 * to make deflate deterministic.
133 */
134 if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
135
136 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
137
138 do {
139 Assert(cur_match < s->strstart, "no future");
140 match = s->window + cur_match;
141
142 /* Skip to next match if the match length cannot increase
143 * or if the match length is less than 2:
144 */
145#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
146 /* This code assumes sizeof(unsigned short) == 2. Do not use
147 * UNALIGNED_OK if your compiler uses a different size.
148 */
149 if (*(ushf*)(match+best_len-1) != scan_end ||
150 *(ushf*)match != scan_start) continue;
151
152 /* It is not necessary to compare scan[2] and match[2] since they are
153 * always equal when the other bytes match, given that the hash keys
154 * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
155 * strstart+3, +5, ... up to strstart+257. We check for insufficient
156 * lookahead only every 4th comparison; the 128th check will be made
157 * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
158 * necessary to put more guard bytes at the end of the window, or
159 * to check more often for insufficient lookahead.
160 */
161 Assert(scan[2] == match[2], "scan[2]?");
162 scan++, match++;
163 do {
164 } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
165 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
166 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
167 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
168 scan < strend);
169 /* The funny "do {}" generates better code on most compilers */
170
171 /* Here, scan <= window+strstart+257 */
172 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
173 if (*scan == *match) scan++;
174
175 len = (MAX_MATCH - 1) - (int)(strend-scan);
176 scan = strend - (MAX_MATCH-1);
177
178#else /* UNALIGNED_OK */
179
180 if (match[best_len] != scan_end ||
181 match[best_len-1] != scan_end1 ||
182 *match != *scan ||
183 *++match != scan[1]) continue;
184
185 /* The check at best_len-1 can be removed because it will be made
186 * again later. (This heuristic is not always a win.)
187 * It is not necessary to compare scan[2] and match[2] since they
188 * are always equal when the other bytes match, given that
189 * the hash keys are equal and that HASH_BITS >= 8.
190 */
191 scan += 2, match++;
192 Assert(*scan == *match, "match[2]?");
193
194 /* We check for insufficient lookahead only every 8th comparison;
195 * the 256th check will be made at strstart+258.
196 */
197 do {
198 } while (*++scan == *++match && *++scan == *++match &&
199 *++scan == *++match && *++scan == *++match &&
200 *++scan == *++match && *++scan == *++match &&
201 *++scan == *++match && *++scan == *++match &&
202 scan < strend);
203
204 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
205
206 len = MAX_MATCH - (int)(strend - scan);
207 scan = strend - MAX_MATCH;
208
209#endif /* UNALIGNED_OK */
210
211 if (len > best_len) {
212 s->match_start = cur_match;
213 best_len = len;
214 if (len >= nice_match) break;
215#ifdef UNALIGNED_OK
216 scan_end = *(ushf*)(scan+best_len-1);
217#else
218 scan_end1 = scan[best_len-1];
219 scan_end = scan[best_len];
220#endif
221 }
222 } while ((cur_match = prev[cur_match & wmask]) > limit
223 && --chain_length != 0);
224
225 if ((uInt)best_len <= s->lookahead) return best_len;
226 return s->lookahead;
227}
228
229#endif /* ASMV */
diff --git a/contrib/asm386/mkgvmt32.bat b/contrib/asm386/mkgvmt32.bat
new file mode 100644
index 0000000..6c5ffd7
--- /dev/null
+++ b/contrib/asm386/mkgvmt32.bat
@@ -0,0 +1 @@
c:\masm611\bin\ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm
diff --git a/contrib/asm386/zlibvc.mak b/contrib/asm386/zlibvc.mak
new file mode 100644
index 0000000..ae3d14b
--- /dev/null
+++ b/contrib/asm386/zlibvc.mak
@@ -0,0 +1,781 @@
1# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
2# ** DO NOT EDIT **
3
4# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
5
6!IF "$(CFG)" == ""
7CFG=zlibvc - Win32 Debug
8!MESSAGE No configuration specified. Defaulting to zlibvc - Win32 Debug.
9!ENDIF
10
11!IF "$(CFG)" != "zlibvc - Win32 Release" && "$(CFG)" != "zlibvc - Win32 Debug"
12!MESSAGE Invalid configuration "$(CFG)" specified.
13!MESSAGE You can specify a configuration when running NMAKE on this makefile
14!MESSAGE by defining the macro CFG on the command line. For example:
15!MESSAGE
16!MESSAGE NMAKE /f "zlibvc.mak" CFG="zlibvc - Win32 Debug"
17!MESSAGE
18!MESSAGE Possible choices for configuration are:
19!MESSAGE
20!MESSAGE "zlibvc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21!MESSAGE "zlibvc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22!MESSAGE
23!ERROR An invalid configuration is specified.
24!ENDIF
25
26!IF "$(OS)" == "Windows_NT"
27NULL=
28!ELSE
29NULL=nul
30!ENDIF
31################################################################################
32# Begin Project
33# PROP Target_Last_Scanned "zlibvc - Win32 Debug"
34CPP=cl.exe
35RSC=rc.exe
36MTL=mktyplib.exe
37
38!IF "$(CFG)" == "zlibvc - Win32 Release"
39
40# PROP BASE Use_MFC 0
41# PROP BASE Use_Debug_Libraries 0
42# PROP BASE Output_Dir "Release"
43# PROP BASE Intermediate_Dir "Release"
44# PROP BASE Target_Dir ""
45# PROP Use_MFC 0
46# PROP Use_Debug_Libraries 0
47# PROP Output_Dir "Release"
48# PROP Intermediate_Dir "Release"
49# PROP Target_Dir ""
50OUTDIR=.\Release
51INTDIR=.\Release
52
53ALL : "$(OUTDIR)\zlib.dll" "$(OUTDIR)\zlibvc.bsc"
54
55CLEAN :
56 -@erase "$(INTDIR)\adler32.obj"
57 -@erase "$(INTDIR)\adler32.sbr"
58 -@erase "$(INTDIR)\compress.obj"
59 -@erase "$(INTDIR)\compress.sbr"
60 -@erase "$(INTDIR)\crc32.obj"
61 -@erase "$(INTDIR)\crc32.sbr"
62 -@erase "$(INTDIR)\deflate.obj"
63 -@erase "$(INTDIR)\deflate.sbr"
64 -@erase "$(INTDIR)\gvmat32c.obj"
65 -@erase "$(INTDIR)\gvmat32c.sbr"
66 -@erase "$(INTDIR)\gzio.obj"
67 -@erase "$(INTDIR)\gzio.sbr"
68 -@erase "$(INTDIR)\infblock.obj"
69 -@erase "$(INTDIR)\infblock.sbr"
70 -@erase "$(INTDIR)\infcodes.obj"
71 -@erase "$(INTDIR)\infcodes.sbr"
72 -@erase "$(INTDIR)\inffast.obj"
73 -@erase "$(INTDIR)\inffast.sbr"
74 -@erase "$(INTDIR)\inflate.obj"
75 -@erase "$(INTDIR)\inflate.sbr"
76 -@erase "$(INTDIR)\inftrees.obj"
77 -@erase "$(INTDIR)\inftrees.sbr"
78 -@erase "$(INTDIR)\infutil.obj"
79 -@erase "$(INTDIR)\infutil.sbr"
80 -@erase "$(INTDIR)\trees.obj"
81 -@erase "$(INTDIR)\trees.sbr"
82 -@erase "$(INTDIR)\uncompr.obj"
83 -@erase "$(INTDIR)\uncompr.sbr"
84 -@erase "$(INTDIR)\zlib.res"
85 -@erase "$(INTDIR)\zutil.obj"
86 -@erase "$(INTDIR)\zutil.sbr"
87 -@erase "$(OUTDIR)\zlib.dll"
88 -@erase "$(OUTDIR)\zlib.exp"
89 -@erase "$(OUTDIR)\zlib.lib"
90 -@erase "$(OUTDIR)\zlib.map"
91 -@erase "$(OUTDIR)\zlibvc.bsc"
92
93"$(OUTDIR)" :
94 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
95
96# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
97# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D fdopen=_fdopen /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "ASMV" /FR /YX /c
98CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "NDEBUG" /D fdopen=_fdopen /D "WIN32" /D\
99 "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "ASMV"\
100 /FR"$(INTDIR)/" /Fp"$(INTDIR)/zlibvc.pch" /YX /Fo"$(INTDIR)/" /c
101CPP_OBJS=.\Release/
102CPP_SBRS=.\Release/
103# ADD BASE MTL /nologo /D "NDEBUG" /win32
104# ADD MTL /nologo /D "NDEBUG" /win32
105MTL_PROJ=/nologo /D "NDEBUG" /win32
106# ADD BASE RSC /l 0x40c /d "NDEBUG"
107# ADD RSC /l 0x40c /d "NDEBUG"
108RSC_PROJ=/l 0x40c /fo"$(INTDIR)/zlib.res" /d "NDEBUG"
109BSC32=bscmake.exe
110# ADD BASE BSC32 /nologo
111# ADD BSC32 /nologo
112BSC32_FLAGS=/nologo /o"$(OUTDIR)/zlibvc.bsc"
113BSC32_SBRS= \
114 "$(INTDIR)\adler32.sbr" \
115 "$(INTDIR)\compress.sbr" \
116 "$(INTDIR)\crc32.sbr" \
117 "$(INTDIR)\deflate.sbr" \
118 "$(INTDIR)\gvmat32c.sbr" \
119 "$(INTDIR)\gzio.sbr" \
120 "$(INTDIR)\infblock.sbr" \
121 "$(INTDIR)\infcodes.sbr" \
122 "$(INTDIR)\inffast.sbr" \
123 "$(INTDIR)\inflate.sbr" \
124 "$(INTDIR)\inftrees.sbr" \
125 "$(INTDIR)\infutil.sbr" \
126 "$(INTDIR)\trees.sbr" \
127 "$(INTDIR)\uncompr.sbr" \
128 "$(INTDIR)\zutil.sbr"
129
130"$(OUTDIR)\zlibvc.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
131 $(BSC32) @<<
132 $(BSC32_FLAGS) $(BSC32_SBRS)
133<<
134
135LINK32=link.exe
136# 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
137# 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:"Release/zlib.dll"
138LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
139 advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo\
140 /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)/zlib.pdb"\
141 /map:"$(INTDIR)/zlib.map" /machine:I386 /nodefaultlib /def:".\zlib.def"\
142 /out:"$(OUTDIR)/zlib.dll" /implib:"$(OUTDIR)/zlib.lib"
143DEF_FILE= \
144 ".\zlib.def"
145LINK32_OBJS= \
146 "$(INTDIR)\adler32.obj" \
147 "$(INTDIR)\compress.obj" \
148 "$(INTDIR)\crc32.obj" \
149 "$(INTDIR)\deflate.obj" \
150 "$(INTDIR)\gvmat32c.obj" \
151 "$(INTDIR)\gzio.obj" \
152 "$(INTDIR)\infblock.obj" \
153 "$(INTDIR)\infcodes.obj" \
154 "$(INTDIR)\inffast.obj" \
155 "$(INTDIR)\inflate.obj" \
156 "$(INTDIR)\inftrees.obj" \
157 "$(INTDIR)\infutil.obj" \
158 "$(INTDIR)\trees.obj" \
159 "$(INTDIR)\uncompr.obj" \
160 "$(INTDIR)\zlib.res" \
161 "$(INTDIR)\zutil.obj" \
162 ".\GVMAT32.obj"
163
164"$(OUTDIR)\zlib.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
165 $(LINK32) @<<
166 $(LINK32_FLAGS) $(LINK32_OBJS)
167<<
168
169!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
170
171# PROP BASE Use_MFC 0
172# PROP BASE Use_Debug_Libraries 1
173# PROP BASE Output_Dir "Debug"
174# PROP BASE Intermediate_Dir "Debug"
175# PROP BASE Target_Dir ""
176# PROP Use_MFC 0
177# PROP Use_Debug_Libraries 1
178# PROP Output_Dir "Debug"
179# PROP Intermediate_Dir "Debug"
180# PROP Target_Dir ""
181OUTDIR=.\Debug
182INTDIR=.\Debug
183
184ALL : "$(OUTDIR)\zlib.dll"
185
186CLEAN :
187 -@erase "$(INTDIR)\adler32.obj"
188 -@erase "$(INTDIR)\compress.obj"
189 -@erase "$(INTDIR)\crc32.obj"
190 -@erase "$(INTDIR)\deflate.obj"
191 -@erase "$(INTDIR)\gvmat32c.obj"
192 -@erase "$(INTDIR)\gzio.obj"
193 -@erase "$(INTDIR)\infblock.obj"
194 -@erase "$(INTDIR)\infcodes.obj"
195 -@erase "$(INTDIR)\inffast.obj"
196 -@erase "$(INTDIR)\inflate.obj"
197 -@erase "$(INTDIR)\inftrees.obj"
198 -@erase "$(INTDIR)\infutil.obj"
199 -@erase "$(INTDIR)\trees.obj"
200 -@erase "$(INTDIR)\uncompr.obj"
201 -@erase "$(INTDIR)\vc40.idb"
202 -@erase "$(INTDIR)\vc40.pdb"
203 -@erase "$(INTDIR)\zlib.res"
204 -@erase "$(INTDIR)\zutil.obj"
205 -@erase "$(OUTDIR)\zlib.dll"
206 -@erase "$(OUTDIR)\zlib.exp"
207 -@erase "$(OUTDIR)\zlib.ilk"
208 -@erase "$(OUTDIR)\zlib.lib"
209 -@erase "$(OUTDIR)\zlib.pdb"
210
211"$(OUTDIR)" :
212 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
213
214# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
215# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /YX /c
216CPP_PROJ=/nologo /MTd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\
217 /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL"\
218 /Fp"$(INTDIR)/zlibvc.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
219CPP_OBJS=.\Debug/
220CPP_SBRS=.\.
221# ADD BASE MTL /nologo /D "_DEBUG" /win32
222# ADD MTL /nologo /D "_DEBUG" /win32
223MTL_PROJ=/nologo /D "_DEBUG" /win32
224# ADD BASE RSC /l 0x40c /d "_DEBUG"
225# ADD RSC /l 0x40c /d "_DEBUG"
226RSC_PROJ=/l 0x40c /fo"$(INTDIR)/zlib.res" /d "_DEBUG"
227BSC32=bscmake.exe
228# ADD BASE BSC32 /nologo
229# ADD BSC32 /nologo
230BSC32_FLAGS=/nologo /o"$(OUTDIR)/zlibvc.bsc"
231BSC32_SBRS= \
232
233LINK32=link.exe
234# 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
235# 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"
236LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
237 advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo\
238 /subsystem:windows /dll /incremental:yes /pdb:"$(OUTDIR)/zlib.pdb" /debug\
239 /machine:I386 /def:".\zlib.def" /out:"$(OUTDIR)/zlib.dll"\
240 /implib:"$(OUTDIR)/zlib.lib"
241DEF_FILE= \
242 ".\zlib.def"
243LINK32_OBJS= \
244 "$(INTDIR)\adler32.obj" \
245 "$(INTDIR)\compress.obj" \
246 "$(INTDIR)\crc32.obj" \
247 "$(INTDIR)\deflate.obj" \
248 "$(INTDIR)\gvmat32c.obj" \
249 "$(INTDIR)\gzio.obj" \
250 "$(INTDIR)\infblock.obj" \
251 "$(INTDIR)\infcodes.obj" \
252 "$(INTDIR)\inffast.obj" \
253 "$(INTDIR)\inflate.obj" \
254 "$(INTDIR)\inftrees.obj" \
255 "$(INTDIR)\infutil.obj" \
256 "$(INTDIR)\trees.obj" \
257 "$(INTDIR)\uncompr.obj" \
258 "$(INTDIR)\zlib.res" \
259 "$(INTDIR)\zutil.obj" \
260 ".\GVMAT32.obj"
261
262"$(OUTDIR)\zlib.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
263 $(LINK32) @<<
264 $(LINK32_FLAGS) $(LINK32_OBJS)
265<<
266
267!ENDIF
268
269.c{$(CPP_OBJS)}.obj:
270 $(CPP) $(CPP_PROJ) $<
271
272.cpp{$(CPP_OBJS)}.obj:
273 $(CPP) $(CPP_PROJ) $<
274
275.cxx{$(CPP_OBJS)}.obj:
276 $(CPP) $(CPP_PROJ) $<
277
278.c{$(CPP_SBRS)}.sbr:
279 $(CPP) $(CPP_PROJ) $<
280
281.cpp{$(CPP_SBRS)}.sbr:
282 $(CPP) $(CPP_PROJ) $<
283
284.cxx{$(CPP_SBRS)}.sbr:
285 $(CPP) $(CPP_PROJ) $<
286
287################################################################################
288# Begin Target
289
290# Name "zlibvc - Win32 Release"
291# Name "zlibvc - Win32 Debug"
292
293!IF "$(CFG)" == "zlibvc - Win32 Release"
294
295!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
296
297!ENDIF
298
299################################################################################
300# Begin Source File
301
302SOURCE=.\adler32.c
303DEP_CPP_ADLER=\
304 ".\zconf.h"\
305 ".\zlib.h"\
306
307
308!IF "$(CFG)" == "zlibvc - Win32 Release"
309
310
311"$(INTDIR)\adler32.obj" : $(SOURCE) $(DEP_CPP_ADLER) "$(INTDIR)"
312
313"$(INTDIR)\adler32.sbr" : $(SOURCE) $(DEP_CPP_ADLER) "$(INTDIR)"
314
315
316!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
317
318
319"$(INTDIR)\adler32.obj" : $(SOURCE) $(DEP_CPP_ADLER) "$(INTDIR)"
320
321
322!ENDIF
323
324# End Source File
325################################################################################
326# Begin Source File
327
328SOURCE=.\compress.c
329DEP_CPP_COMPR=\
330 ".\zconf.h"\
331 ".\zlib.h"\
332
333
334!IF "$(CFG)" == "zlibvc - Win32 Release"
335
336
337"$(INTDIR)\compress.obj" : $(SOURCE) $(DEP_CPP_COMPR) "$(INTDIR)"
338
339"$(INTDIR)\compress.sbr" : $(SOURCE) $(DEP_CPP_COMPR) "$(INTDIR)"
340
341
342!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
343
344
345"$(INTDIR)\compress.obj" : $(SOURCE) $(DEP_CPP_COMPR) "$(INTDIR)"
346
347
348!ENDIF
349
350# End Source File
351################################################################################
352# Begin Source File
353
354SOURCE=.\crc32.c
355DEP_CPP_CRC32=\
356 ".\zconf.h"\
357 ".\zlib.h"\
358
359
360!IF "$(CFG)" == "zlibvc - Win32 Release"
361
362
363"$(INTDIR)\crc32.obj" : $(SOURCE) $(DEP_CPP_CRC32) "$(INTDIR)"
364
365"$(INTDIR)\crc32.sbr" : $(SOURCE) $(DEP_CPP_CRC32) "$(INTDIR)"
366
367
368!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
369
370
371"$(INTDIR)\crc32.obj" : $(SOURCE) $(DEP_CPP_CRC32) "$(INTDIR)"
372
373
374!ENDIF
375
376# End Source File
377################################################################################
378# Begin Source File
379
380SOURCE=.\deflate.c
381
382!IF "$(CFG)" == "zlibvc - Win32 Release"
383
384DEP_CPP_DEFLA=\
385 ".\deflate.h"\
386 ".\zconf.h"\
387 ".\zlib.h"\
388 ".\zutil.h"\
389
390
391"$(INTDIR)\deflate.obj" : $(SOURCE) $(DEP_CPP_DEFLA) "$(INTDIR)"
392
393"$(INTDIR)\deflate.sbr" : $(SOURCE) $(DEP_CPP_DEFLA) "$(INTDIR)"
394
395
396!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
397
398DEP_CPP_DEFLA=\
399 ".\deflate.h"\
400 ".\zconf.h"\
401 ".\zlib.h"\
402 ".\zutil.h"\
403
404NODEP_CPP_DEFLA=\
405 ".\local"\
406
407
408"$(INTDIR)\deflate.obj" : $(SOURCE) $(DEP_CPP_DEFLA) "$(INTDIR)"
409
410
411!ENDIF
412
413# End Source File
414################################################################################
415# Begin Source File
416
417SOURCE=.\gzio.c
418DEP_CPP_GZIO_=\
419 ".\zconf.h"\
420 ".\zlib.h"\
421 ".\zutil.h"\
422
423
424!IF "$(CFG)" == "zlibvc - Win32 Release"
425
426
427"$(INTDIR)\gzio.obj" : $(SOURCE) $(DEP_CPP_GZIO_) "$(INTDIR)"
428
429"$(INTDIR)\gzio.sbr" : $(SOURCE) $(DEP_CPP_GZIO_) "$(INTDIR)"
430
431
432!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
433
434
435"$(INTDIR)\gzio.obj" : $(SOURCE) $(DEP_CPP_GZIO_) "$(INTDIR)"
436
437
438!ENDIF
439
440# End Source File
441################################################################################
442# Begin Source File
443
444SOURCE=.\infblock.c
445DEP_CPP_INFBL=\
446 ".\infblock.h"\
447 ".\infcodes.h"\
448 ".\inftrees.h"\
449 ".\infutil.h"\
450 ".\zconf.h"\
451 ".\zlib.h"\
452 ".\zutil.h"\
453
454
455!IF "$(CFG)" == "zlibvc - Win32 Release"
456
457
458"$(INTDIR)\infblock.obj" : $(SOURCE) $(DEP_CPP_INFBL) "$(INTDIR)"
459
460"$(INTDIR)\infblock.sbr" : $(SOURCE) $(DEP_CPP_INFBL) "$(INTDIR)"
461
462
463!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
464
465
466"$(INTDIR)\infblock.obj" : $(SOURCE) $(DEP_CPP_INFBL) "$(INTDIR)"
467
468
469!ENDIF
470
471# End Source File
472################################################################################
473# Begin Source File
474
475SOURCE=.\infcodes.c
476DEP_CPP_INFCO=\
477 ".\infblock.h"\
478 ".\infcodes.h"\
479 ".\inffast.h"\
480 ".\inftrees.h"\
481 ".\infutil.h"\
482 ".\zconf.h"\
483 ".\zlib.h"\
484 ".\zutil.h"\
485
486
487!IF "$(CFG)" == "zlibvc - Win32 Release"
488
489
490"$(INTDIR)\infcodes.obj" : $(SOURCE) $(DEP_CPP_INFCO) "$(INTDIR)"
491
492"$(INTDIR)\infcodes.sbr" : $(SOURCE) $(DEP_CPP_INFCO) "$(INTDIR)"
493
494
495!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
496
497
498"$(INTDIR)\infcodes.obj" : $(SOURCE) $(DEP_CPP_INFCO) "$(INTDIR)"
499
500
501!ENDIF
502
503# End Source File
504################################################################################
505# Begin Source File
506
507SOURCE=.\inffast.c
508DEP_CPP_INFFA=\
509 ".\infblock.h"\
510 ".\infcodes.h"\
511 ".\inffast.h"\
512 ".\inftrees.h"\
513 ".\infutil.h"\
514 ".\zconf.h"\
515 ".\zlib.h"\
516 ".\zutil.h"\
517
518
519!IF "$(CFG)" == "zlibvc - Win32 Release"
520
521
522"$(INTDIR)\inffast.obj" : $(SOURCE) $(DEP_CPP_INFFA) "$(INTDIR)"
523
524"$(INTDIR)\inffast.sbr" : $(SOURCE) $(DEP_CPP_INFFA) "$(INTDIR)"
525
526
527!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
528
529
530"$(INTDIR)\inffast.obj" : $(SOURCE) $(DEP_CPP_INFFA) "$(INTDIR)"
531
532
533!ENDIF
534
535# End Source File
536################################################################################
537# Begin Source File
538
539SOURCE=.\inflate.c
540DEP_CPP_INFLA=\
541 ".\infblock.h"\
542 ".\zconf.h"\
543 ".\zlib.h"\
544 ".\zutil.h"\
545
546
547!IF "$(CFG)" == "zlibvc - Win32 Release"
548
549
550"$(INTDIR)\inflate.obj" : $(SOURCE) $(DEP_CPP_INFLA) "$(INTDIR)"
551
552"$(INTDIR)\inflate.sbr" : $(SOURCE) $(DEP_CPP_INFLA) "$(INTDIR)"
553
554
555!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
556
557
558"$(INTDIR)\inflate.obj" : $(SOURCE) $(DEP_CPP_INFLA) "$(INTDIR)"
559
560
561!ENDIF
562
563# End Source File
564################################################################################
565# Begin Source File
566
567SOURCE=.\inftrees.c
568DEP_CPP_INFTR=\
569 ".\inftrees.h"\
570 ".\zconf.h"\
571 ".\zlib.h"\
572 ".\zutil.h"\
573
574
575!IF "$(CFG)" == "zlibvc - Win32 Release"
576
577
578"$(INTDIR)\inftrees.obj" : $(SOURCE) $(DEP_CPP_INFTR) "$(INTDIR)"
579
580"$(INTDIR)\inftrees.sbr" : $(SOURCE) $(DEP_CPP_INFTR) "$(INTDIR)"
581
582
583!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
584
585
586"$(INTDIR)\inftrees.obj" : $(SOURCE) $(DEP_CPP_INFTR) "$(INTDIR)"
587
588
589!ENDIF
590
591# End Source File
592################################################################################
593# Begin Source File
594
595SOURCE=.\infutil.c
596DEP_CPP_INFUT=\
597 ".\infblock.h"\
598 ".\infcodes.h"\
599 ".\inftrees.h"\
600 ".\infutil.h"\
601 ".\zconf.h"\
602 ".\zlib.h"\
603 ".\zutil.h"\
604
605
606!IF "$(CFG)" == "zlibvc - Win32 Release"
607
608
609"$(INTDIR)\infutil.obj" : $(SOURCE) $(DEP_CPP_INFUT) "$(INTDIR)"
610
611"$(INTDIR)\infutil.sbr" : $(SOURCE) $(DEP_CPP_INFUT) "$(INTDIR)"
612
613
614!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
615
616
617"$(INTDIR)\infutil.obj" : $(SOURCE) $(DEP_CPP_INFUT) "$(INTDIR)"
618
619
620!ENDIF
621
622# End Source File
623################################################################################
624# Begin Source File
625
626SOURCE=.\trees.c
627DEP_CPP_TREES=\
628 ".\deflate.h"\
629 ".\zconf.h"\
630 ".\zlib.h"\
631 ".\zutil.h"\
632
633
634!IF "$(CFG)" == "zlibvc - Win32 Release"
635
636
637"$(INTDIR)\trees.obj" : $(SOURCE) $(DEP_CPP_TREES) "$(INTDIR)"
638
639"$(INTDIR)\trees.sbr" : $(SOURCE) $(DEP_CPP_TREES) "$(INTDIR)"
640
641
642!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
643
644
645"$(INTDIR)\trees.obj" : $(SOURCE) $(DEP_CPP_TREES) "$(INTDIR)"
646
647
648!ENDIF
649
650# End Source File
651################################################################################
652# Begin Source File
653
654SOURCE=.\uncompr.c
655
656!IF "$(CFG)" == "zlibvc - Win32 Release"
657
658DEP_CPP_UNCOM=\
659 ".\zconf.h"\
660 ".\zlib.h"\
661
662
663"$(INTDIR)\uncompr.obj" : $(SOURCE) $(DEP_CPP_UNCOM) "$(INTDIR)"
664
665"$(INTDIR)\uncompr.sbr" : $(SOURCE) $(DEP_CPP_UNCOM) "$(INTDIR)"
666
667
668!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
669
670DEP_CPP_UNCOM=\
671 ".\zconf.h"\
672 ".\zlib.h"\
673
674NODEP_CPP_UNCOM=\
675 ".\uncompress"\
676
677
678"$(INTDIR)\uncompr.obj" : $(SOURCE) $(DEP_CPP_UNCOM) "$(INTDIR)"
679
680
681!ENDIF
682
683# End Source File
684################################################################################
685# Begin Source File
686
687SOURCE=.\zutil.c
688DEP_CPP_ZUTIL=\
689 ".\zconf.h"\
690 ".\zlib.h"\
691 ".\zutil.h"\
692
693
694!IF "$(CFG)" == "zlibvc - Win32 Release"
695
696
697"$(INTDIR)\zutil.obj" : $(SOURCE) $(DEP_CPP_ZUTIL) "$(INTDIR)"
698
699"$(INTDIR)\zutil.sbr" : $(SOURCE) $(DEP_CPP_ZUTIL) "$(INTDIR)"
700
701
702!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
703
704
705"$(INTDIR)\zutil.obj" : $(SOURCE) $(DEP_CPP_ZUTIL) "$(INTDIR)"
706
707
708!ENDIF
709
710# End Source File
711################################################################################
712# Begin Source File
713
714SOURCE=.\zlib.rc
715
716"$(INTDIR)\zlib.res" : $(SOURCE) "$(INTDIR)"
717 $(RSC) $(RSC_PROJ) $(SOURCE)
718
719
720# End Source File
721################################################################################
722# Begin Source File
723
724SOURCE=.\zlib.def
725
726!IF "$(CFG)" == "zlibvc - Win32 Release"
727
728!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
729
730!ENDIF
731
732# End Source File
733################################################################################
734# Begin Source File
735
736SOURCE=.\GVMAT32.obj
737
738!IF "$(CFG)" == "zlibvc - Win32 Release"
739
740!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
741
742!ENDIF
743
744# End Source File
745################################################################################
746# Begin Source File
747
748SOURCE=.\gvmat32c.c
749
750!IF "$(CFG)" == "zlibvc - Win32 Release"
751
752DEP_CPP_GVMAT=\
753 ".\deflate.h"\
754 ".\zconf.h"\
755 ".\zlib.h"\
756 ".\zutil.h"\
757
758
759"$(INTDIR)\gvmat32c.obj" : $(SOURCE) $(DEP_CPP_GVMAT) "$(INTDIR)"
760
761"$(INTDIR)\gvmat32c.sbr" : $(SOURCE) $(DEP_CPP_GVMAT) "$(INTDIR)"
762
763
764!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug"
765
766DEP_CPP_GVMAT=\
767 ".\deflate.h"\
768 ".\zconf.h"\
769 ".\zlib.h"\
770 ".\zutil.h"\
771
772
773"$(INTDIR)\gvmat32c.obj" : $(SOURCE) $(DEP_CPP_GVMAT) "$(INTDIR)"
774
775
776!ENDIF
777
778# End Source File
779# End Target
780# End Project
781################################################################################
diff --git a/contrib/iostream/test.cpp b/contrib/iostream/test.cpp
new file mode 100644
index 0000000..7d265b3
--- /dev/null
+++ b/contrib/iostream/test.cpp
@@ -0,0 +1,24 @@
1
2#include "zfstream.h"
3
4int main() {
5
6 // Construct a stream object with this filebuffer. Anything sent
7 // to this stream will go to standard out.
8 gzofstream os( 1, ios::out );
9
10 // This text is getting compressed and sent to stdout.
11 // To prove this, run 'test | zcat'.
12 os << "Hello, Mommy" << endl;
13
14 os << setcompressionlevel( Z_NO_COMPRESSION );
15 os << "hello, hello, hi, ho!" << endl;
16
17 setcompressionlevel( os, Z_DEFAULT_COMPRESSION )
18 << "I'm compressing again" << endl;
19
20 os.close();
21
22 return 0;
23
24}
diff --git a/contrib/iostream/zfstream.cpp b/contrib/iostream/zfstream.cpp
new file mode 100644
index 0000000..a690bbe
--- /dev/null
+++ b/contrib/iostream/zfstream.cpp
@@ -0,0 +1,329 @@
1
2#include <memory.h>
3#include "zfstream.h"
4
5gzfilebuf::gzfilebuf() :
6 file(NULL),
7 mode(0),
8 own_file_descriptor(0)
9{ }
10
11gzfilebuf::~gzfilebuf() {
12
13 sync();
14 if ( own_file_descriptor )
15 close();
16
17}
18
19gzfilebuf *gzfilebuf::open( const char *name,
20 int io_mode ) {
21
22 if ( is_open() )
23 return NULL;
24
25 char char_mode[10];
26 char *p;
27 memset(char_mode,'\0',10);
28 p = char_mode;
29
30 if ( io_mode & ios::in ) {
31 mode = ios::in;
32 *p++ = 'r';
33 } else if ( io_mode & ios::app ) {
34 mode = ios::app;
35 *p++ = 'a';
36 } else {
37 mode = ios::out;
38 *p++ = 'w';
39 }
40
41 if ( io_mode & ios::binary ) {
42 mode |= ios::binary;
43 *p++ = 'b';
44 }
45
46 // Hard code the compression level
47 if ( io_mode & (ios::out|ios::app )) {
48 *p++ = '9';
49 }
50
51 if ( (file = gzopen(name, char_mode)) == NULL )
52 return NULL;
53
54 own_file_descriptor = 1;
55
56 return this;
57
58}
59
60gzfilebuf *gzfilebuf::attach( int file_descriptor,
61 int io_mode ) {
62
63 if ( is_open() )
64 return NULL;
65
66 char char_mode[10];
67 char *p;
68 memset(char_mode,'\0',10);
69 p = char_mode;
70
71 if ( io_mode & ios::in ) {
72 mode = ios::in;
73 *p++ = 'r';
74 } else if ( io_mode & ios::app ) {
75 mode = ios::app;
76 *p++ = 'a';
77 } else {
78 mode = ios::out;
79 *p++ = 'w';
80 }
81
82 if ( io_mode & ios::binary ) {
83 mode |= ios::binary;
84 *p++ = 'b';
85 }
86
87 // Hard code the compression level
88 if ( io_mode & (ios::out|ios::app )) {
89 *p++ = '9';
90 }
91
92 if ( (file = gzdopen(file_descriptor, char_mode)) == NULL )
93 return NULL;
94
95 own_file_descriptor = 0;
96
97 return this;
98
99}
100
101gzfilebuf *gzfilebuf::close() {
102
103 if ( is_open() ) {
104
105 sync();
106 gzclose( file );
107 file = NULL;
108
109 }
110
111 return this;
112
113}
114
115int gzfilebuf::setcompressionlevel( short comp_level ) {
116
117 return gzsetparams(file, comp_level, -2);
118
119}
120
121int gzfilebuf::setcompressionstrategy( short comp_strategy ) {
122
123 return gzsetparams(file, -2, comp_strategy);
124
125}
126
127
128streampos gzfilebuf::seekoff( streamoff off, ios::seek_dir dir, int which ) {
129
130 return streampos(EOF);
131
132}
133
134int gzfilebuf::underflow() {
135
136 // If the file hasn't been opened for reading, error.
137 if ( !is_open() || !(mode & ios::in) )
138 return EOF;
139
140 // if a buffer doesn't exists, allocate one.
141 if ( !base() ) {
142
143 if ( (allocate()) == EOF )
144 return EOF;
145 setp(0,0);
146
147 } else {
148
149 if ( in_avail() )
150 return (unsigned char) *gptr();
151
152 if ( out_waiting() ) {
153 if ( flushbuf() == EOF )
154 return EOF;
155 }
156
157 }
158
159 // Attempt to fill the buffer.
160
161 int result = fillbuf();
162 if ( result == EOF ) {
163 // disable get area
164 setg(0,0,0);
165 return EOF;
166 }
167
168 return (unsigned char) *gptr();
169
170}
171
172int gzfilebuf::overflow( int c ) {
173
174 if ( !is_open() || !(mode & ios::out) )
175 return EOF;
176
177 if ( !base() ) {
178 if ( allocate() == EOF )
179 return EOF;
180 setg(0,0,0);
181 } else {
182 if (in_avail()) {
183 return EOF;
184 }
185 if (out_waiting()) {
186 if (flushbuf() == EOF)
187 return EOF;
188 }
189 }
190
191 int bl = blen();
192 setp( base(), base() + bl);
193
194 if ( c != EOF ) {
195
196 *pptr() = c;
197 pbump(1);
198
199 }
200
201 return 0;
202
203}
204
205int gzfilebuf::sync() {
206
207 if ( !is_open() )
208 return EOF;
209
210 if ( out_waiting() )
211 return flushbuf();
212
213 return 0;
214
215}
216
217int gzfilebuf::flushbuf() {
218
219 int n;
220 char *q;
221
222 q = pbase();
223 n = pptr() - q;
224
225 if ( gzwrite( file, q, n) < n )
226 return EOF;
227
228 setp(0,0);
229
230 return 0;
231
232}
233
234int gzfilebuf::fillbuf() {
235
236 int required;
237 char *p;
238
239 p = base();
240
241 required = blen();
242
243 int t = gzread( file, p, required );
244
245 if ( t <= 0) return EOF;
246
247 setg( base(), base(), base()+t);
248
249 return t;
250
251}
252
253gzfilestream_common::gzfilestream_common() :
254 ios( gzfilestream_common::rdbuf() )
255{ }
256
257gzfilestream_common::~gzfilestream_common()
258{ }
259
260void gzfilestream_common::attach( int fd, int io_mode ) {
261
262 if ( !buffer.attach( fd, io_mode) )
263 clear( ios::failbit | ios::badbit );
264 else
265 clear();
266
267}
268
269void gzfilestream_common::open( const char *name, int io_mode ) {
270
271 if ( !buffer.open( name, io_mode ) )
272 clear( ios::failbit | ios::badbit );
273 else
274 clear();
275
276}
277
278void gzfilestream_common::close() {
279
280 if ( !buffer.close() )
281 clear( ios::failbit | ios::badbit );
282
283}
284
285gzfilebuf *gzfilestream_common::rdbuf() {
286
287 return &buffer;
288
289}
290
291gzifstream::gzifstream() :
292 ios( gzfilestream_common::rdbuf() )
293{
294 clear( ios::badbit );
295}
296
297gzifstream::gzifstream( const char *name, int io_mode ) :
298 ios( gzfilestream_common::rdbuf() )
299{
300 gzfilestream_common::open( name, io_mode );
301}
302
303gzifstream::gzifstream( int fd, int io_mode ) :
304 ios( gzfilestream_common::rdbuf() )
305{
306 gzfilestream_common::attach( fd, io_mode );
307}
308
309gzifstream::~gzifstream() { }
310
311gzofstream::gzofstream() :
312 ios( gzfilestream_common::rdbuf() )
313{
314 clear( ios::badbit );
315}
316
317gzofstream::gzofstream( const char *name, int io_mode ) :
318 ios( gzfilestream_common::rdbuf() )
319{
320 gzfilestream_common::open( name, io_mode );
321}
322
323gzofstream::gzofstream( int fd, int io_mode ) :
324 ios( gzfilestream_common::rdbuf() )
325{
326 gzfilestream_common::attach( fd, io_mode );
327}
328
329gzofstream::~gzofstream() { }
diff --git a/contrib/iostream/zfstream.h b/contrib/iostream/zfstream.h
new file mode 100644
index 0000000..c87fa08
--- /dev/null
+++ b/contrib/iostream/zfstream.h
@@ -0,0 +1,142 @@
1
2#ifndef _zfstream_h
3#define _zfstream_h
4
5#include <fstream.h>
6#include "zlib.h"
7
8class gzfilebuf : public streambuf {
9
10public:
11
12 gzfilebuf( );
13 virtual ~gzfilebuf();
14
15 gzfilebuf *open( const char *name, int io_mode );
16 gzfilebuf *attach( int file_descriptor, int io_mode );
17 gzfilebuf *close();
18
19 int setcompressionlevel( short comp_level );
20 int setcompressionstrategy( short comp_strategy );
21
22 inline int is_open() const { return (file !=NULL); }
23
24 virtual streampos seekoff( streamoff, ios::seek_dir, int );
25
26 virtual int sync();
27
28protected:
29
30 virtual int underflow();
31 virtual int overflow( int = EOF );
32
33private:
34
35 gzFile file;
36 short mode;
37 short own_file_descriptor;
38
39 int flushbuf();
40 int fillbuf();
41
42};
43
44class gzfilestream_common : virtual public ios {
45
46 friend class gzifstream;
47 friend class gzofstream;
48 friend gzofstream &setcompressionlevel( gzofstream &, int );
49 friend gzofstream &setcompressionstrategy( gzofstream &, int );
50
51public:
52 virtual ~gzfilestream_common();
53
54 void attach( int fd, int io_mode );
55 void open( const char *name, int io_mode );
56 void close();
57
58protected:
59 gzfilestream_common();
60
61private:
62 gzfilebuf *rdbuf();
63
64 gzfilebuf buffer;
65
66};
67
68class gzifstream : public gzfilestream_common, public istream {
69
70public:
71
72 gzifstream();
73 gzifstream( const char *name, int io_mode = ios::in );
74 gzifstream( int fd, int io_mode = ios::in );
75
76 virtual ~gzifstream();
77
78};
79
80class gzofstream : public gzfilestream_common, public ostream {
81
82public:
83
84 gzofstream();
85 gzofstream( const char *name, int io_mode = ios::out );
86 gzofstream( int fd, int io_mode = ios::out );
87
88 virtual ~gzofstream();
89
90};
91
92template<class T> class gzomanip {
93 friend gzofstream &operator<<(gzofstream &, const gzomanip<T> &);
94public:
95 gzomanip(gzofstream &(*f)(gzofstream &, T), T v) : func(f), val(v) { }
96private:
97 gzofstream &(*func)(gzofstream &, T);
98 T val;
99};
100
101template<class T> gzofstream &operator<<(gzofstream &s,
102 const gzomanip<T> &m) {
103 return (*m.func)(s, m.val);
104
105}
106
107inline gzofstream &setcompressionlevel( gzofstream &s, int l ) {
108 (s.rdbuf())->setcompressionlevel(l);
109 return s;
110}
111
112inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) {
113 (s.rdbuf())->setcompressionstrategy(l);
114 return s;
115}
116
117inline gzomanip<int> setcompressionlevel(int l)
118{
119 return gzomanip<int>(&setcompressionlevel,l);
120}
121
122inline gzomanip<int> setcompressionstrategy(int l)
123{
124 return gzomanip<int>(&setcompressionstrategy,l);
125}
126
127#endif
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
diff --git a/contrib/iostream2/zstream.h b/contrib/iostream2/zstream.h
new file mode 100644
index 0000000..43d2332
--- /dev/null
+++ b/contrib/iostream2/zstream.h
@@ -0,0 +1,307 @@
1/*
2 *
3 * Copyright (c) 1997
4 * Christian Michelsen Research AS
5 * Advanced Computing
6 * Fantoftvegen 38, 5036 BERGEN, Norway
7 * http://www.cmr.no
8 *
9 * Permission to use, copy, modify, distribute and sell this software
10 * and its documentation for any purpose is hereby granted without fee,
11 * provided that the above copyright notice appear in all copies and
12 * that both that copyright notice and this permission notice appear
13 * in supporting documentation. Christian Michelsen Research AS makes no
14 * representations about the suitability of this software for any
15 * purpose. It is provided "as is" without express or implied warranty.
16 *
17 */
18
19#ifndef ZSTREAM__H
20#define ZSTREAM__H
21
22/*
23 * zstream.h - C++ interface to the 'zlib' general purpose compression library
24 * $Id: zstream.h 1.1 1997-06-25 12:00:56+02 tyge Exp tyge $
25 */
26
27#include <strstream.h>
28#include <string.h>
29#include <stdio.h>
30#include "zlib.h"
31
32#if defined(_WIN32)
33# include <fcntl.h>
34# include <io.h>
35# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
36#else
37# define SET_BINARY_MODE(file)
38#endif
39
40class zstringlen {
41public:
42 zstringlen(class izstream&);
43 zstringlen(class ozstream&, const char*);
44 size_t value() const { return val.word; }
45private:
46 struct Val { unsigned char byte; size_t word; } val;
47};
48
49// ----------------------------- izstream -----------------------------
50
51class izstream
52{
53 public:
54 izstream() : m_fp(0) {}
55 izstream(FILE* fp) : m_fp(0) { open(fp); }
56 izstream(const char* name) : m_fp(0) { open(name); }
57 ~izstream() { close(); }
58
59 /* Opens a gzip (.gz) file for reading.
60 * open() can be used to read a file which is not in gzip format;
61 * in this case read() will directly read from the file without
62 * decompression. errno can be checked to distinguish two error
63 * cases (if errno is zero, the zlib error is Z_MEM_ERROR).
64 */
65 void open(const char* name) {
66 if (m_fp) close();
67 m_fp = ::gzopen(name, "rb");
68 }
69
70 void open(FILE* fp) {
71 SET_BINARY_MODE(fp);
72 if (m_fp) close();
73 m_fp = ::gzdopen(fileno(fp), "rb");
74 }
75
76 /* Flushes all pending input if necessary, closes the compressed file
77 * and deallocates all the (de)compression state. The return value is
78 * the zlib error number (see function error() below).
79 */
80 int close() {
81 int r = ::gzclose(m_fp);
82 m_fp = 0; return r;
83 }
84
85 /* Binary read the given number of bytes from the compressed file.
86 */
87 int read(void* buf, size_t len) {
88 return ::gzread(m_fp, buf, len);
89 }
90
91 /* Returns the error message for the last error which occurred on the
92 * given compressed file. errnum is set to zlib error number. If an
93 * error occurred in the file system and not in the compression library,
94 * errnum is set to Z_ERRNO and the application may consult errno
95 * to get the exact error code.
96 */
97 const char* error(int* errnum) {
98 return ::gzerror(m_fp, errnum);
99 }
100
101 gzFile fp() { return m_fp; }
102
103 private:
104 gzFile m_fp;
105};
106
107/*
108 * Binary read the given (array of) object(s) from the compressed file.
109 * If the input file was not in gzip format, read() copies the objects number
110 * of bytes into the buffer.
111 * returns the number of uncompressed bytes actually read
112 * (0 for end of file, -1 for error).
113 */
114template <class T, class Items>
115inline int read(izstream& zs, T* x, Items items) {
116 return ::gzread(zs.fp(), x, items*sizeof(T));
117}
118
119/*
120 * Binary input with the '>' operator.
121 */
122template <class T>
123inline izstream& operator>(izstream& zs, T& x) {
124 ::gzread(zs.fp(), &x, sizeof(T));
125 return zs;
126}
127
128
129inline zstringlen::zstringlen(izstream& zs) {
130 zs > val.byte;
131 if (val.byte == 255) zs > val.word;
132 else val.word = val.byte;
133}
134
135/*
136 * Read length of string + the string with the '>' operator.
137 */
138inline izstream& operator>(izstream& zs, char* x) {
139 zstringlen len(zs);
140 ::gzread(zs.fp(), x, len.value());
141 x[len.value()] = '\0';
142 return zs;
143}
144
145inline char* read_string(izstream& zs) {
146 zstringlen len(zs);
147 char* x = new char[len.value()+1];
148 ::gzread(zs.fp(), x, len.value());
149 x[len.value()] = '\0';
150 return x;
151}
152
153// ----------------------------- ozstream -----------------------------
154
155class ozstream
156{
157 public:
158 ozstream() : m_fp(0), m_os(0) {
159 }
160 ozstream(FILE* fp, int level = Z_DEFAULT_COMPRESSION)
161 : m_fp(0), m_os(0) {
162 open(fp, level);
163 }
164 ozstream(const char* name, int level = Z_DEFAULT_COMPRESSION)
165 : m_fp(0), m_os(0) {
166 open(name, level);
167 }
168 ~ozstream() {
169 close();
170 }
171
172 /* Opens a gzip (.gz) file for writing.
173 * The compression level parameter should be in 0..9
174 * errno can be checked to distinguish two error cases
175 * (if errno is zero, the zlib error is Z_MEM_ERROR).
176 */
177 void open(const char* name, int level = Z_DEFAULT_COMPRESSION) {
178 char mode[4] = "wb\0";
179 if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level;
180 if (m_fp) close();
181 m_fp = ::gzopen(name, mode);
182 }
183
184 /* open from a FILE pointer.
185 */
186 void open(FILE* fp, int level = Z_DEFAULT_COMPRESSION) {
187 SET_BINARY_MODE(fp);
188 char mode[4] = "wb\0";
189 if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level;
190 if (m_fp) close();
191 m_fp = ::gzdopen(fileno(fp), mode);
192 }
193
194 /* Flushes all pending output if necessary, closes the compressed file
195 * and deallocates all the (de)compression state. The return value is
196 * the zlib error number (see function error() below).
197 */
198 int close() {
199 if (m_os) {
200 ::gzwrite(m_fp, m_os->str(), m_os->pcount());
201 delete[] m_os->str(); delete m_os; m_os = 0;
202 }
203 int r = ::gzclose(m_fp); m_fp = 0; return r;
204 }
205
206 /* Binary write the given number of bytes into the compressed file.
207 */
208 int write(const void* buf, size_t len) {
209 return ::gzwrite(m_fp, (voidp) buf, len);
210 }
211
212 /* Flushes all pending output into the compressed file. The parameter
213 * _flush is as in the deflate() function. The return value is the zlib
214 * error number (see function gzerror below). flush() returns Z_OK if
215 * the flush_ parameter is Z_FINISH and all output could be flushed.
216 * flush() should be called only when strictly necessary because it can
217 * degrade compression.
218 */
219 int flush(int _flush) {
220 os_flush();
221 return ::gzflush(m_fp, _flush);
222 }
223
224 /* Returns the error message for the last error which occurred on the
225 * given compressed file. errnum is set to zlib error number. If an
226 * error occurred in the file system and not in the compression library,
227 * errnum is set to Z_ERRNO and the application may consult errno
228 * to get the exact error code.
229 */
230 const char* error(int* errnum) {
231 return ::gzerror(m_fp, errnum);
232 }
233
234 gzFile fp() { return m_fp; }
235
236 ostream& os() {
237 if (m_os == 0) m_os = new ostrstream;
238 return *m_os;
239 }
240
241 void os_flush() {
242 if (m_os && m_os->pcount()>0) {
243 ostrstream* oss = new ostrstream;
244 oss->fill(m_os->fill());
245 oss->flags(m_os->flags());
246 oss->precision(m_os->precision());
247 oss->width(m_os->width());
248 ::gzwrite(m_fp, m_os->str(), m_os->pcount());
249 delete[] m_os->str(); delete m_os; m_os = oss;
250 }
251 }
252
253 private:
254 gzFile m_fp;
255 ostrstream* m_os;
256};
257
258/*
259 * Binary write the given (array of) object(s) into the compressed file.
260 * returns the number of uncompressed bytes actually written
261 * (0 in case of error).
262 */
263template <class T, class Items>
264inline int write(ozstream& zs, const T* x, Items items) {
265 return ::gzwrite(zs.fp(), (voidp) x, items*sizeof(T));
266}
267
268/*
269 * Binary output with the '<' operator.
270 */
271template <class T>
272inline ozstream& operator<(ozstream& zs, const T& x) {
273 ::gzwrite(zs.fp(), (voidp) &x, sizeof(T));
274 return zs;
275}
276
277inline zstringlen::zstringlen(ozstream& zs, const char* x) {
278 val.byte = 255; val.word = ::strlen(x);
279 if (val.word < 255) zs < (val.byte = val.word);
280 else zs < val;
281}
282
283/*
284 * Write length of string + the string with the '<' operator.
285 */
286inline ozstream& operator<(ozstream& zs, const char* x) {
287 zstringlen len(zs, x);
288 ::gzwrite(zs.fp(), (voidp) x, len.value());
289 return zs;
290}
291
292#ifdef _MSC_VER
293inline ozstream& operator<(ozstream& zs, char* const& x) {
294 return zs < (const char*) x;
295}
296#endif
297
298/*
299 * Ascii write with the << operator;
300 */
301template <class T>
302inline ostream& operator<<(ozstream& zs, const T& x) {
303 zs.os_flush();
304 return zs.os() << x;
305}
306
307#endif
diff --git a/contrib/iostream2/zstream_test.cpp b/contrib/iostream2/zstream_test.cpp
new file mode 100644
index 0000000..5bbd56c
--- /dev/null
+++ b/contrib/iostream2/zstream_test.cpp
@@ -0,0 +1,25 @@
1#include "zstream.h"
2#include <math.h>
3#include <stdlib.h>
4#include <iomanip.h>
5
6void main() {
7 char h[256] = "Hello";
8 char* g = "Goodbye";
9 ozstream out("temp.gz");
10 out < "This works well" < h < g;
11 out.close();
12
13 izstream in("temp.gz"); // read it back
14 char *x = read_string(in), *y = new char[256], z[256];
15 in > y > z;
16 in.close();
17 cout << x << endl << y << endl << z << endl;
18
19 out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results
20 out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl;
21 out << z << endl << y << endl << x << endl;
22 out << 1.1234567890123456789 << endl;
23
24 delete[] x; delete[] y;
25}
diff --git a/contrib/untgz/Makefile b/contrib/untgz/Makefile
new file mode 100644
index 0000000..409b4bd
--- /dev/null
+++ b/contrib/untgz/Makefile
@@ -0,0 +1,14 @@
1CC=cc
2CFLAGS=-g
3
4untgz: untgz.o ../../libz.a
5 $(CC) $(CFLAGS) -o untgz untgz.o -L../.. -lz
6
7untgz.o: untgz.c ../../zlib.h
8 $(CC) $(CFLAGS) -c -I../.. untgz.c
9
10../../libz.a:
11 cd ../..; make
12
13clean:
14 rm -f untgz untgz.o *~
diff --git a/contrib/untgz/makefile.w32 b/contrib/untgz/makefile.w32
new file mode 100644
index 0000000..c99dc28
--- /dev/null
+++ b/contrib/untgz/makefile.w32
@@ -0,0 +1,63 @@
1# Makefile for zlib. Modified for mingw32
2# For conditions of distribution and use, see copyright notice in zlib.h
3
4# To compile,
5#
6# make -fmakefile.w32
7#
8
9CC=gcc
10
11# Generate dependencies (see end of the file)
12
13CPPFLAGS=-MMD
14
15#CFLAGS=-MMD -O
16#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
17#CFLAGS=-MMD -g -DDEBUG
18CFLAGS=-O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
19 -Wstrict-prototypes -Wmissing-prototypes
20
21# If cp.exe is not found, replace with copy /Y .
22CP=cp -f
23
24# The default value of RM is "rm -f."
25# If "rm.exe" is not found, uncomment:
26# RM=del
27
28LD=gcc
29LDLIBS=-L. -lz
30LDFLAGS=-s
31
32
33INCL=zlib.h zconf.h
34LIBS=libz.a
35
36AR=ar rcs
37
38OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
39 zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o \
40 inffast.o
41
42TEST_OBJS = minigzip.o untgz.o
43
44all: minigzip.exe untgz.exe
45
46rebuild: clean all
47
48libz.a: $(OBJS)
49 $(AR) $@ $(OBJS)
50
51%.exe : %.o $(LIBS)
52 $(LD) $(LDFLAGS) -o $@ $< $(LDLIBS)
53
54.PHONY : clean
55
56clean:
57 $(RM) *.d *.o *.exe libz.a foo.gz
58
59DEPS := $(wildcard *.d)
60ifneq ($(DEPS),)
61include $(DEPS)
62endif
63
diff --git a/contrib/untgz/untgz.c b/contrib/untgz/untgz.c
new file mode 100644
index 0000000..6fa9a5d
--- /dev/null
+++ b/contrib/untgz/untgz.c
@@ -0,0 +1,478 @@
1/*
2 * untgz.c -- Display contents and/or extract file from
3 * a gzip'd TAR file
4 * written by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
5 * adaptation to Unix by Jean-loup Gailly <jloup@gzip.org>
6 */
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include <time.h>
12#include <utime.h>
13#include <errno.h>
14#include <fcntl.h>
15#ifdef unix
16# include <unistd.h>
17#else
18# include <direct.h>
19# include <io.h>
20#endif
21
22#include "zlib.h"
23
24/* Values used in typeflag field. */
25
26#define REGTYPE '0' /* regular file */
27#define AREGTYPE '\0' /* regular file */
28#define LNKTYPE '1' /* link */
29#define SYMTYPE '2' /* reserved */
30#define CHRTYPE '3' /* character special */
31#define BLKTYPE '4' /* block special */
32#define DIRTYPE '5' /* directory */
33#define FIFOTYPE '6' /* FIFO special */
34#define CONTTYPE '7' /* reserved */
35
36#define BLOCKSIZE 512
37
38struct tar_header
39{ /* byte offset */
40 char name[100]; /* 0 */
41 char mode[8]; /* 100 */
42 char uid[8]; /* 108 */
43 char gid[8]; /* 116 */
44 char size[12]; /* 124 */
45 char mtime[12]; /* 136 */
46 char chksum[8]; /* 148 */
47 char typeflag; /* 156 */
48 char linkname[100]; /* 157 */
49 char magic[6]; /* 257 */
50 char version[2]; /* 263 */
51 char uname[32]; /* 265 */
52 char gname[32]; /* 297 */
53 char devmajor[8]; /* 329 */
54 char devminor[8]; /* 337 */
55 char prefix[155]; /* 345 */
56 /* 500 */
57};
58
59union tar_buffer {
60 char buffer[BLOCKSIZE];
61 struct tar_header header;
62};
63
64enum { TGZ_EXTRACT = 0, TGZ_LIST };
65
66static char *TGZfname OF((const char *));
67void TGZnotfound OF((const char *));
68
69int getoct OF((char *, int));
70char *strtime OF((time_t *));
71int ExprMatch OF((char *,char *));
72
73int makedir OF((char *));
74int matchname OF((int,int,char **,char *));
75
76void error OF((const char *));
77int tar OF((gzFile, int, int, int, char **));
78
79void help OF((int));
80int main OF((int, char **));
81
82char *prog;
83
84/* This will give a benign warning */
85
86static char *TGZprefix[] = { "\0", ".tgz", ".tar.gz", NULL };
87
88/* Return the real name of the TGZ archive */
89/* or NULL if it does not exist. */
90
91static char *TGZfname OF((const char *fname))
92{
93 static char buffer[1024];
94 int origlen,i;
95
96 strcpy(buffer,fname);
97 origlen = strlen(buffer);
98
99 for (i=0; TGZprefix[i]; i++)
100 {
101 strcpy(buffer+origlen,TGZprefix[i]);
102 if (access(buffer,F_OK) == 0)
103 return buffer;
104 }
105 return NULL;
106}
107
108/* error message for the filename */
109
110void TGZnotfound OF((const char *fname))
111{
112 int i;
113
114 fprintf(stderr,"%s : couldn't find ",prog);
115 for (i=0;TGZprefix[i];i++)
116 fprintf(stderr,(TGZprefix[i+1]) ? "%s%s, " : "or %s%s\n",
117 fname,
118 TGZprefix[i]);
119 exit(1);
120}
121
122
123/* help functions */
124
125int getoct(char *p,int width)
126{
127 int result = 0;
128 char c;
129
130 while (width --)
131 {
132 c = *p++;
133 if (c == ' ')
134 continue;
135 if (c == 0)
136 break;
137 result = result * 8 + (c - '0');
138 }
139 return result;
140}
141
142char *strtime (time_t *t)
143{
144 struct tm *local;
145 static char result[32];
146
147 local = localtime(t);
148 sprintf(result,"%2d/%02d/%4d %02d:%02d:%02d",
149 local->tm_mday, local->tm_mon+1, local->tm_year+1900,
150 local->tm_hour, local->tm_min, local->tm_sec);
151 return result;
152}
153
154
155/* regular expression matching */
156
157#define ISSPECIAL(c) (((c) == '*') || ((c) == '/'))
158
159int ExprMatch(char *string,char *expr)
160{
161 while (1)
162 {
163 if (ISSPECIAL(*expr))
164 {
165 if (*expr == '/')
166 {
167 if (*string != '\\' && *string != '/')
168 return 0;
169 string ++; expr++;
170 }
171 else if (*expr == '*')
172 {
173 if (*expr ++ == 0)
174 return 1;
175 while (*++string != *expr)
176 if (*string == 0)
177 return 0;
178 }
179 }
180 else
181 {
182 if (*string != *expr)
183 return 0;
184 if (*expr++ == 0)
185 return 1;
186 string++;
187 }
188 }
189}
190
191/* recursive make directory */
192/* abort if you get an ENOENT errno somewhere in the middle */
193/* e.g. ignore error "mkdir on existing directory" */
194/* */
195/* return 1 if OK */
196/* 0 on error */
197
198int makedir (char *newdir)
199{
200 char *buffer = strdup(newdir);
201 char *p;
202 int len = strlen(buffer);
203
204 if (len <= 0) {
205 free(buffer);
206 return 0;
207 }
208 if (buffer[len-1] == '/') {
209 buffer[len-1] = '\0';
210 }
211 if (mkdir(buffer, 0775) == 0)
212 {
213 free(buffer);
214 return 1;
215 }
216
217 p = buffer+1;
218 while (1)
219 {
220 char hold;
221
222 while(*p && *p != '\\' && *p != '/')
223 p++;
224 hold = *p;
225 *p = 0;
226 if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT))
227 {
228 fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer);
229 free(buffer);
230 return 0;
231 }
232 if (hold == 0)
233 break;
234 *p++ = hold;
235 }
236 free(buffer);
237 return 1;
238}
239
240int matchname (int arg,int argc,char **argv,char *fname)
241{
242 if (arg == argc) /* no arguments given (untgz tgzarchive) */
243 return 1;
244
245 while (arg < argc)
246 if (ExprMatch(fname,argv[arg++]))
247 return 1;
248
249 return 0; /* ignore this for the moment being */
250}
251
252
253/* Tar file list or extract */
254
255int tar (gzFile in,int action,int arg,int argc,char **argv)
256{
257 union tar_buffer buffer;
258 int len;
259 int err;
260 int getheader = 1;
261 int remaining = 0;
262 FILE *outfile = NULL;
263 char fname[BLOCKSIZE];
264 time_t tartime;
265
266 if (action == TGZ_LIST)
267 printf(" day time size file\n"
268 " ---------- -------- --------- -------------------------------------\n");
269 while (1)
270 {
271 len = gzread(in, &buffer, BLOCKSIZE);
272 if (len < 0)
273 error (gzerror(in, &err));
274 /*
275 * if we met the end of the tar
276 * or the end-of-tar block,
277 * we are done
278 */
279 if ((len == 0) || (buffer.header.name[0]== 0))
280 break;
281
282 /*
283 * Always expect complete blocks to process
284 * the tar information.
285 */
286 if (len != BLOCKSIZE)
287 error("gzread: incomplete block read");
288
289 /*
290 * If we have to get a tar header
291 */
292 if (getheader == 1)
293 {
294 tartime = (time_t)getoct(buffer.header.mtime,12);
295 strcpy(fname,buffer.header.name);
296
297 switch (buffer.header.typeflag)
298 {
299 case DIRTYPE:
300 if (action == TGZ_LIST)
301 printf(" %s <dir> %s\n",strtime(&tartime),fname);
302 if (action == TGZ_EXTRACT)
303 makedir(fname);
304 break;
305 case REGTYPE:
306 case AREGTYPE:
307 remaining = getoct(buffer.header.size,12);
308 if (action == TGZ_LIST)
309 printf(" %s %9d %s\n",strtime(&tartime),remaining,fname);
310 if (action == TGZ_EXTRACT)
311 {
312 if ((remaining) && (matchname(arg,argc,argv,fname)))
313 {
314 outfile = fopen(fname,"wb");
315 if (outfile == NULL) {
316 /* try creating directory */
317 char *p = strrchr(fname, '/');
318 if (p != NULL) {
319 *p = '\0';
320 makedir(fname);
321 *p = '/';
322 outfile = fopen(fname,"wb");
323 }
324 }
325 fprintf(stderr,
326 "%s %s\n",
327 (outfile) ? "Extracting" : "Couldn't create",
328 fname);
329 }
330 else
331 outfile = NULL;
332 }
333 /*
334 * could have no contents
335 */
336 getheader = (remaining) ? 0 : 1;
337 break;
338 default:
339 if (action == TGZ_LIST)
340 printf(" %s <---> %s\n",strtime(&tartime),fname);
341 break;
342 }
343 }
344 else
345 {
346 unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining;
347
348 if ((action == TGZ_EXTRACT) && (outfile != NULL))
349 {
350 if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes)
351 {
352 fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname);
353 fclose(outfile);
354 unlink(fname);
355 }
356 }
357 remaining -= bytes;
358 if (remaining == 0)
359 {
360 getheader = 1;
361 if ((action == TGZ_EXTRACT) && (outfile != NULL))
362 {
363 struct utimbuf settime;
364
365 settime.actime = settime.modtime = tartime;
366
367 fclose(outfile);
368 outfile = NULL;
369 utime(fname,&settime);
370 }
371 }
372 }
373 }
374
375 if (gzclose(in) != Z_OK)
376 error("failed gzclose");
377
378 return 0;
379}
380
381
382/* =========================================================== */
383
384void help(int exitval)
385{
386 fprintf(stderr,
387 "untgz v 0.1\n"
388 " an sample application of zlib 1.0.4\n\n"
389 "Usage : untgz TGZfile to extract all files\n"
390 " untgz TGZfile fname ... to extract selected files\n"
391 " untgz -l TGZfile to list archive contents\n"
392 " untgz -h to display this help\n\n");
393 exit(exitval);
394}
395
396void error(const char *msg)
397{
398 fprintf(stderr, "%s: %s\n", prog, msg);
399 exit(1);
400}
401
402
403/* ====================================================================== */
404
405int _CRT_glob = 0; /* disable globbing of the arguments */
406
407int main(int argc,char **argv)
408{
409 int action = TGZ_EXTRACT;
410 int arg = 1;
411 char *TGZfile;
412 gzFile *f;
413
414
415 prog = strrchr(argv[0],'\\');
416 if (prog == NULL)
417 {
418 prog = strrchr(argv[0],'/');
419 if (prog == NULL)
420 {
421 prog = strrchr(argv[0],':');
422 if (prog == NULL)
423 prog = argv[0];
424 else
425 prog++;
426 }
427 else
428 prog++;
429 }
430 else
431 prog++;
432
433 if (argc == 1)
434 help(0);
435
436 if (strcmp(argv[arg],"-l") == 0)
437 {
438 action = TGZ_LIST;
439 if (argc == ++arg)
440 help(0);
441 }
442 else if (strcmp(argv[arg],"-h") == 0)
443 {
444 help(0);
445 }
446
447 if ((TGZfile = TGZfname(argv[arg])) == NULL)
448 TGZnotfound(argv[arg]);
449
450 ++arg;
451 if ((action == TGZ_LIST) && (arg != argc))
452 help(1);
453
454/*
455 * Process the TGZ file
456 */
457 switch(action)
458 {
459 case TGZ_LIST:
460 case TGZ_EXTRACT:
461 f = gzopen(TGZfile,"rb");
462 if (f == NULL)
463 {
464 fprintf(stderr,"%s: Couldn't gzopen %s\n",
465 prog,
466 TGZfile);
467 return 1;
468 }
469 exit(tar(f, action, arg, argc, argv));
470 break;
471
472 default:
473 error("Unknown option!");
474 exit(1);
475 }
476
477 return 0;
478}
diff --git a/contrib/visual-basic.txt b/contrib/visual-basic.txt
new file mode 100644
index 0000000..18aa084
--- /dev/null
+++ b/contrib/visual-basic.txt
@@ -0,0 +1,57 @@
1From: "Jon Caruana" <jon-net@usa.net>
2To: "Jean-loup Gailly" <gzip@prep.ai.mit.edu>
3Subject: Re: How to port zlib declares to vb?
4Date: Mon, 28 Oct 1996 18:33:03 -0600
5
6Got the answer! (I haven't had time to check this but it's what I got, and
7looks correct):
8
9He has the following routines working:
10 compress
11 uncompress
12 gzopen
13 gzwrite
14 gzread
15 gzclose
16
17Declares follow: (Quoted from Carlos Rios <c_rios@sonda.cl>, in Vb4 form)
18
19#If Win16 Then 'Use Win16 calls.
20Declare Function compress Lib "ZLIB.DLL" (ByVal compr As
21 String, comprLen As Any, ByVal buf As String, ByVal buflen
22 As Long) As Integer
23Declare Function uncompress Lib "ZLIB.DLL" (ByVal uncompr
24 As String, uncomprLen As Any, ByVal compr As String, ByVal
25 lcompr As Long) As Integer
26Declare Function gzopen Lib "ZLIB.DLL" (ByVal filePath As
27 String, ByVal mode As String) As Long
28Declare Function gzread Lib "ZLIB.DLL" (ByVal file As
29 Long, ByVal uncompr As String, ByVal uncomprLen As Integer)
30 As Integer
31Declare Function gzwrite Lib "ZLIB.DLL" (ByVal file As
32 Long, ByVal uncompr As String, ByVal uncomprLen As Integer)
33 As Integer
34Declare Function gzclose Lib "ZLIB.DLL" (ByVal file As
35 Long) As Integer
36#Else
37Declare Function compress Lib "ZLIB32.DLL"
38 (ByVal compr As String, comprLen As Any, ByVal buf As
39 String, ByVal buflen As Long) As Integer
40Declare Function uncompress Lib "ZLIB32.DLL"
41 (ByVal uncompr As String, uncomprLen As Any, ByVal compr As
42 String, ByVal lcompr As Long) As Long
43Declare Function gzopen Lib "ZLIB32.DLL"
44 (ByVal file As String, ByVal mode As String) As Long
45Declare Function gzread Lib "ZLIB32.DLL"
46 (ByVal file As Long, ByVal uncompr As String, ByVal
47 uncomprLen As Long) As Long
48Declare Function gzwrite Lib "ZLIB32.DLL"
49 (ByVal file As Long, ByVal uncompr As String, ByVal
50 uncomprLen As Long) As Long
51Declare Function gzclose Lib "ZLIB32.DLL"
52 (ByVal file As Long) As Long
53#End If
54
55-Jon Caruana
56jon-net@usa.net
57Microsoft Sitebuilder Network Level 1 Member - HTML Writer's Guild Member