aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--INDEX1
-rw-r--r--Makefile2
-rw-r--r--Makefile.dj27
-rw-r--r--Makefile.in2
-rw-r--r--Makefile.msc4
-rw-r--r--Makefile.riscos46
-rw-r--r--README33
-rw-r--r--algorithm.doc14
-rw-r--r--deflate.c145
-rw-r--r--deflate.h4
-rw-r--r--gzio.c12
-rw-r--r--infblock.c8
-rw-r--r--infblock.h8
-rw-r--r--infcodes.c6
-rw-r--r--infcodes.h6
-rw-r--r--inffast.c2
-rw-r--r--inffast.h2
-rw-r--r--inflate.c15
-rw-r--r--inftrees.c12
-rw-r--r--inftrees.h6
-rw-r--r--infutil.c2
-rw-r--r--infutil.h2
-rw-r--r--minigzip.c11
-rw-r--r--trees.c4
-rw-r--r--zconf.h20
-rw-r--r--zlib.def2
-rw-r--r--zlib.h54
-rw-r--r--zlib.rc6
-rw-r--r--zutil.c25
-rw-r--r--zutil.h14
31 files changed, 302 insertions, 192 deletions
diff --git a/ChangeLog b/ChangeLog
index ffbe1c4..218cfb0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,25 @@
1 1
2 ChangeLog file for zlib 2 ChangeLog file for zlib
3 3
4Changes in 1.0.4 (24 Jul 96)
5- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
6 bit, so the decompressor could decompress all the correct data but went
7 on to attempt decompressing extra garbage data. This affected minigzip too.
8- zlibVersion and gzerror return const char* (needed for DLL)
9- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
10- use z_error only for DEBUG (avoid problem with DLLs)
11
12Changes in 1.0.3 (2 Jul 96)
13- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS
14 small and medium models; this makes the library incompatible with previous
15 versions for these models. (No effect in large model or on other systems.)
16- return OK instead of BUF_ERROR if previous deflate call returned with
17 avail_out as zero but there is nothing to do
18- added memcmp for non STDC compilers
19- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly)
20- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO)
21- better check for 16-bit mode MSC (avoids problem with Symantec)
22
4Changes in 1.0.2 (23 May 96) 23Changes in 1.0.2 (23 May 96)
5- added Windows DLL support 24- added Windows DLL support
6- added a function zlibVersion (for the DLL support) 25- added a function zlibVersion (for the DLL support)
diff --git a/INDEX b/INDEX
index dc13753..bb1e3f0 100644
--- a/INDEX
+++ b/INDEX
@@ -7,6 +7,7 @@ Makefile.bor makefile for Borland C/C++ 16-bit
7Makefile.dj2 makefile for DJGPP 2.x 7Makefile.dj2 makefile for DJGPP 2.x
8Makefile.in makefile for Unix (template for configure) 8Makefile.in makefile for Unix (template for configure)
9Makefile.msc makefile for Microsoft C 16-bit 9Makefile.msc makefile for Microsoft C 16-bit
10Makefile.riscos makefile for RISCOS
10Makefile.sas makefile for Amiga SAS/C 11Makefile.sas makefile for Amiga SAS/C
11Makefile.tc makefile for Turbo C 12Makefile.tc makefile for Turbo C
12Makefile.wat makefile for Watcom C 13Makefile.wat makefile for Watcom C
diff --git a/Makefile b/Makefile
index f2ff262..71b269b 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ CFLAGS=-O
22LDFLAGS=-L. -lz 22LDFLAGS=-L. -lz
23LDSHARED=$(CC) 23LDSHARED=$(CC)
24 24
25VER=1.0.2 25VER=1.0.4
26LIBS=libz.a 26LIBS=libz.a
27 27
28AR=ar rc 28AR=ar rc
diff --git a/Makefile.dj2 b/Makefile.dj2
index 07a9bb1..398f28b 100644
--- a/Makefile.dj2
+++ b/Makefile.dj2
@@ -42,7 +42,6 @@ LDLIBS=-L. -lz
42LD=$(CC) -s -o 42LD=$(CC) -s -o
43LDSHARED=$(CC) 43LDSHARED=$(CC)
44 44
45VER=1.0.2
46INCL=zlib.h zconf.h 45INCL=zlib.h zconf.h
47LIBS=libz.a 46LIBS=libz.a
48 47
@@ -68,10 +67,6 @@ test: all
68libz.a: $(OBJS) 67libz.a: $(OBJS)
69 $(AR) $@ $(OBJS) 68 $(AR) $@ $(OBJS)
70 69
71libz.so.$(VER): $(OBJS)
72 $(LDSHARED) -o $@ $(OBJS)
73 $(RM) libz.so; ln -s $@ libz.so
74
75%.exe : %.o $(LIBS) 70%.exe : %.o $(LIBS)
76 $(LD) $@ $< $(LDLIBS) 71 $(LD) $@ $< $(LDLIBS)
77 72
@@ -90,7 +85,7 @@ uninstall:
90 for %%p in ($(LIBS)) do $(RM) $(LIBRARY_PATH)\%%p 85 for %%p in ($(LIBS)) do $(RM) $(LIBRARY_PATH)\%%p
91 86
92clean: 87clean:
93 for %%p in (*.d *.o *.exe libz.a libz.so*) do $(RM) %%p 88 for %%p in (*.d *.o *.exe libz.a libz.so* foo.gz) do $(RM) %%p
94 89
95DEPS := $(wildcard *.d) 90DEPS := $(wildcard *.d)
96ifneq ($(DEPS),) 91ifneq ($(DEPS),)
diff --git a/Makefile.in b/Makefile.in
index f2ff262..71b269b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -22,7 +22,7 @@ CFLAGS=-O
22LDFLAGS=-L. -lz 22LDFLAGS=-L. -lz
23LDSHARED=$(CC) 23LDSHARED=$(CC)
24 24
25VER=1.0.2 25VER=1.0.4
26LIBS=libz.a 26LIBS=libz.a
27 27
28AR=ar rc 28AR=ar rc
diff --git a/Makefile.msc b/Makefile.msc
index 3b7aabd..112684a 100644
--- a/Makefile.msc
+++ b/Makefile.msc
@@ -28,6 +28,8 @@ OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \
28OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ 28OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\
29 infutil$(O)+inffast$(O) 29 infutil$(O)+inffast$(O)
30 30
31all: zlib.lib example.exe minigzip.exe
32
31adler32.obj: adler32.c zutil.h zlib.h zconf.h 33adler32.obj: adler32.c zutil.h zlib.h zconf.h
32 $(CC) -c $(CFLAGS) $*.c 34 $(CC) -c $(CFLAGS) $*.c
33 35
@@ -80,7 +82,7 @@ minigzip.obj: minigzip.c zlib.h zconf.h
80 82
81# we must cut the command line to fit in the MS/DOS 128 byte limit: 83# we must cut the command line to fit in the MS/DOS 128 byte limit:
82zlib.lib: $(OBJ1) $(OBJ2) 84zlib.lib: $(OBJ1) $(OBJ2)
83 del zlib.lib 85 if exist zlib.lib del zlib.lib
84 lib zlib $(OBJ1); 86 lib zlib $(OBJ1);
85 lib zlib $(OBJ2); 87 lib zlib $(OBJ2);
86 88
diff --git a/Makefile.riscos b/Makefile.riscos
new file mode 100644
index 0000000..0f10aa8
--- /dev/null
+++ b/Makefile.riscos
@@ -0,0 +1,46 @@
1# Project: zlib_1_03
2
3
4# Toolflags:
5CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fnah
6C++flags = -c -depend !Depend -IC: -throwback
7Linkflags = -aif -c++ -o $@
8ObjAsmflags = -throwback -NoCache -depend !Depend
9CMHGflags =
10LibFileflags = -c -l -o $@
11Squeezeflags = -o $@
12
13
14# Final targets:
15@.zlib_lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \
16 @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \
17 @.o.uncompress @.o.zutil
18 LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \
19 @.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \
20 @.o.trees @.o.uncompress @.o.zutil
21@.test: @.tests.minigzip @.tests.example
22 echo Please run "Test" in directory tests
23@.tests.minigzip: @.o.minigzip @.zlib_lib C:o.Stubs
24 Link $(Linkflags) @.o.minigzip @.zlib_lib C:o.Stubs
25@.tests.example: @.o.example @.zlib_lib C:o.Stubs
26 Link $(Linkflags) @.o.example @.zlib_lib C:o.Stubs
27
28
29# User-editable dependencies:
30.c.o:
31 cc $(ccflags) -o $@ $<
32
33# Static dependencies:
34@.o.example: @.tests.c.example
35 cc $(ccflags) -o @.o.example @.tests.c.example
36@.o.minigzip: @.tests.c.minigzip
37 cc $(ccflags) -o @.o.minigzip @.tests.c.minigzip
38
39
40# Dynamic dependencies:
41o.minigzip: tests.c.minigzip
42o.minigzip: h.zlib
43o.minigzip: h.zconf
44o.example: tests.c.example
45o.example: h.zlib
46o.example: h.zconf
diff --git a/README b/README
index 217f3b1..28adc90 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
1zlib 1.0.2 is a general purpose data compression library. All the code 1zlib 1.0.4 is a general purpose data compression library. All the code
2is reentrant (thread safe). The data format used by the zlib library 2is reentrant (thread safe). The data format used by the zlib library
3is described by RFCs (Request for Comments) 1950 to 1952 in the files 3is described by RFCs (Request for Comments) 1950 to 1952 in the files
4ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate 4ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
@@ -18,21 +18,17 @@ makefiles such as Makefile.msc; for VMS, use Make_vms.com or descrip.mms.
18 18
19Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov> or, 19Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov> or,
20if this fails, to the addresses given below in the Copyright section. 20if this fails, to the addresses given below in the Copyright section.
21The zlib home page is http://quest.jpl.nasa.gov/zlib/
22
23The changes made in version 1.0.4 are documented in the file ChangeLog.
24The main changes since 1.0.3 are:
25
26- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
27 bit, so the decompressor could decompress all the correct data but went
28 on to attempt decompressing extra garbage data. This affected minigzip too.
29- zlibVersion and gzerror return const char* (needed for DLL)
30- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
21 31
22The changes made in version 1.0.2 are documented in the file ChangeLog.
23The main changes since 0.99 are:
24
25- fix array overlay in deflate.c which sometimes caused bad compressed data
26- fix inflate bug with empty stored block
27- fix MSDOS medium model which was broken in 0.99
28- fix deflateParams() which could generated bad compressed data.
29- added an INDEX file
30- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
31 Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas)
32- several portability improvements
33- added algorithm.doc
34- added Windows DLL support
35- added a function zlibVersion (for the DLL support)
36 32
37A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk> 33A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk>
38is in the CPAN (Comprehensive Perl Archive Network) sites, such as: 34is in the CPAN (Comprehensive Perl Archive Network) sites, such as:
@@ -46,7 +42,7 @@ Notes for some targets:
46 42
47- For 64-bit Iris, deflate.c must be compiled without any optimization. 43- For 64-bit Iris, deflate.c must be compiled without any optimization.
48 With -O, one libpng test fails. The test works in 32 bit mode (with 44 With -O, one libpng test fails. The test works in 32 bit mode (with
49 the -32 compiler flag). 45 the -32 compiler flag). The compiler bug has been reported to SGI.
50 46
51- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 47- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1
52 it works when compiled with cc. 48 it works when compiled with cc.
@@ -57,7 +53,10 @@ Notes for some targets:
57- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc 53- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
58 and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL 54 and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL
59 For help on building a zlib DLL, contact Alessandro Iacopetti 55 For help on building a zlib DLL, contact Alessandro Iacopetti
60 <iaco@cicladi.unial.it> 56 <iaco@email.alessandria.alpcom.it> http://lisa.unial.it/iaco ,
57 or contact Brad Clarke <bclarke@cyberus.ca>.
58
59- gzdopen is not supported on RISCOS
61 60
62 61
63Acknowledgments: 62Acknowledgments:
diff --git a/algorithm.doc b/algorithm.doc
index 156058a..01902af 100644
--- a/algorithm.doc
+++ b/algorithm.doc
@@ -7,7 +7,7 @@ pointer to the previous string, in the form of a pair (distance,
7length). Distances are limited to 32K bytes, and lengths are limited 7length). Distances are limited to 32K bytes, and lengths are limited
8to 258 bytes. When a string does not occur anywhere in the previous 8to 258 bytes. When a string does not occur anywhere in the previous
932K bytes, it is emitted as a sequence of literal bytes. (In this 932K bytes, it is emitted as a sequence of literal bytes. (In this
10description, 'string' must be taken as an arbitrary sequence of bytes, 10description, `string' must be taken as an arbitrary sequence of bytes,
11and is not restricted to printable characters.) 11and is not restricted to printable characters.)
12 12
13Literals or match lengths are compressed with one Huffman tree, and 13Literals or match lengths are compressed with one Huffman tree, and
@@ -16,7 +16,7 @@ in a compact form at the start of each block. The blocks can have any
16size (except that the compressed data for one block must fit in 16size (except that the compressed data for one block must fit in
17available memory). A block is terminated when deflate() determines that 17available memory). A block is terminated when deflate() determines that
18it would be useful to start another block with fresh trees. (This is 18it would be useful to start another block with fresh trees. (This is
19somewhat similar to compress.) 19somewhat similar to the behavior of LZW-based _compress_.)
20 20
21Duplicated strings are found using a hash table. All input strings of 21Duplicated strings are found using a hash table. All input strings of
22length 3 are inserted in the hash table. A hash index is computed for 22length 3 are inserted in the hash table. A hash index is computed for
@@ -57,7 +57,7 @@ but saves time since there are both fewer insertions and fewer searches.
57 57
582. Decompression algorithm (inflate) 582. Decompression algorithm (inflate)
59 59
60The real question is given a Huffman tree, how to decode fast. The most 60The real question is, given a Huffman tree, how to decode fast. The most
61important realization is that shorter codes are much more common than 61important realization is that shorter codes are much more common than
62longer codes, so pay attention to decoding the short codes fast, and let 62longer codes, so pay attention to decoding the short codes fast, and let
63the long codes take longer to decode. 63the long codes take longer to decode.
@@ -84,7 +84,7 @@ all the data. For inflate, which has 286 possible codes for the
84literal/length tree, the size of the first table is nine bits. Also the 84literal/length tree, the size of the first table is nine bits. Also the
85distance trees have 30 possible values, and the size of the first table is 85distance trees have 30 possible values, and the size of the first table is
86six bits. Note that for each of those cases, the table ended up one bit 86six bits. Note that for each of those cases, the table ended up one bit
87longer than the "average" code length, i.e. the code length of an 87longer than the ``average'' code length, i.e. the code length of an
88approximately flat code which would be a little more than eight bits for 88approximately flat code which would be a little more than eight bits for
89286 symbols and a little less than five bits for 30 symbols. It would be 89286 symbols and a little less than five bits for 30 symbols. It would be
90interesting to see if optimizing the first level table for other 90interesting to see if optimizing the first level table for other
@@ -97,9 +97,9 @@ gzip@prep.ai.mit.edu madler@alumni.caltech.edu
97 97
98References: 98References:
99 99
100[LZ77] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data 100[LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data
101Compression", IEEE Transactions on Information Theory", Vol. 23, No. 3, 101Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3,
102pp. 337-343. 102pp. 337-343.
103 103
104"DEFLATE Compressed Data Format Specification" available in 104``DEFLATE Compressed Data Format Specification'' available in
105ftp://ds.internic.net/rfc/rfc1951.txt 105ftp://ds.internic.net/rfc/rfc1951.txt
diff --git a/deflate.c b/deflate.c
index f882a87..c6ba9b4 100644
--- a/deflate.c
+++ b/deflate.c
@@ -47,11 +47,11 @@
47 * 47 *
48 */ 48 */
49 49
50/* $Id: deflate.c,v 1.13 1996/05/22 11:52:21 me Exp $ */ 50/* $Id: deflate.c,v 1.15 1996/07/24 13:40:58 me Exp $ */
51 51
52#include "deflate.h" 52#include "deflate.h"
53 53
54char deflate_copyright[] = " deflate 1.0.2 Copyright 1995-1996 Jean-loup Gailly "; 54char deflate_copyright[] = " deflate 1.0.4 Copyright 1995-1996 Jean-loup Gailly ";
55/* 55/*
56 If you use the zlib library in a product, an acknowledgment is welcome 56 If you use the zlib library in a product, an acknowledgment is welcome
57 in the documentation of your product. If for some reason you cannot 57 in the documentation of your product. If for some reason you cannot
@@ -62,15 +62,25 @@ char deflate_copyright[] = " deflate 1.0.2 Copyright 1995-1996 Jean-loup Gailly
62/* =========================================================================== 62/* ===========================================================================
63 * Function prototypes. 63 * Function prototypes.
64 */ 64 */
65typedef enum {
66 need_more, /* block not completed, need more input or more output */
67 block_done, /* block flush performed */
68 finish_started, /* finish started, need only more output at next deflate */
69 finish_done /* finish done, accept no more input or output */
70} block_state;
71
72typedef block_state (*compress_func) OF((deflate_state *s, int flush));
73/* Compression function. Returns the block state after the call. */
74
65local void fill_window OF((deflate_state *s)); 75local void fill_window OF((deflate_state *s));
66local int deflate_stored OF((deflate_state *s, int flush)); 76local block_state deflate_stored OF((deflate_state *s, int flush));
67local int deflate_fast OF((deflate_state *s, int flush)); 77local block_state deflate_fast OF((deflate_state *s, int flush));
68local int deflate_slow OF((deflate_state *s, int flush)); 78local block_state deflate_slow OF((deflate_state *s, int flush));
69local void lm_init OF((deflate_state *s)); 79local void lm_init OF((deflate_state *s));
70local uInt longest_match OF((deflate_state *s, IPos cur_match)); 80local uInt longest_match OF((deflate_state *s, IPos cur_match));
71local void putShortMSB OF((deflate_state *s, uInt b)); 81local void putShortMSB OF((deflate_state *s, uInt b));
72local void flush_pending OF((z_stream *strm)); 82local void flush_pending OF((z_streamp strm));
73local int read_buf OF((z_stream *strm, charf *buf, unsigned size)); 83local int read_buf OF((z_streamp strm, charf *buf, unsigned size));
74#ifdef ASMV 84#ifdef ASMV
75 void match_init OF((void)); /* asm code initialization */ 85 void match_init OF((void)); /* asm code initialization */
76#endif 86#endif
@@ -97,9 +107,6 @@ local void check_match OF((deflate_state *s, IPos start, IPos match,
97 * See deflate.c for comments about the MIN_MATCH+1. 107 * See deflate.c for comments about the MIN_MATCH+1.
98 */ 108 */
99 109
100typedef int (*compress_func) OF((deflate_state *s, int flush));
101/* Compressing function */
102
103/* Values for max_lazy_match, good_match and max_chain_length, depending on 110/* Values for max_lazy_match, good_match and max_chain_length, depending on
104 * the desired pack level (0..9). The values given below have been tuned to 111 * the desired pack level (0..9). The values given below have been tuned to
105 * exclude worst case performance for pathological files. Better values may be 112 * exclude worst case performance for pathological files. Better values may be
@@ -169,7 +176,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
169 176
170/* ========================================================================= */ 177/* ========================================================================= */
171int deflateInit_(strm, level, version, stream_size) 178int deflateInit_(strm, level, version, stream_size)
172 z_stream *strm; 179 z_streamp strm;
173 int level; 180 int level;
174 const char *version; 181 const char *version;
175 int stream_size; 182 int stream_size;
@@ -182,7 +189,7 @@ int deflateInit_(strm, level, version, stream_size)
182/* ========================================================================= */ 189/* ========================================================================= */
183int deflateInit2_(strm, level, method, windowBits, memLevel, strategy, 190int deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
184 version, stream_size) 191 version, stream_size)
185 z_stream *strm; 192 z_streamp strm;
186 int level; 193 int level;
187 int method; 194 int method;
188 int windowBits; 195 int windowBits;
@@ -249,7 +256,7 @@ int deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
249 256
250 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || 257 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
251 s->pending_buf == Z_NULL) { 258 s->pending_buf == Z_NULL) {
252 strm->msg = ERR_MSG(Z_MEM_ERROR); 259 strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
253 deflateEnd (strm); 260 deflateEnd (strm);
254 return Z_MEM_ERROR; 261 return Z_MEM_ERROR;
255 } 262 }
@@ -265,7 +272,7 @@ int deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
265 272
266/* ========================================================================= */ 273/* ========================================================================= */
267int deflateSetDictionary (strm, dictionary, dictLength) 274int deflateSetDictionary (strm, dictionary, dictLength)
268 z_stream *strm; 275 z_streamp strm;
269 const Bytef *dictionary; 276 const Bytef *dictionary;
270 uInt dictLength; 277 uInt dictLength;
271{ 278{
@@ -304,7 +311,7 @@ int deflateSetDictionary (strm, dictionary, dictLength)
304 311
305/* ========================================================================= */ 312/* ========================================================================= */
306int deflateReset (strm) 313int deflateReset (strm)
307 z_stream *strm; 314 z_streamp strm;
308{ 315{
309 deflate_state *s; 316 deflate_state *s;
310 317
@@ -334,7 +341,7 @@ int deflateReset (strm)
334 341
335/* ========================================================================= */ 342/* ========================================================================= */
336int deflateParams(strm, level, strategy) 343int deflateParams(strm, level, strategy)
337 z_stream *strm; 344 z_streamp strm;
338 int level; 345 int level;
339 int strategy; 346 int strategy;
340{ 347{
@@ -388,7 +395,7 @@ local void putShortMSB (s, b)
388 * (See also read_buf()). 395 * (See also read_buf()).
389 */ 396 */
390local void flush_pending(strm) 397local void flush_pending(strm)
391 z_stream *strm; 398 z_streamp strm;
392{ 399{
393 unsigned len = strm->state->pending; 400 unsigned len = strm->state->pending;
394 401
@@ -408,14 +415,16 @@ local void flush_pending(strm)
408 415
409/* ========================================================================= */ 416/* ========================================================================= */
410int deflate (strm, flush) 417int deflate (strm, flush)
411 z_stream *strm; 418 z_streamp strm;
412 int flush; 419 int flush;
413{ 420{
414 int old_flush; /* value of flush param for previous deflate call */ 421 int old_flush; /* value of flush param for previous deflate call */
415 deflate_state *s; 422 deflate_state *s;
416 423
417 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; 424 if (strm == Z_NULL || strm->state == Z_NULL ||
418 425 flush > Z_FINISH || flush < 0) {
426 return Z_STREAM_ERROR;
427 }
419 s = strm->state; 428 s = strm->state;
420 429
421 if (strm->next_out == Z_NULL || 430 if (strm->next_out == Z_NULL ||
@@ -447,14 +456,23 @@ int deflate (strm, flush)
447 if (s->strstart != 0) { 456 if (s->strstart != 0) {
448 putShortMSB(s, (uInt)(strm->adler >> 16)); 457 putShortMSB(s, (uInt)(strm->adler >> 16));
449 putShortMSB(s, (uInt)(strm->adler & 0xffff)); 458 putShortMSB(s, (uInt)(strm->adler & 0xffff));
450 strm->adler = 1L;
451 } 459 }
460 strm->adler = 1L;
452 } 461 }
453 462
454 /* Flush as much pending output as possible */ 463 /* Flush as much pending output as possible */
455 if (s->pending != 0) { 464 if (s->pending != 0) {
456 flush_pending(strm); 465 flush_pending(strm);
457 if (strm->avail_out == 0) return Z_OK; 466 if (strm->avail_out == 0) {
467 /* Since avail_out is 0, deflate will be called again with
468 * more output space, but possibly with both pending and
469 * avail_in equal to zero. There won't be anything to do,
470 * but this is not an error situation so make sure we
471 * return OK instead of BUF_ERROR at next call of deflate:
472 */
473 s->last_flush = -1;
474 return Z_OK;
475 }
458 476
459 /* Make sure there is something to do and avoid duplicate consecutive 477 /* Make sure there is something to do and avoid duplicate consecutive
460 * flushes. For repeated and useless calls with Z_FINISH, we keep 478 * flushes. For repeated and useless calls with Z_FINISH, we keep
@@ -474,22 +492,27 @@ int deflate (strm, flush)
474 */ 492 */
475 if (strm->avail_in != 0 || s->lookahead != 0 || 493 if (strm->avail_in != 0 || s->lookahead != 0 ||
476 (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { 494 (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
477 int quit; 495 block_state bstate;
478 496
479 if (flush == Z_FINISH) { 497 bstate = (*(configuration_table[s->level].func))(s, flush);
498
499 if (bstate == finish_started || bstate == finish_done) {
480 s->status = FINISH_STATE; 500 s->status = FINISH_STATE;
481 } 501 }
482 quit = (*(configuration_table[s->level].func))(s, flush); 502 if (bstate == need_more || bstate == finish_started) {
483 503 if (strm->avail_out == 0) {
484 if (quit || strm->avail_out == 0) return Z_OK; 504 s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
485 /* If flush != Z_NO_FLUSH && avail_out == 0, the next call 505 }
486 * of deflate should use the same flush parameter to make sure 506 return Z_OK;
487 * that the flush is complete. So we don't have to output an 507 /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
488 * empty block here, this will be done at next call. This also 508 * of deflate should use the same flush parameter to make sure
489 * ensures that for a very small output buffer, we emit at most 509 * that the flush is complete. So we don't have to output an
490 * one empty block. 510 * empty block here, this will be done at next call. This also
491 */ 511 * ensures that for a very small output buffer, we emit at most
492 if (flush != Z_NO_FLUSH && flush != Z_FINISH) { 512 * one empty block.
513 */
514 }
515 if (bstate == block_done) {
493 if (flush == Z_PARTIAL_FLUSH) { 516 if (flush == Z_PARTIAL_FLUSH) {
494 _tr_align(s); 517 _tr_align(s);
495 } else { /* FULL_FLUSH or SYNC_FLUSH */ 518 } else { /* FULL_FLUSH or SYNC_FLUSH */
@@ -502,7 +525,10 @@ int deflate (strm, flush)
502 } 525 }
503 } 526 }
504 flush_pending(strm); 527 flush_pending(strm);
505 if (strm->avail_out == 0) return Z_OK; 528 if (strm->avail_out == 0) {
529 s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
530 return Z_OK;
531 }
506 } 532 }
507 } 533 }
508 Assert(strm->avail_out > 0, "bug2"); 534 Assert(strm->avail_out > 0, "bug2");
@@ -523,7 +549,7 @@ int deflate (strm, flush)
523 549
524/* ========================================================================= */ 550/* ========================================================================= */
525int deflateEnd (strm) 551int deflateEnd (strm)
526 z_stream *strm; 552 z_streamp strm;
527{ 553{
528 int status; 554 int status;
529 555
@@ -544,8 +570,8 @@ int deflateEnd (strm)
544 570
545/* ========================================================================= */ 571/* ========================================================================= */
546int deflateCopy (dest, source) 572int deflateCopy (dest, source)
547 z_stream *dest; 573 z_streamp dest;
548 z_stream *source; 574 z_streamp source;
549{ 575{
550 if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { 576 if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
551 return Z_STREAM_ERROR; 577 return Z_STREAM_ERROR;
@@ -570,7 +596,7 @@ int deflateCopy (dest, source)
570 * (See also flush_pending()). 596 * (See also flush_pending()).
571 */ 597 */
572local int read_buf(strm, buf, size) 598local int read_buf(strm, buf, size)
573 z_stream *strm; 599 z_streamp strm;
574 charf *buf; 600 charf *buf;
575 unsigned size; 601 unsigned size;
576{ 602{
@@ -916,18 +942,18 @@ local void fill_window(s)
916/* Same but force premature exit if necessary. */ 942/* Same but force premature exit if necessary. */
917#define FLUSH_BLOCK(s, eof) { \ 943#define FLUSH_BLOCK(s, eof) { \
918 FLUSH_BLOCK_ONLY(s, eof); \ 944 FLUSH_BLOCK_ONLY(s, eof); \
919 if (s->strm->avail_out == 0) return 1; \ 945 if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
920} 946}
921 947
922/* =========================================================================== 948/* ===========================================================================
923 * Copy without compression as much as possible from the input stream, return 949 * Copy without compression as much as possible from the input stream, return
924 * true if processing was terminated prematurely (no more input or output 950 * the current block state.
925 * space). This function does not insert new strings in the dictionary 951 * This function does not insert new strings in the dictionary since
926 * since uncompressible data is probably not useful. This function is used 952 * uncompressible data is probably not useful. This function is used
927 * only for the level=0 compression option. 953 * only for the level=0 compression option.
928 * NOTE: this function should be optimized to avoid extra copying. 954 * NOTE: this function should be optimized to avoid extra copying.
929 */ 955 */
930local int deflate_stored(s, flush) 956local block_state deflate_stored(s, flush)
931 deflate_state *s; 957 deflate_state *s;
932 int flush; 958 int flush;
933{ 959{
@@ -939,7 +965,7 @@ local int deflate_stored(s, flush)
939 s->block_start >= (long)s->w_size, "slide too late"); 965 s->block_start >= (long)s->w_size, "slide too late");
940 966
941 fill_window(s); 967 fill_window(s);
942 if (s->lookahead == 0 && flush == Z_NO_FLUSH) return 1; 968 if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
943 969
944 if (s->lookahead == 0) break; /* flush the current block */ 970 if (s->lookahead == 0) break; /* flush the current block */
945 } 971 }
@@ -961,17 +987,17 @@ local int deflate_stored(s, flush)
961 } 987 }
962 } 988 }
963 FLUSH_BLOCK(s, flush == Z_FINISH); 989 FLUSH_BLOCK(s, flush == Z_FINISH);
964 return 0; /* normal exit */ 990 return flush == Z_FINISH ? finish_done : block_done;
965} 991}
966 992
967/* =========================================================================== 993/* ===========================================================================
968 * Compress as much as possible from the input stream, return true if 994 * Compress as much as possible from the input stream, return the current
969 * processing was terminated prematurely (no more input or output space). 995 * block state.
970 * This function does not perform lazy evaluation of matches and inserts 996 * This function does not perform lazy evaluation of matches and inserts
971 * new strings in the dictionary only for unmatched strings or for short 997 * new strings in the dictionary only for unmatched strings or for short
972 * matches. It is used only for the fast compression options. 998 * matches. It is used only for the fast compression options.
973 */ 999 */
974local int deflate_fast(s, flush) 1000local block_state deflate_fast(s, flush)
975 deflate_state *s; 1001 deflate_state *s;
976 int flush; 1002 int flush;
977{ 1003{
@@ -986,8 +1012,9 @@ local int deflate_fast(s, flush)
986 */ 1012 */
987 if (s->lookahead < MIN_LOOKAHEAD) { 1013 if (s->lookahead < MIN_LOOKAHEAD) {
988 fill_window(s); 1014 fill_window(s);
989 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) return 1; 1015 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
990 1016 return need_more;
1017 }
991 if (s->lookahead == 0) break; /* flush the current block */ 1018 if (s->lookahead == 0) break; /* flush the current block */
992 } 1019 }
993 1020
@@ -1055,7 +1082,7 @@ local int deflate_fast(s, flush)
1055 if (bflush) FLUSH_BLOCK(s, 0); 1082 if (bflush) FLUSH_BLOCK(s, 0);
1056 } 1083 }
1057 FLUSH_BLOCK(s, flush == Z_FINISH); 1084 FLUSH_BLOCK(s, flush == Z_FINISH);
1058 return 0; /* normal exit */ 1085 return flush == Z_FINISH ? finish_done : block_done;
1059} 1086}
1060 1087
1061/* =========================================================================== 1088/* ===========================================================================
@@ -1063,7 +1090,7 @@ local int deflate_fast(s, flush)
1063 * evaluation for matches: a match is finally adopted only if there is 1090 * evaluation for matches: a match is finally adopted only if there is
1064 * no better match at the next window position. 1091 * no better match at the next window position.
1065 */ 1092 */
1066local int deflate_slow(s, flush) 1093local block_state deflate_slow(s, flush)
1067 deflate_state *s; 1094 deflate_state *s;
1068 int flush; 1095 int flush;
1069{ 1096{
@@ -1079,8 +1106,9 @@ local int deflate_slow(s, flush)
1079 */ 1106 */
1080 if (s->lookahead < MIN_LOOKAHEAD) { 1107 if (s->lookahead < MIN_LOOKAHEAD) {
1081 fill_window(s); 1108 fill_window(s);
1082 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) return 1; 1109 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1083 1110 return need_more;
1111 }
1084 if (s->lookahead == 0) break; /* flush the current block */ 1112 if (s->lookahead == 0) break; /* flush the current block */
1085 } 1113 }
1086 1114
@@ -1158,7 +1186,7 @@ local int deflate_slow(s, flush)
1158 } 1186 }
1159 s->strstart++; 1187 s->strstart++;
1160 s->lookahead--; 1188 s->lookahead--;
1161 if (s->strm->avail_out == 0) return 1; 1189 if (s->strm->avail_out == 0) return need_more;
1162 } else { 1190 } else {
1163 /* There is no previous match to compare with, wait for 1191 /* There is no previous match to compare with, wait for
1164 * the next step to decide. 1192 * the next step to decide.
@@ -1175,6 +1203,5 @@ local int deflate_slow(s, flush)
1175 s->match_available = 0; 1203 s->match_available = 0;
1176 } 1204 }
1177 FLUSH_BLOCK(s, flush == Z_FINISH); 1205 FLUSH_BLOCK(s, flush == Z_FINISH);
1178 return 0; 1206 return flush == Z_FINISH ? finish_done : block_done;
1179} 1207}
1180
diff --git a/deflate.h b/deflate.h
index 95ca0c2..a7daf7f 100644
--- a/deflate.h
+++ b/deflate.h
@@ -8,7 +8,7 @@
8 subject to change. Applications should only use zlib.h. 8 subject to change. Applications should only use zlib.h.
9 */ 9 */
10 10
11/* $Id: deflate.h,v 1.9 1996/01/30 21:59:13 me Exp $ */ 11/* $Id: deflate.h,v 1.10 1996/07/02 12:41:00 me Exp $ */
12 12
13#ifndef _DEFLATE_H 13#ifndef _DEFLATE_H
14#define _DEFLATE_H 14#define _DEFLATE_H
@@ -80,7 +80,7 @@ typedef unsigned IPos;
80 */ 80 */
81 81
82typedef struct internal_state { 82typedef struct internal_state {
83 z_stream *strm; /* pointer back to this zlib stream */ 83 z_streamp strm; /* pointer back to this zlib stream */
84 int status; /* as the name implies */ 84 int status; /* as the name implies */
85 Bytef *pending_buf; /* output still pending */ 85 Bytef *pending_buf; /* output still pending */
86 Bytef *pending_out; /* next pending byte to output to the stream */ 86 Bytef *pending_out; /* next pending byte to output to the stream */
diff --git a/gzio.c b/gzio.c
index 44ca9e8..6c82677 100644
--- a/gzio.c
+++ b/gzio.c
@@ -3,7 +3,7 @@
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
6/* $Id: gzio.c,v 1.13 1996/05/22 11:52:24 me Exp $ */ 6/* $Id: gzio.c,v 1.14 1996/07/24 13:41:01 me Exp $ */
7 7
8#include <stdio.h> 8#include <stdio.h>
9 9
@@ -496,7 +496,7 @@ int gzclose (file)
496 errnum is set to Z_ERRNO and the application may consult errno 496 errnum is set to Z_ERRNO and the application may consult errno
497 to get the exact error code. 497 to get the exact error code.
498*/ 498*/
499char* gzerror (file, errnum) 499const char* gzerror (file, errnum)
500 gzFile file; 500 gzFile file;
501 int *errnum; 501 int *errnum;
502{ 502{
@@ -505,19 +505,19 @@ char* gzerror (file, errnum)
505 505
506 if (s == NULL) { 506 if (s == NULL) {
507 *errnum = Z_STREAM_ERROR; 507 *errnum = Z_STREAM_ERROR;
508 return ERR_MSG(Z_STREAM_ERROR); 508 return (const char*)ERR_MSG(Z_STREAM_ERROR);
509 } 509 }
510 *errnum = s->z_err; 510 *errnum = s->z_err;
511 if (*errnum == Z_OK) return (char*)""; 511 if (*errnum == Z_OK) return (const char*)"";
512 512
513 m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); 513 m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
514 514
515 if (m == NULL || *m == '\0') m = ERR_MSG(s->z_err); 515 if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
516 516
517 TRYFREE(s->msg); 517 TRYFREE(s->msg);
518 s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); 518 s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
519 strcpy(s->msg, s->path); 519 strcpy(s->msg, s->path);
520 strcat(s->msg, ": "); 520 strcat(s->msg, ": ");
521 strcat(s->msg, m); 521 strcat(s->msg, m);
522 return s->msg; 522 return (const char*)s->msg;
523} 523}
diff --git a/infblock.c b/infblock.c
index 733e983..cc2e674 100644
--- a/infblock.c
+++ b/infblock.c
@@ -63,7 +63,7 @@ local uInt border[] = { /* Order of the bit length code lengths */
63 63
64void inflate_blocks_reset(s, z, c) 64void inflate_blocks_reset(s, z, c)
65inflate_blocks_statef *s; 65inflate_blocks_statef *s;
66z_stream *z; 66z_streamp z;
67uLongf *c; 67uLongf *c;
68{ 68{
69 if (s->checkfn != Z_NULL) 69 if (s->checkfn != Z_NULL)
@@ -87,7 +87,7 @@ uLongf *c;
87 87
88 88
89inflate_blocks_statef *inflate_blocks_new(z, c, w) 89inflate_blocks_statef *inflate_blocks_new(z, c, w)
90z_stream *z; 90z_streamp z;
91check_func c; 91check_func c;
92uInt w; 92uInt w;
93{ 93{
@@ -115,7 +115,7 @@ uInt w;
115#endif 115#endif
116int inflate_blocks(s, z, r) 116int inflate_blocks(s, z, r)
117inflate_blocks_statef *s; 117inflate_blocks_statef *s;
118z_stream *z; 118z_streamp z;
119int r; 119int r;
120{ 120{
121 uInt t; /* temporary storage */ 121 uInt t; /* temporary storage */
@@ -381,7 +381,7 @@ int r;
381 381
382int inflate_blocks_free(s, z, c) 382int inflate_blocks_free(s, z, c)
383inflate_blocks_statef *s; 383inflate_blocks_statef *s;
384z_stream *z; 384z_streamp z;
385uLongf *c; 385uLongf *c;
386{ 386{
387 inflate_blocks_reset(s, z, c); 387 inflate_blocks_reset(s, z, c);
diff --git a/infblock.h b/infblock.h
index ee2c063..3ecd50c 100644
--- a/infblock.h
+++ b/infblock.h
@@ -12,23 +12,23 @@ struct inflate_blocks_state;
12typedef struct inflate_blocks_state FAR inflate_blocks_statef; 12typedef struct inflate_blocks_state FAR inflate_blocks_statef;
13 13
14extern inflate_blocks_statef * inflate_blocks_new OF(( 14extern inflate_blocks_statef * inflate_blocks_new OF((
15 z_stream *z, 15 z_streamp z,
16 check_func c, /* check function */ 16 check_func c, /* check function */
17 uInt w)); /* window size */ 17 uInt w)); /* window size */
18 18
19extern int inflate_blocks OF(( 19extern int inflate_blocks OF((
20 inflate_blocks_statef *, 20 inflate_blocks_statef *,
21 z_stream *, 21 z_streamp ,
22 int)); /* initial return code */ 22 int)); /* initial return code */
23 23
24extern void inflate_blocks_reset OF(( 24extern void inflate_blocks_reset OF((
25 inflate_blocks_statef *, 25 inflate_blocks_statef *,
26 z_stream *, 26 z_streamp ,
27 uLongf *)); /* check value on output */ 27 uLongf *)); /* check value on output */
28 28
29extern int inflate_blocks_free OF(( 29extern int inflate_blocks_free OF((
30 inflate_blocks_statef *, 30 inflate_blocks_statef *,
31 z_stream *, 31 z_streamp ,
32 uLongf *)); /* check value on output */ 32 uLongf *)); /* check value on output */
33 33
34extern void inflate_set_dictionary OF(( 34extern void inflate_set_dictionary OF((
diff --git a/infcodes.c b/infcodes.c
index 6314e80..3ae3818 100644
--- a/infcodes.c
+++ b/infcodes.c
@@ -60,7 +60,7 @@ inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z)
60uInt bl, bd; 60uInt bl, bd;
61inflate_huft *tl; 61inflate_huft *tl;
62inflate_huft *td; /* need separate declaration for Borland C++ */ 62inflate_huft *td; /* need separate declaration for Borland C++ */
63z_stream *z; 63z_streamp z;
64{ 64{
65 inflate_codes_statef *c; 65 inflate_codes_statef *c;
66 66
@@ -80,7 +80,7 @@ z_stream *z;
80 80
81int inflate_codes(s, z, r) 81int inflate_codes(s, z, r)
82inflate_blocks_statef *s; 82inflate_blocks_statef *s;
83z_stream *z; 83z_streamp z;
84int r; 84int r;
85{ 85{
86 uInt j; /* temporary storage */ 86 uInt j; /* temporary storage */
@@ -240,7 +240,7 @@ int r;
240 240
241void inflate_codes_free(c, z) 241void inflate_codes_free(c, z)
242inflate_codes_statef *c; 242inflate_codes_statef *c;
243z_stream *z; 243z_streamp z;
244{ 244{
245 ZFREE(z, c); 245 ZFREE(z, c);
246 Tracev((stderr, "inflate: codes free\n")); 246 Tracev((stderr, "inflate: codes free\n"));
diff --git a/infcodes.h b/infcodes.h
index 8671efa..c2c38df 100644
--- a/infcodes.h
+++ b/infcodes.h
@@ -14,14 +14,14 @@ typedef struct inflate_codes_state FAR inflate_codes_statef;
14extern inflate_codes_statef *inflate_codes_new OF(( 14extern inflate_codes_statef *inflate_codes_new OF((
15 uInt, uInt, 15 uInt, uInt,
16 inflate_huft *, inflate_huft *, 16 inflate_huft *, inflate_huft *,
17 z_stream *)); 17 z_streamp ));
18 18
19extern int inflate_codes OF(( 19extern int inflate_codes OF((
20 inflate_blocks_statef *, 20 inflate_blocks_statef *,
21 z_stream *, 21 z_streamp ,
22 int)); 22 int));
23 23
24extern void inflate_codes_free OF(( 24extern void inflate_codes_free OF((
25 inflate_codes_statef *, 25 inflate_codes_statef *,
26 z_stream *)); 26 z_streamp ));
27 27
diff --git a/inffast.c b/inffast.c
index 209c0ee..86eee4a 100644
--- a/inffast.c
+++ b/inffast.c
@@ -32,7 +32,7 @@ uInt bl, bd;
32inflate_huft *tl; 32inflate_huft *tl;
33inflate_huft *td; /* need separate declaration for Borland C++ */ 33inflate_huft *td; /* need separate declaration for Borland C++ */
34inflate_blocks_statef *s; 34inflate_blocks_statef *s;
35z_stream *z; 35z_streamp z;
36{ 36{
37 inflate_huft *t; /* temporary pointer */ 37 inflate_huft *t; /* temporary pointer */
38 uInt e; /* extra bits or operation */ 38 uInt e; /* extra bits or operation */
diff --git a/inffast.h b/inffast.h
index 843051f..8cc644e 100644
--- a/inffast.h
+++ b/inffast.h
@@ -14,4 +14,4 @@ extern int inflate_fast OF((
14 inflate_huft *, 14 inflate_huft *,
15 inflate_huft *, 15 inflate_huft *,
16 inflate_blocks_statef *, 16 inflate_blocks_statef *,
17 z_stream *)); 17 z_streamp ));
diff --git a/inflate.c b/inflate.c
index 4eed100..74cc69c 100644
--- a/inflate.c
+++ b/inflate.c
@@ -49,7 +49,7 @@ struct internal_state {
49 49
50 50
51int inflateReset(z) 51int inflateReset(z)
52z_stream *z; 52z_streamp z;
53{ 53{
54 uLong c; 54 uLong c;
55 55
@@ -65,7 +65,7 @@ z_stream *z;
65 65
66 66
67int inflateEnd(z) 67int inflateEnd(z)
68z_stream *z; 68z_streamp z;
69{ 69{
70 uLong c; 70 uLong c;
71 71
@@ -81,7 +81,7 @@ z_stream *z;
81 81
82 82
83int inflateInit2_(z, w, version, stream_size) 83int inflateInit2_(z, w, version, stream_size)
84z_stream *z; 84z_streamp z;
85int w; 85int w;
86const char *version; 86const char *version;
87int stream_size; 87int stream_size;
@@ -138,7 +138,7 @@ int stream_size;
138 138
139 139
140int inflateInit_(z, version, stream_size) 140int inflateInit_(z, version, stream_size)
141z_stream *z; 141z_streamp z;
142const char *version; 142const char *version;
143int stream_size; 143int stream_size;
144{ 144{
@@ -150,7 +150,7 @@ int stream_size;
150#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) 150#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
151 151
152int inflate(z, f) 152int inflate(z, f)
153z_stream *z; 153z_streamp z;
154int f; 154int f;
155{ 155{
156 int r; 156 int r;
@@ -272,7 +272,7 @@ int f;
272 272
273 273
274int inflateSetDictionary(z, dictionary, dictLength) 274int inflateSetDictionary(z, dictionary, dictLength)
275z_stream *z; 275z_streamp z;
276const Bytef *dictionary; 276const Bytef *dictionary;
277uInt dictLength; 277uInt dictLength;
278{ 278{
@@ -280,6 +280,7 @@ uInt dictLength;
280 280
281 if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0) 281 if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0)
282 return Z_STREAM_ERROR; 282 return Z_STREAM_ERROR;
283
283 if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR; 284 if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;
284 z->adler = 1L; 285 z->adler = 1L;
285 286
@@ -295,7 +296,7 @@ uInt dictLength;
295 296
296 297
297int inflateSync(z) 298int inflateSync(z)
298z_stream *z; 299z_streamp z;
299{ 300{
300 uInt n; /* number of bytes to look at */ 301 uInt n; /* number of bytes to look at */
301 Bytef *p; /* pointer to bytes */ 302 Bytef *p; /* pointer to bytes */
diff --git a/inftrees.c b/inftrees.c
index ebeac0d..90205bd 100644
--- a/inftrees.c
+++ b/inftrees.c
@@ -6,7 +6,7 @@
6#include "zutil.h" 6#include "zutil.h"
7#include "inftrees.h" 7#include "inftrees.h"
8 8
9char inflate_copyright[] = " inflate 1.0.2 Copyright 1995-1996 Mark Adler "; 9char inflate_copyright[] = " inflate 1.0.4 Copyright 1995-1996 Mark Adler ";
10/* 10/*
11 If you use the zlib library in a product, an acknowledgment is welcome 11 If you use the zlib library in a product, an acknowledgment is welcome
12 in the documentation of your product. If for some reason you cannot 12 in the documentation of your product. If for some reason you cannot
@@ -30,7 +30,7 @@ local int huft_build OF((
30 uIntf *, /* list of extra bits for non-simple codes */ 30 uIntf *, /* list of extra bits for non-simple codes */
31 inflate_huft * FAR*,/* result: starting table */ 31 inflate_huft * FAR*,/* result: starting table */
32 uIntf *, /* maximum lookup bits (returns actual) */ 32 uIntf *, /* maximum lookup bits (returns actual) */
33 z_stream *)); /* for zalloc function */ 33 z_streamp )); /* for zalloc function */
34 34
35local voidpf falloc OF(( 35local voidpf falloc OF((
36 voidpf, /* opaque pointer (not used) */ 36 voidpf, /* opaque pointer (not used) */
@@ -103,7 +103,7 @@ uIntf *d; /* list of base values for non-simple codes */
103uIntf *e; /* list of extra bits for non-simple codes */ 103uIntf *e; /* list of extra bits for non-simple codes */
104inflate_huft * FAR *t; /* result: starting table */ 104inflate_huft * FAR *t; /* result: starting table */
105uIntf *m; /* maximum lookup bits, returns actual */ 105uIntf *m; /* maximum lookup bits, returns actual */
106z_stream *zs; /* for zalloc function */ 106z_streamp zs; /* for zalloc function */
107/* Given a list of code lengths and a maximum table size, make a set of 107/* Given a list of code lengths and a maximum table size, make a set of
108 tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR 108 tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
109 if the given code set is incomplete (the tables are still built in this 109 if the given code set is incomplete (the tables are still built in this
@@ -302,7 +302,7 @@ int inflate_trees_bits(c, bb, tb, z)
302uIntf *c; /* 19 code lengths */ 302uIntf *c; /* 19 code lengths */
303uIntf *bb; /* bits tree desired/actual depth */ 303uIntf *bb; /* bits tree desired/actual depth */
304inflate_huft * FAR *tb; /* bits tree result */ 304inflate_huft * FAR *tb; /* bits tree result */
305z_stream *z; /* for zfree function */ 305z_streamp z; /* for zfree function */
306{ 306{
307 int r; 307 int r;
308 308
@@ -327,7 +327,7 @@ uIntf *bl; /* literal desired/actual bit depth */
327uIntf *bd; /* distance desired/actual bit depth */ 327uIntf *bd; /* distance desired/actual bit depth */
328inflate_huft * FAR *tl; /* literal/length tree result */ 328inflate_huft * FAR *tl; /* literal/length tree result */
329inflate_huft * FAR *td; /* distance tree result */ 329inflate_huft * FAR *td; /* distance tree result */
330z_stream *z; /* for zfree function */ 330z_streamp z; /* for zfree function */
331{ 331{
332 int r; 332 int r;
333 333
@@ -442,7 +442,7 @@ inflate_huft * FAR *td; /* distance tree result */
442 442
443int inflate_trees_free(t, z) 443int inflate_trees_free(t, z)
444inflate_huft *t; /* table to free */ 444inflate_huft *t; /* table to free */
445z_stream *z; /* for zfree function */ 445z_streamp z; /* for zfree function */
446/* Free the malloc'ed tables built by huft_build(), which makes a linked 446/* Free the malloc'ed tables built by huft_build(), which makes a linked
447 list of the tables it made, with the links in a dummy first entry of 447 list of the tables it made, with the links in a dummy first entry of
448 each table. */ 448 each table. */
diff --git a/inftrees.h b/inftrees.h
index 0f0ca2b..b06613d 100644
--- a/inftrees.h
+++ b/inftrees.h
@@ -35,7 +35,7 @@ extern int inflate_trees_bits OF((
35 uIntf *, /* 19 code lengths */ 35 uIntf *, /* 19 code lengths */
36 uIntf *, /* bits tree desired/actual depth */ 36 uIntf *, /* bits tree desired/actual depth */
37 inflate_huft * FAR *, /* bits tree result */ 37 inflate_huft * FAR *, /* bits tree result */
38 z_stream *)); /* for zalloc, zfree functions */ 38 z_streamp )); /* for zalloc, zfree functions */
39 39
40extern int inflate_trees_dynamic OF(( 40extern int inflate_trees_dynamic OF((
41 uInt, /* number of literal/length codes */ 41 uInt, /* number of literal/length codes */
@@ -45,7 +45,7 @@ extern int inflate_trees_dynamic OF((
45 uIntf *, /* distance desired/actual bit depth */ 45 uIntf *, /* distance desired/actual bit depth */
46 inflate_huft * FAR *, /* literal/length tree result */ 46 inflate_huft * FAR *, /* literal/length tree result */
47 inflate_huft * FAR *, /* distance tree result */ 47 inflate_huft * FAR *, /* distance tree result */
48 z_stream *)); /* for zalloc, zfree functions */ 48 z_streamp )); /* for zalloc, zfree functions */
49 49
50extern int inflate_trees_fixed OF(( 50extern int inflate_trees_fixed OF((
51 uIntf *, /* literal desired/actual bit depth */ 51 uIntf *, /* literal desired/actual bit depth */
@@ -55,5 +55,5 @@ extern int inflate_trees_fixed OF((
55 55
56extern int inflate_trees_free OF(( 56extern int inflate_trees_free OF((
57 inflate_huft *, /* tables to free */ 57 inflate_huft *, /* tables to free */
58 z_stream *)); /* for zfree function */ 58 z_streamp )); /* for zfree function */
59 59
diff --git a/infutil.c b/infutil.c
index b56f8cd..eb21199 100644
--- a/infutil.c
+++ b/infutil.c
@@ -22,7 +22,7 @@ uInt inflate_mask[17] = {
22/* copy as much as possible from the sliding window to the output area */ 22/* copy as much as possible from the sliding window to the output area */
23int inflate_flush(s, z, r) 23int inflate_flush(s, z, r)
24inflate_blocks_statef *s; 24inflate_blocks_statef *s;
25z_stream *z; 25z_streamp z;
26int r; 26int r;
27{ 27{
28 uInt n; 28 uInt n;
diff --git a/infutil.h b/infutil.h
index ff7ac15..702cd29 100644
--- a/infutil.h
+++ b/infutil.h
@@ -91,7 +91,7 @@ extern uInt inflate_mask[17];
91/* copy as much as possible from the sliding window to the output area */ 91/* copy as much as possible from the sliding window to the output area */
92extern int inflate_flush OF(( 92extern int inflate_flush OF((
93 inflate_blocks_statef *, 93 inflate_blocks_statef *,
94 z_stream *, 94 z_streamp ,
95 int)); 95 int));
96 96
97struct internal_state {int dummy;}; /* for buggy compilers */ 97struct internal_state {int dummy;}; /* for buggy compilers */
diff --git a/minigzip.c b/minigzip.c
index bd0735b..fcee6a2 100644
--- a/minigzip.c
+++ b/minigzip.c
@@ -13,7 +13,7 @@
13 * or in pipe mode. 13 * or in pipe mode.
14 */ 14 */
15 15
16/* $Id: minigzip.c,v 1.9 1996/05/22 11:52:32 me Exp $ */ 16/* $Id: minigzip.c,v 1.10 1996/07/24 13:41:04 me Exp $ */
17 17
18#include <stdio.h> 18#include <stdio.h>
19#include "zlib.h" 19#include "zlib.h"
@@ -37,7 +37,14 @@
37#ifdef VMS 37#ifdef VMS
38# define unlink delete 38# define unlink delete
39# define GZ_SUFFIX "-gz" 39# define GZ_SUFFIX "-gz"
40#else 40#endif
41#ifdef RISCOS
42# define unlink remove
43# define GZ_SUFFIX "-gz"
44# define fileno(file) file->__file
45#endif
46
47#ifndef GZ_SUFFIX
41# define GZ_SUFFIX ".gz" 48# define GZ_SUFFIX ".gz"
42#endif 49#endif
43#define SUFFIX_LEN sizeof(GZ_SUFFIX) 50#define SUFFIX_LEN sizeof(GZ_SUFFIX)
diff --git a/trees.c b/trees.c
index f943d06..4c4d6f2 100644
--- a/trees.c
+++ b/trees.c
@@ -29,7 +29,7 @@
29 * Addison-Wesley, 1983. ISBN 0-201-06672-6. 29 * Addison-Wesley, 1983. ISBN 0-201-06672-6.
30 */ 30 */
31 31
32/* $Id: trees.c,v 1.10 1996/05/22 11:52:34 me Exp $ */ 32/* $Id: trees.c,v 1.11 1996/07/24 13:41:06 me Exp $ */
33 33
34#include "deflate.h" 34#include "deflate.h"
35 35
@@ -154,7 +154,7 @@ local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
154 154
155#else /* DEBUG */ 155#else /* DEBUG */
156# define send_code(s, c, tree) \ 156# define send_code(s, c, tree) \
157 { if (verbose>1) fprintf(stderr,"\ncd %3d ",(c)); \ 157 { if (verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
158 send_bits(s, tree[c].Code, tree[c].Len); } 158 send_bits(s, tree[c].Code, tree[c].Len); }
159#endif 159#endif
160 160
diff --git a/zconf.h b/zconf.h
index 69aa21b..5f6e887 100644
--- a/zconf.h
+++ b/zconf.h
@@ -3,7 +3,7 @@
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
6/* $Id: zconf.h,v 1.18 1996/05/23 16:51:18 me Exp $ */ 6/* $Id: zconf.h,v 1.20 1996/07/02 15:09:28 me Exp $ */
7 7
8#ifndef _ZCONF_H 8#ifndef _ZCONF_H
9#define _ZCONF_H 9#define _ZCONF_H
@@ -49,8 +49,10 @@
49#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) 49#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
50# define WIN32 50# define WIN32
51#endif 51#endif
52#if (defined(__GNUC__) || defined(WIN32)) && !defined(__32BIT__) 52#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386)
53# define __32BIT__ 53# ifndef __32BIT__
54# define __32BIT__
55# endif
54#endif 56#endif
55#if defined(__MSDOS__) && !defined(MSDOS) 57#if defined(__MSDOS__) && !defined(MSDOS)
56# define MSDOS 58# define MSDOS
@@ -80,9 +82,9 @@
80# endif 82# endif
81#endif 83#endif
82 84
83#ifdef __MWERKS__ /* Metrowerks CodeWarrior declares fileno() in unix.h */ 85/* Some Mac compilers merge all .h files incorrectly: */
84# include <unix.h> 86#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
85# define NO_DUMMY_DECL /* buggy compiler merges all .h files incorrectly */ 87# define NO_DUMMY_DECL
86#endif 88#endif
87 89
88/* Maximum value for memLevel in deflateInit2 */ 90/* Maximum value for memLevel in deflateInit2 */
@@ -146,12 +148,6 @@
146#ifndef FAR 148#ifndef FAR
147# define FAR 149# define FAR
148#endif 150#endif
149/* The Watcom compiler defines M_I86SM and __SMALL__ even in 32 bit mode */
150#if defined(__WATCOMC__) && defined(__386__) && defined(SMALL_MEDIUM)
151# undef FAR
152# define FAR
153# undef SMALL_MEDIUM
154#endif
155 151
156typedef unsigned char Byte; /* 8 bits */ 152typedef unsigned char Byte; /* 8 bits */
157typedef unsigned int uInt; /* 16 bits or more */ 153typedef unsigned int uInt; /* 16 bits or more */
diff --git a/zlib.def b/zlib.def
index 0f5049f..08c6d55 100644
--- a/zlib.def
+++ b/zlib.def
@@ -8,7 +8,7 @@ SUBSYSTEM WINDOWS
8 8
9STUB 'WINSTUB.EXE' 9STUB 'WINSTUB.EXE'
10 10
11VERSION 1.0.2 11VERSION 1.04
12 12
13CODE EXECUTE READ 13CODE EXECUTE READ
14 14
diff --git a/zlib.h b/zlib.h
index 1e61491..337fe9f 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1,5 +1,5 @@
1/* zlib.h -- interface of the 'zlib' general purpose compression library 1/* zlib.h -- interface of the 'zlib' general purpose compression library
2 version 1.0.2, May 23rd, 1996. 2 version 1.0.4, Jul 24th, 1996.
3 3
4 Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler 4 Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler
5 5
@@ -37,7 +37,7 @@ extern "C" {
37 37
38#include "zconf.h" 38#include "zconf.h"
39 39
40#define ZLIB_VERSION "1.0.2" 40#define ZLIB_VERSION "1.0.4"
41 41
42/* 42/*
43 The 'zlib' compression library provides in-memory compression and 43 The 'zlib' compression library provides in-memory compression and
@@ -89,6 +89,8 @@ typedef struct z_stream_s {
89 uLong reserved; /* reserved for future use */ 89 uLong reserved; /* reserved for future use */
90} z_stream; 90} z_stream;
91 91
92typedef z_stream FAR *z_streamp;
93
92/* 94/*
93 The application must update next_in and avail_in when avail_in has 95 The application must update next_in and avail_in when avail_in has
94 dropped to zero. It must update next_out and avail_out when avail_out 96 dropped to zero. It must update next_out and avail_out when avail_out
@@ -166,7 +168,7 @@ typedef struct z_stream_s {
166 168
167 /* basic functions */ 169 /* basic functions */
168 170
169extern char EXPORT *zlibVersion OF((void)); 171extern const char * EXPORT zlibVersion OF((void));
170/* The application can compare zlibVersion and ZLIB_VERSION for consistency. 172/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
171 If the first character differs, the library code actually used is 173 If the first character differs, the library code actually used is
172 not compatible with the zlib.h header file used by the application. 174 not compatible with the zlib.h header file used by the application.
@@ -174,7 +176,7 @@ extern char EXPORT *zlibVersion OF((void));
174 */ 176 */
175 177
176/* 178/*
177extern int EXPORT deflateInit OF((z_stream *strm, int level)); 179extern int EXPORT deflateInit OF((z_streamp strm, int level));
178 180
179 Initializes the internal stream state for compression. The fields 181 Initializes the internal stream state for compression. The fields
180 zalloc, zfree and opaque must be initialized before by the caller. 182 zalloc, zfree and opaque must be initialized before by the caller.
@@ -196,7 +198,7 @@ extern int EXPORT deflateInit OF((z_stream *strm, int level));
196*/ 198*/
197 199
198 200
199extern int EXPORT deflate OF((z_stream *strm, int flush)); 201extern int EXPORT deflate OF((z_streamp strm, int flush));
200/* 202/*
201 Performs one or both of the following actions: 203 Performs one or both of the following actions:
202 204
@@ -239,8 +241,8 @@ extern int EXPORT deflate OF((z_stream *strm, int flush));
239 parameter and more output space (updated avail_out), until the flush is 241 parameter and more output space (updated avail_out), until the flush is
240 complete (deflate returns with non-zero avail_out). 242 complete (deflate returns with non-zero avail_out).
241 243
242 If the parameter flush is set to Z_FINISH, all pending input is processed, 244 If the parameter flush is set to Z_FINISH, pending input is processed,
243 all pending output is flushed and deflate returns with Z_STREAM_END if there 245 pending output is flushed and deflate returns with Z_STREAM_END if there
244 was enough output space; if deflate returns with Z_OK, this function must be 246 was enough output space; if deflate returns with Z_OK, this function must be
245 called again with Z_FINISH and more output space (updated avail_out) but no 247 called again with Z_FINISH and more output space (updated avail_out) but no
246 more input data, until it returns with Z_STREAM_END or an error. After 248 more input data, until it returns with Z_STREAM_END or an error. After
@@ -265,7 +267,7 @@ extern int EXPORT deflate OF((z_stream *strm, int flush));
265*/ 267*/
266 268
267 269
268extern int EXPORT deflateEnd OF((z_stream *strm)); 270extern int EXPORT deflateEnd OF((z_streamp strm));
269/* 271/*
270 All dynamically allocated data structures for this stream are freed. 272 All dynamically allocated data structures for this stream are freed.
271 This function discards any unprocessed input and does not flush any 273 This function discards any unprocessed input and does not flush any
@@ -280,7 +282,7 @@ extern int EXPORT deflateEnd OF((z_stream *strm));
280 282
281 283
282/* 284/*
283extern int EXPORT inflateInit OF((z_stream *strm)); 285extern int EXPORT inflateInit OF((z_streamp strm));
284 286
285 Initializes the internal stream state for decompression. The fields 287 Initializes the internal stream state for decompression. The fields
286 zalloc, zfree and opaque must be initialized before by the caller. If 288 zalloc, zfree and opaque must be initialized before by the caller. If
@@ -295,7 +297,7 @@ extern int EXPORT inflateInit OF((z_stream *strm));
295*/ 297*/
296 298
297 299
298extern int EXPORT inflate OF((z_stream *strm, int flush)); 300extern int EXPORT inflate OF((z_streamp strm, int flush));
299/* 301/*
300 Performs one or both of the following actions: 302 Performs one or both of the following actions:
301 303
@@ -350,7 +352,7 @@ extern int EXPORT inflate OF((z_stream *strm, int flush));
350*/ 352*/
351 353
352 354
353extern int EXPORT inflateEnd OF((z_stream *strm)); 355extern int EXPORT inflateEnd OF((z_streamp strm));
354/* 356/*
355 All dynamically allocated data structures for this stream are freed. 357 All dynamically allocated data structures for this stream are freed.
356 This function discards any unprocessed input and does not flush any 358 This function discards any unprocessed input and does not flush any
@@ -368,7 +370,7 @@ extern int EXPORT inflateEnd OF((z_stream *strm));
368*/ 370*/
369 371
370/* 372/*
371extern int EXPORT deflateInit2 OF((z_stream *strm, 373extern int EXPORT deflateInit2 OF((z_streamp strm,
372 int level, 374 int level,
373 int method, 375 int method,
374 int windowBits, 376 int windowBits,
@@ -426,7 +428,7 @@ extern int EXPORT deflateInit2 OF((z_stream *strm,
426 deflate(). 428 deflate().
427*/ 429*/
428 430
429extern int EXPORT deflateSetDictionary OF((z_stream *strm, 431extern int EXPORT deflateSetDictionary OF((z_streamp strm,
430 const Bytef *dictionary, 432 const Bytef *dictionary,
431 uInt dictLength)); 433 uInt dictLength));
432/* 434/*
@@ -455,8 +457,8 @@ extern int EXPORT deflateSetDictionary OF((z_stream *strm,
455 be done by deflate(). 457 be done by deflate().
456*/ 458*/
457 459
458extern int EXPORT deflateCopy OF((z_stream *dest, 460extern int EXPORT deflateCopy OF((z_streamp dest,
459 z_stream *source)); 461 z_streamp source));
460/* 462/*
461 Sets the destination stream as a complete copy of the source stream. If 463 Sets the destination stream as a complete copy of the source stream. If
462 the source stream is using an application-supplied history buffer, a new 464 the source stream is using an application-supplied history buffer, a new
@@ -478,7 +480,7 @@ extern int EXPORT deflateCopy OF((z_stream *dest,
478 destination. 480 destination.
479*/ 481*/
480 482
481extern int EXPORT deflateReset OF((z_stream *strm)); 483extern int EXPORT deflateReset OF((z_streamp strm));
482/* 484/*
483 This function is equivalent to deflateEnd followed by deflateInit, 485 This function is equivalent to deflateEnd followed by deflateInit,
484 but does not free and reallocate all the internal compression state. 486 but does not free and reallocate all the internal compression state.
@@ -489,7 +491,7 @@ extern int EXPORT deflateReset OF((z_stream *strm));
489 stream state was inconsistent (such as zalloc or state being NULL). 491 stream state was inconsistent (such as zalloc or state being NULL).
490*/ 492*/
491 493
492extern int EXPORT deflateParams OF((z_stream *strm, int level, int strategy)); 494extern int EXPORT deflateParams OF((z_streamp strm, int level, int strategy));
493/* 495/*
494 Dynamically update the compression level and compression strategy. 496 Dynamically update the compression level and compression strategy.
495 This can be used to switch between compression and straight copy of 497 This can be used to switch between compression and straight copy of
@@ -508,7 +510,7 @@ extern int EXPORT deflateParams OF((z_stream *strm, int level, int strategy));
508*/ 510*/
509 511
510/* 512/*
511extern int EXPORT inflateInit2 OF((z_stream *strm, 513extern int EXPORT inflateInit2 OF((z_streamp strm,
512 int windowBits)); 514 int windowBits));
513 515
514 This is another version of inflateInit with more compression options. The 516 This is another version of inflateInit with more compression options. The
@@ -542,7 +544,7 @@ extern int EXPORT inflateInit2 OF((z_stream *strm,
542 inflate(). 544 inflate().
543*/ 545*/
544 546
545extern int EXPORT inflateSetDictionary OF((z_stream *strm, 547extern int EXPORT inflateSetDictionary OF((z_streamp strm,
546 const Bytef *dictionary, 548 const Bytef *dictionary,
547 uInt dictLength)); 549 uInt dictLength));
548/* 550/*
@@ -561,7 +563,7 @@ extern int EXPORT inflateSetDictionary OF((z_stream *strm,
561 inflate(). 563 inflate().
562*/ 564*/
563 565
564extern int EXPORT inflateSync OF((z_stream *strm)); 566extern int EXPORT inflateSync OF((z_streamp strm));
565/* 567/*
566 Skips invalid compressed data until the special marker (see deflate() 568 Skips invalid compressed data until the special marker (see deflate()
567 above) can be found, or until all available input is skipped. No output 569 above) can be found, or until all available input is skipped. No output
@@ -576,7 +578,7 @@ extern int EXPORT inflateSync OF((z_stream *strm));
576 until success or end of the input data. 578 until success or end of the input data.
577*/ 579*/
578 580
579extern int EXPORT inflateReset OF((z_stream *strm)); 581extern int EXPORT inflateReset OF((z_streamp strm));
580/* 582/*
581 This function is equivalent to inflateEnd followed by inflateInit, 583 This function is equivalent to inflateEnd followed by inflateInit,
582 but does not free and reallocate all the internal decompression state. 584 but does not free and reallocate all the internal decompression state.
@@ -690,7 +692,7 @@ extern int EXPORT gzclose OF((gzFile file));
690 error number (see function gzerror below). 692 error number (see function gzerror below).
691*/ 693*/
692 694
693extern char EXPORT *gzerror OF((gzFile file, int *errnum)); 695extern const char * EXPORT gzerror OF((gzFile file, int *errnum));
694/* 696/*
695 Returns the error message for the last error which occurred on the 697 Returns the error message for the last error which occurred on the
696 given compressed file. errnum is set to zlib error number. If an 698 given compressed file. errnum is set to zlib error number. If an
@@ -746,14 +748,14 @@ extern uLong EXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
746/* deflateInit and inflateInit are macros to allow checking the zlib version 748/* deflateInit and inflateInit are macros to allow checking the zlib version
747 * and the compiler's view of z_stream: 749 * and the compiler's view of z_stream:
748 */ 750 */
749extern int EXPORT deflateInit_ OF((z_stream *strm, int level, 751extern int EXPORT deflateInit_ OF((z_streamp strm, int level,
750 const char *version, int stream_size)); 752 const char *version, int stream_size));
751extern int EXPORT inflateInit_ OF((z_stream *strm, 753extern int EXPORT inflateInit_ OF((z_streamp strm,
752 const char *version, int stream_size)); 754 const char *version, int stream_size));
753extern int EXPORT deflateInit2_ OF((z_stream *strm, int level, int method, 755extern int EXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
754 int windowBits, int memLevel, int strategy, 756 int windowBits, int memLevel, int strategy,
755 const char *version, int stream_size)); 757 const char *version, int stream_size));
756extern int EXPORT inflateInit2_ OF((z_stream *strm, int windowBits, 758extern int EXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
757 const char *version, int stream_size)); 759 const char *version, int stream_size));
758#define deflateInit(strm, level) \ 760#define deflateInit(strm, level) \
759 deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) 761 deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
diff --git a/zlib.rc b/zlib.rc
index 5e1d0f7..2c0a3e4 100644
--- a/zlib.rc
+++ b/zlib.rc
@@ -2,8 +2,8 @@
2 2
3#define IDR_VERSION1 1 3#define IDR_VERSION1 1
4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
5 FILEVERSION 1,0,2,0 5 FILEVERSION 1,0,4,0
6 PRODUCTVERSION 1,0,2,0 6 PRODUCTVERSION 1,0,4,0
7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
8 FILEFLAGS 0 8 FILEFLAGS 0
9 FILEOS VOS_DOS_WINDOWS32 9 FILEOS VOS_DOS_WINDOWS32
@@ -17,7 +17,7 @@ BEGIN
17 17
18 BEGIN 18 BEGIN
19 VALUE "FileDescription", "zlib data compression library\0" 19 VALUE "FileDescription", "zlib data compression library\0"
20 VALUE "FileVersion", "1.0.2\0" 20 VALUE "FileVersion", "1.0.4\0"
21 VALUE "InternalName", "zlib\0" 21 VALUE "InternalName", "zlib\0"
22 VALUE "OriginalFilename", "zlib.lib\0" 22 VALUE "OriginalFilename", "zlib.lib\0"
23 VALUE "ProductName", "ZLib.DLL\0" 23 VALUE "ProductName", "ZLib.DLL\0"
diff --git a/zutil.c b/zutil.c
index f32fda5..734e275 100644
--- a/zutil.c
+++ b/zutil.c
@@ -3,7 +3,7 @@
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
6/* $Id: zutil.c,v 1.15 1996/05/23 17:11:36 me Exp $ */ 6/* $Id: zutil.c,v 1.17 1996/07/24 13:41:12 me Exp $ */
7 7
8#include <stdio.h> 8#include <stdio.h>
9 9
@@ -28,17 +28,19 @@ const char *z_errmsg[10] = {
28""}; 28""};
29 29
30 30
31char *zlibVersion() 31const char *zlibVersion()
32{ 32{
33 return ZLIB_VERSION; 33 return ZLIB_VERSION;
34} 34}
35 35
36#ifdef DEBUG
36void z_error (m) 37void z_error (m)
37 char *m; 38 char *m;
38{ 39{
39 fprintf(stderr, "%s\n", m); 40 fprintf(stderr, "%s\n", m);
40 exit(1); 41 exit(1);
41} 42}
43#endif
42 44
43#ifndef HAVE_MEMCPY 45#ifndef HAVE_MEMCPY
44 46
@@ -53,6 +55,19 @@ void zmemcpy(dest, source, len)
53 } while (--len != 0); 55 } while (--len != 0);
54} 56}
55 57
58int zmemcmp(s1, s2, len)
59 Bytef* s1;
60 Bytef* s2;
61 uInt len;
62{
63 uInt j;
64
65 for (j = 0; j < len; j++) {
66 if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
67 }
68 return 0;
69}
70
56void zmemzero(dest, len) 71void zmemzero(dest, len)
57 Bytef* dest; 72 Bytef* dest;
58 uInt len; 73 uInt len;
@@ -138,14 +153,14 @@ void zcfree (voidpf opaque, voidpf ptr)
138 return; 153 return;
139 } 154 }
140 ptr = opaque; /* just to make some compilers happy */ 155 ptr = opaque; /* just to make some compilers happy */
141 z_error("zcfree: ptr not found"); 156 Assert(0, "zcfree: ptr not found");
142} 157}
143#endif 158#endif
144#endif /* __TURBOC__ */ 159#endif /* __TURBOC__ */
145 160
146 161
147#if defined(M_I86) && !(defined(__WATCOMC__) && defined(__386__)) 162#if defined(M_I86) && !defined(__32BIT__)
148/* Microsoft C */ 163/* Microsoft C in 16-bit mode */
149 164
150# define MY_ZCALLOC 165# define MY_ZCALLOC
151 166
diff --git a/zutil.h b/zutil.h
index 5a53321..c81a9f9 100644
--- a/zutil.h
+++ b/zutil.h
@@ -8,14 +8,14 @@
8 subject to change. Applications should only use zlib.h. 8 subject to change. Applications should only use zlib.h.
9 */ 9 */
10 10
11/* $Id: zutil.h,v 1.14 1996/05/22 11:52:40 me Exp $ */ 11/* $Id: zutil.h,v 1.16 1996/07/24 13:41:13 me Exp $ */
12 12
13#ifndef _Z_UTIL_H 13#ifndef _Z_UTIL_H
14#define _Z_UTIL_H 14#define _Z_UTIL_H
15 15
16#include "zlib.h" 16#include "zlib.h"
17 17
18#if defined(MSDOS) || defined(VMS) || defined(CRAY) || defined(WIN32) 18#if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS)
19# include <stddef.h> 19# include <stddef.h>
20# include <errno.h> 20# include <errno.h>
21#else 21#else
@@ -40,10 +40,10 @@ typedef unsigned long ulg;
40extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ 40extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
41/* (size given to avoid silly warnings with Visual C++) */ 41/* (size given to avoid silly warnings with Visual C++) */
42 42
43#define ERR_MSG(err) (char*)z_errmsg[Z_NEED_DICT-(err)] 43#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
44 44
45#define ERR_RETURN(strm,err) \ 45#define ERR_RETURN(strm,err) \
46 return (strm->msg = ERR_MSG(err), (err)) 46 return (strm->msg = (char*)ERR_MSG(err), (err))
47/* To be used only when the state is known to be valid */ 47/* To be used only when the state is known to be valid */
48 48
49 /* common constants */ 49 /* common constants */
@@ -116,7 +116,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
116# define OS_CODE 0x0a 116# define OS_CODE 0x0a
117#endif 117#endif
118 118
119#ifdef _BEOS_ 119#if defined(_BEOS_) || defined(RISCOS)
120# define fdopen(fd,mode) NULL /* No fdopen() */ 120# define fdopen(fd,mode) NULL /* No fdopen() */
121#endif 121#endif
122 122
@@ -163,6 +163,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
163# endif 163# endif
164#else 164#else
165 extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len)); 165 extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len));
166 extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len));
166 extern void zmemzero OF((Bytef* dest, uInt len)); 167 extern void zmemzero OF((Bytef* dest, uInt len));
167#endif 168#endif
168 169
@@ -172,6 +173,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
172# ifndef verbose 173# ifndef verbose
173# define verbose 0 174# define verbose 0
174# endif 175# endif
176 extern void z_error OF((char *m));
175# define Assert(cond,msg) {if(!(cond)) z_error(msg);} 177# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
176# define Trace(x) fprintf x 178# define Trace(x) fprintf x
177# define Tracev(x) {if (verbose) fprintf x ;} 179# define Tracev(x) {if (verbose) fprintf x ;}
@@ -190,8 +192,6 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
190 192
191typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len)); 193typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len));
192 194
193extern void z_error OF((char *m));
194
195voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); 195voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
196void zcfree OF((voidpf opaque, voidpf ptr)); 196void zcfree OF((voidpf opaque, voidpf ptr));
197 197