diff options
Diffstat (limited to '')
| -rw-r--r-- | ChangeLog | 10 | ||||
| -rw-r--r-- | INDEX | 4 | ||||
| -rw-r--r-- | Makefile | 9 | ||||
| -rw-r--r-- | Makefile.dj2 | 61 | ||||
| -rw-r--r-- | Makefile.in | 9 | ||||
| -rw-r--r-- | README | 29 | ||||
| -rw-r--r-- | adler32.c | 2 | ||||
| -rw-r--r-- | algorithm.doc | 105 | ||||
| -rw-r--r-- | compress.c | 5 | ||||
| -rw-r--r-- | deflate.c | 4 | ||||
| -rw-r--r-- | example.c | 13 | ||||
| -rw-r--r-- | gzio.c | 2 | ||||
| -rw-r--r-- | inftrees.c | 2 | ||||
| -rw-r--r-- | infutil.c | 3 | ||||
| -rw-r--r-- | minigzip.c | 2 | ||||
| -rw-r--r-- | trees.c | 2 | ||||
| -rw-r--r-- | zconf.h | 28 | ||||
| -rw-r--r-- | zlib.def | 46 | ||||
| -rw-r--r-- | zlib.h | 119 | ||||
| -rw-r--r-- | zlib.rc | 32 | ||||
| -rw-r--r-- | zutil.c | 9 | ||||
| -rw-r--r-- | zutil.h | 2 |
22 files changed, 379 insertions, 119 deletions
| @@ -1,6 +1,16 @@ | |||
| 1 | 1 | ||
| 2 | ChangeLog file for zlib | 2 | ChangeLog file for zlib |
| 3 | 3 | ||
| 4 | Changes in 1.0.2 (23 May 96) | ||
| 5 | - added Windows DLL support | ||
| 6 | - added a function zlibVersion (for the DLL support) | ||
| 7 | - fixed declarations using Bytef in infutil.c (pb with MSDOS medium model) | ||
| 8 | - Bytef is define's instead of typedef'd only for Borland C | ||
| 9 | - avoid reading uninitialized memory in example.c | ||
| 10 | - mention in README that the zlib format is now RFC1950 | ||
| 11 | - updated Makefile.dj2 | ||
| 12 | - added algorithm.doc | ||
| 13 | |||
| 4 | Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] | 14 | Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] |
| 5 | - fix array overlay in deflate.c which sometimes caused bad compressed data | 15 | - fix array overlay in deflate.c which sometimes caused bad compressed data |
| 6 | - fix inflate bug with empty stored block | 16 | - fix inflate bug with empty stored block |
| @@ -11,8 +11,12 @@ Makefile.sas makefile for Amiga SAS/C | |||
| 11 | Makefile.tc makefile for Turbo C | 11 | Makefile.tc makefile for Turbo C |
| 12 | Makefile.wat makefile for Watcom C | 12 | Makefile.wat makefile for Watcom C |
| 13 | README guess what | 13 | README guess what |
| 14 | algorithm.doc description of the compression & decompression algorithms | ||
| 14 | configure configure script for Unix | 15 | configure configure script for Unix |
| 15 | descrip.mms makefile for Vax/VMS | 16 | descrip.mms makefile for Vax/VMS |
| 17 | zlib.def definition file for Windows DLL | ||
| 18 | zlib.rc definition file for Windows DLL | ||
| 19 | |||
| 16 | 20 | ||
| 17 | zlib public header files (must be kept): | 21 | zlib public header files (must be kept): |
| 18 | zconf.h | 22 | zconf.h |
| @@ -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.1 | 25 | VER=1.0.2 |
| 26 | LIBS=libz.a | 26 | LIBS=libz.a |
| 27 | 27 | ||
| 28 | AR=ar rc | 28 | AR=ar rc |
| @@ -37,7 +37,8 @@ OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | |||
| 37 | 37 | ||
| 38 | TEST_OBJS = example.o minigzip.o | 38 | TEST_OBJS = example.o minigzip.o |
| 39 | 39 | ||
| 40 | DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] descrip.mms *.[ch] | 40 | DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] descrip.mms \ |
| 41 | zlib.def zlib.rc algorithm.doc *.[ch] | ||
| 41 | 42 | ||
| 42 | all: example minigzip | 43 | all: example minigzip |
| 43 | 44 | ||
| @@ -85,8 +86,8 @@ clean: | |||
| 85 | 86 | ||
| 86 | zip: | 87 | zip: |
| 87 | mv Makefile Makefile~; cp -p Makefile.in Makefile | 88 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
| 88 | v=`sed -n -e 's/\./-/g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | 89 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
| 89 | zip -ul9 zlib-$$v $(DISTFILES) | 90 | zip -ul9 zlib$$v $(DISTFILES) |
| 90 | mv Makefile~ Makefile | 91 | mv Makefile~ Makefile |
| 91 | 92 | ||
| 92 | dist: | 93 | dist: |
diff --git a/Makefile.dj2 b/Makefile.dj2 index 82f55ea..07a9bb1 100644 --- a/Makefile.dj2 +++ b/Makefile.dj2 | |||
| @@ -2,32 +2,51 @@ | |||
| 2 | # Copyright (C) 1995-1996 Jean-loup Gailly. | 2 | # Copyright (C) 1995-1996 Jean-loup Gailly. |
| 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 | # To compile and test, type: | 5 | # To compile, or to compile and test, type: |
| 6 | # | ||
| 6 | # make -fmakefile.dj2; make test -fmakefile.dj2 | 7 | # make -fmakefile.dj2; make test -fmakefile.dj2 |
| 7 | 8 | # | |
| 8 | # To install libz.a, zconf.h and zlib.h in the djgpp directories, type: | 9 | # To install libz.a, zconf.h and zlib.h in the djgpp directories, type: |
| 10 | # | ||
| 9 | # make install -fmakefile.dj2 | 11 | # make install -fmakefile.dj2 |
| 10 | # after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env for [make]. | 12 | # |
| 11 | # Alternately these variables may be defined below. | 13 | # after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as |
| 14 | # in the sample below if the pattern of the DJGPP distribution is to | ||
| 15 | # be followed. Remember that, while <sp>'es around <=> are ignored in | ||
| 16 | # makefiles, they are *not* in batch files or in djgpp.env. | ||
| 17 | # - - - - - | ||
| 18 | # [make] | ||
| 19 | # INCLUDE_PATH=%\>;INCLUDE_PATH%%\DJDIR%\include | ||
| 20 | # LIBRARY_PATH=%\>;LIBRARY_PATH%%\DJDIR%\lib | ||
| 21 | # BUTT=-m486 | ||
| 22 | # - - - - - | ||
| 23 | # Alternately, these variables may be defined below, overriding the values | ||
| 24 | # in djgpp.env, as | ||
| 25 | INCLUDE_PATH=c:\usr\include | ||
| 12 | 26 | ||
| 13 | CC=gcc | 27 | CC=gcc |
| 14 | 28 | ||
| 15 | #CFLAGS=-MMD -O | 29 | #CFLAGS=-MMD -O |
| 16 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 | 30 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 |
| 17 | #CFLAGS=-MMD -g -DDEBUG | 31 | #CFLAGS=-MMD -g -DDEBUG |
| 18 | CFLAGS=-MMD -O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ | 32 | CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ |
| 19 | -Wstrict-prototypes -Wmissing-prototypes | 33 | -Wstrict-prototypes -Wmissing-prototypes |
| 34 | |||
| 35 | # If cp.exe is not found, replace with copy /Y . | ||
| 36 | CP=cp -f | ||
| 37 | # If install.exe is not found, replace with $(CP). | ||
| 20 | INSTALL=install | 38 | INSTALL=install |
| 39 | # The default value of RM is "rm -f." If "rm.exe" is not found, uncomment: | ||
| 40 | # RM=del | ||
| 21 | LDLIBS=-L. -lz | 41 | LDLIBS=-L. -lz |
| 22 | LD=$(CC) -s -o | 42 | LD=$(CC) -s -o |
| 23 | LDSHARED=$(CC) | 43 | LDSHARED=$(CC) |
| 24 | 44 | ||
| 25 | VER=1.0 | 45 | VER=1.0.2 |
| 46 | INCL=zlib.h zconf.h | ||
| 26 | LIBS=libz.a | 47 | LIBS=libz.a |
| 27 | 48 | ||
| 28 | AR=ar rcs | 49 | AR=ar rcs |
| 29 | # The default value of RM is "rm -f." If "rm.exe" is not found, uncomment: | ||
| 30 | # RM=del | ||
| 31 | 50 | ||
| 32 | prefix=/usr/local | 51 | prefix=/usr/local |
| 33 | exec_prefix = $(prefix) | 52 | exec_prefix = $(prefix) |
| @@ -37,10 +56,6 @@ OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | |||
| 37 | 56 | ||
| 38 | TEST_OBJS = example.o minigzip.o | 57 | TEST_OBJS = example.o minigzip.o |
| 39 | 58 | ||
| 40 | DISTFILES = README Change.Log configur Makefile.in Makefile Makefile.msc \ | ||
| 41 | Makefile.bor Makefile.tc Make_vms.com descrip.mms zlib099.pat \ | ||
| 42 | *.bak *.old *.[ch] | ||
| 43 | |||
| 44 | all: example.exe minigzip.exe | 59 | all: example.exe minigzip.exe |
| 45 | 60 | ||
| 46 | test: all | 61 | test: all |
| @@ -55,23 +70,27 @@ libz.a: $(OBJS) | |||
| 55 | 70 | ||
| 56 | libz.so.$(VER): $(OBJS) | 71 | libz.so.$(VER): $(OBJS) |
| 57 | $(LDSHARED) -o $@ $(OBJS) | 72 | $(LDSHARED) -o $@ $(OBJS) |
| 58 | rm -f libz.so; ln -s $@ libz.so | 73 | $(RM) libz.so; ln -s $@ libz.so |
| 59 | 74 | ||
| 60 | %.exe : %.o $(LIBS) | 75 | %.exe : %.o $(LIBS) |
| 61 | $(LD) $@ $< $(LDLIBS) | 76 | $(LD) $@ $< $(LDLIBS) |
| 62 | 77 | ||
| 63 | # INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env | 78 | # INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . |
| 79 | |||
| 80 | .PHONY : uninstall clean | ||
| 64 | 81 | ||
| 65 | install: $(LIBS) | 82 | install: $(INCL) $(LIBS) |
| 66 | $(INSTALL) zlib.h zconf.h $(INCLUDE_PATH) | 83 | -@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH) |
| 67 | $(INSTALL) $(LIBS) $(LIBRARY_PATH) | 84 | -@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH) |
| 85 | for %%f in ($(INCL)) do $(INSTALL) %%f $(INCLUDE_PATH) | ||
| 86 | for %%p in ($(LIBS)) do $(INSTALL) %%p $(LIBRARY_PATH) | ||
| 68 | 87 | ||
| 69 | uninstall: | 88 | uninstall: |
| 70 | $(RM) $(LIBRARY_PATH)/$(LIBS) | 89 | for %%f in ($(INCL)) do $(RM) $(INCLUDE_PATH)\%%f |
| 71 | $(RM) $(INCLUDE_PATH)/zlib.h $(INCLUDE_PATH)/zconf.h | 90 | for %%p in ($(LIBS)) do $(RM) $(LIBRARY_PATH)\%%p |
| 72 | 91 | ||
| 73 | clean: | 92 | clean: |
| 74 | $(RM) *.d *.o *.~ *.exe libz.a libz.so* foo.gz | 93 | for %%p in (*.d *.o *.exe libz.a libz.so*) do $(RM) %%p |
| 75 | 94 | ||
| 76 | DEPS := $(wildcard *.d) | 95 | DEPS := $(wildcard *.d) |
| 77 | ifneq ($(DEPS),) | 96 | ifneq ($(DEPS),) |
diff --git a/Makefile.in b/Makefile.in index 3b41059..f2ff262 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.1 | 25 | VER=1.0.2 |
| 26 | LIBS=libz.a | 26 | LIBS=libz.a |
| 27 | 27 | ||
| 28 | AR=ar rc | 28 | AR=ar rc |
| @@ -37,7 +37,8 @@ OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | |||
| 37 | 37 | ||
| 38 | TEST_OBJS = example.o minigzip.o | 38 | TEST_OBJS = example.o minigzip.o |
| 39 | 39 | ||
| 40 | DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] descrip.mms *.[ch] | 40 | DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] descrip.mms \ |
| 41 | zlib.def zlib.rc algorithm.doc *.[ch] | ||
| 41 | 42 | ||
| 42 | all: example minigzip | 43 | all: example minigzip |
| 43 | 44 | ||
| @@ -85,8 +86,8 @@ clean: | |||
| 85 | 86 | ||
| 86 | zip: | 87 | zip: |
| 87 | mv Makefile Makefile~; cp -p Makefile.in Makefile | 88 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
| 88 | v=`sed -n -e 's/\./-/g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | 89 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
| 89 | zip -ul9 zlib-$$v $(DISTFILES) | 90 | zip -ul9 zlib$$v $(DISTFILES) |
| 90 | mv Makefile~ Makefile | 91 | mv Makefile~ Makefile |
| 91 | 92 | ||
| 92 | dist: | 93 | dist: |
| @@ -1,8 +1,9 @@ | |||
| 1 | zlib 1.0.1 is a general purpose data compression library. All the code | 1 | zlib 1.0.2 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 in the files zlib-3.3.doc, deflate-1.3.doc and | 3 | is described by RFCs (Request for Comments) 1950 to 1952 in the files |
| 4 | gzip-4.3.doc, available in various formats from | 4 | ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate |
| 5 | ftp://swrinde.nde.swri.edu/pub/png/documents/zlib/ | 5 | format) and rfc1952.txt (gzip format). These documents are also available in |
| 6 | other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html | ||
| 6 | 7 | ||
| 7 | All functions of the compression library are documented in the file | 8 | All functions of the compression library are documented in the file |
| 8 | zlib.h. A usage example of the library is given in the file example.c | 9 | zlib.h. A usage example of the library is given in the file example.c |
| @@ -18,9 +19,8 @@ makefiles such as Makefile.msc; for VMS, use Make_vms.com or descrip.mms. | |||
| 18 | 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, |
| 19 | 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. |
| 20 | 21 | ||
| 21 | The changes made in version 1.0.1 are documented in the file ChangeLog. | 22 | The changes made in version 1.0.2 are documented in the file ChangeLog. |
| 22 | Version number 1.0 was skipped to avoid confusion with version 0.99 | 23 | The main changes since 0.99 are: |
| 23 | which had some references to 1.0 already. The main changes since 0.99 are: | ||
| 24 | 24 | ||
| 25 | - fix array overlay in deflate.c which sometimes caused bad compressed data | 25 | - fix array overlay in deflate.c which sometimes caused bad compressed data |
| 26 | - fix inflate bug with empty stored block | 26 | - fix inflate bug with empty stored block |
| @@ -30,6 +30,14 @@ which had some references to 1.0 already. The main changes since 0.99 are: | |||
| 30 | - new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), | 30 | - new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), |
| 31 | Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas) | 31 | Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas) |
| 32 | - several portability improvements | 32 | - several portability improvements |
| 33 | - added algorithm.doc | ||
| 34 | - added Windows DLL support | ||
| 35 | - added a function zlibVersion (for the DLL support) | ||
| 36 | |||
| 37 | 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: | ||
| 39 | ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib* | ||
| 40 | |||
| 33 | 41 | ||
| 34 | Notes for some targets: | 42 | Notes for some targets: |
| 35 | 43 | ||
| @@ -46,9 +54,10 @@ Notes for some targets: | |||
| 46 | - zlib doesn't work on HP-UX 9.05 with one cc compiler (the one not | 54 | - zlib doesn't work on HP-UX 9.05 with one cc compiler (the one not |
| 47 | accepting the -O option). It works with the other cc compiler. | 55 | accepting the -O option). It works with the other cc compiler. |
| 48 | 56 | ||
| 49 | A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk> | 57 | - To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc |
| 50 | is in the CPAN (Comprehensive Perl Archive Network) sites, such as: | 58 | and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL |
| 51 | ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib* | 59 | For help on building a zlib DLL, contact Alessandro Iacopetti |
| 60 | <iaco@cicladi.unial.it> | ||
| 52 | 61 | ||
| 53 | 62 | ||
| 54 | Acknowledgments: | 63 | Acknowledgments: |
| @@ -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: adler32.c,v 1.9 1996/01/30 21:59:09 me Exp $ */ | 6 | /* $Id: adler32.c,v 1.10 1996/05/22 11:52:18 me Exp $ */ |
| 7 | 7 | ||
| 8 | #include "zlib.h" | 8 | #include "zlib.h" |
| 9 | 9 | ||
diff --git a/algorithm.doc b/algorithm.doc new file mode 100644 index 0000000..156058a --- /dev/null +++ b/algorithm.doc | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | 1. Compression algorithm (deflate) | ||
| 2 | |||
| 3 | The deflation algorithm used by zlib (also zip and gzip) is a variation of | ||
| 4 | LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in | ||
| 5 | the input data. The second occurrence of a string is replaced by a | ||
| 6 | pointer to the previous string, in the form of a pair (distance, | ||
| 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 | ||
| 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, | ||
| 11 | and is not restricted to printable characters.) | ||
| 12 | |||
| 13 | Literals or match lengths are compressed with one Huffman tree, and | ||
| 14 | match distances are compressed with another tree. The trees are stored | ||
| 15 | 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 | ||
| 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 | ||
| 19 | somewhat similar to compress.) | ||
| 20 | |||
| 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 | ||
| 23 | the next 3 bytes. If the hash chain for this index is not empty, all | ||
| 24 | strings in the chain are compared with the current input string, and | ||
| 25 | the longest match is selected. | ||
| 26 | |||
| 27 | The hash chains are searched starting with the most recent strings, to | ||
| 28 | favor small distances and thus take advantage of the Huffman encoding. | ||
| 29 | The hash chains are singly linked. There are no deletions from the | ||
| 30 | hash chains, the algorithm simply discards matches that are too old. | ||
| 31 | |||
| 32 | To avoid a worst-case situation, very long hash chains are arbitrarily | ||
| 33 | truncated at a certain length, determined by a runtime option (level | ||
| 34 | parameter of deflateInit). So deflate() does not always find the longest | ||
| 35 | possible match but generally finds a match which is long enough. | ||
| 36 | |||
| 37 | deflate() also defers the selection of matches with a lazy evaluation | ||
| 38 | mechanism. After a match of length N has been found, deflate() searches for a | ||
| 39 | longer match at the next input byte. If a longer match is found, the | ||
| 40 | previous match is truncated to a length of one (thus producing a single | ||
| 41 | literal byte) and the longer match is emitted afterwards. Otherwise, | ||
| 42 | the original match is kept, and the next match search is attempted only | ||
| 43 | N steps later. | ||
| 44 | |||
| 45 | The lazy match evaluation is also subject to a runtime parameter. If | ||
| 46 | the current match is long enough, deflate() reduces the search for a longer | ||
| 47 | match, thus speeding up the whole process. If compression ratio is more | ||
| 48 | important than speed, deflate() attempts a complete second search even if | ||
| 49 | the first match is already long enough. | ||
| 50 | |||
| 51 | The lazy match evaluation is not performed for the fastest compression | ||
| 52 | modes (level parameter 1 to 3). For these fast modes, new strings | ||
| 53 | are inserted in the hash table only when no match was found, or | ||
| 54 | when the match is not too long. This degrades the compression ratio | ||
| 55 | but saves time since there are both fewer insertions and fewer searches. | ||
| 56 | |||
| 57 | |||
| 58 | 2. Decompression algorithm (inflate) | ||
| 59 | |||
| 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 | ||
| 62 | longer codes, so pay attention to decoding the short codes fast, and let | ||
| 63 | the long codes take longer to decode. | ||
| 64 | |||
| 65 | inflate() sets up a first level table that covers some number of bits of | ||
| 66 | input less than the length of longest code. It gets that many bits from the | ||
| 67 | stream, and looks it up in the table. The table will tell if the next | ||
| 68 | code is that many bits or less and how many, and if it is, it will tell | ||
| 69 | the value, else it will point to the next level table for which inflate() | ||
| 70 | grabs more bits and tries to decode a longer code. | ||
| 71 | |||
| 72 | How many bits to make the first lookup is a tradeoff between the time it | ||
| 73 | takes to decode and the time it takes to build the table. If building the | ||
| 74 | table took no time (and if you had infinite memory), then there would only | ||
| 75 | be a first level table to cover all the way to the longest code. However, | ||
| 76 | building the table ends up taking a lot longer for more bits since short | ||
| 77 | codes are replicated many times in such a table. What inflate() does is | ||
| 78 | simply to make the number of bits in the first table a variable, and set it | ||
| 79 | for the maximum speed. | ||
| 80 | |||
| 81 | inflate() sends new trees relatively often, so it is possibly set for a | ||
| 82 | smaller first level table than an application that has only one tree for | ||
| 83 | 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 91 | applications gave values within a bit or two of the flat code size. | ||
| 92 | |||
| 93 | |||
| 94 | Jean-loup Gailly Mark Adler | ||
| 95 | gzip@prep.ai.mit.edu madler@alumni.caltech.edu | ||
| 96 | |||
| 97 | |||
| 98 | References: | ||
| 99 | |||
| 100 | [LZ77] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data | ||
| 101 | Compression", IEEE Transactions on Information Theory", Vol. 23, No. 3, | ||
| 102 | pp. 337-343. | ||
| 103 | |||
| 104 | "DEFLATE Compressed Data Format Specification" available in | ||
| 105 | ftp://ds.internic.net/rfc/rfc1951.txt | ||
| @@ -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: compress.c,v 1.9 1996/01/30 21:59:09 me Exp $ */ | 6 | /* $Id: compress.c,v 1.10 1996/05/23 16:51:12 me Exp $ */ |
| 7 | 7 | ||
| 8 | #include "zlib.h" | 8 | #include "zlib.h" |
| 9 | 9 | ||
| @@ -30,9 +30,10 @@ int compress (dest, destLen, source, sourceLen) | |||
| 30 | 30 | ||
| 31 | stream.next_in = (Bytef*)source; | 31 | stream.next_in = (Bytef*)source; |
| 32 | stream.avail_in = (uInt)sourceLen; | 32 | stream.avail_in = (uInt)sourceLen; |
| 33 | #ifdef MAXSEG_64K | ||
| 33 | /* Check for source > 64K on 16-bit machine: */ | 34 | /* Check for source > 64K on 16-bit machine: */ |
| 34 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; | 35 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; |
| 35 | 36 | #endif | |
| 36 | stream.next_out = dest; | 37 | stream.next_out = dest; |
| 37 | stream.avail_out = (uInt)*destLen; | 38 | stream.avail_out = (uInt)*destLen; |
| 38 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; | 39 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; |
| @@ -47,11 +47,11 @@ | |||
| 47 | * | 47 | * |
| 48 | */ | 48 | */ |
| 49 | 49 | ||
| 50 | /* $Id: deflate.c,v 1.12 1996/01/30 21:59:11 me Exp $ */ | 50 | /* $Id: deflate.c,v 1.13 1996/05/22 11:52:21 me Exp $ */ |
| 51 | 51 | ||
| 52 | #include "deflate.h" | 52 | #include "deflate.h" |
| 53 | 53 | ||
| 54 | char deflate_copyright[] = " deflate 1.0.1 Copyright 1995-1996 Jean-loup Gailly "; | 54 | char deflate_copyright[] = " deflate 1.0.2 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 |
| @@ -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: example.c,v 1.13 1996/01/30 21:59:13 me Exp $ */ | 6 | /* $Id: example.c,v 1.16 1996/05/23 17:11:28 me Exp $ */ |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | #include "zlib.h" | 9 | #include "zlib.h" |
| @@ -462,16 +462,19 @@ int main(argc, argv) | |||
| 462 | uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ | 462 | uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ |
| 463 | uLong uncomprLen = comprLen; | 463 | uLong uncomprLen = comprLen; |
| 464 | 464 | ||
| 465 | if (zlib_version[0] != ZLIB_VERSION[0]) { | 465 | if (zlibVersion()[0] != ZLIB_VERSION[0]) { |
| 466 | fprintf(stderr, "incompatible zlib version\n"); | 466 | fprintf(stderr, "incompatible zlib version\n"); |
| 467 | exit(1); | 467 | exit(1); |
| 468 | 468 | ||
| 469 | } else if (strcmp(zlib_version, ZLIB_VERSION) != 0) { | 469 | } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { |
| 470 | fprintf(stderr, "warning: different zlib version\n"); | 470 | fprintf(stderr, "warning: different zlib version\n"); |
| 471 | } | 471 | } |
| 472 | 472 | ||
| 473 | compr = (Byte*)malloc((uInt)comprLen); | 473 | compr = (Byte*)calloc((uInt)comprLen, 1); |
| 474 | uncompr = (Byte*)calloc((uInt)uncomprLen, 1); /* must be cleared */ | 474 | uncompr = (Byte*)calloc((uInt)uncomprLen, 1); |
| 475 | /* compr and uncompr are cleared to avoid reading uninitialized | ||
| 476 | * data and to ensure that uncompr compresses well. | ||
| 477 | */ | ||
| 475 | if (compr == Z_NULL || uncompr == Z_NULL) { | 478 | if (compr == Z_NULL || uncompr == Z_NULL) { |
| 476 | printf("out of memory\n"); | 479 | printf("out of memory\n"); |
| 477 | exit(1); | 480 | exit(1); |
| @@ -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.12 1996/01/30 21:59:14 me Exp $ */ | 6 | /* $Id: gzio.c,v 1.13 1996/05/22 11:52:24 me Exp $ */ |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | 9 | ||
| @@ -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.1 Copyright 1995-1996 Mark Adler "; | 9 | char inflate_copyright[] = " inflate 1.0.2 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 |
| @@ -26,7 +26,8 @@ z_stream *z; | |||
| 26 | int r; | 26 | int r; |
| 27 | { | 27 | { |
| 28 | uInt n; | 28 | uInt n; |
| 29 | Bytef *p, *q; | 29 | Bytef *p; |
| 30 | Bytef *q; | ||
| 30 | 31 | ||
| 31 | /* local copies of source and destination pointers */ | 32 | /* local copies of source and destination pointers */ |
| 32 | p = z->next_out; | 33 | p = z->next_out; |
| @@ -13,7 +13,7 @@ | |||
| 13 | * or in pipe mode. | 13 | * or in pipe mode. |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | /* $Id: minigzip.c,v 1.8 1996/01/30 21:59:23 me Exp $ */ | 16 | /* $Id: minigzip.c,v 1.9 1996/05/22 11:52:32 me Exp $ */ |
| 17 | 17 | ||
| 18 | #include <stdio.h> | 18 | #include <stdio.h> |
| 19 | #include "zlib.h" | 19 | #include "zlib.h" |
| @@ -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.5 1995/05/03 17:27:12 jloup Exp $ */ | 32 | /* $Id: trees.c,v 1.10 1996/05/22 11:52:34 me Exp $ */ |
| 33 | 33 | ||
| 34 | #include "deflate.h" | 34 | #include "deflate.h" |
| 35 | 35 | ||
| @@ -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.12 1995/05/03 17:27:12 jloup Exp $ */ | 6 | /* $Id: zconf.h,v 1.18 1996/05/23 16:51:18 me Exp $ */ |
| 7 | 7 | ||
| 8 | #ifndef _ZCONF_H | 8 | #ifndef _ZCONF_H |
| 9 | #define _ZCONF_H | 9 | #define _ZCONF_H |
| @@ -37,7 +37,7 @@ | |||
| 37 | # define Byte z_Byte | 37 | # define Byte z_Byte |
| 38 | # define uInt z_uInt | 38 | # define uInt z_uInt |
| 39 | # define uLong z_uLong | 39 | # define uLong z_uLong |
| 40 | /* # define Bytef z_Bytef */ | 40 | # define Bytef z_Bytef |
| 41 | # define charf z_charf | 41 | # define charf z_charf |
| 42 | # define intf z_intf | 42 | # define intf z_intf |
| 43 | # define uIntf z_uIntf | 43 | # define uIntf z_uIntf |
| @@ -128,7 +128,8 @@ | |||
| 128 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, | 128 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, |
| 129 | * just define FAR to be empty. | 129 | * just define FAR to be empty. |
| 130 | */ | 130 | */ |
| 131 | #if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ | 131 | #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) |
| 132 | /* MSC small or medium model */ | ||
| 132 | # define SMALL_MEDIUM | 133 | # define SMALL_MEDIUM |
| 133 | # ifdef _MSC_VER | 134 | # ifdef _MSC_VER |
| 134 | # define FAR __far | 135 | # define FAR __far |
| @@ -137,14 +138,16 @@ | |||
| 137 | # endif | 138 | # endif |
| 138 | #endif | 139 | #endif |
| 139 | #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) | 140 | #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) |
| 141 | # ifndef __32BIT__ | ||
| 140 | # define SMALL_MEDIUM | 142 | # define SMALL_MEDIUM |
| 141 | # define FAR __far | 143 | # define FAR __far |
| 144 | # endif | ||
| 142 | #endif | 145 | #endif |
| 143 | #ifndef FAR | 146 | #ifndef FAR |
| 144 | # define FAR | 147 | # define FAR |
| 145 | #endif | 148 | #endif |
| 146 | /* The Watcom compiler defines M_I86SM and __SMALL__ even in 32 bit mode */ | 149 | /* The Watcom compiler defines M_I86SM and __SMALL__ even in 32 bit mode */ |
| 147 | #if defined(__WATCOMC__) && defined(__386__) | 150 | #if defined(__WATCOMC__) && defined(__386__) && defined(SMALL_MEDIUM) |
| 148 | # undef FAR | 151 | # undef FAR |
| 149 | # define FAR | 152 | # define FAR |
| 150 | # undef SMALL_MEDIUM | 153 | # undef SMALL_MEDIUM |
| @@ -154,8 +157,12 @@ typedef unsigned char Byte; /* 8 bits */ | |||
| 154 | typedef unsigned int uInt; /* 16 bits or more */ | 157 | typedef unsigned int uInt; /* 16 bits or more */ |
| 155 | typedef unsigned long uLong; /* 32 bits or more */ | 158 | typedef unsigned long uLong; /* 32 bits or more */ |
| 156 | 159 | ||
| 157 | /* "typedef Byte FAR Bytef;" doesn't work with Borland C/C++ */ | 160 | #if defined(__BORLANDC__) && defined(SMALL_MEDIUM) |
| 158 | #define Bytef Byte FAR | 161 | /* Borland C/C++ ignores FAR inside typedef */ |
| 162 | # define Bytef Byte FAR | ||
| 163 | #else | ||
| 164 | typedef Byte FAR Bytef; | ||
| 165 | #endif | ||
| 159 | typedef char FAR charf; | 166 | typedef char FAR charf; |
| 160 | typedef int FAR intf; | 167 | typedef int FAR intf; |
| 161 | typedef uInt FAR uIntf; | 168 | typedef uInt FAR uIntf; |
| @@ -169,4 +176,13 @@ typedef uLong FAR uLongf; | |||
| 169 | typedef Byte *voidp; | 176 | typedef Byte *voidp; |
| 170 | #endif | 177 | #endif |
| 171 | 178 | ||
| 179 | |||
| 180 | /* Compile with -DZLIB_DLL for Windows DLL support */ | ||
| 181 | #if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL) | ||
| 182 | # include <windows.h> | ||
| 183 | # define EXPORT WINAPI | ||
| 184 | #else | ||
| 185 | # define EXPORT | ||
| 186 | #endif | ||
| 187 | |||
| 172 | #endif /* _ZCONF_H */ | 188 | #endif /* _ZCONF_H */ |
diff --git a/zlib.def b/zlib.def new file mode 100644 index 0000000..0f5049f --- /dev/null +++ b/zlib.def | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | LIBRARY "zlib" | ||
| 2 | |||
| 3 | DESCRIPTION '"""zlib data compression library"""' | ||
| 4 | |||
| 5 | EXETYPE NT | ||
| 6 | |||
| 7 | SUBSYSTEM WINDOWS | ||
| 8 | |||
| 9 | STUB 'WINSTUB.EXE' | ||
| 10 | |||
| 11 | VERSION 1.0.2 | ||
| 12 | |||
| 13 | CODE EXECUTE READ | ||
| 14 | |||
| 15 | DATA READ WRITE | ||
| 16 | |||
| 17 | HEAPSIZE 1048576,4096 | ||
| 18 | |||
| 19 | EXPORTS | ||
| 20 | zlibVersion | ||
| 21 | deflate | ||
| 22 | deflateEnd | ||
| 23 | inflate | ||
| 24 | inflateEnd | ||
| 25 | deflateSetDictionary | ||
| 26 | deflateCopy | ||
| 27 | deflateReset | ||
| 28 | deflateParams | ||
| 29 | inflateSetDictionary | ||
| 30 | inflateSync | ||
| 31 | inflateReset | ||
| 32 | compress | ||
| 33 | uncompress | ||
| 34 | gzopen | ||
| 35 | gzdopen | ||
| 36 | gzread | ||
| 37 | gzwrite | ||
| 38 | gzflush | ||
| 39 | gzclose | ||
| 40 | gzerror | ||
| 41 | adler32 | ||
| 42 | crc32 | ||
| 43 | deflateInit_ | ||
| 44 | inflateInit_ | ||
| 45 | deflateInit2_ | ||
| 46 | inflateInit2_ | ||
| @@ -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.1, May 20th, 1996. | 2 | version 1.0.2, May 23rd, 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 | ||
| @@ -21,7 +21,12 @@ | |||
| 21 | 21 | ||
| 22 | Jean-loup Gailly Mark Adler | 22 | Jean-loup Gailly Mark Adler |
| 23 | gzip@prep.ai.mit.edu madler@alumni.caltech.edu | 23 | gzip@prep.ai.mit.edu madler@alumni.caltech.edu |
| 24 | */ | 24 | |
| 25 | |||
| 26 | The data format used by the zlib library is described by RFCs (Request for | ||
| 27 | Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt | ||
| 28 | (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). | ||
| 29 | */ | ||
| 25 | 30 | ||
| 26 | #ifndef _ZLIB_H | 31 | #ifndef _ZLIB_H |
| 27 | #define _ZLIB_H | 32 | #define _ZLIB_H |
| @@ -32,7 +37,7 @@ extern "C" { | |||
| 32 | 37 | ||
| 33 | #include "zconf.h" | 38 | #include "zconf.h" |
| 34 | 39 | ||
| 35 | #define ZLIB_VERSION "1.0.1" | 40 | #define ZLIB_VERSION "1.0.2" |
| 36 | 41 | ||
| 37 | /* | 42 | /* |
| 38 | The 'zlib' compression library provides in-memory compression and | 43 | The 'zlib' compression library provides in-memory compression and |
| @@ -156,16 +161,20 @@ typedef struct z_stream_s { | |||
| 156 | 161 | ||
| 157 | #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ | 162 | #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ |
| 158 | 163 | ||
| 159 | extern const char *zlib_version; | 164 | #define zlib_version zlibVersion() |
| 160 | /* The application can compare zlib_version and ZLIB_VERSION for consistency. | 165 | /* for compatibility with versions < 1.0.2 */ |
| 166 | |||
| 167 | /* basic functions */ | ||
| 168 | |||
| 169 | extern char EXPORT *zlibVersion OF((void)); | ||
| 170 | /* The application can compare zlibVersion and ZLIB_VERSION for consistency. | ||
| 161 | If the first character differs, the library code actually used is | 171 | If the first character differs, the library code actually used is |
| 162 | not compatible with the zlib.h header file used by the application. | 172 | not compatible with the zlib.h header file used by the application. |
| 173 | This check is automatically made by deflateInit and inflateInit. | ||
| 163 | */ | 174 | */ |
| 164 | 175 | ||
| 165 | /* basic functions */ | ||
| 166 | |||
| 167 | /* | 176 | /* |
| 168 | extern int deflateInit OF((z_stream *strm, int level)); | 177 | extern int EXPORT deflateInit OF((z_stream *strm, int level)); |
| 169 | 178 | ||
| 170 | Initializes the internal stream state for compression. The fields | 179 | Initializes the internal stream state for compression. The fields |
| 171 | zalloc, zfree and opaque must be initialized before by the caller. | 180 | zalloc, zfree and opaque must be initialized before by the caller. |
| @@ -187,7 +196,7 @@ extern int deflateInit OF((z_stream *strm, int level)); | |||
| 187 | */ | 196 | */ |
| 188 | 197 | ||
| 189 | 198 | ||
| 190 | extern int deflate OF((z_stream *strm, int flush)); | 199 | extern int EXPORT deflate OF((z_stream *strm, int flush)); |
| 191 | /* | 200 | /* |
| 192 | Performs one or both of the following actions: | 201 | Performs one or both of the following actions: |
| 193 | 202 | ||
| @@ -256,7 +265,7 @@ extern int deflate OF((z_stream *strm, int flush)); | |||
| 256 | */ | 265 | */ |
| 257 | 266 | ||
| 258 | 267 | ||
| 259 | extern int deflateEnd OF((z_stream *strm)); | 268 | extern int EXPORT deflateEnd OF((z_stream *strm)); |
| 260 | /* | 269 | /* |
| 261 | All dynamically allocated data structures for this stream are freed. | 270 | All dynamically allocated data structures for this stream are freed. |
| 262 | This function discards any unprocessed input and does not flush any | 271 | This function discards any unprocessed input and does not flush any |
| @@ -271,7 +280,7 @@ extern int deflateEnd OF((z_stream *strm)); | |||
| 271 | 280 | ||
| 272 | 281 | ||
| 273 | /* | 282 | /* |
| 274 | extern int inflateInit OF((z_stream *strm)); | 283 | extern int EXPORT inflateInit OF((z_stream *strm)); |
| 275 | 284 | ||
| 276 | Initializes the internal stream state for decompression. The fields | 285 | Initializes the internal stream state for decompression. The fields |
| 277 | zalloc, zfree and opaque must be initialized before by the caller. If | 286 | zalloc, zfree and opaque must be initialized before by the caller. If |
| @@ -286,7 +295,7 @@ extern int inflateInit OF((z_stream *strm)); | |||
| 286 | */ | 295 | */ |
| 287 | 296 | ||
| 288 | 297 | ||
| 289 | extern int inflate OF((z_stream *strm, int flush)); | 298 | extern int EXPORT inflate OF((z_stream *strm, int flush)); |
| 290 | /* | 299 | /* |
| 291 | Performs one or both of the following actions: | 300 | Performs one or both of the following actions: |
| 292 | 301 | ||
| @@ -341,7 +350,7 @@ extern int inflate OF((z_stream *strm, int flush)); | |||
| 341 | */ | 350 | */ |
| 342 | 351 | ||
| 343 | 352 | ||
| 344 | extern int inflateEnd OF((z_stream *strm)); | 353 | extern int EXPORT inflateEnd OF((z_stream *strm)); |
| 345 | /* | 354 | /* |
| 346 | All dynamically allocated data structures for this stream are freed. | 355 | All dynamically allocated data structures for this stream are freed. |
| 347 | This function discards any unprocessed input and does not flush any | 356 | This function discards any unprocessed input and does not flush any |
| @@ -359,12 +368,12 @@ extern int inflateEnd OF((z_stream *strm)); | |||
| 359 | */ | 368 | */ |
| 360 | 369 | ||
| 361 | /* | 370 | /* |
| 362 | extern int deflateInit2 OF((z_stream *strm, | 371 | extern int EXPORT deflateInit2 OF((z_stream *strm, |
| 363 | int level, | 372 | int level, |
| 364 | int method, | 373 | int method, |
| 365 | int windowBits, | 374 | int windowBits, |
| 366 | int memLevel, | 375 | int memLevel, |
| 367 | int strategy)); | 376 | int strategy)); |
| 368 | 377 | ||
| 369 | This is another version of deflateInit with more compression options. The | 378 | This is another version of deflateInit with more compression options. The |
| 370 | fields next_in, zalloc, zfree and opaque must be initialized before by | 379 | fields next_in, zalloc, zfree and opaque must be initialized before by |
| @@ -417,9 +426,9 @@ extern int deflateInit2 OF((z_stream *strm, | |||
| 417 | deflate(). | 426 | deflate(). |
| 418 | */ | 427 | */ |
| 419 | 428 | ||
| 420 | extern int deflateSetDictionary OF((z_stream *strm, | 429 | extern int EXPORT deflateSetDictionary OF((z_stream *strm, |
| 421 | const Bytef *dictionary, | 430 | const Bytef *dictionary, |
| 422 | uInt dictLength)); | 431 | uInt dictLength)); |
| 423 | /* | 432 | /* |
| 424 | Initializes the compression dictionary (history buffer) from the given | 433 | Initializes the compression dictionary (history buffer) from the given |
| 425 | byte sequence without producing any compressed output. This function must | 434 | byte sequence without producing any compressed output. This function must |
| @@ -446,8 +455,8 @@ extern int deflateSetDictionary OF((z_stream *strm, | |||
| 446 | be done by deflate(). | 455 | be done by deflate(). |
| 447 | */ | 456 | */ |
| 448 | 457 | ||
| 449 | extern int deflateCopy OF((z_stream *dest, | 458 | extern int EXPORT deflateCopy OF((z_stream *dest, |
| 450 | z_stream *source)); | 459 | z_stream *source)); |
| 451 | /* | 460 | /* |
| 452 | Sets the destination stream as a complete copy of the source stream. If | 461 | Sets the destination stream as a complete copy of the source stream. If |
| 453 | the source stream is using an application-supplied history buffer, a new | 462 | the source stream is using an application-supplied history buffer, a new |
| @@ -469,7 +478,7 @@ extern int deflateCopy OF((z_stream *dest, | |||
| 469 | destination. | 478 | destination. |
| 470 | */ | 479 | */ |
| 471 | 480 | ||
| 472 | extern int deflateReset OF((z_stream *strm)); | 481 | extern int EXPORT deflateReset OF((z_stream *strm)); |
| 473 | /* | 482 | /* |
| 474 | This function is equivalent to deflateEnd followed by deflateInit, | 483 | This function is equivalent to deflateEnd followed by deflateInit, |
| 475 | but does not free and reallocate all the internal compression state. | 484 | but does not free and reallocate all the internal compression state. |
| @@ -480,7 +489,7 @@ extern int deflateReset OF((z_stream *strm)); | |||
| 480 | stream state was inconsistent (such as zalloc or state being NULL). | 489 | stream state was inconsistent (such as zalloc or state being NULL). |
| 481 | */ | 490 | */ |
| 482 | 491 | ||
| 483 | extern int deflateParams OF((z_stream *strm, int level, int strategy)); | 492 | extern int EXPORT deflateParams OF((z_stream *strm, int level, int strategy)); |
| 484 | /* | 493 | /* |
| 485 | Dynamically update the compression level and compression strategy. | 494 | Dynamically update the compression level and compression strategy. |
| 486 | This can be used to switch between compression and straight copy of | 495 | This can be used to switch between compression and straight copy of |
| @@ -499,8 +508,8 @@ extern int deflateParams OF((z_stream *strm, int level, int strategy)); | |||
| 499 | */ | 508 | */ |
| 500 | 509 | ||
| 501 | /* | 510 | /* |
| 502 | extern int inflateInit2 OF((z_stream *strm, | 511 | extern int EXPORT inflateInit2 OF((z_stream *strm, |
| 503 | int windowBits)); | 512 | int windowBits)); |
| 504 | 513 | ||
| 505 | This is another version of inflateInit with more compression options. The | 514 | This is another version of inflateInit with more compression options. The |
| 506 | fields next_out, zalloc, zfree and opaque must be initialized before by | 515 | fields next_out, zalloc, zfree and opaque must be initialized before by |
| @@ -533,9 +542,9 @@ extern int inflateInit2 OF((z_stream *strm, | |||
| 533 | inflate(). | 542 | inflate(). |
| 534 | */ | 543 | */ |
| 535 | 544 | ||
| 536 | extern int inflateSetDictionary OF((z_stream *strm, | 545 | extern int EXPORT inflateSetDictionary OF((z_stream *strm, |
| 537 | const Bytef *dictionary, | 546 | const Bytef *dictionary, |
| 538 | uInt dictLength)); | 547 | uInt dictLength)); |
| 539 | /* | 548 | /* |
| 540 | Initializes the decompression dictionary (history buffer) from the given | 549 | Initializes the decompression dictionary (history buffer) from the given |
| 541 | uncompressed byte sequence. This function must be called immediately after | 550 | uncompressed byte sequence. This function must be called immediately after |
| @@ -552,7 +561,7 @@ extern int inflateSetDictionary OF((z_stream *strm, | |||
| 552 | inflate(). | 561 | inflate(). |
| 553 | */ | 562 | */ |
| 554 | 563 | ||
| 555 | extern int inflateSync OF((z_stream *strm)); | 564 | extern int EXPORT inflateSync OF((z_stream *strm)); |
| 556 | /* | 565 | /* |
| 557 | Skips invalid compressed data until the special marker (see deflate() | 566 | Skips invalid compressed data until the special marker (see deflate() |
| 558 | above) can be found, or until all available input is skipped. No output | 567 | above) can be found, or until all available input is skipped. No output |
| @@ -567,7 +576,7 @@ extern int inflateSync OF((z_stream *strm)); | |||
| 567 | until success or end of the input data. | 576 | until success or end of the input data. |
| 568 | */ | 577 | */ |
| 569 | 578 | ||
| 570 | extern int inflateReset OF((z_stream *strm)); | 579 | extern int EXPORT inflateReset OF((z_stream *strm)); |
| 571 | /* | 580 | /* |
| 572 | This function is equivalent to inflateEnd followed by inflateInit, | 581 | This function is equivalent to inflateEnd followed by inflateInit, |
| 573 | but does not free and reallocate all the internal decompression state. | 582 | but does not free and reallocate all the internal decompression state. |
| @@ -588,8 +597,8 @@ extern int inflateReset OF((z_stream *strm)); | |||
| 588 | utility functions can easily be modified if you need special options. | 597 | utility functions can easily be modified if you need special options. |
| 589 | */ | 598 | */ |
| 590 | 599 | ||
| 591 | extern int compress OF((Bytef *dest, uLongf *destLen, | 600 | extern int EXPORT compress OF((Bytef *dest, uLongf *destLen, |
| 592 | const Bytef *source, uLong sourceLen)); | 601 | const Bytef *source, uLong sourceLen)); |
| 593 | /* | 602 | /* |
| 594 | Compresses the source buffer into the destination buffer. sourceLen is | 603 | Compresses the source buffer into the destination buffer. sourceLen is |
| 595 | the byte length of the source buffer. Upon entry, destLen is the total | 604 | the byte length of the source buffer. Upon entry, destLen is the total |
| @@ -603,8 +612,8 @@ extern int compress OF((Bytef *dest, uLongf *destLen, | |||
| 603 | buffer. | 612 | buffer. |
| 604 | */ | 613 | */ |
| 605 | 614 | ||
| 606 | extern int uncompress OF((Bytef *dest, uLongf *destLen, | 615 | extern int EXPORT uncompress OF((Bytef *dest, uLongf *destLen, |
| 607 | const Bytef *source, uLong sourceLen)); | 616 | const Bytef *source, uLong sourceLen)); |
| 608 | /* | 617 | /* |
| 609 | Decompresses the source buffer into the destination buffer. sourceLen is | 618 | Decompresses the source buffer into the destination buffer. sourceLen is |
| 610 | the byte length of the source buffer. Upon entry, destLen is the total | 619 | the byte length of the source buffer. Upon entry, destLen is the total |
| @@ -624,7 +633,7 @@ extern int uncompress OF((Bytef *dest, uLongf *destLen, | |||
| 624 | 633 | ||
| 625 | typedef voidp gzFile; | 634 | typedef voidp gzFile; |
| 626 | 635 | ||
| 627 | extern gzFile gzopen OF((const char *path, const char *mode)); | 636 | extern gzFile EXPORT gzopen OF((const char *path, const char *mode)); |
| 628 | /* | 637 | /* |
| 629 | Opens a gzip (.gz) file for reading or writing. The mode parameter | 638 | Opens a gzip (.gz) file for reading or writing. The mode parameter |
| 630 | is as in fopen ("rb" or "wb") but can also include a compression level | 639 | is as in fopen ("rb" or "wb") but can also include a compression level |
| @@ -636,7 +645,7 @@ extern gzFile gzopen OF((const char *path, const char *mode)); | |||
| 636 | zlib error is Z_MEM_ERROR). | 645 | zlib error is Z_MEM_ERROR). |
| 637 | */ | 646 | */ |
| 638 | 647 | ||
| 639 | extern gzFile gzdopen OF((int fd, const char *mode)); | 648 | extern gzFile EXPORT gzdopen OF((int fd, const char *mode)); |
| 640 | /* | 649 | /* |
| 641 | gzdopen() associates a gzFile with the file descriptor fd. File | 650 | gzdopen() associates a gzFile with the file descriptor fd. File |
| 642 | descriptors are obtained from calls like open, dup, creat, pipe or | 651 | descriptors are obtained from calls like open, dup, creat, pipe or |
| @@ -649,7 +658,7 @@ extern gzFile gzdopen OF((int fd, const char *mode)); | |||
| 649 | the (de)compression state. | 658 | the (de)compression state. |
| 650 | */ | 659 | */ |
| 651 | 660 | ||
| 652 | extern int gzread OF((gzFile file, voidp buf, unsigned len)); | 661 | extern int EXPORT gzread OF((gzFile file, voidp buf, unsigned len)); |
| 653 | /* | 662 | /* |
| 654 | Reads the given number of uncompressed bytes from the compressed file. | 663 | Reads the given number of uncompressed bytes from the compressed file. |
| 655 | If the input file was not in gzip format, gzread copies the given number | 664 | If the input file was not in gzip format, gzread copies the given number |
| @@ -657,14 +666,14 @@ extern int gzread OF((gzFile file, voidp buf, unsigned len)); | |||
| 657 | gzread returns the number of uncompressed bytes actually read (0 for | 666 | gzread returns the number of uncompressed bytes actually read (0 for |
| 658 | end of file, -1 for error). */ | 667 | end of file, -1 for error). */ |
| 659 | 668 | ||
| 660 | extern int gzwrite OF((gzFile file, const voidp buf, unsigned len)); | 669 | extern int EXPORT gzwrite OF((gzFile file, const voidp buf, unsigned len)); |
| 661 | /* | 670 | /* |
| 662 | Writes the given number of uncompressed bytes into the compressed file. | 671 | Writes the given number of uncompressed bytes into the compressed file. |
| 663 | gzwrite returns the number of uncompressed bytes actually written | 672 | gzwrite returns the number of uncompressed bytes actually written |
| 664 | (0 in case of error). | 673 | (0 in case of error). |
| 665 | */ | 674 | */ |
| 666 | 675 | ||
| 667 | extern int gzflush OF((gzFile file, int flush)); | 676 | extern int EXPORT gzflush OF((gzFile file, int flush)); |
| 668 | /* | 677 | /* |
| 669 | Flushes all pending output into the compressed file. The parameter | 678 | Flushes all pending output into the compressed file. The parameter |
| 670 | flush is as in the deflate() function. The return value is the zlib | 679 | flush is as in the deflate() function. The return value is the zlib |
| @@ -674,14 +683,14 @@ extern int gzflush OF((gzFile file, int flush)); | |||
| 674 | degrade compression. | 683 | degrade compression. |
| 675 | */ | 684 | */ |
| 676 | 685 | ||
| 677 | extern int gzclose OF((gzFile file)); | 686 | extern int EXPORT gzclose OF((gzFile file)); |
| 678 | /* | 687 | /* |
| 679 | Flushes all pending output if necessary, closes the compressed file | 688 | Flushes all pending output if necessary, closes the compressed file |
| 680 | and deallocates all the (de)compression state. The return value is the zlib | 689 | and deallocates all the (de)compression state. The return value is the zlib |
| 681 | error number (see function gzerror below). | 690 | error number (see function gzerror below). |
| 682 | */ | 691 | */ |
| 683 | 692 | ||
| 684 | extern char* gzerror OF((gzFile file, int *errnum)); | 693 | extern char EXPORT *gzerror OF((gzFile file, int *errnum)); |
| 685 | /* | 694 | /* |
| 686 | Returns the error message for the last error which occurred on the | 695 | Returns the error message for the last error which occurred on the |
| 687 | given compressed file. errnum is set to zlib error number. If an | 696 | given compressed file. errnum is set to zlib error number. If an |
| @@ -698,7 +707,7 @@ extern char* gzerror OF((gzFile file, int *errnum)); | |||
| 698 | compression library. | 707 | compression library. |
| 699 | */ | 708 | */ |
| 700 | 709 | ||
| 701 | extern uLong adler32 OF((uLong adler, const Bytef *buf, uInt len)); | 710 | extern uLong EXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); |
| 702 | 711 | ||
| 703 | /* | 712 | /* |
| 704 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and | 713 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and |
| @@ -715,7 +724,7 @@ extern uLong adler32 OF((uLong adler, const Bytef *buf, uInt len)); | |||
| 715 | if (adler != original_adler) error(); | 724 | if (adler != original_adler) error(); |
| 716 | */ | 725 | */ |
| 717 | 726 | ||
| 718 | extern uLong crc32 OF((uLong crc, const Bytef *buf, uInt len)); | 727 | extern uLong EXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); |
| 719 | /* | 728 | /* |
| 720 | Update a running crc with the bytes buf[0..len-1] and return the updated | 729 | Update a running crc with the bytes buf[0..len-1] and return the updated |
| 721 | crc. If buf is NULL, this function returns the required initial value | 730 | crc. If buf is NULL, this function returns the required initial value |
| @@ -737,15 +746,15 @@ extern uLong crc32 OF((uLong crc, const Bytef *buf, uInt len)); | |||
| 737 | /* deflateInit and inflateInit are macros to allow checking the zlib version | 746 | /* deflateInit and inflateInit are macros to allow checking the zlib version |
| 738 | * and the compiler's view of z_stream: | 747 | * and the compiler's view of z_stream: |
| 739 | */ | 748 | */ |
| 740 | extern int deflateInit_ OF((z_stream *strm, int level, | 749 | extern int EXPORT deflateInit_ OF((z_stream *strm, int level, |
| 741 | const char *version, int stream_size)); | 750 | const char *version, int stream_size)); |
| 742 | extern int inflateInit_ OF((z_stream *strm, | 751 | extern int EXPORT inflateInit_ OF((z_stream *strm, |
| 743 | const char *version, int stream_size)); | 752 | const char *version, int stream_size)); |
| 744 | extern int deflateInit2_ OF((z_stream *strm, int level, int method, | 753 | extern int EXPORT deflateInit2_ OF((z_stream *strm, int level, int method, |
| 745 | int windowBits, int memLevel, int strategy, | 754 | int windowBits, int memLevel, int strategy, |
| 746 | const char *version, int stream_size)); | 755 | const char *version, int stream_size)); |
| 747 | extern int inflateInit2_ OF((z_stream *strm, int windowBits, | 756 | extern int EXPORT inflateInit2_ OF((z_stream *strm, int windowBits, |
| 748 | const char *version, int stream_size)); | 757 | const char *version, int stream_size)); |
| 749 | #define deflateInit(strm, level) \ | 758 | #define deflateInit(strm, level) \ |
| 750 | deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) | 759 | deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) |
| 751 | #define inflateInit(strm) \ | 760 | #define inflateInit(strm) \ |
| @@ -0,0 +1,32 @@ | |||
| 1 | #include <windows.h> | ||
| 2 | |||
| 3 | #define IDR_VERSION1 1 | ||
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE | ||
| 5 | FILEVERSION 1,0,2,0 | ||
| 6 | PRODUCTVERSION 1,0,2,0 | ||
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | ||
| 8 | FILEFLAGS 0 | ||
| 9 | FILEOS VOS_DOS_WINDOWS32 | ||
| 10 | FILETYPE VFT_DLL | ||
| 11 | FILESUBTYPE 0 // not used | ||
| 12 | BEGIN | ||
| 13 | BLOCK "StringFileInfo" | ||
| 14 | BEGIN | ||
| 15 | BLOCK "040904E4" | ||
| 16 | //language ID = U.S. English, char set = Windows, Multilingual | ||
| 17 | |||
| 18 | BEGIN | ||
| 19 | VALUE "FileDescription", "zlib data compression library\0" | ||
| 20 | VALUE "FileVersion", "1.0.2\0" | ||
| 21 | VALUE "InternalName", "zlib\0" | ||
| 22 | VALUE "OriginalFilename", "zlib.lib\0" | ||
| 23 | VALUE "ProductName", "ZLib.DLL\0" | ||
| 24 | VALUE "Comments", "DLL support by Alessandro Iacopetti\0" | ||
| 25 | VALUE "LegalCopyright", "(C) 1995-1996 Jean-loup Gailly & Mark Adler\0" | ||
| 26 | END | ||
| 27 | END | ||
| 28 | BLOCK "VarFileInfo" | ||
| 29 | BEGIN | ||
| 30 | VALUE "Translation", 0x0409, 1252 | ||
| 31 | END | ||
| 32 | END | ||
| @@ -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.12 1996/01/30 21:59:29 me Exp $ */ | 6 | /* $Id: zutil.c,v 1.15 1996/05/23 17:11:36 me Exp $ */ |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | 9 | ||
| @@ -15,8 +15,6 @@ struct internal_state {int dummy;}; /* for buggy compilers */ | |||
| 15 | extern void exit OF((int)); | 15 | extern void exit OF((int)); |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | const char *zlib_version = ZLIB_VERSION; | ||
| 19 | |||
| 20 | const char *z_errmsg[10] = { | 18 | const char *z_errmsg[10] = { |
| 21 | "need dictionary", /* Z_NEED_DICT 2 */ | 19 | "need dictionary", /* Z_NEED_DICT 2 */ |
| 22 | "stream end", /* Z_STREAM_END 1 */ | 20 | "stream end", /* Z_STREAM_END 1 */ |
| @@ -30,6 +28,11 @@ const char *z_errmsg[10] = { | |||
| 30 | ""}; | 28 | ""}; |
| 31 | 29 | ||
| 32 | 30 | ||
| 31 | char *zlibVersion() | ||
| 32 | { | ||
| 33 | return ZLIB_VERSION; | ||
| 34 | } | ||
| 35 | |||
| 33 | void z_error (m) | 36 | void z_error (m) |
| 34 | char *m; | 37 | char *m; |
| 35 | { | 38 | { |
| @@ -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: zutil.h,v 1.13 1996/01/30 21:59:29 me Exp $ */ | 11 | /* $Id: zutil.h,v 1.14 1996/05/22 11:52:40 me Exp $ */ |
| 12 | 12 | ||
| 13 | #ifndef _Z_UTIL_H | 13 | #ifndef _Z_UTIL_H |
| 14 | #define _Z_UTIL_H | 14 | #define _Z_UTIL_H |
