diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:17:02 -0700 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:17:02 -0700 |
| commit | ff11b0a61f7345572ff2e413173d3179486162f2 (patch) | |
| tree | f3c9e2563c4f0ac6684a0012ad48423d4c6aa798 | |
| parent | e26a448e9673d67dc2866e11a48d24fc352e5f80 (diff) | |
| download | zlib-ff11b0a61f7345572ff2e413173d3179486162f2.tar.gz zlib-ff11b0a61f7345572ff2e413173d3179486162f2.tar.bz2 zlib-ff11b0a61f7345572ff2e413173d3179486162f2.zip | |
zlib 1.0.4v1.0.4
Diffstat (limited to '')
| -rw-r--r-- | ChangeLog | 19 | ||||
| -rw-r--r-- | INDEX | 1 | ||||
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | Makefile.dj2 | 7 | ||||
| -rw-r--r-- | Makefile.in | 2 | ||||
| -rw-r--r-- | Makefile.msc | 4 | ||||
| -rw-r--r-- | Makefile.riscos | 46 | ||||
| -rw-r--r-- | README | 33 | ||||
| -rw-r--r-- | algorithm.doc | 14 | ||||
| -rw-r--r-- | deflate.c | 145 | ||||
| -rw-r--r-- | deflate.h | 4 | ||||
| -rw-r--r-- | gzio.c | 12 | ||||
| -rw-r--r-- | infblock.c | 8 | ||||
| -rw-r--r-- | infblock.h | 8 | ||||
| -rw-r--r-- | infcodes.c | 6 | ||||
| -rw-r--r-- | infcodes.h | 6 | ||||
| -rw-r--r-- | inffast.c | 2 | ||||
| -rw-r--r-- | inffast.h | 2 | ||||
| -rw-r--r-- | inflate.c | 15 | ||||
| -rw-r--r-- | inftrees.c | 12 | ||||
| -rw-r--r-- | inftrees.h | 6 | ||||
| -rw-r--r-- | infutil.c | 2 | ||||
| -rw-r--r-- | infutil.h | 2 | ||||
| -rw-r--r-- | minigzip.c | 11 | ||||
| -rw-r--r-- | trees.c | 4 | ||||
| -rw-r--r-- | zconf.h | 20 | ||||
| -rw-r--r-- | zlib.def | 2 | ||||
| -rw-r--r-- | zlib.h | 54 | ||||
| -rw-r--r-- | zlib.rc | 6 | ||||
| -rw-r--r-- | zutil.c | 25 | ||||
| -rw-r--r-- | zutil.h | 14 |
31 files changed, 302 insertions, 192 deletions
| @@ -1,6 +1,25 @@ | |||
| 1 | 1 | ||
| 2 | ChangeLog file for zlib | 2 | ChangeLog file for zlib |
| 3 | 3 | ||
| 4 | Changes 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 | |||
| 12 | Changes 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 | |||
| 4 | Changes in 1.0.2 (23 May 96) | 23 | Changes 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) |
| @@ -7,6 +7,7 @@ Makefile.bor makefile for Borland C/C++ 16-bit | |||
| 7 | Makefile.dj2 makefile for DJGPP 2.x | 7 | Makefile.dj2 makefile for DJGPP 2.x |
| 8 | Makefile.in makefile for Unix (template for configure) | 8 | Makefile.in makefile for Unix (template for configure) |
| 9 | Makefile.msc makefile for Microsoft C 16-bit | 9 | Makefile.msc makefile for Microsoft C 16-bit |
| 10 | Makefile.riscos makefile for RISCOS | ||
| 10 | Makefile.sas makefile for Amiga SAS/C | 11 | Makefile.sas makefile for Amiga SAS/C |
| 11 | Makefile.tc makefile for Turbo C | 12 | Makefile.tc makefile for Turbo C |
| 12 | Makefile.wat makefile for Watcom C | 13 | Makefile.wat makefile for Watcom C |
| @@ -22,7 +22,7 @@ CFLAGS=-O | |||
| 22 | LDFLAGS=-L. -lz | 22 | LDFLAGS=-L. -lz |
| 23 | LDSHARED=$(CC) | 23 | LDSHARED=$(CC) |
| 24 | 24 | ||
| 25 | VER=1.0.2 | 25 | VER=1.0.4 |
| 26 | LIBS=libz.a | 26 | LIBS=libz.a |
| 27 | 27 | ||
| 28 | AR=ar rc | 28 | AR=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 | |||
| 42 | LD=$(CC) -s -o | 42 | LD=$(CC) -s -o |
| 43 | LDSHARED=$(CC) | 43 | LDSHARED=$(CC) |
| 44 | 44 | ||
| 45 | VER=1.0.2 | ||
| 46 | INCL=zlib.h zconf.h | 45 | INCL=zlib.h zconf.h |
| 47 | LIBS=libz.a | 46 | LIBS=libz.a |
| 48 | 47 | ||
| @@ -68,10 +67,6 @@ test: all | |||
| 68 | libz.a: $(OBJS) | 67 | libz.a: $(OBJS) |
| 69 | $(AR) $@ $(OBJS) | 68 | $(AR) $@ $(OBJS) |
| 70 | 69 | ||
| 71 | libz.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 | ||
| 92 | clean: | 87 | clean: |
| 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 | ||
| 95 | DEPS := $(wildcard *.d) | 90 | DEPS := $(wildcard *.d) |
| 96 | ifneq ($(DEPS),) | 91 | ifneq ($(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 | |||
| 22 | LDFLAGS=-L. -lz | 22 | LDFLAGS=-L. -lz |
| 23 | LDSHARED=$(CC) | 23 | LDSHARED=$(CC) |
| 24 | 24 | ||
| 25 | VER=1.0.2 | 25 | VER=1.0.4 |
| 26 | LIBS=libz.a | 26 | LIBS=libz.a |
| 27 | 27 | ||
| 28 | AR=ar rc | 28 | AR=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) \ | |||
| 28 | OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ | 28 | OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ |
| 29 | infutil$(O)+inffast$(O) | 29 | infutil$(O)+inffast$(O) |
| 30 | 30 | ||
| 31 | all: zlib.lib example.exe minigzip.exe | ||
| 32 | |||
| 31 | adler32.obj: adler32.c zutil.h zlib.h zconf.h | 33 | adler32.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: |
| 82 | zlib.lib: $(OBJ1) $(OBJ2) | 84 | zlib.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: | ||
| 5 | CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fnah | ||
| 6 | C++flags = -c -depend !Depend -IC: -throwback | ||
| 7 | Linkflags = -aif -c++ -o $@ | ||
| 8 | ObjAsmflags = -throwback -NoCache -depend !Depend | ||
| 9 | CMHGflags = | ||
| 10 | LibFileflags = -c -l -o $@ | ||
| 11 | Squeezeflags = -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: | ||
| 41 | o.minigzip: tests.c.minigzip | ||
| 42 | o.minigzip: h.zlib | ||
| 43 | o.minigzip: h.zconf | ||
| 44 | o.example: tests.c.example | ||
| 45 | o.example: h.zlib | ||
| 46 | o.example: h.zconf | ||
| @@ -1,4 +1,4 @@ | |||
| 1 | zlib 1.0.2 is a general purpose data compression library. All the code | 1 | zlib 1.0.4 is a general purpose data compression library. All the code |
| 2 | is reentrant (thread safe). The data format used by the zlib library | 2 | is reentrant (thread safe). The data format used by the zlib library |
| 3 | is described by RFCs (Request for Comments) 1950 to 1952 in the files | 3 | is described by RFCs (Request for Comments) 1950 to 1952 in the files |
| 4 | ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate | 4 | ftp://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 | ||
| 19 | Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov> or, | 19 | Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov> or, |
| 20 | if this fails, to the addresses given below in the Copyright section. | 20 | if this fails, to the addresses given below in the Copyright section. |
| 21 | The zlib home page is http://quest.jpl.nasa.gov/zlib/ | ||
| 22 | |||
| 23 | The changes made in version 1.0.4 are documented in the file ChangeLog. | ||
| 24 | The 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 | ||
| 22 | The changes made in version 1.0.2 are documented in the file ChangeLog. | ||
| 23 | The 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 | ||
| 37 | A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk> | 33 | A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk> |
| 38 | is in the CPAN (Comprehensive Perl Archive Network) sites, such as: | 34 | is 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 | ||
| 63 | Acknowledgments: | 62 | Acknowledgments: |
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, | |||
| 7 | length). Distances are limited to 32K bytes, and lengths are limited | 7 | length). Distances are limited to 32K bytes, and lengths are limited |
| 8 | to 258 bytes. When a string does not occur anywhere in the previous | 8 | to 258 bytes. When a string does not occur anywhere in the previous |
| 9 | 32K bytes, it is emitted as a sequence of literal bytes. (In this | 9 | 32K bytes, it is emitted as a sequence of literal bytes. (In this |
| 10 | description, 'string' must be taken as an arbitrary sequence of bytes, | 10 | description, `string' must be taken as an arbitrary sequence of bytes, |
| 11 | and is not restricted to printable characters.) | 11 | and is not restricted to printable characters.) |
| 12 | 12 | ||
| 13 | Literals or match lengths are compressed with one Huffman tree, and | 13 | Literals 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 | |||
| 16 | size (except that the compressed data for one block must fit in | 16 | size (except that the compressed data for one block must fit in |
| 17 | available memory). A block is terminated when deflate() determines that | 17 | available memory). A block is terminated when deflate() determines that |
| 18 | it would be useful to start another block with fresh trees. (This is | 18 | it would be useful to start another block with fresh trees. (This is |
| 19 | somewhat similar to compress.) | 19 | somewhat similar to the behavior of LZW-based _compress_.) |
| 20 | 20 | ||
| 21 | Duplicated strings are found using a hash table. All input strings of | 21 | Duplicated strings are found using a hash table. All input strings of |
| 22 | length 3 are inserted in the hash table. A hash index is computed for | 22 | length 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 | ||
| 58 | 2. Decompression algorithm (inflate) | 58 | 2. Decompression algorithm (inflate) |
| 59 | 59 | ||
| 60 | The real question is given a Huffman tree, how to decode fast. The most | 60 | The real question is, given a Huffman tree, how to decode fast. The most |
| 61 | important realization is that shorter codes are much more common than | 61 | important realization is that shorter codes are much more common than |
| 62 | longer codes, so pay attention to decoding the short codes fast, and let | 62 | longer codes, so pay attention to decoding the short codes fast, and let |
| 63 | the long codes take longer to decode. | 63 | the long codes take longer to decode. |
| @@ -84,7 +84,7 @@ all the data. For inflate, which has 286 possible codes for the | |||
| 84 | literal/length tree, the size of the first table is nine bits. Also the | 84 | literal/length tree, the size of the first table is nine bits. Also the |
| 85 | distance trees have 30 possible values, and the size of the first table is | 85 | distance trees have 30 possible values, and the size of the first table is |
| 86 | six bits. Note that for each of those cases, the table ended up one bit | 86 | six bits. Note that for each of those cases, the table ended up one bit |
| 87 | longer than the "average" code length, i.e. the code length of an | 87 | longer than the ``average'' code length, i.e. the code length of an |
| 88 | approximately flat code which would be a little more than eight bits for | 88 | approximately flat code which would be a little more than eight bits for |
| 89 | 286 symbols and a little less than five bits for 30 symbols. It would be | 89 | 286 symbols and a little less than five bits for 30 symbols. It would be |
| 90 | interesting to see if optimizing the first level table for other | 90 | interesting 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 | ||
| 98 | References: | 98 | References: |
| 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 |
| 101 | Compression", IEEE Transactions on Information Theory", Vol. 23, No. 3, | 101 | Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3, |
| 102 | pp. 337-343. | 102 | pp. 337-343. |
| 103 | 103 | ||
| 104 | "DEFLATE Compressed Data Format Specification" available in | 104 | ``DEFLATE Compressed Data Format Specification'' available in |
| 105 | ftp://ds.internic.net/rfc/rfc1951.txt | 105 | ftp://ds.internic.net/rfc/rfc1951.txt |
| @@ -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 | ||
| 54 | char deflate_copyright[] = " deflate 1.0.2 Copyright 1995-1996 Jean-loup Gailly "; | 54 | char 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 | */ |
| 65 | typedef 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 | |||
| 72 | typedef block_state (*compress_func) OF((deflate_state *s, int flush)); | ||
| 73 | /* Compression function. Returns the block state after the call. */ | ||
| 74 | |||
| 65 | local void fill_window OF((deflate_state *s)); | 75 | local void fill_window OF((deflate_state *s)); |
| 66 | local int deflate_stored OF((deflate_state *s, int flush)); | 76 | local block_state deflate_stored OF((deflate_state *s, int flush)); |
| 67 | local int deflate_fast OF((deflate_state *s, int flush)); | 77 | local block_state deflate_fast OF((deflate_state *s, int flush)); |
| 68 | local int deflate_slow OF((deflate_state *s, int flush)); | 78 | local block_state deflate_slow OF((deflate_state *s, int flush)); |
| 69 | local void lm_init OF((deflate_state *s)); | 79 | local void lm_init OF((deflate_state *s)); |
| 70 | local uInt longest_match OF((deflate_state *s, IPos cur_match)); | 80 | local uInt longest_match OF((deflate_state *s, IPos cur_match)); |
| 71 | local void putShortMSB OF((deflate_state *s, uInt b)); | 81 | local void putShortMSB OF((deflate_state *s, uInt b)); |
| 72 | local void flush_pending OF((z_stream *strm)); | 82 | local void flush_pending OF((z_streamp strm)); |
| 73 | local int read_buf OF((z_stream *strm, charf *buf, unsigned size)); | 83 | local 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 | ||
| 100 | typedef 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 | /* ========================================================================= */ |
| 171 | int deflateInit_(strm, level, version, stream_size) | 178 | int 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 | /* ========================================================================= */ |
| 183 | int deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | 190 | int 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 | /* ========================================================================= */ |
| 267 | int deflateSetDictionary (strm, dictionary, dictLength) | 274 | int 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 | /* ========================================================================= */ |
| 306 | int deflateReset (strm) | 313 | int 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 | /* ========================================================================= */ |
| 336 | int deflateParams(strm, level, strategy) | 343 | int 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 | */ |
| 390 | local void flush_pending(strm) | 397 | local 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 | /* ========================================================================= */ |
| 410 | int deflate (strm, flush) | 417 | int 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 | /* ========================================================================= */ |
| 525 | int deflateEnd (strm) | 551 | int 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 | /* ========================================================================= */ |
| 546 | int deflateCopy (dest, source) | 572 | int 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 | */ |
| 572 | local int read_buf(strm, buf, size) | 598 | local 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 | */ |
| 930 | local int deflate_stored(s, flush) | 956 | local 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 | */ |
| 974 | local int deflate_fast(s, flush) | 1000 | local 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 | */ |
| 1066 | local int deflate_slow(s, flush) | 1093 | local 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 | |||
| @@ -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 | ||
| 82 | typedef struct internal_state { | 82 | typedef 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 */ |
| @@ -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 | */ |
| 499 | char* gzerror (file, errnum) | 499 | const 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 | } |
| @@ -63,7 +63,7 @@ local uInt border[] = { /* Order of the bit length code lengths */ | |||
| 63 | 63 | ||
| 64 | void inflate_blocks_reset(s, z, c) | 64 | void inflate_blocks_reset(s, z, c) |
| 65 | inflate_blocks_statef *s; | 65 | inflate_blocks_statef *s; |
| 66 | z_stream *z; | 66 | z_streamp z; |
| 67 | uLongf *c; | 67 | uLongf *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 | ||
| 89 | inflate_blocks_statef *inflate_blocks_new(z, c, w) | 89 | inflate_blocks_statef *inflate_blocks_new(z, c, w) |
| 90 | z_stream *z; | 90 | z_streamp z; |
| 91 | check_func c; | 91 | check_func c; |
| 92 | uInt w; | 92 | uInt w; |
| 93 | { | 93 | { |
| @@ -115,7 +115,7 @@ uInt w; | |||
| 115 | #endif | 115 | #endif |
| 116 | int inflate_blocks(s, z, r) | 116 | int inflate_blocks(s, z, r) |
| 117 | inflate_blocks_statef *s; | 117 | inflate_blocks_statef *s; |
| 118 | z_stream *z; | 118 | z_streamp z; |
| 119 | int r; | 119 | int r; |
| 120 | { | 120 | { |
| 121 | uInt t; /* temporary storage */ | 121 | uInt t; /* temporary storage */ |
| @@ -381,7 +381,7 @@ int r; | |||
| 381 | 381 | ||
| 382 | int inflate_blocks_free(s, z, c) | 382 | int inflate_blocks_free(s, z, c) |
| 383 | inflate_blocks_statef *s; | 383 | inflate_blocks_statef *s; |
| 384 | z_stream *z; | 384 | z_streamp z; |
| 385 | uLongf *c; | 385 | uLongf *c; |
| 386 | { | 386 | { |
| 387 | inflate_blocks_reset(s, z, c); | 387 | inflate_blocks_reset(s, z, c); |
| @@ -12,23 +12,23 @@ struct inflate_blocks_state; | |||
| 12 | typedef struct inflate_blocks_state FAR inflate_blocks_statef; | 12 | typedef struct inflate_blocks_state FAR inflate_blocks_statef; |
| 13 | 13 | ||
| 14 | extern inflate_blocks_statef * inflate_blocks_new OF(( | 14 | extern 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 | ||
| 19 | extern int inflate_blocks OF(( | 19 | extern 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 | ||
| 24 | extern void inflate_blocks_reset OF(( | 24 | extern 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 | ||
| 29 | extern int inflate_blocks_free OF(( | 29 | extern 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 | ||
| 34 | extern void inflate_set_dictionary OF(( | 34 | extern void inflate_set_dictionary OF(( |
| @@ -60,7 +60,7 @@ inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) | |||
| 60 | uInt bl, bd; | 60 | uInt bl, bd; |
| 61 | inflate_huft *tl; | 61 | inflate_huft *tl; |
| 62 | inflate_huft *td; /* need separate declaration for Borland C++ */ | 62 | inflate_huft *td; /* need separate declaration for Borland C++ */ |
| 63 | z_stream *z; | 63 | z_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 | ||
| 81 | int inflate_codes(s, z, r) | 81 | int inflate_codes(s, z, r) |
| 82 | inflate_blocks_statef *s; | 82 | inflate_blocks_statef *s; |
| 83 | z_stream *z; | 83 | z_streamp z; |
| 84 | int r; | 84 | int r; |
| 85 | { | 85 | { |
| 86 | uInt j; /* temporary storage */ | 86 | uInt j; /* temporary storage */ |
| @@ -240,7 +240,7 @@ int r; | |||
| 240 | 240 | ||
| 241 | void inflate_codes_free(c, z) | 241 | void inflate_codes_free(c, z) |
| 242 | inflate_codes_statef *c; | 242 | inflate_codes_statef *c; |
| 243 | z_stream *z; | 243 | z_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")); |
| @@ -14,14 +14,14 @@ typedef struct inflate_codes_state FAR inflate_codes_statef; | |||
| 14 | extern inflate_codes_statef *inflate_codes_new OF(( | 14 | extern 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 | ||
| 19 | extern int inflate_codes OF(( | 19 | extern int inflate_codes OF(( |
| 20 | inflate_blocks_statef *, | 20 | inflate_blocks_statef *, |
| 21 | z_stream *, | 21 | z_streamp , |
| 22 | int)); | 22 | int)); |
| 23 | 23 | ||
| 24 | extern void inflate_codes_free OF(( | 24 | extern void inflate_codes_free OF(( |
| 25 | inflate_codes_statef *, | 25 | inflate_codes_statef *, |
| 26 | z_stream *)); | 26 | z_streamp )); |
| 27 | 27 | ||
| @@ -32,7 +32,7 @@ uInt bl, bd; | |||
| 32 | inflate_huft *tl; | 32 | inflate_huft *tl; |
| 33 | inflate_huft *td; /* need separate declaration for Borland C++ */ | 33 | inflate_huft *td; /* need separate declaration for Borland C++ */ |
| 34 | inflate_blocks_statef *s; | 34 | inflate_blocks_statef *s; |
| 35 | z_stream *z; | 35 | z_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 */ |
| @@ -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 )); |
| @@ -49,7 +49,7 @@ struct internal_state { | |||
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | int inflateReset(z) | 51 | int inflateReset(z) |
| 52 | z_stream *z; | 52 | z_streamp z; |
| 53 | { | 53 | { |
| 54 | uLong c; | 54 | uLong c; |
| 55 | 55 | ||
| @@ -65,7 +65,7 @@ z_stream *z; | |||
| 65 | 65 | ||
| 66 | 66 | ||
| 67 | int inflateEnd(z) | 67 | int inflateEnd(z) |
| 68 | z_stream *z; | 68 | z_streamp z; |
| 69 | { | 69 | { |
| 70 | uLong c; | 70 | uLong c; |
| 71 | 71 | ||
| @@ -81,7 +81,7 @@ z_stream *z; | |||
| 81 | 81 | ||
| 82 | 82 | ||
| 83 | int inflateInit2_(z, w, version, stream_size) | 83 | int inflateInit2_(z, w, version, stream_size) |
| 84 | z_stream *z; | 84 | z_streamp z; |
| 85 | int w; | 85 | int w; |
| 86 | const char *version; | 86 | const char *version; |
| 87 | int stream_size; | 87 | int stream_size; |
| @@ -138,7 +138,7 @@ int stream_size; | |||
| 138 | 138 | ||
| 139 | 139 | ||
| 140 | int inflateInit_(z, version, stream_size) | 140 | int inflateInit_(z, version, stream_size) |
| 141 | z_stream *z; | 141 | z_streamp z; |
| 142 | const char *version; | 142 | const char *version; |
| 143 | int stream_size; | 143 | int 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 | ||
| 152 | int inflate(z, f) | 152 | int inflate(z, f) |
| 153 | z_stream *z; | 153 | z_streamp z; |
| 154 | int f; | 154 | int f; |
| 155 | { | 155 | { |
| 156 | int r; | 156 | int r; |
| @@ -272,7 +272,7 @@ int f; | |||
| 272 | 272 | ||
| 273 | 273 | ||
| 274 | int inflateSetDictionary(z, dictionary, dictLength) | 274 | int inflateSetDictionary(z, dictionary, dictLength) |
| 275 | z_stream *z; | 275 | z_streamp z; |
| 276 | const Bytef *dictionary; | 276 | const Bytef *dictionary; |
| 277 | uInt dictLength; | 277 | uInt 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 | ||
| 297 | int inflateSync(z) | 298 | int inflateSync(z) |
| 298 | z_stream *z; | 299 | z_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 */ |
| @@ -6,7 +6,7 @@ | |||
| 6 | #include "zutil.h" | 6 | #include "zutil.h" |
| 7 | #include "inftrees.h" | 7 | #include "inftrees.h" |
| 8 | 8 | ||
| 9 | char inflate_copyright[] = " inflate 1.0.2 Copyright 1995-1996 Mark Adler "; | 9 | char 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 | ||
| 35 | local voidpf falloc OF(( | 35 | local 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 */ | |||
| 103 | uIntf *e; /* list of extra bits for non-simple codes */ | 103 | uIntf *e; /* list of extra bits for non-simple codes */ |
| 104 | inflate_huft * FAR *t; /* result: starting table */ | 104 | inflate_huft * FAR *t; /* result: starting table */ |
| 105 | uIntf *m; /* maximum lookup bits, returns actual */ | 105 | uIntf *m; /* maximum lookup bits, returns actual */ |
| 106 | z_stream *zs; /* for zalloc function */ | 106 | z_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) | |||
| 302 | uIntf *c; /* 19 code lengths */ | 302 | uIntf *c; /* 19 code lengths */ |
| 303 | uIntf *bb; /* bits tree desired/actual depth */ | 303 | uIntf *bb; /* bits tree desired/actual depth */ |
| 304 | inflate_huft * FAR *tb; /* bits tree result */ | 304 | inflate_huft * FAR *tb; /* bits tree result */ |
| 305 | z_stream *z; /* for zfree function */ | 305 | z_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 */ | |||
| 327 | uIntf *bd; /* distance desired/actual bit depth */ | 327 | uIntf *bd; /* distance desired/actual bit depth */ |
| 328 | inflate_huft * FAR *tl; /* literal/length tree result */ | 328 | inflate_huft * FAR *tl; /* literal/length tree result */ |
| 329 | inflate_huft * FAR *td; /* distance tree result */ | 329 | inflate_huft * FAR *td; /* distance tree result */ |
| 330 | z_stream *z; /* for zfree function */ | 330 | z_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 | ||
| 443 | int inflate_trees_free(t, z) | 443 | int inflate_trees_free(t, z) |
| 444 | inflate_huft *t; /* table to free */ | 444 | inflate_huft *t; /* table to free */ |
| 445 | z_stream *z; /* for zfree function */ | 445 | z_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. */ |
| @@ -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 | ||
| 40 | extern int inflate_trees_dynamic OF(( | 40 | extern 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 | ||
| 50 | extern int inflate_trees_fixed OF(( | 50 | extern 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 | ||
| 56 | extern int inflate_trees_free OF(( | 56 | extern 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 | ||
| @@ -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 */ |
| 23 | int inflate_flush(s, z, r) | 23 | int inflate_flush(s, z, r) |
| 24 | inflate_blocks_statef *s; | 24 | inflate_blocks_statef *s; |
| 25 | z_stream *z; | 25 | z_streamp z; |
| 26 | int r; | 26 | int r; |
| 27 | { | 27 | { |
| 28 | uInt n; | 28 | uInt n; |
| @@ -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 */ |
| 92 | extern int inflate_flush OF(( | 92 | extern int inflate_flush OF(( |
| 93 | inflate_blocks_statef *, | 93 | inflate_blocks_statef *, |
| 94 | z_stream *, | 94 | z_streamp , |
| 95 | int)); | 95 | int)); |
| 96 | 96 | ||
| 97 | struct internal_state {int dummy;}; /* for buggy compilers */ | 97 | struct internal_state {int dummy;}; /* for buggy compilers */ |
| @@ -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) |
| @@ -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 | ||
| @@ -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 | ||
| 156 | typedef unsigned char Byte; /* 8 bits */ | 152 | typedef unsigned char Byte; /* 8 bits */ |
| 157 | typedef unsigned int uInt; /* 16 bits or more */ | 153 | typedef unsigned int uInt; /* 16 bits or more */ |
| @@ -8,7 +8,7 @@ SUBSYSTEM WINDOWS | |||
| 8 | 8 | ||
| 9 | STUB 'WINSTUB.EXE' | 9 | STUB 'WINSTUB.EXE' |
| 10 | 10 | ||
| 11 | VERSION 1.0.2 | 11 | VERSION 1.04 |
| 12 | 12 | ||
| 13 | CODE EXECUTE READ | 13 | CODE EXECUTE READ |
| 14 | 14 | ||
| @@ -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 | ||
| 92 | typedef 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 | ||
| 169 | extern char EXPORT *zlibVersion OF((void)); | 171 | extern 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 | /* |
| 177 | extern int EXPORT deflateInit OF((z_stream *strm, int level)); | 179 | extern 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 | ||
| 199 | extern int EXPORT deflate OF((z_stream *strm, int flush)); | 201 | extern 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 | ||
| 268 | extern int EXPORT deflateEnd OF((z_stream *strm)); | 270 | extern 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 | /* |
| 283 | extern int EXPORT inflateInit OF((z_stream *strm)); | 285 | extern 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 | ||
| 298 | extern int EXPORT inflate OF((z_stream *strm, int flush)); | 300 | extern 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 | ||
| 353 | extern int EXPORT inflateEnd OF((z_stream *strm)); | 355 | extern 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 | /* |
| 371 | extern int EXPORT deflateInit2 OF((z_stream *strm, | 373 | extern 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 | ||
| 429 | extern int EXPORT deflateSetDictionary OF((z_stream *strm, | 431 | extern 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 | ||
| 458 | extern int EXPORT deflateCopy OF((z_stream *dest, | 460 | extern 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 | ||
| 481 | extern int EXPORT deflateReset OF((z_stream *strm)); | 483 | extern 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 | ||
| 492 | extern int EXPORT deflateParams OF((z_stream *strm, int level, int strategy)); | 494 | extern 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 | /* |
| 511 | extern int EXPORT inflateInit2 OF((z_stream *strm, | 513 | extern 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 | ||
| 545 | extern int EXPORT inflateSetDictionary OF((z_stream *strm, | 547 | extern 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 | ||
| 564 | extern int EXPORT inflateSync OF((z_stream *strm)); | 566 | extern 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 | ||
| 579 | extern int EXPORT inflateReset OF((z_stream *strm)); | 581 | extern 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 | ||
| 693 | extern char EXPORT *gzerror OF((gzFile file, int *errnum)); | 695 | extern 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 | */ |
| 749 | extern int EXPORT deflateInit_ OF((z_stream *strm, int level, | 751 | extern int EXPORT deflateInit_ OF((z_streamp strm, int level, |
| 750 | const char *version, int stream_size)); | 752 | const char *version, int stream_size)); |
| 751 | extern int EXPORT inflateInit_ OF((z_stream *strm, | 753 | extern int EXPORT inflateInit_ OF((z_streamp strm, |
| 752 | const char *version, int stream_size)); | 754 | const char *version, int stream_size)); |
| 753 | extern int EXPORT deflateInit2_ OF((z_stream *strm, int level, int method, | 755 | extern 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)); |
| 756 | extern int EXPORT inflateInit2_ OF((z_stream *strm, int windowBits, | 758 | extern 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)) |
| @@ -2,8 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | #define IDR_VERSION1 1 | 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE | 4 | IDR_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" |
| @@ -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 | ||
| 31 | char *zlibVersion() | 31 | const char *zlibVersion() |
| 32 | { | 32 | { |
| 33 | return ZLIB_VERSION; | 33 | return ZLIB_VERSION; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | #ifdef DEBUG | ||
| 36 | void z_error (m) | 37 | void 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 | ||
| 58 | int 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 | |||
| 56 | void zmemzero(dest, len) | 71 | void 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 | ||
| @@ -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; | |||
| 40 | extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ | 40 | extern 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 | ||
| 191 | typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len)); | 193 | typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len)); |
| 192 | 194 | ||
| 193 | extern void z_error OF((char *m)); | ||
| 194 | |||
| 195 | voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); | 195 | voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); |
| 196 | void zcfree OF((voidpf opaque, voidpf ptr)); | 196 | void zcfree OF((voidpf opaque, voidpf ptr)); |
| 197 | 197 | ||
