zlib 1.0.2
This commit is contained in:
parent
423eb40306
commit
e26a448e96
10
ChangeLog
10
ChangeLog
@ -1,6 +1,16 @@
|
||||
|
||||
ChangeLog file for zlib
|
||||
|
||||
Changes in 1.0.2 (23 May 96)
|
||||
- added Windows DLL support
|
||||
- added a function zlibVersion (for the DLL support)
|
||||
- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model)
|
||||
- Bytef is define's instead of typedef'd only for Borland C
|
||||
- avoid reading uninitialized memory in example.c
|
||||
- mention in README that the zlib format is now RFC1950
|
||||
- updated Makefile.dj2
|
||||
- added algorithm.doc
|
||||
|
||||
Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
|
||||
- fix array overlay in deflate.c which sometimes caused bad compressed data
|
||||
- fix inflate bug with empty stored block
|
||||
|
4
INDEX
4
INDEX
@ -11,8 +11,12 @@ Makefile.sas makefile for Amiga SAS/C
|
||||
Makefile.tc makefile for Turbo C
|
||||
Makefile.wat makefile for Watcom C
|
||||
README guess what
|
||||
algorithm.doc description of the compression & decompression algorithms
|
||||
configure configure script for Unix
|
||||
descrip.mms makefile for Vax/VMS
|
||||
zlib.def definition file for Windows DLL
|
||||
zlib.rc definition file for Windows DLL
|
||||
|
||||
|
||||
zlib public header files (must be kept):
|
||||
zconf.h
|
||||
|
9
Makefile
9
Makefile
@ -22,7 +22,7 @@ CFLAGS=-O
|
||||
LDFLAGS=-L. -lz
|
||||
LDSHARED=$(CC)
|
||||
|
||||
VER=1.0.1
|
||||
VER=1.0.2
|
||||
LIBS=libz.a
|
||||
|
||||
AR=ar rc
|
||||
@ -37,7 +37,8 @@ OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] descrip.mms *.[ch]
|
||||
DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] descrip.mms \
|
||||
zlib.def zlib.rc algorithm.doc *.[ch]
|
||||
|
||||
all: example minigzip
|
||||
|
||||
@ -85,8 +86,8 @@ clean:
|
||||
|
||||
zip:
|
||||
mv Makefile Makefile~; cp -p Makefile.in Makefile
|
||||
v=`sed -n -e 's/\./-/g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
|
||||
zip -ul9 zlib-$$v $(DISTFILES)
|
||||
v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
|
||||
zip -ul9 zlib$$v $(DISTFILES)
|
||||
mv Makefile~ Makefile
|
||||
|
||||
dist:
|
||||
|
59
Makefile.dj2
59
Makefile.dj2
@ -2,32 +2,51 @@
|
||||
# Copyright (C) 1995-1996 Jean-loup Gailly.
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile and test, type:
|
||||
# To compile, or to compile and test, type:
|
||||
#
|
||||
# make -fmakefile.dj2; make test -fmakefile.dj2
|
||||
|
||||
#
|
||||
# To install libz.a, zconf.h and zlib.h in the djgpp directories, type:
|
||||
#
|
||||
# make install -fmakefile.dj2
|
||||
# after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env for [make].
|
||||
# Alternately these variables may be defined below.
|
||||
#
|
||||
# after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as
|
||||
# in the sample below if the pattern of the DJGPP distribution is to
|
||||
# be followed. Remember that, while <sp>'es around <=> are ignored in
|
||||
# makefiles, they are *not* in batch files or in djgpp.env.
|
||||
# - - - - -
|
||||
# [make]
|
||||
# INCLUDE_PATH=%\>;INCLUDE_PATH%%\DJDIR%\include
|
||||
# LIBRARY_PATH=%\>;LIBRARY_PATH%%\DJDIR%\lib
|
||||
# BUTT=-m486
|
||||
# - - - - -
|
||||
# Alternately, these variables may be defined below, overriding the values
|
||||
# in djgpp.env, as
|
||||
INCLUDE_PATH=c:\usr\include
|
||||
|
||||
CC=gcc
|
||||
|
||||
#CFLAGS=-MMD -O
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-MMD -g -DDEBUG
|
||||
CFLAGS=-MMD -O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
-Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
# If cp.exe is not found, replace with copy /Y .
|
||||
CP=cp -f
|
||||
# If install.exe is not found, replace with $(CP).
|
||||
INSTALL=install
|
||||
# The default value of RM is "rm -f." If "rm.exe" is not found, uncomment:
|
||||
# RM=del
|
||||
LDLIBS=-L. -lz
|
||||
LD=$(CC) -s -o
|
||||
LDSHARED=$(CC)
|
||||
|
||||
VER=1.0
|
||||
VER=1.0.2
|
||||
INCL=zlib.h zconf.h
|
||||
LIBS=libz.a
|
||||
|
||||
AR=ar rcs
|
||||
# The default value of RM is "rm -f." If "rm.exe" is not found, uncomment:
|
||||
# RM=del
|
||||
|
||||
prefix=/usr/local
|
||||
exec_prefix = $(prefix)
|
||||
@ -37,10 +56,6 @@ OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
DISTFILES = README Change.Log configur Makefile.in Makefile Makefile.msc \
|
||||
Makefile.bor Makefile.tc Make_vms.com descrip.mms zlib099.pat \
|
||||
*.bak *.old *.[ch]
|
||||
|
||||
all: example.exe minigzip.exe
|
||||
|
||||
test: all
|
||||
@ -55,23 +70,27 @@ libz.a: $(OBJS)
|
||||
|
||||
libz.so.$(VER): $(OBJS)
|
||||
$(LDSHARED) -o $@ $(OBJS)
|
||||
rm -f libz.so; ln -s $@ libz.so
|
||||
$(RM) libz.so; ln -s $@ libz.so
|
||||
|
||||
%.exe : %.o $(LIBS)
|
||||
$(LD) $@ $< $(LDLIBS)
|
||||
|
||||
# INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env
|
||||
# INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env .
|
||||
|
||||
install: $(LIBS)
|
||||
$(INSTALL) zlib.h zconf.h $(INCLUDE_PATH)
|
||||
$(INSTALL) $(LIBS) $(LIBRARY_PATH)
|
||||
.PHONY : uninstall clean
|
||||
|
||||
install: $(INCL) $(LIBS)
|
||||
-@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH)
|
||||
-@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH)
|
||||
for %%f in ($(INCL)) do $(INSTALL) %%f $(INCLUDE_PATH)
|
||||
for %%p in ($(LIBS)) do $(INSTALL) %%p $(LIBRARY_PATH)
|
||||
|
||||
uninstall:
|
||||
$(RM) $(LIBRARY_PATH)/$(LIBS)
|
||||
$(RM) $(INCLUDE_PATH)/zlib.h $(INCLUDE_PATH)/zconf.h
|
||||
for %%f in ($(INCL)) do $(RM) $(INCLUDE_PATH)\%%f
|
||||
for %%p in ($(LIBS)) do $(RM) $(LIBRARY_PATH)\%%p
|
||||
|
||||
clean:
|
||||
$(RM) *.d *.o *.~ *.exe libz.a libz.so* foo.gz
|
||||
for %%p in (*.d *.o *.exe libz.a libz.so*) do $(RM) %%p
|
||||
|
||||
DEPS := $(wildcard *.d)
|
||||
ifneq ($(DEPS),)
|
||||
|
@ -22,7 +22,7 @@ CFLAGS=-O
|
||||
LDFLAGS=-L. -lz
|
||||
LDSHARED=$(CC)
|
||||
|
||||
VER=1.0.1
|
||||
VER=1.0.2
|
||||
LIBS=libz.a
|
||||
|
||||
AR=ar rc
|
||||
@ -37,7 +37,8 @@ OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
|
||||
|
||||
TEST_OBJS = example.o minigzip.o
|
||||
|
||||
DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] descrip.mms *.[ch]
|
||||
DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] descrip.mms \
|
||||
zlib.def zlib.rc algorithm.doc *.[ch]
|
||||
|
||||
all: example minigzip
|
||||
|
||||
@ -85,8 +86,8 @@ clean:
|
||||
|
||||
zip:
|
||||
mv Makefile Makefile~; cp -p Makefile.in Makefile
|
||||
v=`sed -n -e 's/\./-/g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
|
||||
zip -ul9 zlib-$$v $(DISTFILES)
|
||||
v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
|
||||
zip -ul9 zlib$$v $(DISTFILES)
|
||||
mv Makefile~ Makefile
|
||||
|
||||
dist:
|
||||
|
29
README
29
README
@ -1,8 +1,9 @@
|
||||
zlib 1.0.1 is a general purpose data compression library. All the code
|
||||
zlib 1.0.2 is a general purpose data compression library. All the code
|
||||
is reentrant (thread safe). The data format used by the zlib library
|
||||
is described in the files zlib-3.3.doc, deflate-1.3.doc and
|
||||
gzip-4.3.doc, available in various formats from
|
||||
ftp://swrinde.nde.swri.edu/pub/png/documents/zlib/
|
||||
is described by RFCs (Request for Comments) 1950 to 1952 in the files
|
||||
ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
|
||||
format) and rfc1952.txt (gzip format). These documents are also available in
|
||||
other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
||||
|
||||
All functions of the compression library are documented in the file
|
||||
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.
|
||||
Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov> or,
|
||||
if this fails, to the addresses given below in the Copyright section.
|
||||
|
||||
The changes made in version 1.0.1 are documented in the file ChangeLog.
|
||||
Version number 1.0 was skipped to avoid confusion with version 0.99
|
||||
which had some references to 1.0 already. The main changes since 0.99 are:
|
||||
The changes made in version 1.0.2 are documented in the file ChangeLog.
|
||||
The main changes since 0.99 are:
|
||||
|
||||
- fix array overlay in deflate.c which sometimes caused bad compressed data
|
||||
- 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:
|
||||
- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
|
||||
Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas)
|
||||
- several portability improvements
|
||||
- added algorithm.doc
|
||||
- added Windows DLL support
|
||||
- added a function zlibVersion (for the DLL support)
|
||||
|
||||
A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk>
|
||||
is in the CPAN (Comprehensive Perl Archive Network) sites, such as:
|
||||
ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib*
|
||||
|
||||
|
||||
Notes for some targets:
|
||||
|
||||
@ -46,9 +54,10 @@ Notes for some targets:
|
||||
- zlib doesn't work on HP-UX 9.05 with one cc compiler (the one not
|
||||
accepting the -O option). It works with the other cc compiler.
|
||||
|
||||
A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk>
|
||||
is in the CPAN (Comprehensive Perl Archive Network) sites, such as:
|
||||
ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib*
|
||||
- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
|
||||
and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL
|
||||
For help on building a zlib DLL, contact Alessandro Iacopetti
|
||||
<iaco@cicladi.unial.it>
|
||||
|
||||
|
||||
Acknowledgments:
|
||||
|
@ -3,7 +3,7 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* $Id: adler32.c,v 1.9 1996/01/30 21:59:09 me Exp $ */
|
||||
/* $Id: adler32.c,v 1.10 1996/05/22 11:52:18 me Exp $ */
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
|
105
algorithm.doc
Normal file
105
algorithm.doc
Normal file
@ -0,0 +1,105 @@
|
||||
1. Compression algorithm (deflate)
|
||||
|
||||
The deflation algorithm used by zlib (also zip and gzip) is a variation of
|
||||
LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in
|
||||
the input data. The second occurrence of a string is replaced by a
|
||||
pointer to the previous string, in the form of a pair (distance,
|
||||
length). Distances are limited to 32K bytes, and lengths are limited
|
||||
to 258 bytes. When a string does not occur anywhere in the previous
|
||||
32K bytes, it is emitted as a sequence of literal bytes. (In this
|
||||
description, 'string' must be taken as an arbitrary sequence of bytes,
|
||||
and is not restricted to printable characters.)
|
||||
|
||||
Literals or match lengths are compressed with one Huffman tree, and
|
||||
match distances are compressed with another tree. The trees are stored
|
||||
in a compact form at the start of each block. The blocks can have any
|
||||
size (except that the compressed data for one block must fit in
|
||||
available memory). A block is terminated when deflate() determines that
|
||||
it would be useful to start another block with fresh trees. (This is
|
||||
somewhat similar to compress.)
|
||||
|
||||
Duplicated strings are found using a hash table. All input strings of
|
||||
length 3 are inserted in the hash table. A hash index is computed for
|
||||
the next 3 bytes. If the hash chain for this index is not empty, all
|
||||
strings in the chain are compared with the current input string, and
|
||||
the longest match is selected.
|
||||
|
||||
The hash chains are searched starting with the most recent strings, to
|
||||
favor small distances and thus take advantage of the Huffman encoding.
|
||||
The hash chains are singly linked. There are no deletions from the
|
||||
hash chains, the algorithm simply discards matches that are too old.
|
||||
|
||||
To avoid a worst-case situation, very long hash chains are arbitrarily
|
||||
truncated at a certain length, determined by a runtime option (level
|
||||
parameter of deflateInit). So deflate() does not always find the longest
|
||||
possible match but generally finds a match which is long enough.
|
||||
|
||||
deflate() also defers the selection of matches with a lazy evaluation
|
||||
mechanism. After a match of length N has been found, deflate() searches for a
|
||||
longer match at the next input byte. If a longer match is found, the
|
||||
previous match is truncated to a length of one (thus producing a single
|
||||
literal byte) and the longer match is emitted afterwards. Otherwise,
|
||||
the original match is kept, and the next match search is attempted only
|
||||
N steps later.
|
||||
|
||||
The lazy match evaluation is also subject to a runtime parameter. If
|
||||
the current match is long enough, deflate() reduces the search for a longer
|
||||
match, thus speeding up the whole process. If compression ratio is more
|
||||
important than speed, deflate() attempts a complete second search even if
|
||||
the first match is already long enough.
|
||||
|
||||
The lazy match evaluation is not performed for the fastest compression
|
||||
modes (level parameter 1 to 3). For these fast modes, new strings
|
||||
are inserted in the hash table only when no match was found, or
|
||||
when the match is not too long. This degrades the compression ratio
|
||||
but saves time since there are both fewer insertions and fewer searches.
|
||||
|
||||
|
||||
2. Decompression algorithm (inflate)
|
||||
|
||||
The real question is given a Huffman tree, how to decode fast. The most
|
||||
important realization is that shorter codes are much more common than
|
||||
longer codes, so pay attention to decoding the short codes fast, and let
|
||||
the long codes take longer to decode.
|
||||
|
||||
inflate() sets up a first level table that covers some number of bits of
|
||||
input less than the length of longest code. It gets that many bits from the
|
||||
stream, and looks it up in the table. The table will tell if the next
|
||||
code is that many bits or less and how many, and if it is, it will tell
|
||||
the value, else it will point to the next level table for which inflate()
|
||||
grabs more bits and tries to decode a longer code.
|
||||
|
||||
How many bits to make the first lookup is a tradeoff between the time it
|
||||
takes to decode and the time it takes to build the table. If building the
|
||||
table took no time (and if you had infinite memory), then there would only
|
||||
be a first level table to cover all the way to the longest code. However,
|
||||
building the table ends up taking a lot longer for more bits since short
|
||||
codes are replicated many times in such a table. What inflate() does is
|
||||
simply to make the number of bits in the first table a variable, and set it
|
||||
for the maximum speed.
|
||||
|
||||
inflate() sends new trees relatively often, so it is possibly set for a
|
||||
smaller first level table than an application that has only one tree for
|
||||
all the data. For inflate, which has 286 possible codes for the
|
||||
literal/length tree, the size of the first table is nine bits. Also the
|
||||
distance trees have 30 possible values, and the size of the first table is
|
||||
six bits. Note that for each of those cases, the table ended up one bit
|
||||
longer than the "average" code length, i.e. the code length of an
|
||||
approximately flat code which would be a little more than eight bits for
|
||||
286 symbols and a little less than five bits for 30 symbols. It would be
|
||||
interesting to see if optimizing the first level table for other
|
||||
applications gave values within a bit or two of the flat code size.
|
||||
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
gzip@prep.ai.mit.edu madler@alumni.caltech.edu
|
||||
|
||||
|
||||
References:
|
||||
|
||||
[LZ77] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data
|
||||
Compression", IEEE Transactions on Information Theory", Vol. 23, No. 3,
|
||||
pp. 337-343.
|
||||
|
||||
"DEFLATE Compressed Data Format Specification" available in
|
||||
ftp://ds.internic.net/rfc/rfc1951.txt
|
@ -3,7 +3,7 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* $Id: compress.c,v 1.9 1996/01/30 21:59:09 me Exp $ */
|
||||
/* $Id: compress.c,v 1.10 1996/05/23 16:51:12 me Exp $ */
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
@ -30,9 +30,10 @@ int compress (dest, destLen, source, sourceLen)
|
||||
|
||||
stream.next_in = (Bytef*)source;
|
||||
stream.avail_in = (uInt)sourceLen;
|
||||
#ifdef MAXSEG_64K
|
||||
/* Check for source > 64K on 16-bit machine: */
|
||||
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
|
||||
|
||||
#endif
|
||||
stream.next_out = dest;
|
||||
stream.avail_out = (uInt)*destLen;
|
||||
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
|
||||
|
@ -47,11 +47,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* $Id: deflate.c,v 1.12 1996/01/30 21:59:11 me Exp $ */
|
||||
/* $Id: deflate.c,v 1.13 1996/05/22 11:52:21 me Exp $ */
|
||||
|
||||
#include "deflate.h"
|
||||
|
||||
char deflate_copyright[] = " deflate 1.0.1 Copyright 1995-1996 Jean-loup Gailly ";
|
||||
char deflate_copyright[] = " deflate 1.0.2 Copyright 1995-1996 Jean-loup Gailly ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
|
13
example.c
13
example.c
@ -3,7 +3,7 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* $Id: example.c,v 1.13 1996/01/30 21:59:13 me Exp $ */
|
||||
/* $Id: example.c,v 1.16 1996/05/23 17:11:28 me Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "zlib.h"
|
||||
@ -462,16 +462,19 @@ int main(argc, argv)
|
||||
uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
|
||||
uLong uncomprLen = comprLen;
|
||||
|
||||
if (zlib_version[0] != ZLIB_VERSION[0]) {
|
||||
if (zlibVersion()[0] != ZLIB_VERSION[0]) {
|
||||
fprintf(stderr, "incompatible zlib version\n");
|
||||
exit(1);
|
||||
|
||||
} else if (strcmp(zlib_version, ZLIB_VERSION) != 0) {
|
||||
} else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
|
||||
fprintf(stderr, "warning: different zlib version\n");
|
||||
}
|
||||
|
||||
compr = (Byte*)malloc((uInt)comprLen);
|
||||
uncompr = (Byte*)calloc((uInt)uncomprLen, 1); /* must be cleared */
|
||||
compr = (Byte*)calloc((uInt)comprLen, 1);
|
||||
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
|
||||
/* compr and uncompr are cleared to avoid reading uninitialized
|
||||
* data and to ensure that uncompr compresses well.
|
||||
*/
|
||||
if (compr == Z_NULL || uncompr == Z_NULL) {
|
||||
printf("out of memory\n");
|
||||
exit(1);
|
||||
|
2
gzio.c
2
gzio.c
@ -3,7 +3,7 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* $Id: gzio.c,v 1.12 1996/01/30 21:59:14 me Exp $ */
|
||||
/* $Id: gzio.c,v 1.13 1996/05/22 11:52:24 me Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
|
||||
char inflate_copyright[] = " inflate 1.0.1 Copyright 1995-1996 Mark Adler ";
|
||||
char inflate_copyright[] = " inflate 1.0.2 Copyright 1995-1996 Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
|
@ -26,7 +26,8 @@ z_stream *z;
|
||||
int r;
|
||||
{
|
||||
uInt n;
|
||||
Bytef *p, *q;
|
||||
Bytef *p;
|
||||
Bytef *q;
|
||||
|
||||
/* local copies of source and destination pointers */
|
||||
p = z->next_out;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* or in pipe mode.
|
||||
*/
|
||||
|
||||
/* $Id: minigzip.c,v 1.8 1996/01/30 21:59:23 me Exp $ */
|
||||
/* $Id: minigzip.c,v 1.9 1996/05/22 11:52:32 me Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "zlib.h"
|
||||
|
2
trees.c
2
trees.c
@ -29,7 +29,7 @@
|
||||
* Addison-Wesley, 1983. ISBN 0-201-06672-6.
|
||||
*/
|
||||
|
||||
/* $Id: trees.c,v 1.5 1995/05/03 17:27:12 jloup Exp $ */
|
||||
/* $Id: trees.c,v 1.10 1996/05/22 11:52:34 me Exp $ */
|
||||
|
||||
#include "deflate.h"
|
||||
|
||||
|
26
zconf.h
26
zconf.h
@ -3,7 +3,7 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* $Id: zconf.h,v 1.12 1995/05/03 17:27:12 jloup Exp $ */
|
||||
/* $Id: zconf.h,v 1.18 1996/05/23 16:51:18 me Exp $ */
|
||||
|
||||
#ifndef _ZCONF_H
|
||||
#define _ZCONF_H
|
||||
@ -37,7 +37,7 @@
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
/* # define Bytef z_Bytef */
|
||||
# define Bytef z_Bytef
|
||||
# define charf z_charf
|
||||
# define intf z_intf
|
||||
# define uIntf z_uIntf
|
||||
@ -128,7 +128,8 @@
|
||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||
* just define FAR to be empty.
|
||||
*/
|
||||
#if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */
|
||||
#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR __far
|
||||
@ -137,14 +138,16 @@
|
||||
# endif
|
||||
#endif
|
||||
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
# ifndef __32BIT__
|
||||
# define SMALL_MEDIUM
|
||||
# define FAR __far
|
||||
# endif
|
||||
#endif
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
/* The Watcom compiler defines M_I86SM and __SMALL__ even in 32 bit mode */
|
||||
#if defined(__WATCOMC__) && defined(__386__)
|
||||
#if defined(__WATCOMC__) && defined(__386__) && defined(SMALL_MEDIUM)
|
||||
# undef FAR
|
||||
# define FAR
|
||||
# undef SMALL_MEDIUM
|
||||
@ -154,8 +157,12 @@ typedef unsigned char Byte; /* 8 bits */
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
/* "typedef Byte FAR Bytef;" doesn't work with Borland C/C++ */
|
||||
#if defined(__BORLANDC__) && defined(SMALL_MEDIUM)
|
||||
/* Borland C/C++ ignores FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
typedef uInt FAR uIntf;
|
||||
@ -169,4 +176,13 @@ typedef uLong FAR uLongf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
|
||||
/* Compile with -DZLIB_DLL for Windows DLL support */
|
||||
#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL)
|
||||
# include <windows.h>
|
||||
# define EXPORT WINAPI
|
||||
#else
|
||||
# define EXPORT
|
||||
#endif
|
||||
|
||||
#endif /* _ZCONF_H */
|
||||
|
46
zlib.def
Normal file
46
zlib.def
Normal file
@ -0,0 +1,46 @@
|
||||
LIBRARY "zlib"
|
||||
|
||||
DESCRIPTION '"""zlib data compression library"""'
|
||||
|
||||
EXETYPE NT
|
||||
|
||||
SUBSYSTEM WINDOWS
|
||||
|
||||
STUB 'WINSTUB.EXE'
|
||||
|
||||
VERSION 1.0.2
|
||||
|
||||
CODE EXECUTE READ
|
||||
|
||||
DATA READ WRITE
|
||||
|
||||
HEAPSIZE 1048576,4096
|
||||
|
||||
EXPORTS
|
||||
zlibVersion
|
||||
deflate
|
||||
deflateEnd
|
||||
inflate
|
||||
inflateEnd
|
||||
deflateSetDictionary
|
||||
deflateCopy
|
||||
deflateReset
|
||||
deflateParams
|
||||
inflateSetDictionary
|
||||
inflateSync
|
||||
inflateReset
|
||||
compress
|
||||
uncompress
|
||||
gzopen
|
||||
gzdopen
|
||||
gzread
|
||||
gzwrite
|
||||
gzflush
|
||||
gzclose
|
||||
gzerror
|
||||
adler32
|
||||
crc32
|
||||
deflateInit_
|
||||
inflateInit_
|
||||
deflateInit2_
|
||||
inflateInit2_
|
83
zlib.h
83
zlib.h
@ -1,5 +1,5 @@
|
||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.0.1, May 20th, 1996.
|
||||
version 1.0.2, May 23rd, 1996.
|
||||
|
||||
Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler
|
||||
|
||||
@ -21,6 +21,11 @@
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
gzip@prep.ai.mit.edu madler@alumni.caltech.edu
|
||||
|
||||
|
||||
The data format used by the zlib library is described by RFCs (Request for
|
||||
Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
|
||||
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
|
||||
*/
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
@ -32,7 +37,7 @@ extern "C" {
|
||||
|
||||
#include "zconf.h"
|
||||
|
||||
#define ZLIB_VERSION "1.0.1"
|
||||
#define ZLIB_VERSION "1.0.2"
|
||||
|
||||
/*
|
||||
The 'zlib' compression library provides in-memory compression and
|
||||
@ -156,16 +161,20 @@ typedef struct z_stream_s {
|
||||
|
||||
#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
|
||||
|
||||
extern const char *zlib_version;
|
||||
/* The application can compare zlib_version and ZLIB_VERSION for consistency.
|
||||
If the first character differs, the library code actually used is
|
||||
not compatible with the zlib.h header file used by the application.
|
||||
*/
|
||||
#define zlib_version zlibVersion()
|
||||
/* for compatibility with versions < 1.0.2 */
|
||||
|
||||
/* basic functions */
|
||||
|
||||
extern char EXPORT *zlibVersion OF((void));
|
||||
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
|
||||
If the first character differs, the library code actually used is
|
||||
not compatible with the zlib.h header file used by the application.
|
||||
This check is automatically made by deflateInit and inflateInit.
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int deflateInit OF((z_stream *strm, int level));
|
||||
extern int EXPORT deflateInit OF((z_stream *strm, int level));
|
||||
|
||||
Initializes the internal stream state for compression. The fields
|
||||
zalloc, zfree and opaque must be initialized before by the caller.
|
||||
@ -187,7 +196,7 @@ extern int deflateInit OF((z_stream *strm, int level));
|
||||
*/
|
||||
|
||||
|
||||
extern int deflate OF((z_stream *strm, int flush));
|
||||
extern int EXPORT deflate OF((z_stream *strm, int flush));
|
||||
/*
|
||||
Performs one or both of the following actions:
|
||||
|
||||
@ -256,7 +265,7 @@ extern int deflate OF((z_stream *strm, int flush));
|
||||
*/
|
||||
|
||||
|
||||
extern int deflateEnd OF((z_stream *strm));
|
||||
extern int EXPORT deflateEnd OF((z_stream *strm));
|
||||
/*
|
||||
All dynamically allocated data structures for this stream are freed.
|
||||
This function discards any unprocessed input and does not flush any
|
||||
@ -271,7 +280,7 @@ extern int deflateEnd OF((z_stream *strm));
|
||||
|
||||
|
||||
/*
|
||||
extern int inflateInit OF((z_stream *strm));
|
||||
extern int EXPORT inflateInit OF((z_stream *strm));
|
||||
|
||||
Initializes the internal stream state for decompression. The fields
|
||||
zalloc, zfree and opaque must be initialized before by the caller. If
|
||||
@ -286,7 +295,7 @@ extern int inflateInit OF((z_stream *strm));
|
||||
*/
|
||||
|
||||
|
||||
extern int inflate OF((z_stream *strm, int flush));
|
||||
extern int EXPORT inflate OF((z_stream *strm, int flush));
|
||||
/*
|
||||
Performs one or both of the following actions:
|
||||
|
||||
@ -341,7 +350,7 @@ extern int inflate OF((z_stream *strm, int flush));
|
||||
*/
|
||||
|
||||
|
||||
extern int inflateEnd OF((z_stream *strm));
|
||||
extern int EXPORT inflateEnd OF((z_stream *strm));
|
||||
/*
|
||||
All dynamically allocated data structures for this stream are freed.
|
||||
This function discards any unprocessed input and does not flush any
|
||||
@ -359,7 +368,7 @@ extern int inflateEnd OF((z_stream *strm));
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int deflateInit2 OF((z_stream *strm,
|
||||
extern int EXPORT deflateInit2 OF((z_stream *strm,
|
||||
int level,
|
||||
int method,
|
||||
int windowBits,
|
||||
@ -417,7 +426,7 @@ extern int deflateInit2 OF((z_stream *strm,
|
||||
deflate().
|
||||
*/
|
||||
|
||||
extern int deflateSetDictionary OF((z_stream *strm,
|
||||
extern int EXPORT deflateSetDictionary OF((z_stream *strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength));
|
||||
/*
|
||||
@ -446,7 +455,7 @@ extern int deflateSetDictionary OF((z_stream *strm,
|
||||
be done by deflate().
|
||||
*/
|
||||
|
||||
extern int deflateCopy OF((z_stream *dest,
|
||||
extern int EXPORT deflateCopy OF((z_stream *dest,
|
||||
z_stream *source));
|
||||
/*
|
||||
Sets the destination stream as a complete copy of the source stream. If
|
||||
@ -469,7 +478,7 @@ extern int deflateCopy OF((z_stream *dest,
|
||||
destination.
|
||||
*/
|
||||
|
||||
extern int deflateReset OF((z_stream *strm));
|
||||
extern int EXPORT deflateReset OF((z_stream *strm));
|
||||
/*
|
||||
This function is equivalent to deflateEnd followed by deflateInit,
|
||||
but does not free and reallocate all the internal compression state.
|
||||
@ -480,7 +489,7 @@ extern int deflateReset OF((z_stream *strm));
|
||||
stream state was inconsistent (such as zalloc or state being NULL).
|
||||
*/
|
||||
|
||||
extern int deflateParams OF((z_stream *strm, int level, int strategy));
|
||||
extern int EXPORT deflateParams OF((z_stream *strm, int level, int strategy));
|
||||
/*
|
||||
Dynamically update the compression level and compression strategy.
|
||||
This can be used to switch between compression and straight copy of
|
||||
@ -499,7 +508,7 @@ extern int deflateParams OF((z_stream *strm, int level, int strategy));
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int inflateInit2 OF((z_stream *strm,
|
||||
extern int EXPORT inflateInit2 OF((z_stream *strm,
|
||||
int windowBits));
|
||||
|
||||
This is another version of inflateInit with more compression options. The
|
||||
@ -533,7 +542,7 @@ extern int inflateInit2 OF((z_stream *strm,
|
||||
inflate().
|
||||
*/
|
||||
|
||||
extern int inflateSetDictionary OF((z_stream *strm,
|
||||
extern int EXPORT inflateSetDictionary OF((z_stream *strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength));
|
||||
/*
|
||||
@ -552,7 +561,7 @@ extern int inflateSetDictionary OF((z_stream *strm,
|
||||
inflate().
|
||||
*/
|
||||
|
||||
extern int inflateSync OF((z_stream *strm));
|
||||
extern int EXPORT inflateSync OF((z_stream *strm));
|
||||
/*
|
||||
Skips invalid compressed data until the special marker (see deflate()
|
||||
above) can be found, or until all available input is skipped. No output
|
||||
@ -567,7 +576,7 @@ extern int inflateSync OF((z_stream *strm));
|
||||
until success or end of the input data.
|
||||
*/
|
||||
|
||||
extern int inflateReset OF((z_stream *strm));
|
||||
extern int EXPORT inflateReset OF((z_stream *strm));
|
||||
/*
|
||||
This function is equivalent to inflateEnd followed by inflateInit,
|
||||
but does not free and reallocate all the internal decompression state.
|
||||
@ -588,7 +597,7 @@ extern int inflateReset OF((z_stream *strm));
|
||||
utility functions can easily be modified if you need special options.
|
||||
*/
|
||||
|
||||
extern int compress OF((Bytef *dest, uLongf *destLen,
|
||||
extern int EXPORT compress OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen));
|
||||
/*
|
||||
Compresses the source buffer into the destination buffer. sourceLen is
|
||||
@ -603,7 +612,7 @@ extern int compress OF((Bytef *dest, uLongf *destLen,
|
||||
buffer.
|
||||
*/
|
||||
|
||||
extern int uncompress OF((Bytef *dest, uLongf *destLen,
|
||||
extern int EXPORT uncompress OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen));
|
||||
/*
|
||||
Decompresses the source buffer into the destination buffer. sourceLen is
|
||||
@ -624,7 +633,7 @@ extern int uncompress OF((Bytef *dest, uLongf *destLen,
|
||||
|
||||
typedef voidp gzFile;
|
||||
|
||||
extern gzFile gzopen OF((const char *path, const char *mode));
|
||||
extern gzFile EXPORT gzopen OF((const char *path, const char *mode));
|
||||
/*
|
||||
Opens a gzip (.gz) file for reading or writing. The mode parameter
|
||||
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));
|
||||
zlib error is Z_MEM_ERROR).
|
||||
*/
|
||||
|
||||
extern gzFile gzdopen OF((int fd, const char *mode));
|
||||
extern gzFile EXPORT gzdopen OF((int fd, const char *mode));
|
||||
/*
|
||||
gzdopen() associates a gzFile with the file descriptor fd. File
|
||||
descriptors are obtained from calls like open, dup, creat, pipe or
|
||||
@ -649,7 +658,7 @@ extern gzFile gzdopen OF((int fd, const char *mode));
|
||||
the (de)compression state.
|
||||
*/
|
||||
|
||||
extern int gzread OF((gzFile file, voidp buf, unsigned len));
|
||||
extern int EXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
||||
/*
|
||||
Reads the given number of uncompressed bytes from the compressed file.
|
||||
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));
|
||||
gzread returns the number of uncompressed bytes actually read (0 for
|
||||
end of file, -1 for error). */
|
||||
|
||||
extern int gzwrite OF((gzFile file, const voidp buf, unsigned len));
|
||||
extern int EXPORT gzwrite OF((gzFile file, const voidp buf, unsigned len));
|
||||
/*
|
||||
Writes the given number of uncompressed bytes into the compressed file.
|
||||
gzwrite returns the number of uncompressed bytes actually written
|
||||
(0 in case of error).
|
||||
*/
|
||||
|
||||
extern int gzflush OF((gzFile file, int flush));
|
||||
extern int EXPORT gzflush OF((gzFile file, int flush));
|
||||
/*
|
||||
Flushes all pending output into the compressed file. The parameter
|
||||
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));
|
||||
degrade compression.
|
||||
*/
|
||||
|
||||
extern int gzclose OF((gzFile file));
|
||||
extern int EXPORT gzclose OF((gzFile file));
|
||||
/*
|
||||
Flushes all pending output if necessary, closes the compressed file
|
||||
and deallocates all the (de)compression state. The return value is the zlib
|
||||
error number (see function gzerror below).
|
||||
*/
|
||||
|
||||
extern char* gzerror OF((gzFile file, int *errnum));
|
||||
extern char EXPORT *gzerror OF((gzFile file, int *errnum));
|
||||
/*
|
||||
Returns the error message for the last error which occurred on the
|
||||
given compressed file. errnum is set to zlib error number. If an
|
||||
@ -698,7 +707,7 @@ extern char* gzerror OF((gzFile file, int *errnum));
|
||||
compression library.
|
||||
*/
|
||||
|
||||
extern uLong adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||
extern uLong EXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||
|
||||
/*
|
||||
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));
|
||||
if (adler != original_adler) error();
|
||||
*/
|
||||
|
||||
extern uLong crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||
extern uLong EXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||
/*
|
||||
Update a running crc with the bytes buf[0..len-1] and return the updated
|
||||
crc. If buf is NULL, this function returns the required initial value
|
||||
@ -737,14 +746,14 @@ extern uLong crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||
/* deflateInit and inflateInit are macros to allow checking the zlib version
|
||||
* and the compiler's view of z_stream:
|
||||
*/
|
||||
extern int deflateInit_ OF((z_stream *strm, int level,
|
||||
extern int EXPORT deflateInit_ OF((z_stream *strm, int level,
|
||||
const char *version, int stream_size));
|
||||
extern int inflateInit_ OF((z_stream *strm,
|
||||
extern int EXPORT inflateInit_ OF((z_stream *strm,
|
||||
const char *version, int stream_size));
|
||||
extern int deflateInit2_ OF((z_stream *strm, int level, int method,
|
||||
extern int EXPORT deflateInit2_ OF((z_stream *strm, int level, int method,
|
||||
int windowBits, int memLevel, int strategy,
|
||||
const char *version, int stream_size));
|
||||
extern int inflateInit2_ OF((z_stream *strm, int windowBits,
|
||||
extern int EXPORT inflateInit2_ OF((z_stream *strm, int windowBits,
|
||||
const char *version, int stream_size));
|
||||
#define deflateInit(strm, level) \
|
||||
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
|
||||
|
32
zlib.rc
Normal file
32
zlib.rc
Normal file
@ -0,0 +1,32 @@
|
||||
#include <windows.h>
|
||||
|
||||
#define IDR_VERSION1 1
|
||||
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||
FILEVERSION 1,0,2,0
|
||||
PRODUCTVERSION 1,0,2,0
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS 0
|
||||
FILEOS VOS_DOS_WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0 // not used
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
//language ID = U.S. English, char set = Windows, Multilingual
|
||||
|
||||
BEGIN
|
||||
VALUE "FileDescription", "zlib data compression library\0"
|
||||
VALUE "FileVersion", "1.0.2\0"
|
||||
VALUE "InternalName", "zlib\0"
|
||||
VALUE "OriginalFilename", "zlib.lib\0"
|
||||
VALUE "ProductName", "ZLib.DLL\0"
|
||||
VALUE "Comments", "DLL support by Alessandro Iacopetti\0"
|
||||
VALUE "LegalCopyright", "(C) 1995-1996 Jean-loup Gailly & Mark Adler\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0409, 1252
|
||||
END
|
||||
END
|
9
zutil.c
9
zutil.c
@ -3,7 +3,7 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* $Id: zutil.c,v 1.12 1996/01/30 21:59:29 me Exp $ */
|
||||
/* $Id: zutil.c,v 1.15 1996/05/23 17:11:36 me Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -15,8 +15,6 @@ struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
extern void exit OF((int));
|
||||
#endif
|
||||
|
||||
const char *zlib_version = ZLIB_VERSION;
|
||||
|
||||
const char *z_errmsg[10] = {
|
||||
"need dictionary", /* Z_NEED_DICT 2 */
|
||||
"stream end", /* Z_STREAM_END 1 */
|
||||
@ -30,6 +28,11 @@ const char *z_errmsg[10] = {
|
||||
""};
|
||||
|
||||
|
||||
char *zlibVersion()
|
||||
{
|
||||
return ZLIB_VERSION;
|
||||
}
|
||||
|
||||
void z_error (m)
|
||||
char *m;
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user