pull/2/head v1.1.3
Mark Adler 13 years ago
parent c34c1fcbb1
commit 14763ac7c6
  1. 48
      ChangeLog
  2. 72
      FAQ
  3. 6
      INDEX
  4. 8
      Make_vms.com
  5. 54
      Makefile
  6. 54
      Makefile.in
  7. 145
      Makefile.riscos
  8. 67
      README
  9. 59
      configure
  10. 10
      contrib/README.contrib
  11. 43
      contrib/asm586/README.586
  12. 354
      contrib/asm586/match.S
  13. 34
      contrib/asm686/README.686
  14. 327
      contrib/asm686/match.S
  15. 36
      contrib/delphi/zlib.mak
  16. 169
      contrib/delphi/zlibdef.pas
  17. 224
      contrib/delphi2/d_zlib.bpr
  18. 17
      contrib/delphi2/d_zlib.cpp
  19. 17
      contrib/delphi2/readme.txt
  20. 26
      contrib/delphi2/zlib.bpg
  21. 225
      contrib/delphi2/zlib.bpr
  22. 22
      contrib/delphi2/zlib.cpp
  23. 534
      contrib/delphi2/zlib.pas
  24. 174
      contrib/delphi2/zlib32.bpr
  25. 42
      contrib/delphi2/zlib32.cpp
  26. 2
      contrib/minizip/unzip.c
  27. 90
      contrib/minizip/zip.c
  28. 64
      contrib/untgz/untgz.c
  29. 14
      contrib/visual-basic.txt
  30. 8
      deflate.c
  31. 6
      deflate.h
  32. 14
      example.c
  33. 14
      gzio.c
  34. 7
      infblock.c
  35. 7
      infcodes.c
  36. 246
      inffixed.h
  37. 2
      inftrees.c
  38. 38
      maketree.c
  39. 3
      minigzip.c
  40. 4
      msdos/Makefile.b32
  41. 86
      msdos/Makefile.bor
  42. 69
      msdos/Makefile.emx
  43. 114
      msdos/Makefile.msc
  44. 65
      msdos/Makefile.tc
  45. 4
      msdos/Makefile.w32
  46. 4
      msdos/Makefile.wat
  47. 2
      msdos/zlib.def
  48. 6
      msdos/zlib.rc
  49. 138
      nt/Makefile.emx
  50. 87
      nt/Makefile.gcc
  51. 136
      os2/Makefile.os2
  52. 51
      os2/zlib.def
  53. 52
      trees.c
  54. 47
      zconf.h
  55. 4
      zlib.3
  56. 109
      zlib.h
  57. 8
      zutil.c
  58. 15
      zutil.h

@ -1,6 +1,54 @@
ChangeLog file for zlib ChangeLog file for zlib
Changes in 1.1.3 (9 July 1998)
- fix "an inflate input buffer bug that shows up on rare but persistent
occasions" (Mark)
- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
- fix gzseek(..., SEEK_SET) in write mode
- fix crc check after a gzeek (Frank Faubert)
- fix miniunzip when the last entry in a zip file is itself a zip file
(J Lillge)
- add contrib/asm586 and contrib/asm686 (Brian Raiter)
See http://www.muppetlabs.com/~breadbox/software/assembly.html
- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
- added a FAQ file
- Support gzdopen on Mac with Metrowerks (Jason Linhart)
- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart)
- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young)
- avoid some warnings with Borland C (Tom Tanner)
- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant)
- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant)
- allow several arguments to configure (Tim Mooney, Frodo Looijaard)
- use libdir and includedir in Makefile.in (Tim Mooney)
- support shared libraries on OSF1 V4 (Tim Mooney)
- remove so_locations in "make clean" (Tim Mooney)
- fix maketree.c compilation error (Glenn, Mark)
- Python interface to zlib now in Python 1.5 (Jeremy Hylton)
- new Makefile.riscos (Rich Walker)
- initialize static descriptors in trees.c for embedded targets (Nick Smith)
- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith)
- add the OS/2 files in Makefile.in too (Andrew Zabolotny)
- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane)
- fix maketree.c to allow clean compilation of inffixed.h (Mark)
- fix parameter check in deflateCopy (Gunther Nikl)
- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler)
- Many portability patches by Christian Spieler:
. zutil.c, zutil.h: added "const" for zmem*
. Make_vms.com: fixed some typos
. Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists
. msdos/Makefile.msc: remove "default rtl link library" info from obj files
. msdos/Makefile.*: use model-dependent name for the built zlib library
. msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc:
new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT)
- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane)
- replace __far with _far for better portability (Christian Spieler, Tom Lane)
- fix test for errno.h in configure (Tim Newsham)
Changes in 1.1.2 (19 March 98) Changes in 1.1.2 (19 March 98)
- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) - added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant)
See http://www.winimage.com/zLibDll/unzip.html See http://www.winimage.com/zLibDll/unzip.html

72
FAQ

@ -0,0 +1,72 @@
Frequently Asked Questions about zlib
If your question is not there, please check the zlib home page
http://www.cdrom.com/pub/infozip/zlib/ which may have more recent information.
1) I need a Windows DLL
2) I need a Visual Basic interface to zlib
3) compress() returns Z_BUF_ERROR
4) deflate or inflate returns Z_BUF_ERROR
5) Where is the zlib documentation (man pages, etc...)?
6) Why don't you use GNU autoconf, libtool, etc...?
7) There is a bug in zlib.
8) I get "undefined reference to gzputc"
1) I need a Windows DLL
The zlib sources can be compiled without change to produce a DLL.
If you want a precompiled DLL, see http://www.winimage.com/zLibDll
2) I need a Visual Basic interface to zlib
See http://www.tcfb.com/dowseware/cmp-z-it.zip
http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm
and contrib/visual-basic.txt
3) compress() returns Z_BUF_ERROR
Make sure that before the call of compress, the length of the
compressed buffer is equal to the total size of the compressed buffer
and not zero. For Visual Basic, check that this parameter is passed
by reference ("as any"), not by value ("as long").
4) deflate or inflate returns Z_BUF_ERROR
Make sure that before the call avail_in and avail_out are not zero.
5) Where is the zlib documentation (man pages, etc...)?
It's in zlib.h for the moment. Volunteers to transform this
to man pages, please contact jloup@gzip.org. Examples of zlib usage
are in the files example.c and minigzip.c.
6) Why don't you use GNU autoconf, libtool, etc...?
Because we would like to keep zlib as a very small and simple package.
zlib is rather portable and doesn't need much configuration.
7) There is a bug in zlib.
Most of the time, such problems are due to an incorrect usage
of zlib. Please try to reproduce the problem with a small
program and send us the corresponding source at zlib@quest.jpl.nasa.gov
Do not send multi-megabyte data files without prior agreement.
8) I get "undefined reference to gzputc"
If "make test" produces something like
example.o(.text+0x174):
check that you don't have old files libz.* in /usr/lib, /usr/local/lib
or /usr/X11R6/lib. Remove old versions then do "make install".

@ -1,9 +1,9 @@
ChangeLog history of changes ChangeLog history of changes
INDEX this file INDEX this file
FAQ Frequently Asked Questions about zlib
Make_vms.com script for Vax/VMS Make_vms.com script for Vax/VMS
Makefile makefile for Unix (generated by configure) Makefile makefile for Unix (generated by configure)
Makefile.in makefile for Unix (template for configure) Makefile.in makefile for Unix (template for configure)
Makefile.msc makefile for Microsoft C 16-bit
Makefile.riscos makefile for RISCOS Makefile.riscos makefile for RISCOS
README guess what README guess what
algorithm.txt description of the (de)compression algorithm algorithm.txt description of the (de)compression algorithm
@ -19,6 +19,8 @@ msdos/Makefile.w32 makefile for Microsoft Visual C++ 32-bit
msdos/Makefile.b32 makefile for Borland C++ 32-bit msdos/Makefile.b32 makefile for Borland C++ 32-bit
msdos/Makefile.bor makefile for Borland C/C++ 16-bit msdos/Makefile.bor makefile for Borland C/C++ 16-bit
msdos/Makefile.dj2 makefile for DJGPP 2.x msdos/Makefile.dj2 makefile for DJGPP 2.x
msdos/Makefile.emx makefile for EMX 0.9c (32-bit DOS/OS2)
msdos/Makefile.msc makefile for Microsoft C 16-bit
msdos/Makefile.tc makefile for Turbo C msdos/Makefile.tc makefile for Turbo C
msdos/Makefile.wat makefile for Watcom C msdos/Makefile.wat makefile for Watcom C
msdos/zlib.def definition file for Windows DLL msdos/zlib.def definition file for Windows DLL
@ -26,6 +28,8 @@ msdos/zlib.rc definition file for Windows DLL
nt/Makefile.nt makefile for Windows NT nt/Makefile.nt makefile for Windows NT
nt/zlib.dnt definition file for Windows NT DLL nt/zlib.dnt definition file for Windows NT DLL
nt/Makefile.emx makefile for EMX 0.9c/RSXNT 1.41 (Win32 Intel)
nt/Makefile.gcc makefile for Windows NT using GCC (mingw32)
zlib public header files (must be kept): zlib public header files (must be kept):

@ -28,15 +28,15 @@ $ if f$search("SYS$SYSTEM:MMS.EXE").eqs.""
$ then $ then
$ dele example.obj;*,minigzip.obj;* $ dele example.obj;*,minigzip.obj;*
$ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" - $ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" -
adler32.c zutil.h zlib.h zconf.h adler32.c zlib.h zconf.h
$ CALL MAKE compress.OBJ "CC ''CCOPT' compress" - $ CALL MAKE compress.OBJ "CC ''CCOPT' compress" -
compress.c zlib.h zconf.h compress.c zlib.h zconf.h
$ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" - $ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" -
crc32.c zutil.h zlib.h zconf.h crc32.c zlib.h zconf.h
$ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" - $ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" -
deflatec.c deflate.h zutil.h zlib.h zconf.h deflate.c deflate.h zutil.h zlib.h zconf.h
$ CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" - $ CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" -
gsio.c zutil.h zlib.h zconf.h gzio.c zutil.h zlib.h zconf.h
$ CALL MAKE infblock.OBJ "CC ''CCOPT' infblock" - $ CALL MAKE infblock.OBJ "CC ''CCOPT' infblock" -
infblock.c zutil.h zlib.h zconf.h infblock.h infblock.c zutil.h zlib.h zconf.h infblock.h
$ CALL MAKE infcodes.OBJ "CC ''CCOPT' infcodes" - $ CALL MAKE infcodes.OBJ "CC ''CCOPT' infcodes" -

@ -22,8 +22,9 @@ CFLAGS=-O
LDFLAGS=-L. -lz LDFLAGS=-L. -lz
LDSHARED=$(CC) LDSHARED=$(CC)
CPP=$(CC) -E
VER=1.1.2 VER=1.1.3
LIBS=libz.a LIBS=libz.a
SHAREDLIB=libz.so SHAREDLIB=libz.so
@ -34,21 +35,27 @@ SHELL=/bin/sh
prefix = /usr/local prefix = /usr/local
exec_prefix = ${prefix} exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
OBJA =
# to use the asm code: make OBJA=match.o
TEST_OBJS = example.o minigzip.o TEST_OBJS = example.o minigzip.o
DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ DISTFILES = README FAQ INDEX ChangeLog configure Make*[a-z0-9] *.[ch] *.mms \
algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \
nt/Makefile.nt nt/zlib.dnt amiga/Make*.??? contrib/README.contrib \ nt/Make*[a-z0-9] nt/zlib.dnt amiga/Make*.??? os2/M*.os2 os2/zlib.def \
contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \ contrib/RE*.contrib contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \
contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/asm[56]86/*.?86 \
contrib/asm[56]86/*.S contrib/iostream/*.cpp \
contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \
contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \ contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \
contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? \
contrib/delphi*/*.???
all: example minigzip all: example minigzip
@ -62,10 +69,16 @@ test: all
echo ' *** zlib test FAILED ***'; \ echo ' *** zlib test FAILED ***'; \
fi fi
libz.a: $(OBJS) libz.a: $(OBJS) $(OBJA)
$(AR) $@ $(OBJS) $(AR) $@ $(OBJS) $(OBJA)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1 -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s
$(SHAREDLIB).$(VER): $(OBJS) $(SHAREDLIB).$(VER): $(OBJS)
$(LDSHARED) -o $@ $(OBJS) $(LDSHARED) -o $@ $(OBJS)
rm -f $(SHAREDLIB) $(SHAREDLIB).1 rm -f $(SHAREDLIB) $(SHAREDLIB).1
@ -79,14 +92,14 @@ minigzip: minigzip.o $(LIBS)
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
install: $(LIBS) install: $(LIBS)
-@if [ ! -d $(prefix)/include ]; then mkdir $(prefix)/include; fi -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi
-@if [ ! -d $(exec_prefix)/lib ]; then mkdir $(exec_prefix)/lib; fi -@if [ ! -d $(libdir) ]; then mkdir $(libdir); fi
cp zlib.h zconf.h $(prefix)/include cp zlib.h zconf.h $(includedir)
chmod 644 $(prefix)/include/zlib.h $(prefix)/include/zconf.h chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
cp $(LIBS) $(exec_prefix)/lib cp $(LIBS) $(libdir)
cd $(exec_prefix)/lib; chmod 755 $(LIBS) cd $(libdir); chmod 755 $(LIBS)
-@(cd $(exec_prefix)/lib; $(RANLIB) libz.a || true) >/dev/null 2>&1 -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
cd $(exec_prefix)/lib; if test -f $(SHAREDLIB).$(VER); then \ cd $(libdir); if test -f $(SHAREDLIB).$(VER); then \
rm -f $(SHAREDLIB) $(SHAREDLIB).1; \ rm -f $(SHAREDLIB) $(SHAREDLIB).1; \
ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB); \ ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB); \
ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \ ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \
@ -96,19 +109,20 @@ install: $(LIBS)
# ldconfig is for Linux # ldconfig is for Linux
uninstall: uninstall:
cd $(prefix)/include; \ cd $(includedir); \
v=$(VER); \ v=$(VER); \
if test -f zlib.h; then \ if test -f zlib.h; then \
v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \ v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \
rm -f zlib.h zconf.h; \ rm -f zlib.h zconf.h; \
fi; \ fi; \
cd $(exec_prefix)/lib; rm -f libz.a; \ cd $(libdir); rm -f libz.a; \
if test -f $(SHAREDLIB).$$v; then \ if test -f $(SHAREDLIB).$$v; then \
rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \ rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \
fi fi
clean: clean:
rm -f *.o *~ example minigzip libz.a libz.so* foo.gz rm -f *.o *~ example minigzip libz.a libz.so* foo.gz so_locations \
_match.s maketree
distclean: clean distclean: clean

@ -22,8 +22,9 @@ CFLAGS=-O
LDFLAGS=-L. -lz LDFLAGS=-L. -lz
LDSHARED=$(CC) LDSHARED=$(CC)
CPP=$(CC) -E
VER=1.1.2 VER=1.1.3
LIBS=libz.a LIBS=libz.a
SHAREDLIB=libz.so SHAREDLIB=libz.so
@ -34,21 +35,27 @@ SHELL=/bin/sh
prefix = /usr/local prefix = /usr/local
exec_prefix = ${prefix} exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
OBJA =
# to use the asm code: make OBJA=match.o
TEST_OBJS = example.o minigzip.o TEST_OBJS = example.o minigzip.o
DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ DISTFILES = README FAQ INDEX ChangeLog configure Make*[a-z0-9] *.[ch] *.mms \
algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \
nt/Makefile.nt nt/zlib.dnt amiga/Make*.??? contrib/README.contrib \ nt/Make*[a-z0-9] nt/zlib.dnt amiga/Make*.??? os2/M*.os2 os2/zlib.def \
contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \ contrib/RE*.contrib contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \
contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/asm[56]86/*.?86 \
contrib/asm[56]86/*.S contrib/iostream/*.cpp \
contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \
contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \ contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \
contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? \
contrib/delphi*/*.???
all: example minigzip all: example minigzip
@ -62,10 +69,16 @@ test: all
echo ' *** zlib test FAILED ***'; \ echo ' *** zlib test FAILED ***'; \
fi fi
libz.a: $(OBJS) libz.a: $(OBJS) $(OBJA)
$(AR) $@ $(OBJS) $(AR) $@ $(OBJS) $(OBJA)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1 -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s
$(SHAREDLIB).$(VER): $(OBJS) $(SHAREDLIB).$(VER): $(OBJS)
$(LDSHARED) -o $@ $(OBJS) $(LDSHARED) -o $@ $(OBJS)
rm -f $(SHAREDLIB) $(SHAREDLIB).1 rm -f $(SHAREDLIB) $(SHAREDLIB).1
@ -79,14 +92,14 @@ minigzip: minigzip.o $(LIBS)
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
install: $(LIBS) install: $(LIBS)
-@if [ ! -d $(prefix)/include ]; then mkdir $(prefix)/include; fi -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi
-@if [ ! -d $(exec_prefix)/lib ]; then mkdir $(exec_prefix)/lib; fi -@if [ ! -d $(libdir) ]; then mkdir $(libdir); fi
cp zlib.h zconf.h $(prefix)/include cp zlib.h zconf.h $(includedir)
chmod 644 $(prefix)/include/zlib.h $(prefix)/include/zconf.h chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
cp $(LIBS) $(exec_prefix)/lib cp $(LIBS) $(libdir)
cd $(exec_prefix)/lib; chmod 755 $(LIBS) cd $(libdir); chmod 755 $(LIBS)
-@(cd $(exec_prefix)/lib; $(RANLIB) libz.a || true) >/dev/null 2>&1 -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
cd $(exec_prefix)/lib; if test -f $(SHAREDLIB).$(VER); then \ cd $(libdir); if test -f $(SHAREDLIB).$(VER); then \
rm -f $(SHAREDLIB) $(SHAREDLIB).1; \ rm -f $(SHAREDLIB) $(SHAREDLIB).1; \
ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB); \ ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB); \
ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \ ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \
@ -96,19 +109,20 @@ install: $(LIBS)
# ldconfig is for Linux # ldconfig is for Linux
uninstall: uninstall:
cd $(prefix)/include; \ cd $(includedir); \
v=$(VER); \ v=$(VER); \
if test -f zlib.h; then \ if test -f zlib.h; then \
v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \ v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \
rm -f zlib.h zconf.h; \ rm -f zlib.h zconf.h; \
fi; \ fi; \
cd $(exec_prefix)/lib; rm -f libz.a; \ cd $(libdir); rm -f libz.a; \
if test -f $(SHAREDLIB).$$v; then \ if test -f $(SHAREDLIB).$$v; then \
rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \ rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \
fi fi
clean: clean:
rm -f *.o *~ example minigzip libz.a libz.so* foo.gz rm -f *.o *~ example minigzip libz.a libz.so* foo.gz so_locations \
_match.s maketree
distclean: clean distclean: clean

@ -1,8 +1,9 @@
# Project: zlib_1_03 # Project: zlib_1_03
# Patched for zlib 1.1.2 rw@shadow.org.uk 19980430
# test works out-of-the-box, installs `somewhere' on demand
# Toolflags: # Toolflags:
CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fnah CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fah
C++flags = -c -depend !Depend -IC: -throwback C++flags = -c -depend !Depend -IC: -throwback
Linkflags = -aif -c++ -o $@ Linkflags = -aif -c++ -o $@
ObjAsmflags = -throwback -NoCache -depend !Depend ObjAsmflags = -throwback -NoCache -depend !Depend
@ -10,37 +11,141 @@ CMHGflags =
LibFileflags = -c -l -o $@ LibFileflags = -c -l -o $@
Squeezeflags = -o $@ Squeezeflags = -o $@
# change the line below to where _you_ want the library installed.
libdest = lib:zlib
# Final targets: # Final targets:
@.zlib_lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \ @.lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \
@.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \ @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \
@.o.uncompress @.o.zutil @.o.uncompr @.o.zutil
LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \ LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \
@.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \ @.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \
@.o.trees @.o.uncompress @.o.zutil @.o.trees @.o.uncompr @.o.zutil
@.test: @.tests.minigzip @.tests.example test: @.minigzip @.example @.lib
echo Please run "Test" in directory tests @copy @.lib @.libc A~C~DF~L~N~P~Q~RS~TV
@.tests.minigzip: @.o.minigzip @.zlib_lib C:o.Stubs @echo running tests: hang on.
Link $(Linkflags) @.o.minigzip @.zlib_lib C:o.Stubs @/@.minigzip -f -9 libc
@.tests.example: @.o.example @.zlib_lib C:o.Stubs @/@.minigzip -d libc-gz
Link $(Linkflags) @.o.example @.zlib_lib C:o.Stubs @/@.minigzip -f -1 libc
@/@.minigzip -d libc-gz
@/@.minigzip -h -9 libc
@/@.minigzip -d libc-gz
@/@.minigzip -h -1 libc
@/@.minigzip -d libc-gz
@/@.minigzip -9 libc
@/@.minigzip -d libc-gz
@/@.minigzip -1 libc
@/@.minigzip -d libc-gz
@diff @.lib @.libc
@echo that should have reported '@.lib and @.libc identical' if you have diff.
@/@.example @.fred @.fred
@echo that will have given lots of hello!'s.
@.minigzip: @.o.minigzip @.lib C:o.Stubs
Link $(Linkflags) @.o.minigzip @.lib C:o.Stubs
@.example: @.o.example @.lib C:o.Stubs
Link $(Linkflags) @.o.example @.lib C:o.Stubs
install: @.lib
cdir $(libdest)
cdir $(libdest).h
@copy @.h.zlib $(libdest).h.zlib A~C~DF~L~N~P~Q~RS~TV
@copy @.h.zconf $(libdest).h.zconf A~C~DF~L~N~P~Q~RS~TV
@copy @.lib $(libdest).lib A~C~DF~L~N~P~Q~RS~TV
@echo okay, installed zlib in $(libdest)
clean:; remove @.minigzip
remove @.example
remove @.libc
-wipe @.o.* F~r~cV
remove @.fred
# User-editable dependencies: # User-editable dependencies:
.c.o: .c.o:
cc $(ccflags) -o $@ $< cc $(ccflags) -o $@ $<
# Static dependencies: # Static dependencies:
@.o.example: @.tests.c.example
cc $(ccflags) -o @.o.example @.tests.c.example
@.o.minigzip: @.tests.c.minigzip
cc $(ccflags) -o @.o.minigzip @.tests.c.minigzip
# Dynamic dependencies: # Dynamic dependencies:
o.minigzip: tests.c.minigzip o.example: c.example
o.minigzip: h.zlib
o.minigzip: h.zconf
o.example: tests.c.example
o.example: h.zlib o.example: h.zlib
o.example: h.zconf o.example: h.zconf
o.minigzip: c.minigzip
o.minigzip: h.zlib
o.minigzip: h.zconf
o.adler32: c.adler32
o.adler32: h.zlib
o.adler32: h.zconf
o.compress: c.compress
o.compress: h.zlib
o.compress: h.zconf
o.crc32: c.crc32
o.crc32: h.zlib
o.crc32: h.zconf
o.deflate: c.deflate
o.deflate: h.deflate
o.deflate: h.zutil
o.deflate: h.zlib
o.deflate: h.zconf
o.gzio: c.gzio
o.gzio: h.zutil
o.gzio: h.zlib
o.gzio: h.zconf
o.infblock: c.infblock
o.infblock: h.zutil
o.infblock: h.zlib
o.infblock: h.zconf
o.infblock: h.infblock
o.infblock: h.inftrees
o.infblock: h.infcodes
o.infblock: h.infutil
o.infcodes: c.infcodes
o.infcodes: h.zutil
o.infcodes: h.zlib
o.infcodes: h.zconf
o.infcodes: h.inftrees
o.infcodes: h.infblock
o.infcodes: h.infcodes
o.infcodes: h.infutil
o.infcodes: h.inffast
o.inffast: c.inffast
o.inffast: h.zutil
o.inffast: h.zlib
o.inffast: h.zconf
o.inffast: h.inftrees
o.inffast: h.infblock
o.inffast: h.infcodes
o.inffast: h.infutil
o.inffast: h.inffast
o.inflate: c.inflate
o.inflate: h.zutil
o.inflate: h.zlib
o.inflate: h.zconf
o.inflate: h.infblock
o.inftrees: c.inftrees
o.inftrees: h.zutil
o.inftrees: h.zlib
o.inftrees: h.zconf
o.inftrees: h.inftrees
o.inftrees: h.inffixed
o.infutil: c.infutil
o.infutil: h.zutil
o.infutil: h.zlib
o.infutil: h.zconf
o.infutil: h.infblock
o.infutil: h.inftrees
o.infutil: h.infcodes
o.infutil: h.infutil
o.trees: c.trees
o.trees: h.deflate
o.trees: h.zutil
o.trees: h.zlib
o.trees: h.zconf
o.trees: h.trees
o.uncompr: c.uncompr
o.uncompr: h.zlib
o.uncompr: h.zconf
o.zutil: c.zutil
o.zutil: h.zutil
o.zutil: h.zlib
o.zutil: h.zconf

@ -1,4 +1,4 @@
zlib 1.1.2 is a general purpose data compression library. All the code zlib 1.1.3 is a general purpose data compression library. All the code
is thread safe. The data format used by the zlib library is thread safe. The data format used by the zlib library
is described by RFCs (Request for Comments) 1950 to 1952 in the files 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 ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
@ -14,35 +14,41 @@ except example.c and minigzip.c.
To compile all files and run the test program, follow the instructions To compile all files and run the test program, follow the instructions
given at the top of Makefile. In short "make test; make install" given at the top of Makefile. In short "make test; make install"
should work for most machines. For MSDOS, use one of the special should work for most machines. For Unix: "configure; make test; make install"
makefiles such as Makefile.msc; for VMS, use Make_vms.com or descrip.mms. For MSDOS, use one of the special 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, Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov>, or to
if this fails, to the addresses given below in the Copyright section. Gilles Vollant <info@winimage.com> for the Windows DLL version.
The zlib home page is http://www.cdrom.com/pub/infozip/zlib/ The zlib home page is http://www.cdrom.com/pub/infozip/zlib/
The official zlib ftp site is ftp://ftp.cdrom.com/pub/infozip/zlib/ The official zlib ftp site is ftp://ftp.cdrom.com/pub/infozip/zlib/
Before reporting a problem, please check those sites to verify that
you have the latest version of zlib; otherwise get the latest version and
check whether the problem still exists or not.
Mark Nelson <markn@tiny.com> wrote an article about zlib for the Jan. 1997 Mark Nelson <markn@tiny.com> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available in issue of Dr. Dobb's Journal; a copy of the article is available in
http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm
The changes made in version 1.1.2 are documented in the file ChangeLog. The changes made in version 1.1.3 are documented in the file ChangeLog.
The main changes since 1.1.1 are: The main changes since 1.1.2 are:
- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) - fix "an inflate input buffer bug that shows up on rare but persistent
See http://www.winimage.com/zLibDll/unzip.html occasions" (Mark)
- preinitialize the inflate tables for fixed codes, to make the code - fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
completely thread safe (Mark) - fix gzseek(..., SEEK_SET) in write mode
- some simplifications and slight speed-up to the inflate code (Mark) - fix crc check after a gzeek (Frank Faubert)
- fix gzeof on non-compressed files (Allan Schrum) - fix miniunzip when the last entry in a zip file is itself a zip file
- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs) (J Lillge)
- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn) - add contrib/asm586 and contrib/asm686 (Brian Raiter)
- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny) See http://www.muppetlabs.com/~breadbox/software/assembly.html
- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori) - add support for Delphi 3 in contrib/delphi (Bob Dellaca)
- do not wrap extern "C" around system includes (Tom Lane) - add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert) - do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson) - use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
- allow "configure --prefix $HOME" (Tim Mooney) - added a FAQ file
plus many changes for portability.
Unsupported third party contributions are provided in directory "contrib". Unsupported third party contributions are provided in directory "contrib".
@ -55,8 +61,8 @@ 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* ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib*
A Python interface to zlib written by A.M. Kuchling <amk@magnet.com> A Python interface to zlib written by A.M. Kuchling <amk@magnet.com>
is available from the Python Software Association sites, such as: is available in Python 1.5 and later versions, see
ftp://ftp.python.org/pub/python/contrib/Encoding/zlib*.tar.gz http://www.python.org/doc/lib/module-zlib.html
A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com>
is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html
@ -77,8 +83,8 @@ Notes for some targets:
From Visual Basic, you can call the DLL functions which do not take From Visual Basic, you can call the DLL functions which do not take
a structure as argument: compress, uncompress and all gz* functions. a structure as argument: compress, uncompress and all gz* functions.
See contrib/visual-basic.txt for more information. See contrib/visual-basic.txt for more information, or get
I don't know how to handle structures in Visual Basic, sorry. http://www.tcfb.com/dowseware/cmp-z-it.zip
- For 64-bit Irix, deflate.c must be compiled without any optimization. - For 64-bit Irix, deflate.c must be compiled without any optimization.
With -O, one libpng test fails. The test works in 32 bit mode (with With -O, one libpng test fails. The test works in 32 bit mode (with
@ -93,15 +99,14 @@ Notes for some targets:
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works
with other compilers. Use "make test" to check your compiler. with other compilers. Use "make test" to check your compiler.
- For shared memory multiprocessors, the decompression code assumes that
writes to pointers are atomic. Also the functions zalloc and zfree passed
to deflateInit must be multi-threaded in this case.
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers. - gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
- For Turbo C the small model is supported only with reduced performance to - For Turbo C the small model is supported only with reduced performance to
avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
- For PalmOs, see http://www.cs.uit.no/~perm/PASTA/pilot/software.html
Per Harald Myrvang <perm@stud.cs.uit.no>
Acknowledgments: Acknowledgments:

59
configure vendored

@ -24,18 +24,34 @@ VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
AR=${AR-"ar rc"} AR=${AR-"ar rc"}
RANLIB=${RANLIB-"ranlib"} RANLIB=${RANLIB-"ranlib"}
prefix=${prefix-/usr/local} prefix=${prefix-/usr/local}
exec_prefix=${exec_prefix-'${prefix}'}
libdir=${libdir-'${exec_prefix}/lib'}
includedir=${includedir-'${prefix}/include'}
shared_ext='.so' shared_ext='.so'
shared=0 shared=0
gcc=0 gcc=0
old_cc="$CC" old_cc="$CC"
old_cflags="$CFLAGS" old_cflags="$CFLAGS"
while test $# -ge 1
do
case "$1" in case "$1" in
-h* | --h*) echo 'syntax: configure [ --shared ] [--prefix PREFIX]'; exit 0;; -h* | --h*)
echo 'usage:'
echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
exit 0;;
-p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;; -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
-p* | --p*) prefix="$2"; shift; shift;; -p* | --p*) prefix="$2"; shift; shift;;
-e* | --e*) exec_prefix="$2"; shift; shift;;
-l* | --l*) libdir="$2"; shift; shift;;
-i* | --i*) includedir="$2"; shift; shift;;
-s* | --s*) shared=1; shift;; -s* | --s*) shared=1; shift;;
esac esac
done
test=ztest$$ test=ztest$$
cat > $test.c <<EOF cat > $test.c <<EOF
@ -46,6 +62,7 @@ EOF
test -z "$CC" && echo Checking for gcc... test -z "$CC" && echo Checking for gcc...
cc=${CC-gcc} cc=${CC-gcc}
cflags=${CFLAGS-"-O3"} cflags=${CFLAGS-"-O3"}
# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
case "$cc" in case "$cc" in
*gcc*) gcc=1;; *gcc*) gcc=1;;
esac esac
@ -71,7 +88,10 @@ else
IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
CFLAGS=${CFLAGS-"-ansi -O2"} CFLAGS=${CFLAGS-"-ansi -O2"}
LDSHARED=${LDSHARED-"cc -shared"};; LDSHARED=${LDSHARED-"cc -shared"};;
OSF1) SFLAGS=${CFLAGS-"-O -std1"} OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
CFLAGS=${CFLAGS-"-O -std1"}
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,$SHAREDLIB -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
CFLAGS=${CFLAGS-"-O -std1"} CFLAGS=${CFLAGS-"-O -std1"}
LDSHARED=${LDSHARED-"cc -shared"};; LDSHARED=${LDSHARED-"cc -shared"};;
QNX*) SFLAGS=${CFLAGS-"-4 -O"} QNX*) SFLAGS=${CFLAGS-"-4 -O"}
@ -124,11 +144,25 @@ if test $shared -eq 0; then
echo Building static library $LIBS version $VER with $CC. echo Building static library $LIBS version $VER with $CC.
fi fi
if test -f /usr/include/unistd.h; then cat > $test.c <<EOF
#include <unistd.h>
int main() { return 0; }
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
CFLAGS="$CFLAGS -DHAVE_UNISTD_H" CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
echo "Checking for unistd.h... Yes."
else
echo "Checking for unistd.h... No."
fi fi
if test ! -f /usr/include/errno.h; then cat > $test.c <<EOF
#include <errno.h>
int main() { return 0; }
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for errno.h... Yes."
else
echo "Checking for errno.h... No."
CFLAGS="$CFLAGS -DNO_ERRNO_H" CFLAGS="$CFLAGS -DNO_ERRNO_H"
fi fi
@ -147,12 +181,24 @@ else
echo Checking for mmap support... No. echo Checking for mmap support... No.
fi fi
CPP=${CPP-"$CC -E"}
case $CFLAGS in
*ASMV*)
if test "`nm $test.o | grep _hello`" = ""; then
CPP="$CPP -DNO_UNDERLINE"
echo Checking for underline in external names... No.
else
echo Checking for underline in external names... Yes.
fi;;
esac
rm -f $test.[co] $test$shared_ext rm -f $test.[co] $test$shared_ext
# udpate Makefile # udpate Makefile
sed < Makefile.in " sed < Makefile.in "
/^CC *=/s%=.*%=$CC% /^CC *=/s%=.*%=$CC%
/^CFLAGS *=/s%=.*%=$CFLAGS% /^CFLAGS *=/s%=.*%=$CFLAGS%
/^CPP *=/s%=.*%=$CPP%
/^LDSHARED *=/s%=.*%=$LDSHARED% /^LDSHARED *=/s%=.*%=$LDSHARED%
/^LIBS *=/s%=.*%=$LIBS% /^LIBS *=/s%=.*%=$LIBS%
/^SHAREDLIB *=/s%=.*%=$SHAREDLIB% /^SHAREDLIB *=/s%=.*%=$SHAREDLIB%
@ -160,4 +206,7 @@ sed < Makefile.in "
/^RANLIB *=/s%=.*%=$RANLIB% /^RANLIB *=/s%=.*%=$RANLIB%
/^VER *=/s%=.*%=$VER% /^VER *=/s%=.*%=$VER%
/^prefix *=/s%=.*%=$prefix% /^prefix *=/s%=.*%=$prefix%
/^exec_prefix *=/s%=.*%=$exec_prefix%
/^libdir *=/s%=.*%=$libdir%
/^includedir *=/s%=.*%=$includedir%
" > Makefile " > Makefile

@ -7,6 +7,16 @@ for help about these, not the zlib authors. Thanks.
asm386/ by Gilles Vollant <info@winimage.com> asm386/ by Gilles Vollant <info@winimage.com>
386 asm code replacing longest_match(), for Visual C++ 4.2 and ML 6.11c 386 asm code replacing longest_match(), for Visual C++ 4.2 and ML 6.11c
asm586/ and asm686/ by Brian Raiter <breadbox@muppetlabs.com>
asm code for Pentium and Pentium Pro
See http://www.muppetlabs.com/~breadbox/software/assembly.html
delphi/ by Bob Dellaca <bobdl@xtra.co.nz>
Support for Delphi
delphi2/ by Davide Moretti <dave@rimini.com>
Another support for C++Builder and Delphi
minizip/ by Gilles Vollant <info@winimage.com> minizip/ by Gilles Vollant <info@winimage.com>
Mini zip and unzip based on zlib Mini zip and unzip based on zlib
See http://www.winimage.com/zLibDll/unzip.html See http://www.winimage.com/zLibDll/unzip.html

@ -0,0 +1,43 @@
This is a patched version of zlib modified to use
Pentium-optimized assembly code in the deflation algorithm. The files
changed/added by this patch are:
README.586
match.S
The effectiveness of these modifications is a bit marginal, as the the
program's bottleneck seems to be mostly L1-cache contention, for which
there is no real way to work around without rewriting the basic
algorithm. The speedup on average is around 5-10% (which is generally
less than the amount of variance between subsequent executions).
However, when used at level 9 compression, the cache contention can
drop enough for the assembly version to achieve 10-20% speedup (and
sometimes more, depending on the amount of overall redundancy in the
files). Even here, though, cache contention can still be the limiting
factor, depending on the nature of the program using the zlib library.
This may also mean that better improvements will be seen on a Pentium
with MMX, which suffers much less from L1-cache contention, but I have
not yet verified this.
Note that this code has been tailored for the Pentium in particular,
and will not perform well on the Pentium Pro (due to the use of a
partial register in the inner loop).
If you are using an assembler other than GNU as, you will have to
translate match.S to use your assembler's syntax. (Have fun.)
Brian Raiter
breadbox@muppetlabs.com
April, 1998
Added for zlib 1.1.3:
The patches come from
http://www.muppetlabs.com/~breadbox/software/assembly.html
To compile zlib with this asm file, copy match.S to the zlib directory
then do:
CFLAGS="-O3 -DASMV" ./configure
make OBJA=match.o

@ -0,0 +1,354 @@
/* match.s -- Pentium-optimized version of longest_match()
* Written for zlib 1.1.2
* Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License.
*/
#ifndef NO_UNDERLINE
#define match_init _match_init
#define longest_match _longest_match
#endif
#define MAX_MATCH (258)
#define MIN_MATCH (3)
#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1)
#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7)
/* stack frame offsets */
#define wmask 0 /* local copy of s->wmask */
#define window 4 /* local copy of s->window */
#define windowbestlen 8 /* s->window + bestlen */
#define chainlenscanend 12 /* high word: current chain len */
/* low word: last bytes sought */
#define scanstart 16 /* first two bytes of string */
#define scanalign 20 /* dword-misalignment of string */
#define nicematch 24 /* a good enough match size */
#define bestlen 28 /* size of best match so far */
#define scan 32 /* ptr to string wanting match */
#define LocalVarsSize (36)
/* saved ebx 36 */
/* saved edi 40 */
/* saved esi 44 */
/* saved ebp 48 */
/* return address 52 */
#define deflatestate 56 /* the function arguments */
#define curmatch 60
/* Offsets for fields in the deflate_state structure. These numbers
* are calculated from the definition of deflate_state, with the
* assumption that the compiler will dword-align the fields. (Thus,
* changing the definition of deflate_state could easily cause this
* program to crash horribly, without so much as a warning at
* compile time. Sigh.)
*/
#define dsWSize 36
#define dsWMask 44
#define dsWindow 48
#define dsPrev 56
#define dsMatchLen 88
#define dsPrevMatch 92
#define dsStrStart 100
#define dsMatchStart 104
#define dsLookahead 108
#define dsPrevLen 112
#define dsMaxChainLen 116
#define dsGoodMatch 132
#define dsNiceMatch 136
.file "match.S"
.globl match_init, longest_match
.text
/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */
longest_match:
/* Save registers that the compiler may be using, and adjust %esp to */
/* make room for our stack frame. */
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
subl $LocalVarsSize, %esp
/* Retrieve the function arguments. %ecx will hold cur_match */
/* throughout the entire function. %edx will hold the pointer to the */
/* deflate_state structure during the function's setup (before */
/* entering the main loop). */
movl deflatestate(%esp), %edx
movl curmatch(%esp), %ecx
/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */
movl dsNiceMatch(%edx), %eax
movl dsLookahead(%edx), %ebx
cmpl %eax, %ebx
jl LookaheadLess
movl %eax, %ebx
LookaheadLess: movl %ebx, nicematch(%esp)
/* register Bytef *scan = s->window + s->strstart; */
movl dsWindow(%edx), %esi
movl %esi, window(%esp)
movl dsStrStart(%edx), %ebp
lea (%esi,%ebp), %edi
movl %edi, scan(%esp)
/* Determine how many bytes the scan ptr is off from being */
/* dword-aligned. */
movl %edi, %eax
negl %eax
andl $3, %eax
movl %eax, scanalign(%esp)
/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */
/* s->strstart - (IPos)MAX_DIST(s) : NIL; */
movl dsWSize(%edx), %eax
subl $MIN_LOOKAHEAD, %eax
subl %eax, %ebp
jg LimitPositive
xorl %ebp, %ebp
LimitPositive:
/* unsigned chain_length = s->max_chain_length; */
/* if (s->prev_length >= s->good_match) { */
/* chain_length >>= 2; */
/* } */
movl dsPrevLen(%edx), %eax
movl dsGoodMatch(%edx), %ebx
cmpl %ebx, %eax
movl dsMaxChainLen(%edx), %ebx
jl LastMatchGood
shrl $2, %ebx
LastMatchGood:
/* chainlen is decremented once beforehand so that the function can */
/* use the sign flag instead of the zero flag for the exit test. */
/* It is then shifted into the high word, to make room for the scanend */
/* scanend value, which it will always accompany. */
decl %ebx
shll $16, %ebx
/* int best_len = s->prev_length; */
movl dsPrevLen(%edx), %eax
movl %eax, bestlen(%esp)
/* Store the sum of s->window + best_len in %esi locally, and in %esi. */
addl %eax, %esi
movl %esi, windowbestlen(%esp)
/* register ush scan_start = *(ushf*)scan; */
/* register ush scan_end = *(ushf*)(scan+best_len-1); */
movw (%edi), %bx
movw %bx, scanstart(%esp)
movw -1(%edi,%eax), %bx
movl %ebx, chainlenscanend(%esp)
/* Posf *prev = s->prev; */
/* uInt wmask = s->w_mask; */
movl dsPrev(%edx), %edi
movl dsWMask(%edx), %edx
mov %edx, wmask(%esp)
/* Jump into the main loop. */
jmp LoopEntry
.balign 16
/* do {
* match = s->window + cur_match;
* if (*(ushf*)(match+best_len-1) != scan_end ||
* *(ushf*)match != scan_start) continue;
* [...]
* } while ((cur_match = prev[cur_match & wmask]) > limit
* && --chain_length != 0);
*
* Here is the inner loop of the function. The function will spend the
* majority of its time in this loop, and majority of that time will
* be spent in the first ten instructions.
*
* Within this loop:
* %ebx = chainlenscanend - i.e., ((chainlen << 16) | scanend)
* %ecx = curmatch
* %edx = curmatch & wmask
* %esi = windowbestlen - i.e., (window + bestlen)
* %edi = prev
* %ebp = limit
*
* Two optimization notes on the choice of instructions:
*
* The first instruction uses a 16-bit address, which costs an extra,
* unpairable cycle. This is cheaper than doing a 32-bit access and
* zeroing the high word, due to the 3-cycle misalignment penalty which
* would occur half the time. This also turns out to be cheaper than
* doing two separate 8-bit accesses, as the memory is so rarely in the
* L1 cache.
*
* The window buffer, however, apparently spends a lot of time in the
* cache, and so it is faster to retrieve the word at the end of the
* match string with two 8-bit loads. The instructions that test the
* word at the beginning of the match string, however, are executed
* much less frequently, and there it was cheaper to use 16-bit
* instructions, which avoided the necessity of saving off and
* subsequently reloading one of the other registers.
*/
LookupLoop:
/* 1 U & V */
movw (%edi,%edx,2), %cx /* 2 U pipe */
movl wmask(%esp), %edx /* 2 V pipe */
cmpl %ebp, %ecx /* 3 U pipe */
jbe LeaveNow /* 3 V pipe */
subl $0x00010000, %ebx /* 4 U pipe */
js LeaveNow /* 4 V pipe */
LoopEntry: movb -1(%esi,%ecx), %al /* 5 U pipe */
andl %ecx, %edx /* 5 V pipe */
cmpb %bl, %al /* 6 U pipe */
jnz LookupLoop /* 6 V pipe */
movb (%esi,%ecx), %ah
cmpb %bh, %ah
jnz LookupLoop
movl window(%esp), %eax
movw (%eax,%ecx), %ax
cmpw scanstart(%esp), %ax
jnz LookupLoop
/* Store the current value of chainlen. */
movl %ebx, chainlenscanend(%esp)
/* Point %edi to the string under scrutiny, and %esi to the string we */
/* are hoping to match it up with. In actuality, %esi and %edi are */
/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */
/* initialized to -(MAX_MATCH_8 - scanalign). */
movl window(%esp), %esi
movl scan(%esp), %edi
addl %ecx, %esi
movl scanalign(%esp), %eax
movl $(-MAX_MATCH_8), %edx
lea MAX_MATCH_8(%edi,%eax), %edi
lea MAX_MATCH_8(%esi,%eax), %esi
/* Test the strings for equality, 8 bytes at a time. At the end,
* adjust %edx so that it is offset to the exact byte that mismatched.
*
* We already know at this point that the first three bytes of the
* strings match each other, and they can be safely passed over before
* starting the compare loop. So what this code does is skip over 0-3
* bytes, as much as necessary in order to dword-align the %edi
* pointer. (%esi will still be misaligned three times out of four.)
*
* It should be confessed that this loop usually does not represent
* much of the total running time. Replacing it with a more
* straightforward "rep cmpsb" would not drastically degrade
* performance.
*/
LoopCmps:
movl (%esi,%edx), %eax
movl (%edi,%edx), %ebx
xorl %ebx, %eax
jnz LeaveLoopCmps
movl 4(%esi,%edx), %eax
movl 4(%edi,%edx), %ebx
xorl %ebx, %eax
jnz LeaveLoopCmps4
addl $8, %edx
jnz LoopCmps
jmp LenMaximum
LeaveLoopCmps4: addl $4, %edx
LeaveLoopCmps: testl $0x0000FFFF, %eax
jnz LenLower
addl $2, %edx
shrl $16, %eax
LenLower: subb $1, %al
adcl $0, %edx
/* Calculate the length of the match. If it is longer than MAX_MATCH, */
/* then automatically accept it as the best possible match and leave. */
lea (%edi,%edx), %eax
movl scan(%esp), %edi
subl %edi, %eax
cmpl $MAX_MATCH, %eax
jge LenMaximum
/* If the length of the match is not longer than the best match we */
/* have so far, then forget it and return to the lookup loop. */
movl deflatestate(%esp), %edx
movl bestlen(%esp), %ebx
cmpl %ebx, %eax
jg LongerMatch
movl chainlenscanend(%esp), %ebx
movl windowbestlen(%esp), %esi
movl dsPrev(%edx), %edi
movl wmask(%esp), %edx
andl %ecx, %edx
jmp LookupLoop
/* s->match_start = cur_match; */
/* best_len = len; */
/* if (len >= nice_match) break; */
/* scan_end = *(ushf*)(scan+best_len-1); */
LongerMatch: movl nicematch(%esp), %ebx
movl %eax, bestlen(%esp)
movl %ecx, dsMatchStart(%edx)
cmpl %ebx, %eax
jge LeaveNow
movl window(%esp), %esi
addl %eax, %esi
movl %esi, windowbestlen(%esp)
movl chainlenscanend(%esp), %ebx
movw -1(%edi,%eax), %bx
movl dsPrev(%edx), %edi
movl %ebx, chainlenscanend(%esp)
movl wmask(%esp), %edx
andl %ecx, %edx
jmp LookupLoop
/* Accept the current string, with the maximum possible length. */
LenMaximum: movl deflatestate(%esp), %edx
movl $MAX_MATCH, bestlen(%esp)
movl %ecx, dsMatchStart(%edx)
/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */
/* return s->lookahead; */
LeaveNow:
movl deflatestate(%esp), %edx
movl bestlen(%esp), %ebx
movl dsLookahead(%edx), %eax
cmpl %eax, %ebx
jg LookaheadRet
movl %ebx, %eax
LookaheadRet:
/* Restore the stack and return from whence we came. */
addl $LocalVarsSize, %esp
popl %ebx
popl %esi
popl %edi
popl %ebp
match_init: ret

@ -0,0 +1,34 @@
This is a patched version of zlib, modified to use
Pentium-Pro-optimized assembly code in the deflation algorithm. The
files changed/added by this patch are:
README.686
match.S
The speedup that this patch provides varies, depending on whether the
compiler used to build the original version of zlib falls afoul of the
PPro's speed traps. My own tests show a speedup of around 10-20% at
the default compression level, and 20-30% using -9, against a version
compiled using gcc 2.7.2.3. Your mileage may vary.
Note that this code has been tailored for the PPro/PII in particular,
and will not perform particuarly well on a Pentium.
If you are using an assembler other than GNU as, you will have to
translate match.S to use your assembler's syntax. (Have fun.)
Brian Raiter
breadbox@muppetlabs.com
April, 1998
Added for zlib 1.1.3:
The patches come from
http://www.muppetlabs.com/~breadbox/software/assembly.html
To compile zlib with this asm file, copy match.S to the zlib directory
then do:
CFLAGS="-O3 -DASMV" ./configure
make OBJA=match.o

@ -0,0 +1,327 @@
/* match.s -- Pentium-Pro-optimized version of longest_match()
* Written for zlib 1.1.2
* Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License.
*/
#ifndef NO_UNDERLINE
#define match_init _match_init
#define longest_match _longest_match
#endif
#define MAX_MATCH (258)
#define MIN_MATCH (3)
#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1)
#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7)
/* stack frame offsets */
#define chainlenwmask 0 /* high word: current chain len */
/* low word: s->wmask */
#define window 4 /* local copy of s->window */
#define windowbestlen 8 /* s->window + bestlen */
#define scanstart 16 /* first two bytes of string */
#define scanend 12 /* last two bytes of string */
#define scanalign 20 /* dword-misalignment of string */
#define nicematch 24 /* a good enough match size */
#define bestlen 28 /* size of best match so far */
#define scan 32 /* ptr to string wanting match */
#define LocalVarsSize (36)
/* saved ebx 36 */
/* saved edi 40 */
/* saved esi 44 */
/* saved ebp 48 */
/* return address 52 */
#define deflatestate 56 /* the function arguments */
#define curmatch 60
/* Offsets for fields in the deflate_state structure. These numbers
* are calculated from the definition of deflate_state, with the
* assumption that the compiler will dword-align the fields. (Thus,
* changing the definition of deflate_state could easily cause this
* program to crash horribly, without so much as a warning at
* compile time. Sigh.)
*/
#define dsWSize 36
#define dsWMask 44
#define dsWindow 48
#define dsPrev 56
#define dsMatchLen 88
#define dsPrevMatch 92
#define dsStrStart 100
#define dsMatchStart 104
#define dsLookahead 108
#define dsPrevLen 112
#define dsMaxChainLen 116
#define dsGoodMatch 132
#define dsNiceMatch 136
.file "match.S"
.globl match_init, longest_match
.text
/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */
longest_match:
/* Save registers that the compiler may be using, and adjust %esp to */
/* make room for our stack frame. */
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
subl $LocalVarsSize, %esp
/* Retrieve the function arguments. %ecx will hold cur_match */
/* throughout the entire function. %edx will hold the pointer to the */
/* deflate_state structure during the function's setup (before */
/* entering the main loop). */
movl deflatestate(%esp), %edx
movl curmatch(%esp), %ecx
/* uInt wmask = s->w_mask; */
/* unsigned chain_length = s->max_chain_length; */
/* if (s->prev_length >= s->good_match) { */
/* chain_length >>= 2; */
/* } */
movl dsPrevLen(%edx), %eax
movl dsGoodMatch(%edx), %ebx
cmpl %ebx, %eax
movl dsWMask(%edx), %eax
movl dsMaxChainLen(%edx), %ebx
jl LastMatchGood
shrl $2, %ebx
LastMatchGood:
/* chainlen is decremented once beforehand so that the function can */
/* use the sign flag instead of the zero flag for the exit test. */
/* It is then shifted into the high word, to make room for the wmask */
/* value, which it will always accompany. */
decl %ebx
shll $16, %ebx
orl %eax, %ebx
movl %ebx, chainlenwmask(%esp)
/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */
movl dsNiceMatch(%edx), %eax
movl dsLookahead(%edx), %ebx
cmpl %eax, %ebx
jl LookaheadLess
movl %eax, %ebx
LookaheadLess: movl %ebx, nicematch(%esp)
/* register Bytef *scan = s->window + s->strstart; */
movl dsWindow(%edx), %esi
movl %esi, window(%esp)
movl dsStrStart(%edx), %ebp
lea (%esi,%ebp), %edi
movl %edi, scan(%esp)
/* Determine how many bytes the scan ptr is off from being */
/* dword-aligned. */
movl %edi, %eax
negl %eax
andl $3, %eax
movl %eax, scanalign(%esp)
/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */
/* s->strstart - (IPos)MAX_DIST(s) : NIL; */
movl dsWSize(%edx), %eax
subl $MIN_LOOKAHEAD, %eax
subl %eax, %ebp
jg LimitPositive
xorl %ebp, %ebp
LimitPositive:
/* int best_len = s->prev_length; */
movl dsPrevLen(%edx), %eax
movl %eax, bestlen(%esp)
/* Store the sum of s->window + best_len in %esi locally, and in %esi. */
addl %eax, %esi
movl %esi, windowbestlen(%esp)
/* register ush scan_start = *(ushf*)scan; */
/* register ush scan_end = *(ushf*)(scan+best_len-1); */
/* Posf *prev = s->prev; */
movzwl (%edi), %ebx
movl %ebx, scanstart(%esp)
movzwl -1(%edi,%eax), %ebx
movl %ebx, scanend(%esp)
movl dsPrev(%edx), %edi
/* Jump into the main loop. */
movl chainlenwmask(%esp), %edx
jmp LoopEntry
.balign 16
/* do {
* match = s->window + cur_match;
* if (*(ushf*)(match+best_len-1) != scan_end ||
* *(ushf*)match != scan_start) continue;
* [...]
* } while ((cur_match = prev[cur_match & wmask]) > limit
* && --chain_length != 0);
*
* Here is the inner loop of the function. The function will spend the
* majority of its time in this loop, and majority of that time will
* be spent in the first ten instructions.
*
* Within this loop:
* %ebx = scanend
* %ecx = curmatch
* %edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
* %esi = windowbestlen - i.e., (window + bestlen)
* %edi = prev
* %ebp = limit
*/
LookupLoop:
andl %edx, %ecx
movzwl (%edi,%ecx,2), %ecx
cmpl %ebp, %ecx
jbe LeaveNow
subl $0x00010000, %edx
js LeaveNow
LoopEntry: movzwl -1(%esi,%ecx), %eax
cmpl %ebx, %eax
jnz LookupLoop
movl window(%esp), %eax
movzwl (%eax,%ecx), %eax
cmpl scanstart(%esp), %eax
jnz LookupLoop
/* Store the current value of chainlen. */
movl %edx, chainlenwmask(%esp)
/* Point %edi to the string under scrutiny, and %esi to the string we */
/* are hoping to match it up with. In actuality, %esi and %edi are */
/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */
/* initialized to -(MAX_MATCH_8 - scanalign). */
movl window(%esp), %esi
movl scan(%esp), %edi
addl %ecx, %esi
movl scanalign(%esp), %eax
movl $(-MAX_MATCH_8), %edx
lea MAX_MATCH_8(%edi,%eax), %edi
lea MAX_MATCH_8(%esi,%eax), %esi
/* Test the strings for equality, 8 bytes at a time. At the end,
* adjust %edx so that it is offset to the exact byte that mismatched.
*
* We already know at this point that the first three bytes of the
* strings match each other, and they can be safely passed over before
* starting the compare loop. So what this code does is skip over 0-3
* bytes, as much as necessary in order to dword-align the %edi
* pointer. (%esi will still be misaligned three times out of four.)
*
* It should be confessed that this loop usually does not represent
* much of the total running time. Replacing it with a more
* straightforward "rep cmpsb" would not drastically degrade
* performance.
*/
LoopCmps:
movl (%esi,%edx), %eax
xorl (%edi,%edx), %eax
jnz LeaveLoopCmps
movl 4(%esi,%edx), %eax
xorl 4(%edi,%edx), %eax
jnz LeaveLoopCmps4
addl $8, %edx
jnz LoopCmps
jmp LenMaximum
LeaveLoopCmps4: addl $4, %edx
LeaveLoopCmps: testl $0x0000FFFF, %eax
jnz LenLower
addl $2, %edx
shrl $16, %eax
LenLower: subb $1, %al
adcl $0, %edx
/* Calculate the length of the match. If it is longer than MAX_MATCH, */
/* then automatically accept it as the best possible match and leave. */
lea (%edi,%edx), %eax
movl scan(%esp), %edi
subl %edi, %eax
cmpl $MAX_MATCH, %eax
jge LenMaximum
/* If the length of the match is not longer than the best match we */
/* have so far, then forget it and return to the lookup loop. */
movl deflatestate(%esp), %edx
movl bestlen(%esp), %ebx
cmpl %ebx, %eax
jg LongerMatch
movl windowbestlen(%esp), %esi
movl dsPrev(%edx), %edi
movl scanend(%esp), %ebx
movl chainlenwmask(%esp), %edx
jmp LookupLoop
/* s->match_start = cur_match; */
/* best_len = len; */
/* if (len >= nice_match) break; */
/* scan_end = *(ushf*)(scan+best_len-1); */
LongerMatch: movl nicematch(%esp), %ebx
movl %eax, bestlen(%esp)
movl %ecx, dsMatchStart(%edx)
cmpl %ebx, %eax
jge LeaveNow
movl window(%esp), %esi
addl %eax, %esi
movl %esi, windowbestlen(%esp)
movzwl -1(%edi,%eax), %ebx
movl dsPrev(%edx), %edi
movl %ebx, scanend(%esp)
movl chainlenwmask(%esp), %edx
jmp LookupLoop
/* Accept the current string, with the maximum possible length. */
LenMaximum: movl deflatestate(%esp), %edx
movl $MAX_MATCH, bestlen(%esp)
movl %ecx, dsMatchStart(%edx)
/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */
/* return s->lookahead; */
LeaveNow:
movl deflatestate(%esp), %edx
movl bestlen(%esp), %ebx
movl dsLookahead(%edx), %eax
cmpl %eax, %ebx
jg LookaheadRet
movl %ebx, %eax
LookaheadRet:
/* Restore the stack and return from whence we came. */
addl $LocalVarsSize, %esp
popl %ebx
popl %esi
popl %edi
popl %ebp
match_init: ret

@ -0,0 +1,36 @@
# Makefile for zlib32bd.lib
# ------------- Borland C++ 4.5 -------------
# The (32-bit) zlib32bd.lib made with this makefile is intended for use
# in making the (32-bit) DLL, png32bd.dll. It uses the "stdcall" calling
# convention.
CFLAGS= -ps -O2 -C -K -N- -k- -d -3 -r- -w-par -w-aus -WDE
CC=f:\bc45\bin\bcc32
LIBFLAGS= /C
LIB=f:\bc45\bin\tlib
ZLIB=zlib32bd.lib
.autodepend
.c.obj:
$(CC) -c $(CFLAGS) $<
OBJ1=adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj
OBJ2=infcodes.obj inflate.obj inftrees.obj infutil.obj inffast.obj
OBJ3=trees.obj uncompr.obj zutil.obj
pOBJ1=+adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infblock.obj
pOBJ2=+infcodes.obj+inflate.obj+inftrees.obj+infutil.obj+inffast.obj
pOBJ3=+trees.obj+uncompr.obj+zutil.obj
all: $(ZLIB)
$(ZLIB): $(OBJ1) $(OBJ2) $(OBJ3)
@if exist $@ del $@
$(LIB) @&&|
$@ $(LIBFLAGS) &
$(pOBJ1) &
$(pOBJ2) &
$(pOBJ3)
|
# End of makefile for zlib32bd.lib

@ -0,0 +1,169 @@
unit zlibdef;
interface
uses
Windows;
const
ZLIB_VERSION = '1.1.3';
type
voidpf = Pointer;
int = Integer;
uInt = Cardinal;
pBytef = PChar;
uLong = Cardinal;
alloc_func = function(opaque: voidpf; items, size: uInt): voidpf;
stdcall;
free_func = procedure(opaque, address: voidpf);
stdcall;
internal_state = Pointer;
z_streamp = ^z_stream;
z_stream = packed record
next_in: pBytef; // next input byte
avail_in: uInt; // number of bytes available at next_in
total_in: uLong; // total nb of input bytes read so far
next_out: pBytef; // next output byte should be put there
avail_out: uInt; // remaining free space at next_out
total_out: uLong; // total nb of bytes output so far
msg: PChar; // last error message, NULL if no error
state: internal_state; // not visible by applications
zalloc: alloc_func; // used to allocate the internal state
zfree: free_func; // used to free the internal state
opaque: voidpf; // private data object passed to zalloc and zfree
data_type: int; // best guess about the data type: ascii or binary
adler: uLong; // adler32 value of the uncompressed data
reserved: uLong; // reserved for future use
end;
const
Z_NO_FLUSH = 0;
Z_SYNC_FLUSH = 2;
Z_FULL_FLUSH = 3;
Z_FINISH = 4;
Z_OK = 0;
Z_STREAM_END = 1;
Z_NO_COMPRESSION = 0;
Z_BEST_SPEED = 1;
Z_BEST_COMPRESSION = 9;
Z_DEFAULT_COMPRESSION = -1;
Z_FILTERED = 1;
Z_HUFFMAN_ONLY = 2;
Z_DEFAULT_STRATEGY = 0;
Z_BINARY = 0;
Z_ASCII = 1;
Z_UNKNOWN = 2;
Z_DEFLATED = 8;
MAX_MEM_LEVEL = 9;
function adler32(adler: uLong; const buf: pBytef; len: uInt): uLong;
stdcall;
function crc32(crc: uLong; const buf: pBytef; len: uInt): uLong;
stdcall;
function deflate(strm: z_streamp; flush: int): int;
stdcall;
function deflateCopy(dest, source: z_streamp): int;
stdcall;
function deflateEnd(strm: z_streamp): int;
stdcall;
function deflateInit2_(strm: z_streamp; level, method,
windowBits, memLevel, strategy: int;
const version: PChar; stream_size: int): int;
stdcall;
function deflateInit_(strm: z_streamp; level: int;
const version: PChar; stream_size: int): int;
stdcall;
function deflateParams(strm: z_streamp; level, strategy: int): int;
stdcall;
function deflateReset(strm: z_streamp): int;
stdcall;
function deflateSetDictionary(strm: z_streamp;
const dictionary: pBytef;
dictLength: uInt): int;
stdcall;
function inflate(strm: z_streamp; flush: int): int;
stdcall;
function inflateEnd(strm: z_streamp): int;
stdcall;
function inflateInit2_(strm: z_streamp; windowBits: int;
const version: PChar; stream_size: int): int;
stdcall;
function inflateInit_(strm: z_streamp; const version: PChar;
stream_size: int): int;
stdcall;
function inflateReset(strm: z_streamp): int;
stdcall;
function inflateSetDictionary(strm: z_streamp;
const dictionary: pBytef;
dictLength: uInt): int;
stdcall;
function inflateSync(strm: z_streamp): int;
stdcall;
function deflateInit(strm: z_streamp; level: int): int;
function deflateInit2(strm: z_streamp; level, method, windowBits,
memLevel, strategy: int): int;
function inflateInit(strm: z_streamp): int;
function inflateInit2(strm: z_streamp; windowBits: int): int;
implementation
function deflateInit(strm: z_streamp; level: int): int;
begin
Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream));
end;
function deflateInit2(strm: z_streamp; level, method, windowBits,
memLevel, strategy: int): int;
begin
Result := deflateInit2_(strm, level, method, windowBits, memLevel,
strategy, ZLIB_VERSION, sizeof(z_stream));
end;
function inflateInit(strm: z_streamp): int;
begin
Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream));
end;
function inflateInit2(strm: z_streamp; windowBits: int): int;
begin
Result := inflateInit2_(strm, windowBits, ZLIB_VERSION,
sizeof(z_stream));
end;
const
zlibDLL = 'png32bd.dll';
function adler32; external zlibDLL;
function crc32; external zlibDLL;
function deflate; external zlibDLL;
function deflateCopy; external zlibDLL;
function deflateEnd; external zlibDLL;
function deflateInit2_; external zlibDLL;
function deflateInit_; external zlibDLL;
function deflateParams; external zlibDLL;
function deflateReset; external zlibDLL;
function deflateSetDictionary; external zlibDLL;
function inflate; external zlibDLL;
function inflateEnd; external zlibDLL;
function inflateInit2_; external zlibDLL;
function inflateInit_; external zlibDLL;
function inflateReset; external zlibDLL;
function inflateSetDictionary; external zlibDLL;
function inflateSync; external zlibDLL;
end.

@ -0,0 +1,224 @@
# ---------------------------------------------------------------------------
!if !$d(BCB)
BCB = $(MAKEDIR)\..
!endif
# ---------------------------------------------------------------------------
# IDE SECTION
# ---------------------------------------------------------------------------
# The following section of the project makefile is managed by the BCB IDE.
# It is recommended to use the IDE to change any of the values in this
# section.
# ---------------------------------------------------------------------------
VERSION = BCB.03
# ---------------------------------------------------------------------------
PROJECT = d_zlib.lib
OBJFILES = d_zlib.obj adler32.obj deflate.obj infblock.obj infcodes.obj inffast.obj \
inflate.obj inftrees.obj infutil.obj trees.obj
RESFILES =
RESDEPEN = $(RESFILES)
LIBFILES =
LIBRARIES = VCL35.lib
SPARELIBS = VCL35.lib
DEFFILE =
PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \
dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \
NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi
# ---------------------------------------------------------------------------
PATHCPP = .;
PATHASM = .;
PATHPAS = .;
PATHRC = .;
DEBUGLIBPATH = $(BCB)\lib\debug
RELEASELIBPATH = $(BCB)\lib\release
# ---------------------------------------------------------------------------
CFLAG1 = -O2 -Ve -d -k- -vi
CFLAG2 = -I$(BCB)\include;$(BCB)\include\vcl -H=$(BCB)\lib\vcl35.csm
CFLAG3 = -ff -pr -5
PFLAGS = -U;$(DEBUGLIBPATH) -I$(BCB)\include;$(BCB)\include\vcl -H -W -$I- -v -JPHN -M
RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl
AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn
LFLAGS =
IFLAGS = -g -Gn
# ---------------------------------------------------------------------------
ALLOBJ = c0w32.obj $(OBJFILES)
ALLRES = $(RESFILES)
ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib
# ---------------------------------------------------------------------------
!!ifdef IDEOPTIONS
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=1040
CodePage=1252
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[HistoryLists\hlIncludePath]
Count=2
Item0=$(BCB)\include
Item1=$(BCB)\include;$(BCB)\include\vcl
[HistoryLists\hlLibraryPath]
Count=1
Item0=$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[Debugging]
DebugSourceDirs=
[Parameters]
RunParams=
HostApplication=
!endif
---------------------------------------------------------------------------
# MAKE SECTION
# ---------------------------------------------------------------------------
# This section of the project file is not used by the BCB IDE. It is for
# the benefit of building from the command-line using the MAKE utility.
# ---------------------------------------------------------------------------
.autodepend
# ---------------------------------------------------------------------------
!if !$d(BCC32)
BCC32 = bcc32
!endif
!if !$d(DCC32)
DCC32 = dcc32
!endif
!if !$d(TASM32)
TASM32 = tasm32
!endif
!if !$d(LINKER)
LINKER = TLib
!endif
!if !$d(BRCC32)
BRCC32 = brcc32
!endif
# ---------------------------------------------------------------------------
!if $d(PATHCPP)
.PATH.CPP = $(PATHCPP)
.PATH.C = $(PATHCPP)
!endif
!if $d(PATHPAS)
.PATH.PAS = $(PATHPAS)
!endif
!if $d(PATHASM)
.PATH.ASM = $(PATHASM)
!endif
!if $d(PATHRC)
.PATH.RC = $(PATHRC)
!endif
# ---------------------------------------------------------------------------
!ifdef IDEOPTIONS
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=1040
CodePage=1252
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[HistoryLists\hlIncludePath]
Count=2
Item0=$(BCB)\include;$(BCB)\include\vcl
Item1=$(BCB)\include
[HistoryLists\hlLibraryPath]
Count=1
Item0=$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[Debugging]
DebugSourceDirs=
[Parameters]
RunParams=
HostApplication=
!endif
$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE)
$(BCB)\BIN\$(LINKER) @&&!
$(LFLAGS) $(IFLAGS) +
$(ALLOBJ), +
$(PROJECT),, +
$(ALLLIB), +
$(DEFFILE), +
$(ALLRES)
!
# ---------------------------------------------------------------------------
.pas.hpp:
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< }
.pas.obj:
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< }
.cpp.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< }
.c.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< }
.asm.obj:
$(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@
.rc.res:
$(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $<
# ---------------------------------------------------------------------------

@ -0,0 +1,17 @@
#include <condefs.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEUNIT("adler32.c");
USEUNIT("deflate.c");
USEUNIT("infblock.c");
USEUNIT("infcodes.c");
USEUNIT("inffast.c");
USEUNIT("inflate.c");
USEUNIT("inftrees.c");
USEUNIT("infutil.c");
USEUNIT("trees.c");
//---------------------------------------------------------------------------
#define Library
// To add a file to the library use the Project menu 'Add to Project'.

@ -0,0 +1,17 @@
These are files used to compile zlib under Borland C++ Builder 3.
zlib.bpg is the main project group that can be loaded in the BCB IDE and
loads all other *.bpr projects
zlib.bpr is a project used to create a static zlib.lib library with C calling
convention for functions.
zlib32.bpr creates a zlib32.dll dynamic link library with Windows standard
calling convention.
d_zlib.bpr creates a set of .obj files with register calling convention.
These files are used by zlib.pas to create a Delphi unit containing zlib.
The d_zlib.lib file generated isn't useful and can be deleted.
zlib.cpp, zlib32.cpp and d_zlib.cpp are used by the above projects.

@ -0,0 +1,26 @@
#------------------------------------------------------------------------------
VERSION = BWS.01
#------------------------------------------------------------------------------
!ifndef ROOT
ROOT = $(MAKEDIR)\..
!endif
#------------------------------------------------------------------------------
MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
DCC = $(ROOT)\bin\dcc32.exe $**
BRCC = $(ROOT)\bin\brcc32.exe $**
#------------------------------------------------------------------------------
PROJECTS = zlib zlib32 d_zlib
#------------------------------------------------------------------------------
default: $(PROJECTS)
#------------------------------------------------------------------------------
zlib: zlib.bpr
$(MAKE)
zlib32: zlib32.bpr
$(MAKE)
d_zlib: d_zlib.bpr
$(MAKE)

@ -0,0 +1,225 @@
# ---------------------------------------------------------------------------
!if !$d(BCB)
BCB = $(MAKEDIR)\..
!endif
# ---------------------------------------------------------------------------
# IDE SECTION
# ---------------------------------------------------------------------------
# The following section of the project makefile is managed by the BCB IDE.
# It is recommended to use the IDE to change any of the values in this
# section.
# ---------------------------------------------------------------------------
VERSION = BCB.03
# ---------------------------------------------------------------------------
PROJECT = zlib.lib
OBJFILES = zlib.obj adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj \
infcodes.obj inffast.obj inflate.obj inftrees.obj infutil.obj trees.obj \
uncompr.obj zutil.obj
RESFILES =
RESDEPEN = $(RESFILES)
LIBFILES =
LIBRARIES = VCL35.lib
SPARELIBS = VCL35.lib
DEFFILE =
PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \
dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \
NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi
# ---------------------------------------------------------------------------
PATHCPP = .;
PATHASM = .;
PATHPAS = .;
PATHRC = .;
DEBUGLIBPATH = $(BCB)\lib\debug
RELEASELIBPATH = $(BCB)\lib\release
# ---------------------------------------------------------------------------
CFLAG1 = -O2 -Ve -d -k- -vi
CFLAG2 = -I$(BCB)\include;$(BCB)\include\vcl -H=$(BCB)\lib\vcl35.csm
CFLAG3 = -ff -5
PFLAGS = -U;$(DEBUGLIBPATH) -I$(BCB)\include;$(BCB)\include\vcl -H -W -$I- -v -JPHN -M
RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl
AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn
LFLAGS =
IFLAGS = -g -Gn
# ---------------------------------------------------------------------------
ALLOBJ = c0w32.obj $(OBJFILES)
ALLRES = $(RESFILES)
ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib
# ---------------------------------------------------------------------------
!!ifdef IDEOPTIONS
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=1040
CodePage=1252
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[HistoryLists\hlIncludePath]
Count=2
Item0=$(BCB)\include
Item1=$(BCB)\include;$(BCB)\include\vcl
[HistoryLists\hlLibraryPath]
Count=1
Item0=$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[Debugging]
DebugSourceDirs=
[Parameters]
RunParams=
HostApplication=
!endif
---------------------------------------------------------------------------
# MAKE SECTION
# ---------------------------------------------------------------------------
# This section of the project file is not used by the BCB IDE. It is for
# the benefit of building from the command-line using the MAKE utility.
# ---------------------------------------------------------------------------
.autodepend
# ---------------------------------------------------------------------------
!if !$d(BCC32)
BCC32 = bcc32
!endif
!if !$d(DCC32)
DCC32 = dcc32
!endif
!if !$d(TASM32)
TASM32 = tasm32
!endif
!if !$d(LINKER)
LINKER = TLib
!endif
!if !$d(BRCC32)
BRCC32 = brcc32
!endif
# ---------------------------------------------------------------------------
!if $d(PATHCPP)
.PATH.CPP = $(PATHCPP)
.PATH.C = $(PATHCPP)
!endif
!if $d(PATHPAS)
.PATH.PAS = $(PATHPAS)
!endif
!if $d(PATHASM)
.PATH.ASM = $(PATHASM)
!endif
!if $d(PATHRC)
.PATH.RC = $(PATHRC)
!endif
# ---------------------------------------------------------------------------
!ifdef IDEOPTIONS
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=1040
CodePage=1252
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[HistoryLists\hlIncludePath]
Count=2
Item0=$(BCB)\include;$(BCB)\include\vcl
Item1=$(BCB)\include
[HistoryLists\hlLibraryPath]
Count=1
Item0=$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[Debugging]
DebugSourceDirs=
[Parameters]
RunParams=
HostApplication=
!endif
$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE)
$(BCB)\BIN\$(LINKER) @&&!
$(LFLAGS) $(IFLAGS) +
$(ALLOBJ), +
$(PROJECT),, +
$(ALLLIB), +
$(DEFFILE), +
$(ALLRES)
!
# ---------------------------------------------------------------------------
.pas.hpp:
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< }
.pas.obj:
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< }
.cpp.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< }
.c.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< }
.asm.obj:
$(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@
.rc.res:
$(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $<
# ---------------------------------------------------------------------------

@ -0,0 +1,22 @@
#include <condefs.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEUNIT("adler32.c");
USEUNIT("compress.c");
USEUNIT("crc32.c");
USEUNIT("deflate.c");
USEUNIT("gzio.c");
USEUNIT("infblock.c");
USEUNIT("infcodes.c");
USEUNIT("inffast.c");
USEUNIT("inflate.c");
USEUNIT("inftrees.c");
USEUNIT("infutil.c");
USEUNIT("trees.c");
USEUNIT("uncompr.c");
USEUNIT("zutil.c");
//---------------------------------------------------------------------------
#define Library
// To add a file to the library use the Project menu 'Add to Project'.

@ -0,0 +1,534 @@
{*******************************************************}
{ }
{ Delphi Supplemental Components }
{ ZLIB Data Compression Interface Unit }
{ }
{ Copyright (c) 1997 Borland International }
{ }
{*******************************************************}
{ Modified for zlib 1.1.3 by Davide Moretti <dave@rimini.com }
unit zlib;
interface
uses Sysutils, Classes;
type
TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer;
TFree = procedure (AppData, Block: Pointer);
// Internal structure. Ignore.
TZStreamRec = packed record
next_in: PChar; // next input byte
avail_in: Integer; // number of bytes available at next_in
total_in: Integer; // total nb of input bytes read so far
next_out: PChar; // next output byte should be put here
avail_out: Integer; // remaining free space at next_out
total_out: Integer; // total nb of bytes output so far
msg: PChar; // last error message, NULL if no error
internal: Pointer; // not visible by applications
zalloc: TAlloc; // used to allocate the internal state
zfree: TFree; // used to free the internal state
AppData: Pointer; // private data object passed to zalloc and zfree
data_type: Integer; // best guess about the data type: ascii or binary
adler: Integer; // adler32 value of the uncompressed data
reserved: Integer; // reserved for future use
end;
// Abstract ancestor class
TCustomZlibStream = class(TStream)
private
FStrm: TStream;
FStrmPos: Integer;
FOnProgress: TNotifyEvent;
FZRec: TZStreamRec;
FBuffer: array [Word] of Char;
protected
procedure Progress(Sender: TObject); dynamic;
property OnProgress: TNotifyEvent read FOnProgress write FOnProgress;
constructor Create(Strm: TStream);
end;
{ TCompressionStream compresses data on the fly as data is written to it, and
stores the compressed data to another stream.
TCompressionStream is write-only and strictly sequential. Reading from the
stream will raise an exception. Using Seek to move the stream pointer
will raise an exception.
Output data is cached internally, written to the output stream only when
the internal output buffer is full. All pending output data is flushed
when the stream is destroyed.
The Position property returns the number of uncompressed bytes of
data that have been written to the stream so far.
CompressionRate returns the on-the-fly percentage by which the original
data has been compressed: (1 - (CompressedBytes / UncompressedBytes)) * 100
If raw data size = 100 and compressed data size = 25, the CompressionRate
is 75%
The OnProgress event is called each time the output buffer is filled and
written to the output stream. This is useful for updating a progress
indicator when you are writing a large chunk of data to the compression
stream in a single call.}
TCompressionLevel = (clNone, clFastest, clDefault, clMax);
TCompressionStream = class(TCustomZlibStream)
private
function GetCompressionRate: Single;
public
constructor Create(CompressionLevel: TCompressionLevel; Dest: TStream);
destructor Destroy; override;
function Read(var Buffer; Count: Longint): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override;
function Seek(Offset: Longint; Origin: Word): Longint; override;
property CompressionRate: Single read GetCompressionRate;
property OnProgress;
end;
{ TDecompressionStream decompresses data on the fly as data is read from it.
Compressed data comes from a separate source stream. TDecompressionStream
is read-only and unidirectional; you can seek forward in the stream, but not
backwards. The special case of setting the stream position to zero is
allowed. Seeking forward decompresses data until the requested position in
the uncompressed data has been reached. Seeking backwards, seeking relative
to the end of the stream, requesting the size of the stream, and writing to
the stream will raise an exception.
The Position property returns the number of bytes of uncompressed data that
have been read from the stream so far.
The OnProgress event is called each time the internal input buffer of
compressed data is exhausted and the next block is read from the input stream.
This is useful for updating a progress indicator when you are reading a
large chunk of data from the decompression stream in a single call.}
TDecompressionStream = class(TCustomZlibStream)
public
constructor Create(Source: TStream);
destructor Destroy; override;
function Read(var Buffer; Count: Longint): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override;
function Seek(Offset: Longint; Origin: Word): Longint; override;
property OnProgress;
end;
{ CompressBuf compresses data, buffer to buffer, in one call.
In: InBuf = ptr to compressed data
InBytes = number of bytes in InBuf
Out: OutBuf = ptr to newly allocated buffer containing decompressed data
OutBytes = number of bytes in OutBuf }
procedure CompressBuf(const InBuf: Pointer; InBytes: Integer;
out OutBuf: Pointer; out OutBytes: Integer);
{ DecompressBuf decompresses data, buffer to buffer, in one call.
In: InBuf = ptr to compressed data
InBytes = number of bytes in InBuf
OutEstimate = zero, or est. size of the decompressed data
Out: OutBuf = ptr to newly allocated buffer containing decompressed data
OutBytes = number of bytes in OutBuf }
procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer;
OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer);
const
zlib_version = '1.1.3';
type
EZlibError = class(Exception);
ECompressionError = class(EZlibError);
EDecompressionError = class(EZlibError);
function adler32(adler: Integer; buf: PChar; len: Integer): Integer;
implementation
const
Z_NO_FLUSH = 0;
Z_PARTIAL_FLUSH = 1;
Z_SYNC_FLUSH = 2;
Z_FULL_FLUSH = 3;
Z_FINISH = 4;
Z_OK = 0;
Z_STREAM_END = 1;
Z_NEED_DICT = 2;
Z_ERRNO = (-1);
Z_STREAM_ERROR = (-2);
Z_DATA_ERROR = (-3);
Z_MEM_ERROR = (-4);
Z_BUF_ERROR = (-5);
Z_VERSION_ERROR = (-6);
Z_NO_COMPRESSION = 0;
Z_BEST_SPEED = 1;
Z_BEST_COMPRESSION = 9;
Z_DEFAULT_COMPRESSION = (-1);
Z_FILTERED = 1;
Z_HUFFMAN_ONLY = 2;
Z_DEFAULT_STRATEGY = 0;
Z_BINARY = 0;
Z_ASCII = 1;
Z_UNKNOWN = 2;
Z_DEFLATED = 8;
_z_errmsg: array[0..9] of PChar = (
'need dictionary', // Z_NEED_DICT (2)
'stream end', // Z_STREAM_END (1)
'', // Z_OK (0)
'file error', // Z_ERRNO (-1)
'stream error', // Z_STREAM_ERROR (-2)
'data error', // Z_DATA_ERROR (-3)
'insufficient memory', // Z_MEM_ERROR (-4)
'buffer error', // Z_BUF_ERROR (-5)
'incompatible version', // Z_VERSION_ERROR (-6)
''
);
{$L deflate.obj}
{$L inflate.obj}
{$L inftrees.obj}
{$L trees.obj}
{$L adler32.obj}
{$L infblock.obj}
{$L infcodes.obj}
{$L infutil.obj}
{$L inffast.obj}
procedure _tr_init; external;
procedure _tr_tally; external;
procedure _tr_flush_block; external;
procedure _tr_align; external;
procedure _tr_stored_block; external;
function adler32; external;
procedure inflate_blocks_new; external;
procedure inflate_blocks; external;
procedure inflate_blocks_reset; external;
procedure inflate_blocks_free; external;
procedure inflate_set_dictionary; external;
procedure inflate_trees_bits; external;
procedure inflate_trees_dynamic; external;
procedure inflate_trees_fixed; external;
procedure inflate_codes_new; external;
procedure inflate_codes; external;
procedure inflate_codes_free; external;
procedure _inflate_mask; external;
procedure inflate_flush; external;
procedure inflate_fast; external;
procedure _memset(P: Pointer; B: Byte; count: Integer);cdecl;
begin
FillChar(P^, count, B);
end;
procedure _memcpy(dest, source: Pointer; count: Integer);cdecl;
begin
Move(source^, dest^, count);
end;
// deflate compresses data
function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar;
recsize: Integer): Integer; external;
function deflate(var strm: TZStreamRec; flush: Integer): Integer; external;
function deflateEnd(var strm: TZStreamRec): Integer; external;
// inflate decompresses data
function inflateInit_(var strm: TZStreamRec; version: PChar;
recsize: Integer): Integer; external;
function inflate(var strm: TZStreamRec; flush: Integer): Integer; external;
function inflateEnd(var strm: TZStreamRec): Integer; external;
function inflateReset(var strm: TZStreamRec): Integer; external;
function zcalloc(AppData: Pointer; Items, Size: Integer): Pointer;
begin
GetMem(Result, Items*Size);
end;
procedure zcfree(AppData, Block: Pointer);
begin
FreeMem(Block);
end;
function zlibCheck(code: Integer): Integer;
begin
Result := code;
if code < 0 then
raise EZlibError.Create('error'); //!!
end;
function CCheck(code: Integer): Integer;
begin
Result := code;
if code < 0 then
raise ECompressionError.Create('error'); //!!
end;
function DCheck(code: Integer): Integer;
begin
Result := code;
if code < 0 then
raise EDecompressionError.Create('error'); //!!
end;
procedure CompressBuf(const InBuf: Pointer; InBytes: Integer;
out OutBuf: Pointer; out OutBytes: Integer);
var
strm: TZStreamRec;
P: Pointer;
begin
FillChar(strm, sizeof(strm), 0);
OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255;
GetMem(OutBuf, OutBytes);
try
strm.next_in := InBuf;
strm.avail_in := InBytes;
strm.next_out := OutBuf;
strm.avail_out := OutBytes;
CCheck(deflateInit_(strm, Z_BEST_COMPRESSION, zlib_version, sizeof(strm)));
try
while CCheck(deflate(strm, Z_FINISH)) <> Z_STREAM_END do
begin
P := OutBuf;
Inc(OutBytes, 256);
ReallocMem(OutBuf, OutBytes);
strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P)));
strm.avail_out := 256;
end;
finally
CCheck(deflateEnd(strm));
end;
ReallocMem(OutBuf, strm.total_out);
OutBytes := strm.total_out;
except
FreeMem(OutBuf);
raise
end;
end;
procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer;
OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer);
var
strm: TZStreamRec;
P: Pointer;
BufInc: Integer;
begin
FillChar(strm, sizeof(strm), 0);
BufInc := (InBytes + 255) and not 255;
if OutEstimate = 0 then
OutBytes := BufInc
else
OutBytes := OutEstimate;
GetMem(OutBuf, OutBytes);
try
strm.next_in := InBuf;
strm.avail_in := InBytes;
strm.next_out := OutBuf;
strm.avail_out := OutBytes;
DCheck(inflateInit_(strm, zlib_version, sizeof(strm)));
try
while DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END do
begin
P := OutBuf;
Inc(OutBytes, BufInc);
ReallocMem(OutBuf, OutBytes);
strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P)));
strm.avail_out := BufInc;
end;
finally
DCheck(inflateEnd(strm));
end;
ReallocMem(OutBuf, strm.total_out);
OutBytes := strm.total_out;
except
FreeMem(OutBuf);
raise
end;
end;
// TCustomZlibStream
constructor TCustomZLibStream.Create(Strm: TStream);
begin
inherited Create;
FStrm := Strm;
FStrmPos := Strm.Position;
end;
procedure TCustomZLibStream.Progress(Sender: TObject);
begin
if Assigned(FOnProgress) then FOnProgress(Sender);
end;
// TCompressionStream
constructor TCompressionStream.Create(CompressionLevel: TCompressionLevel;
Dest: TStream);
const
Levels: array [TCompressionLevel] of ShortInt =
(Z_NO_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_BEST_COMPRESSION);
begin
inherited Create(Dest);
FZRec.next_out := FBuffer;
FZRec.avail_out := sizeof(FBuffer);
CCheck(deflateInit_(FZRec, Levels[CompressionLevel], zlib_version, sizeof(FZRec)));
end;
destructor TCompressionStream.Destroy;
begin
FZRec.next_in := nil;
FZRec.avail_in := 0;
try
if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos;
while (CCheck(deflate(FZRec, Z_FINISH)) <> Z_STREAM_END)
and (FZRec.avail_out = 0) do
begin
FStrm.WriteBuffer(FBuffer, sizeof(FBuffer));
FZRec.next_out := FBuffer;
FZRec.avail_out := sizeof(FBuffer);
end;
if FZRec.avail_out < sizeof(FBuffer) then
FStrm.WriteBuffer(FBuffer, sizeof(FBuffer) - FZRec.avail_out);
finally
deflateEnd(FZRec);
end;
inherited Destroy;
end;
function TCompressionStream.Read(var Buffer; Count: Longint): Longint;
begin
raise ECompressionError.Create('Invalid stream operation');
end;
function TCompressionStream.Write(const Buffer; Count: Longint): Longint;
begin
FZRec.next_in := @Buffer;
FZRec.avail_in := Count;
if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos;
while (FZRec.avail_in > 0) do
begin
CCheck(deflate(FZRec, 0));
if FZRec.avail_out = 0 then
begin
FStrm.WriteBuffer(FBuffer, sizeof(FBuffer));
FZRec.next_out := FBuffer;
FZRec.avail_out := sizeof(FBuffer);
FStrmPos := FStrm.Position;
Progress(Self);
end;
end;
Result := Count;
end;
function TCompressionStream.Seek(Offset: Longint; Origin: Word): Longint;
begin
if (Offset = 0) and (Origin = soFromCurrent) then
Result := FZRec.total_in
else
raise ECompressionError.Create('Invalid stream operation');
end;
function TCompressionStream.GetCompressionRate: Single;
begin
if FZRec.total_in = 0 then
Result := 0
else
Result := (1.0 - (FZRec.total_out / FZRec.total_in)) * 100.0;
end;
// TDecompressionStream
constructor TDecompressionStream.Create(Source: TStream);
begin
inherited Create(Source);
FZRec.next_in := FBuffer;
FZRec.avail_in := 0;
DCheck(inflateInit_(FZRec, zlib_version, sizeof(FZRec)));
end;
destructor TDecompressionStream.Destroy;
begin
inflateEnd(FZRec);
inherited Destroy;
end;
function TDecompressionStream.Read(var Buffer; Count: Longint): Longint;
begin
FZRec.next_out := @Buffer;
FZRec.avail_out := Count;
if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos;
while (FZRec.avail_out > 0) do
begin
if FZRec.avail_in = 0 then
begin
FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer));
if FZRec.avail_in = 0 then
begin
Result := Count - FZRec.avail_out;
Exit;
end;
FZRec.next_in := FBuffer;
FStrmPos := FStrm.Position;
Progress(Self);
end;
DCheck(inflate(FZRec, 0));
end;
Result := Count;
end;
function TDecompressionStream.Write(const Buffer; Count: Longint): Longint;
begin
raise EDecompressionError.Create('Invalid stream operation');
end;
function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint;
var
I: Integer;
Buf: array [0..4095] of Char;
begin
if (Offset = 0) and (Origin = soFromBeginning) then
begin
DCheck(inflateReset(FZRec));
FZRec.next_in := FBuffer;
FZRec.avail_in := 0;
FStrm.Position := 0;
FStrmPos := 0;
end
else if ( (Offset >= 0) and (Origin = soFromCurrent)) or
( ((Offset - FZRec.total_out) > 0) and (Origin = soFromBeginning)) then
begin
if Origin = soFromBeginning then Dec(Offset, FZRec.total_out);
if Offset > 0 then
begin
for I := 1 to Offset div sizeof(Buf) do
ReadBuffer(Buf, sizeof(Buf));
ReadBuffer(Buf, Offset mod sizeof(Buf));
end;
end
else
raise EDecompressionError.Create('Invalid stream operation');
Result := FZRec.total_out;
end;
end.

@ -0,0 +1,174 @@
# ---------------------------------------------------------------------------
!if !$d(BCB)
BCB = $(MAKEDIR)\..
!endif
# ---------------------------------------------------------------------------
# IDE SECTION
# ---------------------------------------------------------------------------
# The following section of the project makefile is managed by the BCB IDE.
# It is recommended to use the IDE to change any of the values in this
# section.
# ---------------------------------------------------------------------------
VERSION = BCB.03
# ---------------------------------------------------------------------------
PROJECT = zlib32.dll
OBJFILES = zlib32.obj adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj \
infcodes.obj inffast.obj inflate.obj inftrees.obj infutil.obj trees.obj \
uncompr.obj zutil.obj
RESFILES =
RESDEPEN = $(RESFILES)
LIBFILES =
LIBRARIES =
SPARELIBS =
DEFFILE =
PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \
dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \
NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi
# ---------------------------------------------------------------------------
PATHCPP = .;
PATHASM = .;
PATHPAS = .;
PATHRC = .;
DEBUGLIBPATH = $(BCB)\lib\debug
RELEASELIBPATH = $(BCB)\lib\release
# ---------------------------------------------------------------------------
CFLAG1 = -WD -O2 -Ve -d -k- -vi -c -tWD
CFLAG2 = -D_NO_VCL;ZLIB_DLL -I$(BCB)\include
CFLAG3 = -ff -5
PFLAGS = -D_NO_VCL;ZLIB_DLL -U$(BCB)\lib;$(RELEASELIBPATH) -I$(BCB)\include -$I- -v \
-JPHN -M
RFLAGS = -D_NO_VCL;ZLIB_DLL -i$(BCB)\include
AFLAGS = /i$(BCB)\include /d_NO_VCL /dZLIB_DLL /mx /w2 /zn
LFLAGS = -L$(BCB)\lib;$(RELEASELIBPATH) -aa -Tpd -x -Gi
IFLAGS = -Gn -g
# ---------------------------------------------------------------------------
ALLOBJ = c0d32.obj $(OBJFILES)
ALLRES = $(RESFILES)
ALLLIB = $(LIBFILES) import32.lib cw32mt.lib
# ---------------------------------------------------------------------------
!ifdef IDEOPTIONS
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=1
Locale=1040
CodePage=1252
[Version Info Keys]
CompanyName=
FileDescription=DLL (GUI)
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[HistoryLists\hlIncludePath]
Count=1
Item0=$(BCB)\include
[HistoryLists\hlLibraryPath]
Count=1
Item0=$(BCB)\lib
[HistoryLists\hlConditionals]
Count=1
Item0=_NO_VCL;ZLIB_DLL
[Debugging]
DebugSourceDirs=
[Parameters]
RunParams=
HostApplication=
!endif
# ---------------------------------------------------------------------------
# MAKE SECTION
# ---------------------------------------------------------------------------
# This section of the project file is not used by the BCB IDE. It is for
# the benefit of building from the command-line using the MAKE utility.
# ---------------------------------------------------------------------------
.autodepend
# ---------------------------------------------------------------------------
!if !$d(BCC32)
BCC32 = bcc32
!endif
!if !$d(DCC32)
DCC32 = dcc32
!endif
!if !$d(TASM32)
TASM32 = tasm32
!endif
!if !$d(LINKER)
LINKER = ilink32
!endif
!if !$d(BRCC32)
BRCC32 = brcc32
!endif
# ---------------------------------------------------------------------------
!if $d(PATHCPP)
.PATH.CPP = $(PATHCPP)
.PATH.C = $(PATHCPP)
!endif
!if $d(PATHPAS)
.PATH.PAS = $(PATHPAS)
!endif
!if $d(PATHASM)
.PATH.ASM = $(PATHASM)
!endif
!if $d(PATHRC)
.PATH.RC = $(PATHRC)
!endif
# ---------------------------------------------------------------------------
$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE)
$(BCB)\BIN\$(LINKER) @&&!
$(LFLAGS) $(IFLAGS) +
$(ALLOBJ), +
$(PROJECT),, +
$(ALLLIB), +
$(DEFFILE), +
$(ALLRES)
!
# ---------------------------------------------------------------------------
.pas.hpp:
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< }
.pas.obj:
$(BCB)\BIN\$(DCC32) $(PFLAGS) {$< }
.cpp.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< }
.c.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< }
.asm.obj:
$(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@
.rc.res:
$(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $<
# ---------------------------------------------------------------------------

@ -0,0 +1,42 @@
#include <windows.h>
#pragma hdrstop
#include <condefs.h>
//---------------------------------------------------------------------------
// Important note about DLL memory management in a VCL DLL:
//
//
//
// If your DLL uses VCL and exports any functions that pass VCL String objects
// (or structs/classes containing nested Strings) as parameter or function
// results, you will need to build both your DLL project and any EXE projects
// that use your DLL with the dynamic RTL (the RTL DLL). This will change your
// DLL and its calling EXE's to use BORLNDMM.DLL as their memory manager. In
// these cases, the file BORLNDMM.DLL should be deployed along with your DLL
// and the RTL DLL (CP3240MT.DLL). To avoid the requiring BORLNDMM.DLL in
// these situations, pass string information using "char *" or ShortString
// parameters and then link with the static RTL.
//
//---------------------------------------------------------------------------
USEUNIT("adler32.c");
USEUNIT("compress.c");
USEUNIT("crc32.c");
USEUNIT("deflate.c");
USEUNIT("gzio.c");
USEUNIT("infblock.c");
USEUNIT("infcodes.c");
USEUNIT("inffast.c");
USEUNIT("inflate.c");
USEUNIT("inftrees.c");
USEUNIT("infutil.c");
USEUNIT("trees.c");
USEUNIT("uncompr.c");
USEUNIT("zutil.c");
//---------------------------------------------------------------------------
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return 1;
}

@ -315,7 +315,7 @@ local uLong unzlocal_SearchCentralDir(fin)
if (fread(buf,(uInt)uReadSize,1,fin)!=1) if (fread(buf,(uInt)uReadSize,1,fin)!=1)
break; break;
for (i=0;i<(int)uReadSize-3;i++) for (i=(int)uReadSize-3; (i--)>0;)
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
{ {

@ -242,6 +242,8 @@ local int write_datablock(fout,ll)
Outputs a long in LSB order to the given file Outputs a long in LSB order to the given file
nbByte == 1, 2 or 4 (byte, short or long) nbByte == 1, 2 or 4 (byte, short or long)
*/ */
local int ziplocal_putValue OF((FILE *file, uLong x, int nbByte));
local int ziplocal_putValue (file, x, nbByte) local int ziplocal_putValue (file, x, nbByte)
FILE *file; FILE *file;
uLong x; uLong x;
@ -259,7 +261,7 @@ local int ziplocal_putValue (file, x, nbByte)
return ZIP_OK; return ZIP_OK;
} }
local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte));
local void ziplocal_putValue_inmemory (dest, x, nbByte) local void ziplocal_putValue_inmemory (dest, x, nbByte)
void* dest; void* dest;
uLong x; uLong x;
@ -390,34 +392,34 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
zi->ci.pos_local_header = ftell(zi->filezip); zi->ci.pos_local_header = ftell(zi->filezip);
zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename +
size_extrafield_global + size_comment; size_extrafield_global + size_comment;
zi->ci.central_header = (char*)ALLOC(zi->ci.size_centralheader); zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader);
ziplocal_putValue_inmemory(zi->ci.central_header,CENTRALHEADERMAGIC,4); ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4);
/* version info */ /* version info */
ziplocal_putValue_inmemory(zi->ci.central_header+4,VERSIONMADEBY,2); ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2);
ziplocal_putValue_inmemory(zi->ci.central_header+6,20,2); ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2);
ziplocal_putValue_inmemory(zi->ci.central_header+8,zi->ci.flag,2); ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2);
ziplocal_putValue_inmemory(zi->ci.central_header+10,zi->ci.method,2); ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2);
ziplocal_putValue_inmemory(zi->ci.central_header+12,zi->ci.dosDate,4); ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4);
ziplocal_putValue_inmemory(zi->ci.central_header+16,0,4); /*crc*/ ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/
ziplocal_putValue_inmemory(zi->ci.central_header+20,0,4); /*compr size*/ ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/
ziplocal_putValue_inmemory(zi->ci.central_header+24,0,4); /*uncompr size*/ ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/
ziplocal_putValue_inmemory(zi->ci.central_header+28,size_filename,2); ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2);
ziplocal_putValue_inmemory(zi->ci.central_header+30,size_extrafield_global,2); ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2);
ziplocal_putValue_inmemory(zi->ci.central_header+32,size_comment,2); ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2);
ziplocal_putValue_inmemory(zi->ci.central_header+34,0,2); /*disk nm start*/ ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/
if (zipfi==NULL) if (zipfi==NULL)
ziplocal_putValue_inmemory(zi->ci.central_header+36,0,2); ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2);
else else
ziplocal_putValue_inmemory(zi->ci.central_header+36,zipfi->internal_fa,2); ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2);
if (zipfi==NULL) if (zipfi==NULL)
ziplocal_putValue_inmemory(zi->ci.central_header+38,0,4); ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4);
else else
ziplocal_putValue_inmemory(zi->ci.central_header+38,zipfi->external_fa,4); ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4);
ziplocal_putValue_inmemory(zi->ci.central_header+42,zi->ci.pos_local_header,4); ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header,4);
for (i=0;i<size_filename;i++) for (i=0;i<size_filename;i++)
*(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i); *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);
@ -433,25 +435,25 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
return ZIP_INTERNALERROR; return ZIP_INTERNALERROR;
/* write the local header */ /* write the local header */
err = ziplocal_putValue(zi->filezip,LOCALHEADERMAGIC,4); err = ziplocal_putValue(zi->filezip,(uLong)LOCALHEADERMAGIC,4);
if (err==ZIP_OK) if (err==ZIP_OK)
err = ziplocal_putValue(zi->filezip,20,2);/* version needed to extract */ err = ziplocal_putValue(zi->filezip,(uLong)20,2);/* version needed to extract */
if (err==ZIP_OK) if (err==ZIP_OK)
err = ziplocal_putValue(zi->filezip,zi->ci.flag,2); err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.flag,2);
if (err==ZIP_OK) if (err==ZIP_OK)
err = ziplocal_putValue(zi->filezip,zi->ci.method,2); err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.method,2);
if (err==ZIP_OK) if (err==ZIP_OK)
err = ziplocal_putValue(zi->filezip,zi->ci.dosDate,4); err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.dosDate,4);
if (err==ZIP_OK) if (err==ZIP_OK)
err = ziplocal_putValue(zi->filezip,0,4); /* crc 32, unknown */ err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* crc 32, unknown */
if (err==ZIP_OK) if (err==ZIP_OK)
err = ziplocal_putValue(zi->filezip,0,4); /* compressed size, unknown */ err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* compressed size, unknown */
if (err==ZIP_OK) if (err==ZIP_OK)
err = ziplocal_putValue(zi->filezip,0,4); /* uncompressed size, unknown */ err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* uncompressed size, unknown */
if (err==ZIP_OK) if (err==ZIP_OK)
err = ziplocal_putValue(zi->filezip,(uLong)size_filename,2); err = ziplocal_putValue(zi->filezip,(uLong)size_filename,2);
@ -481,7 +483,7 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
zi->ci.stream.opaque = (voidpf)0; zi->ci.stream.opaque = (voidpf)0;
err = deflateInit2(&zi->ci.stream, level, err = deflateInit2(&zi->ci.stream, level,
Z_DEFLATED, -MAX_WBITS, /*DEF_MEM_LEVEL*/8, 0); Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, 0);
if (err==Z_OK) if (err==Z_OK)
zi->ci.stream_initialised = 1; zi->ci.stream_initialised = 1;
@ -528,7 +530,7 @@ extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
{ {
uLong uTotalOutBefore = zi->ci.stream.total_out; uLong uTotalOutBefore = zi->ci.stream.total_out;
err=deflate(&zi->ci.stream, Z_NO_FLUSH); err=deflate(&zi->ci.stream, Z_NO_FLUSH);
zi->ci.pos_in_buffered_data += zi->ci.stream.total_out - uTotalOutBefore ; zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
} }
else else
@ -585,7 +587,7 @@ extern int ZEXPORT zipCloseFileInZip (file)
} }
uTotalOutBefore = zi->ci.stream.total_out; uTotalOutBefore = zi->ci.stream.total_out;
err=deflate(&zi->ci.stream, Z_FINISH); err=deflate(&zi->ci.stream, Z_FINISH);
zi->ci.pos_in_buffered_data += zi->ci.stream.total_out - uTotalOutBefore ; zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
} }
if (err==Z_STREAM_END) if (err==Z_STREAM_END)
@ -602,11 +604,11 @@ extern int ZEXPORT zipCloseFileInZip (file)
zi->ci.stream_initialised = 0; zi->ci.stream_initialised = 0;
} }
ziplocal_putValue_inmemory(zi->ci.central_header+16,zi->ci.crc32,4); /*crc*/ ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)zi->ci.crc32,4); /*crc*/
ziplocal_putValue_inmemory(zi->ci.central_header+20, ziplocal_putValue_inmemory(zi->ci.central_header+20,
zi->ci.stream.total_out,4); /*compr size*/ (uLong)zi->ci.stream.total_out,4); /*compr size*/
ziplocal_putValue_inmemory(zi->ci.central_header+24, ziplocal_putValue_inmemory(zi->ci.central_header+24,
zi->ci.stream.total_in,4); /*uncompr size*/ (uLong)zi->ci.stream.total_in,4); /*uncompr size*/
if (err==ZIP_OK) if (err==ZIP_OK)
err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header,
@ -621,13 +623,13 @@ extern int ZEXPORT zipCloseFileInZip (file)
err = ZIP_ERRNO; err = ZIP_ERRNO;
if (err==ZIP_OK) if (err==ZIP_OK)
err = ziplocal_putValue(zi->filezip,zi->ci.crc32,4); /* crc 32, unknown */ err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.crc32,4); /* crc 32, unknown */
if (err==ZIP_OK) /* compressed size, unknown */ if (err==ZIP_OK) /* compressed size, unknown */
err = ziplocal_putValue(zi->filezip,zi->ci.stream.total_out,4); err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_out,4);
if (err==ZIP_OK) /* uncompressed size, unknown */ if (err==ZIP_OK) /* uncompressed size, unknown */
err = ziplocal_putValue(zi->filezip,zi->ci.stream.total_in,4); err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_in,4);
if (fseek(zi->filezip, if (fseek(zi->filezip,
cur_pos_inzip,SEEK_SET)!=0) cur_pos_inzip,SEEK_SET)!=0)
@ -682,26 +684,26 @@ extern int ZEXPORT zipClose (file, global_comment)
free_datablock(zi->central_dir.first_block); free_datablock(zi->central_dir.first_block);
if (err==ZIP_OK) /* Magic End */ if (err==ZIP_OK) /* Magic End */
err = ziplocal_putValue(zi->filezip,ENDHEADERMAGIC,4); err = ziplocal_putValue(zi->filezip,(uLong)ENDHEADERMAGIC,4);
if (err==ZIP_OK) /* number of this disk */ if (err==ZIP_OK) /* number of this disk */
err = ziplocal_putValue(zi->filezip,0,2); err = ziplocal_putValue(zi->filezip,(uLong)0,2);
if (err==ZIP_OK) /* number of the disk with the start of the central directory */ if (err==ZIP_OK) /* number of the disk with the start of the central directory */
err = ziplocal_putValue(zi->filezip,0,2); err = ziplocal_putValue(zi->filezip,(uLong)0,2);
if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ if (err==ZIP_OK) /* total number of entries in the central dir on this disk */
err = ziplocal_putValue(zi->filezip,zi->number_entry,2); err = ziplocal_putValue(zi->filezip,(uLong)zi->number_entry,2);
if (err==ZIP_OK) /* total number of entries in the central dir */ if (err==ZIP_OK) /* total number of entries in the central dir */
err = ziplocal_putValue(zi->filezip,zi->number_entry,2); err = ziplocal_putValue(zi->filezip,(uLong)zi->number_entry,2);
if (err==ZIP_OK) /* size of the central directory */ if (err==ZIP_OK) /* size of the central directory */
err = ziplocal_putValue(zi->filezip,size_centraldir,4); err = ziplocal_putValue(zi->filezip,(uLong)size_centraldir,4);
if (err==ZIP_OK) /* offset of start of central directory with respect to the if (err==ZIP_OK) /* offset of start of central directory with respect to the
starting disk number */ starting disk number */
err = ziplocal_putValue(zi->filezip,centraldir_pos_inzip ,4); err = ziplocal_putValue(zi->filezip,(uLong)centraldir_pos_inzip ,4);
if (err==ZIP_OK) /* zipfile comment length */ if (err==ZIP_OK) /* zipfile comment length */
err = ziplocal_putValue(zi->filezip,(uLong)size_global_comment,2); err = ziplocal_putValue(zi->filezip,(uLong)size_global_comment,2);

@ -9,7 +9,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <utime.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef unix #ifdef unix
@ -21,6 +20,23 @@
#include "zlib.h" #include "zlib.h"
#ifdef WIN32
# ifndef F_OK
# define F_OK (0)
# endif
# ifdef _MSC_VER
# define mkdir(dirname,mode) _mkdir(dirname)
# define strdup(str) _strdup(str)
# define unlink(fn) _unlink(fn)
# define access(path,mode) _access(path,mode)
# else
# define mkdir(dirname,mode) _mkdir(dirname)
# endif
#else
# include <utime.h>
#endif
/* Values used in typeflag field. */ /* Values used in typeflag field. */
#define REGTYPE '0' /* regular file */ #define REGTYPE '0' /* regular file */
@ -83,7 +99,7 @@ char *prog;
/* This will give a benign warning */ /* This will give a benign warning */
static char *TGZprefix[] = { "\0", ".tgz", ".tar.gz", NULL }; static char *TGZprefix[] = { "\0", ".tgz", ".tar.gz", ".tar", NULL };
/* Return the real name of the TGZ archive */ /* Return the real name of the TGZ archive */
/* or NULL if it does not exist. */ /* or NULL if it does not exist. */
@ -271,14 +287,6 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
len = gzread(in, &buffer, BLOCKSIZE); len = gzread(in, &buffer, BLOCKSIZE);
if (len < 0) if (len < 0)
error (gzerror(in, &err)); error (gzerror(in, &err));
/*
* if we met the end of the tar
* or the end-of-tar block,
* we are done
*/
if ((len == 0) || (buffer.header.name[0]== 0))
break;
/* /*
* Always expect complete blocks to process * Always expect complete blocks to process
* the tar information. * the tar information.
@ -291,6 +299,13 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
*/ */
if (getheader == 1) if (getheader == 1)
{ {
/*
* if we met the end of the tar
* or the end-of-tar block,
* we are done
*/
if ((len == 0) || (buffer.header.name[0]== 0)) break;
tartime = (time_t)getoct(buffer.header.mtime,12); tartime = (time_t)getoct(buffer.header.mtime,12);
strcpy(fname,buffer.header.name); strcpy(fname,buffer.header.name);
@ -360,6 +375,34 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
getheader = 1; getheader = 1;
if ((action == TGZ_EXTRACT) && (outfile != NULL)) if ((action == TGZ_EXTRACT) && (outfile != NULL))
{ {
#ifdef WIN32
HANDLE hFile;
FILETIME ftm,ftLocal;
SYSTEMTIME st;
struct tm localt;
fclose(outfile);
localt = *localtime(&tartime);
hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING, 0, NULL);
st.wYear = (WORD)localt.tm_year+1900;
st.wMonth = (WORD)localt.tm_mon;
st.wDayOfWeek = (WORD)localt.tm_wday;
st.wDay = (WORD)localt.tm_mday;
st.wHour = (WORD)localt.tm_hour;
st.wMinute = (WORD)localt.tm_min;
st.wSecond = (WORD)localt.tm_sec;
st.wMilliseconds = 0;
SystemTimeToFileTime(&st,&ftLocal);
LocalFileTimeToFileTime(&ftLocal,&ftm);
SetFileTime(hFile,&ftm,NULL,&ftm);
CloseHandle(hFile);
outfile = NULL;
#else
struct utimbuf settime; struct utimbuf settime;
settime.actime = settime.modtime = tartime; settime.actime = settime.modtime = tartime;
@ -367,6 +410,7 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
fclose(outfile); fclose(outfile);
outfile = NULL; outfile = NULL;
utime(fname,&settime); utime(fname,&settime);
#endif
} }
} }
} }

@ -1,5 +1,17 @@
See below some functions declarations for Visual Basic.
Frequently Asked Question:
Q: Each time I use the compress function I get the -5 error (not enough
room in the output buffer).
A: Make sure that the length of the compressed buffer is passed by
reference ("as any"), not by value ("as long"). Also check that
before the call of compress this length is equal to the total size of
the compressed buffer and not zero.
From: "Jon Caruana" <jon-net@usa.net> From: "Jon Caruana" <jon-net@usa.net>
To: "Jean-loup Gailly" <gzip@prep.ai.mit.edu>
Subject: Re: How to port zlib declares to vb? Subject: Re: How to port zlib declares to vb?
Date: Mon, 28 Oct 1996 18:33:03 -0600 Date: Mon, 28 Oct 1996 18:33:03 -0600

@ -52,7 +52,7 @@
#include "deflate.h" #include "deflate.h"
const char deflate_copyright[] = const char deflate_copyright[] =
" deflate 1.1.2 Copyright 1995-1998 Jean-loup Gailly "; " deflate 1.1.3 Copyright 1995-1998 Jean-loup Gailly ";
/* /*
If you use the zlib library in a product, an acknowledgment is welcome 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 in the documentation of your product. If for some reason you cannot
@ -608,11 +608,13 @@ int ZEXPORT deflateCopy (dest, source)
deflate_state *ss; deflate_state *ss;
ushf *overlay; ushf *overlay;
ss = source->state;
if (source == Z_NULL || dest == Z_NULL || ss == Z_NULL) { if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
} }
ss = source->state;
*dest = *source; *dest = *source;
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));

@ -230,12 +230,12 @@ typedef struct internal_state {
ulg opt_len; /* bit length of current block with optimal trees */ ulg opt_len; /* bit length of current block with optimal trees */
ulg static_len; /* bit length of current block with static trees */ ulg static_len; /* bit length of current block with static trees */
ulg compressed_len; /* total bit length of compressed file */
uInt matches; /* number of string matches in current block */ uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */ int last_eob_len; /* bit length of EOB code for last block */
#ifdef DEBUG #ifdef DEBUG
ulg bits_sent; /* bit length of the compressed data */ ulg compressed_len; /* total bit length of compressed file mod 2^32 */
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif #endif
ush bi_buf; ush bi_buf;
@ -268,7 +268,7 @@ typedef struct internal_state {
/* in trees.c */ /* in trees.c */
void _tr_init OF((deflate_state *s)); void _tr_init OF((deflate_state *s));
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
ulg _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof)); int eof));
void _tr_align OF((deflate_state *s)); void _tr_align OF((deflate_state *s));
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,

@ -15,6 +15,12 @@
extern void exit OF((int)); extern void exit OF((int));
#endif #endif
#if defined(VMS) || defined(RISCOS)
# define TESTFILE "foo-gz"
#else
# define TESTFILE "foo.gz"
#endif
#define CHECK_ERR(err, msg) { \ #define CHECK_ERR(err, msg) { \
if (err != Z_OK) { \ if (err != Z_OK) { \
fprintf(stderr, "%s error: %d\n", msg, err); \ fprintf(stderr, "%s error: %d\n", msg, err); \
@ -79,8 +85,8 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
* Test read/write of .gz files * Test read/write of .gz files
*/ */
void test_gzio(out, in, uncompr, uncomprLen) void test_gzio(out, in, uncompr, uncomprLen)
const char *out; /* output file */ const char *out; /* compressed output file */
const char *in; /* input file */ const char *in; /* compressed input file */
Byte *uncompr; Byte *uncompr;
int uncomprLen; int uncomprLen;
{ {
@ -528,8 +534,8 @@ int main(argc, argv)
} }
test_compress(compr, comprLen, uncompr, uncomprLen); test_compress(compr, comprLen, uncompr, uncomprLen);
test_gzio((argc > 1 ? argv[1] : "foo.gz"), test_gzio((argc > 1 ? argv[1] : TESTFILE),
(argc > 2 ? argv[2] : "foo.gz"), (argc > 2 ? argv[2] : TESTFILE),
uncompr, (int)uncomprLen); uncompr, (int)uncomprLen);
test_deflate(compr, comprLen); test_deflate(compr, comprLen);

@ -414,10 +414,14 @@ int ZEXPORT gzread (file, buf, len)
s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
start = s->stream.next_out; start = s->stream.next_out;
if (getLong(s) != s->crc || getLong(s) != s->stream.total_out) { if (getLong(s) != s->crc) {
s->z_err = Z_DATA_ERROR; s->z_err = Z_DATA_ERROR;
} else { } else {
/* Check for concatenated .gz files: */ (void)getLong(s);
/* The uncompressed length returned by above getlong() may
* be different from s->stream.total_out) in case of
* concatenated .gz files. Check for such files:
*/
check_header(s); check_header(s);
if (s->z_err == Z_OK) { if (s->z_err == Z_OK) {
uLong total_in = s->stream.total_in; uLong total_in = s->stream.total_in;
@ -670,7 +674,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
return -1L; return -1L;
#else #else
if (whence == SEEK_SET) { if (whence == SEEK_SET) {
offset -= s->stream.total_out; offset -= s->stream.total_in;
} }
if (offset < 0) return -1L; if (offset < 0) return -1L;
@ -745,6 +749,7 @@ int ZEXPORT gzrewind (file)
s->z_eof = 0; s->z_eof = 0;
s->stream.avail_in = 0; s->stream.avail_in = 0;
s->stream.next_in = s->inbuf; s->stream.next_in = s->inbuf;
s->crc = crc32(0L, Z_NULL, 0);
if (s->startpos == 0) { /* not a compressed file */ if (s->startpos == 0) { /* not a compressed file */
rewind(s->file); rewind(s->file);
@ -793,7 +798,8 @@ local void putLong (file, x)
} }
/* =========================================================================== /* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets Reads a long in LSB order from the given gz_stream. Sets z_err in case
of error.
*/ */
local uLong getLong (s) local uLong getLong (s)
gz_stream *s; gz_stream *s;

@ -345,13 +345,6 @@ int r;
s->mode = TYPE; s->mode = TYPE;
break; break;
} }
if (k > 7) /* return unused byte, if any */
{
Assert(k < 16, "inflate_codes grabbed too many bytes")
k -= 8;
n++;
p--; /* can always return one */
}
s->mode = DRY; s->mode = DRY;
case DRY: case DRY:
FLUSH FLUSH

@ -221,6 +221,13 @@ int r;
c->mode = START; c->mode = START;
break; break;
case WASH: /* o: got eob, possibly more output */ case WASH: /* o: got eob, possibly more output */
if (k > 7) /* return unused byte, if any */
{
Assert(k < 16, "inflate_codes grabbed too many bytes")
k -= 8;
n++;
p--; /* can always return one */
}
FLUSH FLUSH
if (s->read != s->write) if (s->read != s->write)
LEAVE LEAVE

@ -10,116 +10,142 @@
local uInt fixed_bl = 9; local uInt fixed_bl = 9;
local uInt fixed_bd = 5; local uInt fixed_bd = 5;
local inflate_huft fixed_tl[] = { local inflate_huft fixed_tl[] = {
{{96,7},256}, {{0,8},80}, {{0,8},16}, {{84,8},115}, {{82,7},31}, {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
{{0,8},112}, {{0,8},48}, {{0,9},192}, {{80,7},10}, {{0,8},96}, {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},
{{0,8},32}, {{0,9},160}, {{0,8},0}, {{0,8},128}, {{0,8},64}, {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},
{{0,9},224}, {{80,7},6}, {{0,8},88}, {{0,8},24}, {{0,9},144}, {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},
{{83,7},59}, {{0,8},120}, {{0,8},56}, {{0,9},208}, {{81,7},17}, {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},
{{0,8},104}, {{0,8},40}, {{0,9},176}, {{0,8},8}, {{0,8},136}, {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},
{{0,8},72}, {{0,9},240}, {{80,7},4}, {{0,8},84}, {{0,8},20}, {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},
{{85,8},227}, {{83,7},43}, {{0,8},116}, {{0,8},52}, {{0,9},200}, {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},
{{81,7},13}, {{0,8},100}, {{0,8},36}, {{0,9},168}, {{0,8},4}, {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
{{0,8},132}, {{0,8},68}, {{0,9},232}, {{80,7},8}, {{0,8},92}, {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},
{{0,8},28}, {{0,9},152}, {{84,7},83}, {{0,8},124}, {{0,8},60}, {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},
{{0,9},216}, {{82,7},23}, {{0,8},108}, {{0,8},44}, {{0,9},184}, {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},
{{0,8},12}, {{0,8},140}, {{0,8},76}, {{0,9},248}, {{80,7},3}, {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},
{{0,8},82}, {{0,8},18}, {{85,8},163}, {{83,7},35}, {{0,8},114}, {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},
{{0,8},50}, {{0,9},196}, {{81,7},11}, {{0,8},98}, {{0,8},34}, {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},
{{0,9},164}, {{0,8},2}, {{0,8},130}, {{0,8},66}, {{0,9},228}, {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},
{{80,7},7}, {{0,8},90}, {{0,8},26}, {{0,9},148}, {{84,7},67}, {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
{{0,8},122}, {{0,8},58}, {{0,9},212}, {{82,7},19}, {{0,8},106}, {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},
{{0,8},42}, {{0,9},180}, {{0,8},10}, {{0,8},138}, {{0,8},74}, {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},
{{0,9},244}, {{80,7},5}, {{0,8},86}, {{0,8},22}, {{192,8},0}, {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},
{{83,7},51}, {{0,8},118}, {{0,8},54}, {{0,9},204}, {{81,7},15}, {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},
{{0,8},102}, {{0,8},38}, {{0,9},172}, {{0,8},6}, {{0,8},134}, {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},
{{0,8},70}, {{0,9},236}, {{80,7},9}, {{0,8},94}, {{0,8},30}, {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},
{{0,9},156}, {{84,7},99}, {{0,8},126}, {{0,8},62}, {{0,9},220}, {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},
{{82,7},27}, {{0,8},110}, {{0,8},46}, {{0,9},188}, {{0,8},14}, {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
{{0,8},142}, {{0,8},78}, {{0,9},252}, {{96,7},256}, {{0,8},81}, {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},
{{0,8},17}, {{85,8},131}, {{82,7},31}, {{0,8},113}, {{0,8},49}, {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},
{{0,9},194}, {{80,7},10}, {{0,8},97}, {{0,8},33}, {{0,9},162}, {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},
{{0,8},1}, {{0,8},129}, {{0,8},65}, {{0,9},226}, {{80,7},6}, {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},
{{0,8},89}, {{0,8},25}, {{0,9},146}, {{83,7},59}, {{0,8},121}, {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},
{{0,8},57}, {{0,9},210}, {{81,7},17}, {{0,8},105}, {{0,8},41}, {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},
{{0,9},178}, {{0,8},9}, {{0,8},137}, {{0,8},73}, {{0,9},242}, {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},
{{80,7},4}, {{0,8},85}, {{0,8},21}, {{80,8},258}, {{83,7},43}, {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
{{0,8},117}, {{0,8},53}, {{0,9},202}, {{81,7},13}, {{0,8},101}, {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},
{{0,8},37}, {{0,9},170}, {{0,8},5}, {{0,8},133}, {{0,8},69}, {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},
{{0,9},234}, {{80,7},8}, {{0,8},93}, {{0,8},29}, {{0,9},154}, {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},
{{84,7},83}, {{0,8},125}, {{0,8},61}, {{0,9},218}, {{82,7},23}, {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},
{{0,8},109}, {{0,8},45}, {{0,9},186}, {{0,8},13}, {{0,8},141}, {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},
{{0,8},77}, {{0,9},250}, {{80,7},3}, {{0,8},83}, {{0,8},19}, {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},
{{85,8},195}, {{83,7},35}, {{0,8},115}, {{0,8},51}, {{0,9},198}, {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},
{{81,7},11}, {{0,8},99}, {{0,8},35}, {{0,9},166}, {{0,8},3}, {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
{{0,8},131}, {{0,8},67}, {{0,9},230}, {{80,7},7}, {{0,8},91}, {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},
{{0,8},27}, {{0,9},150}, {{84,7},67}, {{0,8},123}, {{0,8},59}, {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},
{{0,9},214}, {{82,7},19}, {{0,8},107}, {{0,8},43}, {{0,9},182}, {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},
{{0,8},11}, {{0,8},139}, {{0,8},75}, {{0,9},246}, {{80,7},5}, {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},
{{0,8},87}, {{0,8},23}, {{192,8},0}, {{83,7},51}, {{0,8},119}, {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},
{{0,8},55}, {{0,9},206}, {{81,7},15}, {{0,8},103}, {{0,8},39}, {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},
{{0,9},174}, {{0,8},7}, {{0,8},135}, {{0,8},71}, {{0,9},238}, {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},
{{80,7},9}, {{0,8},95}, {{0,8},31}, {{0,9},158}, {{84,7},99}, {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
{{0,8},127}, {{0,8},63}, {{0,9},222}, {{82,7},27}, {{0,8},111}, {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},
{{0,8},47}, {{0,9},190}, {{0,8},15}, {{0,8},143}, {{0,8},79}, {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},
{{0,9},254}, {{96,7},256}, {{0,8},80}, {{0,8},16}, {{84,8},115}, {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},
{{82,7},31}, {{0,8},112}, {{0,8},48}, {{0,9},193}, {{80,7},10}, {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},
{{0,8},96}, {{0,8},32}, {{0,9},161}, {{0,8},0}, {{0,8},128}, {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},
{{0,8},64}, {{0,9},225}, {{80,7},6}, {{0,8},88}, {{0,8},24}, {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},
{{0,9},145}, {{83,7},59}, {{0,8},120}, {{0,8},56}, {{0,9},209}, {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},
{{81,7},17}, {{0,8},104}, {{0,8},40}, {{0,9},177}, {{0,8},8}, {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
{{0,8},136}, {{0,8},72}, {{0,9},241}, {{80,7},4}, {{0,8},84}, {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},
{{0,8},20}, {{85,8},227}, {{83,7},43}, {{0,8},116}, {{0,8},52}, {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},
{{0,9},201}, {{81,7},13}, {{0,8},100}, {{0,8},36}, {{0,9},169}, {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},
{{0,8},4}, {{0,8},132}, {{0,8},68}, {{0,9},233}, {{80,7},8}, {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},
{{0,8},92}, {{0,8},28}, {{0,9},153}, {{84,7},83}, {{0,8},124}, {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},
{{0,8},60}, {{0,9},217}, {{82,7},23}, {{0,8},108}, {{0,8},44}, {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},
{{0,9},185}, {{0,8},12}, {{0,8},140}, {{0,8},76}, {{0,9},249}, {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},
{{80,7},3}, {{0,8},82}, {{0,8},18}, {{85,8},163}, {{83,7},35}, {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
{{0,8},114}, {{0,8},50}, {{0,9},197}, {{81,7},11}, {{0,8},98}, {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},
{{0,8},34}, {{0,9},165}, {{0,8},2}, {{0,8},130}, {{0,8},66}, {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},
{{0,9},229}, {{80,7},7}, {{0,8},90}, {{0,8},26}, {{0,9},149}, {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},
{{84,7},67}, {{0,8},122}, {{0,8},58}, {{0,9},213}, {{82,7},19}, {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},
{{0,8},106}, {{0,8},42}, {{0,9},181}, {{0,8},10}, {{0,8},138}, {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},
{{0,8},74}, {{0,9},245}, {{80,7},5}, {{0,8},86}, {{0,8},22}, {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},
{{192,8},0}, {{83,7},51}, {{0,8},118}, {{0,8},54}, {{0,9},205}, {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},
{{81,7},15}, {{0,8},102}, {{0,8},38}, {{0,9},173}, {{0,8},6}, {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
{{0,8},134}, {{0,8},70}, {{0,9},237}, {{80,7},9}, {{0,8},94}, {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},
{{0,8},30}, {{0,9},157}, {{84,7},99}, {{0,8},126}, {{0,8},62}, {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},
{{0,9},221}, {{82,7},27}, {{0,8},110}, {{0,8},46}, {{0,9},189}, {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},
{{0,8},14}, {{0,8},142}, {{0,8},78}, {{0,9},253}, {{96,7},256}, {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},
{{0,8},81}, {{0,8},17}, {{85,8},131}, {{82,7},31}, {{0,8},113}, {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},
{{0,8},49}, {{0,9},195}, {{80,7},10}, {{0,8},97}, {{0,8},33}, {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},
{{0,9},163}, {{0,8},1}, {{0,8},129}, {{0,8},65}, {{0,9},227}, {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},
{{80,7},6}, {{0,8},89}, {{0,8},25}, {{0,9},147}, {{83,7},59}, {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
{{0,8},121}, {{0,8},57}, {{0,9},211}, {{81,7},17}, {{0,8},105}, {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},
{{0,8},41}, {{0,9},179}, {{0,8},9}, {{0,8},137}, {{0,8},73}, {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},
{{0,9},243}, {{80,7},4}, {{0,8},85}, {{0,8},21}, {{80,8},258}, {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},
{{83,7},43}, {{0,8},117}, {{0,8},53}, {{0,9},203}, {{81,7},13}, {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},
{{0,8},101}, {{0,8},37}, {{0,9},171}, {{0,8},5}, {{0,8},133}, {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},
{{0,8},69}, {{0,9},235}, {{80,7},8}, {{0,8},93}, {{0,8},29}, {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},
{{0,9},155}, {{84,7},83}, {{0,8},125}, {{0,8},61}, {{0,9},219}, {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},
{{82,7},23}, {{0,8},109}, {{0,8},45}, {{0,9},187}, {{0,8},13}, {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
{{0,8},141}, {{0,8},77}, {{0,9},251}, {{80,7},3}, {{0,8},83}, {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},
{{0,8},19}, {{85,8},195}, {{83,7},35}, {{0,8},115}, {{0,8},51}, {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},
{{0,9},199}, {{81,7},11}, {{0,8},99}, {{0,8},35}, {{0,9},167}, {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},
{{0,8},3}, {{0,8},131}, {{0,8},67}, {{0,9},231}, {{80,7},7}, {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},
{{0,8},91}, {{0,8},27}, {{0,9},151}, {{84,7},67}, {{0,8},123}, {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},
{{0,8},59}, {{0,9},215}, {{82,7},19}, {{0,8},107}, {{0,8},43}, {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},
{{0,9},183}, {{0,8},11}, {{0,8},139}, {{0,8},75}, {{0,9},247}, {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},
{{80,7},5}, {{0,8},87}, {{0,8},23}, {{192,8},0}, {{83,7},51}, {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
{{0,8},119}, {{0,8},55}, {{0,9},207}, {{81,7},15}, {{0,8},103}, {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},
{{0,8},39}, {{0,9},175}, {{0,8},7}, {{0,8},135}, {{0,8},71}, {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},
{{0,9},239}, {{80,7},9}, {{0,8},95}, {{0,8},31}, {{0,9},159}, {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},
{{84,7},99}, {{0,8},127}, {{0,8},63}, {{0,9},223}, {{82,7},27}, {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},
{{0,8},111}, {{0,8},47}, {{0,9},191}, {{0,8},15}, {{0,8},143}, {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},
{{0,8},79}, {{0,9},255} {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
}; };
local inflate_huft fixed_td[] = { local inflate_huft fixed_td[] = {
{{80,5},1}, {{87,5},257}, {{83,5},17}, {{91,5},4097}, {{81,5},5}, {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
{{89,5},1025}, {{85,5},65}, {{93,5},16385}, {{80,5},3}, {{88,5},513}, {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
{{84,5},33}, {{92,5},8193}, {{82,5},9}, {{90,5},2049}, {{86,5},129}, {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
{{192,5},24577}, {{80,5},2}, {{87,5},385}, {{83,5},25}, {{91,5},6145}, {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
{{81,5},7}, {{89,5},1537}, {{85,5},97}, {{93,5},24577}, {{80,5},4}, {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
{{88,5},769}, {{84,5},49}, {{92,5},12289}, {{82,5},13}, {{90,5},3073}, {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
{{86,5},193}, {{192,5},24577} {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
{{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
}; };

@ -11,7 +11,7 @@
#endif #endif
const char inflate_copyright[] = const char inflate_copyright[] =
" inflate 1.1.2 Copyright 1995-1998 Mark Adler "; " inflate 1.1.3 Copyright 1995-1998 Mark Adler ";
/* /*
If you use the zlib library in a product, an acknowledgment is welcome 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 in the documentation of your product. If for some reason you cannot

@ -24,36 +24,6 @@
#define exop word.what.Exop #define exop word.what.Exop
#define bits word.what.Bits #define bits word.what.Bits
/* showtree is only used for debugging purposes */
void showtree(uInt b, inflate_huft *t, int d)
{
int i, e;
char p[2*d+1];
for (i = 0; i < 2*d; i++)
p[i] = ' ';
p[i] = 0;
printf("%s[%d]\n", p, 1<<b);
for (i = 0; i < (1<<b); i++)
{
e = t[i].exop;
if (e == 0) /* simple code */
printf("%s%d(%d): literal=%d\n", p, i, t[i].bits, t[i].base);
else if (e & 16) /* length */
printf("%s%d(%d): length/distance=%d+(%d)\n",
p, i, t[i].bits, t[i].base, e & 15);
else if ((e & 64) == 0) /* next table */
{
printf("%s%d(%d): *sub table*\n", p, i, t[i].bits);
showtree(e, t + t[i].base, d + 1);
}
else if (e & 32) /* end of block */
printf("%s%d(%d): end of block\n", p, i, t[i].bits);
else /* bad code */
printf("%s%d: bad code\n", p, i);
}
}
/* generate initialization table for an inflate_huft structure array */ /* generate initialization table for an inflate_huft structure array */
void maketree(uInt b, inflate_huft *t) void maketree(uInt b, inflate_huft *t)
{ {
@ -68,9 +38,9 @@ void maketree(uInt b, inflate_huft *t)
fprintf(stderr, "maketree: cannot initialize sub-tables!\n"); fprintf(stderr, "maketree: cannot initialize sub-tables!\n");
exit(1); exit(1);
} }
if (i % 5 == 0) if (i % 4 == 0)
printf("\n "); printf("\n ");
printf(" {{%u,%u},%u}", t[i].exop, t[i].bits, t[i].base); printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base);
if (++i == (1<<b)) if (++i == (1<<b))
break; break;
putchar(','); putchar(',');
@ -95,10 +65,6 @@ void main(void)
fprintf(stderr, "inflate_trees_fixed error %d\n", r); fprintf(stderr, "inflate_trees_fixed error %d\n", r);
return; return;
} }
/* puts("Literal/Length Tree:");
showtree(bl, tl, 1);
puts("Distance Tree:");
showtree(bd, td, 1); */
puts("/* inffixed.h -- table for decoding fixed codes"); puts("/* inffixed.h -- table for decoding fixed codes");
puts(" * Generated automatically by the maketree.c program"); puts(" * Generated automatically by the maketree.c program");
puts(" */"); puts(" */");

@ -48,6 +48,9 @@
# define GZ_SUFFIX "-gz" # define GZ_SUFFIX "-gz"
# define fileno(file) file->__file # define fileno(file) file->__file
#endif #endif
#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fileno */
#endif
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */ #ifndef WIN32 /* unlink already in stdio.h for WIN32 */
extern int unlink OF((const char *)); extern int unlink OF((const char *));

@ -33,13 +33,13 @@ OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\
all: test all: test
adler32.obj: adler32.c zutil.h zlib.h zconf.h adler32.obj: adler32.c zlib.h zconf.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
compress.obj: compress.c zlib.h zconf.h compress.obj: compress.c zlib.h zconf.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
crc32.obj: crc32.c zutil.h zlib.h zconf.h crc32.obj: crc32.c zlib.h zconf.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h

@ -2,24 +2,40 @@
# Borland C++ ************ UNTESTED *********** # Borland C++ ************ UNTESTED ***********
# To use, do "make -fmakefile.bor" # To use, do "make -fmakefile.bor"
# To compile in small model, set below: MODEL=-ms # To compile in small model, set below: MODEL=s
# WARNING: the small model is supported but only for small values of # WARNING: the small model is supported but only for small values of
# MAX_WBITS and MAX_MEM_LEVEL. For example: # MAX_WBITS and MAX_MEM_LEVEL. For example:
# -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3 # -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3
# If you wish to reduce the memory requirements (default 256K for big # If you wish to reduce the memory requirements (default 256K for big
# objects plus a few K), you can add to CFLAGS below: # objects plus a few K), you can add to the LOC macro below:
# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
# See zconf.h for details about the memory requirements. # See zconf.h for details about the memory requirements.
# ------------- Turbo C++, Borland C++ ------------- # ------------- Turbo C++, Borland C++ -------------
MODEL=-ml
CFLAGS=-O2 -Z $(MODEL) # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7)
# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added
# to the declaration of LOC here:
LOC = $(LOCAL_ZLIB)
# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
CPU_TYP = 0
# Memory model: one of s, m, c, l (small, medium, compact, large)
MODEL=l
CC=bcc CC=bcc
LD=bcc
LIB=tlib
# replace bcc with tcc for Turbo C++ 1.0, with bcc32 for the 32 bit version # replace bcc with tcc for Turbo C++ 1.0, with bcc32 for the 32 bit version
LDFLAGS=$(MODEL) LD=$(CC)
AR=tlib
# compiler flags
CFLAGS=-O2 -Z -m$(MODEL) $(LOC)
# replace "-O2" by "-O -G -a -d" for Turbo C++ 1.0
LDFLAGS=-m$(MODEL)
O=.obj O=.obj
# variables # variables
@ -32,69 +48,73 @@ OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \
OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\
infutil$(O)+inffast$(O) infutil$(O)+inffast$(O)
ZLIB_H = zlib.h zconf.h
ZUTIL_H = zutil.h $(ZLIB_H)
ZLIB_LIB = zlib_$(MODEL).lib
all: test all: test
adler32.obj: adler32.c zutil.h zlib.h zconf.h # individual dependencies and action rules:
adler32.obj: adler32.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
compress.obj: compress.c zlib.h zconf.h compress.obj: compress.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
crc32.obj: crc32.c zutil.h zlib.h zconf.h crc32.obj: crc32.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h deflate.obj: deflate.c deflate.h $(ZUTIL_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
gzio.obj: gzio.c zutil.h zlib.h zconf.h gzio.obj: gzio.c $(ZUTIL_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h\ infblock.obj: infblock.c $(ZUTIL_H) infblock.h inftrees.h infcodes.h infutil.h
infcodes.h infutil.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h\ infcodes.obj: infcodes.c $(ZUTIL_H) inftrees.h infutil.h infcodes.h inffast.h
infcodes.h inffast.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h inflate.obj: inflate.c $(ZUTIL_H) infblock.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h inftrees.obj: inftrees.c $(ZUTIL_H) inftrees.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h infutil.obj: infutil.c $(ZUTIL_H) inftrees.h infutil.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h inffast.obj: inffast.c $(ZUTIL_H) inftrees.h infutil.h inffast.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h trees.obj: trees.c deflate.h $(ZUTIL_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
uncompr.obj: uncompr.c zlib.h zconf.h uncompr.obj: uncompr.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
zutil.obj: zutil.c zutil.h zlib.h zconf.h zutil.obj: zutil.c $(ZUTIL_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
example.obj: example.c zlib.h zconf.h example.obj: example.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
minigzip.obj: minigzip.c zlib.h zconf.h minigzip.obj: minigzip.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
# we must cut the command line to fit in the MS/DOS 128 byte limit: # we must cut the command line to fit in the MS/DOS 128 byte limit:
zlib.lib: $(OBJ1) $(OBJ2) $(ZLIB_LIB): $(OBJ1) $(OBJ2)
del zlib.lib del $(ZLIB_LIB)
$(LIB) zlib +$(OBJP1) $(AR) $(ZLIB_LIB) +$(OBJP1)
$(LIB) zlib +$(OBJP2) $(AR) $(ZLIB_LIB) +$(OBJP2)
example.exe: example.obj zlib.lib example.exe: example.obj $(ZLIB_LIB)
$(LD) $(LDFLAGS) example.obj zlib.lib $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB)
minigzip.exe: minigzip.obj zlib.lib minigzip.exe: minigzip.obj $(ZLIB_LIB)
$(LD) $(LDFLAGS) minigzip.obj zlib.lib $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB)
test: example.exe minigzip.exe test: example.exe minigzip.exe
example example

@ -0,0 +1,69 @@
# Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98.
# Copyright (C) 1995-1998 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile, or to compile and test, type:
#
# make -fmakefile.emx; make test -fmakefile.emx
#
CC=gcc
#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-MMD -g -DDEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes
# If cp.exe is available, replace "copy /Y" with "cp -fp" .
CP=copy /Y
# If gnu install.exe is available, replace $(CP) with ginstall.
INSTALL=$(CP)
# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
RM=del
LDLIBS=-L. -lzlib
LD=$(CC) -s -o
LDSHARED=$(CC)
INCL=zlib.h zconf.h
LIBS=zlib.a
AR=ar rcs
prefix=/usr/local
exec_prefix = $(prefix)
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
TEST_OBJS = example.o minigzip.o
all: example.exe minigzip.exe
test: all
./example
echo hello world | .\minigzip | .\minigzip -d
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
zlib.a: $(OBJS)
$(AR) $@ $(OBJS)
%.exe : %.o $(LIBS)
$(LD) $@ $< $(LDLIBS)
.PHONY : clean
clean:
$(RM) *.d
$(RM) *.o
$(RM) *.exe
$(RM) zlib.a
$(RM) foo.gz
DEPS := $(wildcard *.d)
ifneq ($(DEPS),)
include $(DEPS)
endif

@ -2,20 +2,36 @@
# Microsoft C 5.1 or later # Microsoft C 5.1 or later
# To use, do "make makefile.msc" # To use, do "make makefile.msc"
# To compile in small model, set below: MODEL=-AS # To compile in small model, set below: MODEL=S
# If you wish to reduce the memory requirements (default 256K for big # If you wish to reduce the memory requirements (default 256K for big
# objects plus a few K), you can add to CFLAGS below: # objects plus a few K), you can add to the LOC macro below:
# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
# See zconf.h for details about the memory requirements. # See zconf.h for details about the memory requirements.
# ------------- Microsoft C 5.1 and later ------------- # ------------- Microsoft C 5.1 and later -------------
MODEL=-AL
CFLAGS=-Oait -Gs -nologo -W3 $(MODEL) # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7)
#-Ox generates bad code with MSC 5.1 # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added
# to the declaration of LOC here:
LOC = $(LOCAL_ZLIB)
# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
CPU_TYP = 0
# Memory model: one of S, M, C, L (small, medium, compact, large)
MODEL=L
CC=cl CC=cl
CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC)
#-Ox generates bad code with MSC 5.1
LIB_CFLAGS=-Zl $(CFLAGS)
LD=link LD=link
LDFLAGS=/e/st:0x1500/noe LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode
# "/farcall/packcode" are only useful for `large code' memory models
# but should be a "no-op" for small code models.
O=.obj O=.obj
# variables # variables
@ -28,69 +44,73 @@ OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \
OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\
infutil$(O)+inffast$(O) infutil$(O)+inffast$(O)
all: zlib.lib example.exe minigzip.exe ZLIB_H = zlib.h zconf.h
ZUTIL_H = zutil.h $(ZLIB_H)
adler32.obj: adler32.c zutil.h zlib.h zconf.h ZLIB_LIB = zlib_$(MODEL).lib
$(CC) -c $(CFLAGS) $*.c
compress.obj: compress.c zlib.h zconf.h all: $(ZLIB_LIB) example.exe minigzip.exe
$(CC) -c $(CFLAGS) $*.c
crc32.obj: crc32.c zutil.h zlib.h zconf.h # individual dependencies and action rules:
$(CC) -c $(CFLAGS) $*.c adler32.obj: adler32.c $(ZLIB_H)
$(CC) -c $(LIB_CFLAGS) $*.c
deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h compress.obj: compress.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(LIB_CFLAGS) $*.c
gzio.obj: gzio.c zutil.h zlib.h zconf.h crc32.obj: crc32.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(LIB_CFLAGS) $*.c
infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h\ deflate.obj: deflate.c deflate.h $(ZUTIL_H)
infcodes.h infutil.h $(CC) -c $(LIB_CFLAGS) $*.c
$(CC) -c $(CFLAGS) $*.c
infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h\ gzio.obj: gzio.c $(ZUTIL_H)
infcodes.h inffast.h $(CC) -c $(LIB_CFLAGS) $*.c
$(CC) -c $(CFLAGS) $*.c
inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h infblock.obj: infblock.c $(ZUTIL_H) infblock.h inftrees.h infcodes.h infutil.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(LIB_CFLAGS) $*.c
inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h infcodes.obj: infcodes.c $(ZUTIL_H) inftrees.h infutil.h infcodes.h inffast.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(LIB_CFLAGS) $*.c
infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h inflate.obj: inflate.c $(ZUTIL_H) infblock.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(LIB_CFLAGS) $*.c
inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h inftrees.obj: inftrees.c $(ZUTIL_H) inftrees.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(LIB_CFLAGS) $*.c
trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h infutil.obj: infutil.c $(ZUTIL_H) inftrees.h infutil.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(LIB_CFLAGS) $*.c
uncompr.obj: uncompr.c zlib.h zconf.h inffast.obj: inffast.c $(ZUTIL_H) inftrees.h infutil.h inffast.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(LIB_CFLAGS) $*.c
zutil.obj: zutil.c zutil.h zlib.h zconf.h trees.obj: trees.c deflate.h $(ZUTIL_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(LIB_CFLAGS) $*.c
uncompr.obj: uncompr.c $(ZLIB_H)
$(CC) -c $(LIB_CFLAGS) $*.c
zutil.obj: zutil.c $(ZUTIL_H)
$(CC) -c $(LIB_CFLAGS) $*.c
example.obj: example.c zlib.h zconf.h example.obj: example.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
minigzip.obj: minigzip.c zlib.h zconf.h minigzip.obj: minigzip.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
# we must cut the command line to fit in the MS/DOS 128 byte limit: # we must cut the command line to fit in the MS/DOS 128 byte limit:
zlib.lib: $(OBJ1) $(OBJ2) $(ZLIB_LIB): $(OBJ1) $(OBJ2)
if exist zlib.lib del zlib.lib if exist $(ZLIB_LIB) del $(ZLIB_LIB)
lib zlib $(OBJ1); lib $(ZLIB_LIB) $(OBJ1);
lib zlib $(OBJ2); lib $(ZLIB_LIB) $(OBJ2);
example.exe: example.obj zlib.lib example.exe: example.obj $(ZLIB_LIB)
$(LD) $(LDFLAGS) example.obj,,,zlib.lib; $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB);
minigzip.exe: minigzip.obj zlib.lib minigzip.exe: minigzip.obj $(ZLIB_LIB)
$(LD) $(LDFLAGS) minigzip.obj,,,zlib.lib; $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB);
test: example.exe minigzip.exe test: example.exe minigzip.exe
example example

@ -13,13 +13,13 @@
# See zconf.h for details about the memory requirements. # See zconf.h for details about the memory requirements.
# ------------- Turbo C 2.0 ------------- # ------------- Turbo C 2.0 -------------
MODEL=-ml MODEL=l
# CFLAGS=-O2 -G -Z $(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 # CFLAGS=-O2 -G -Z -m$(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
CFLAGS=-O2 -G -Z $(MODEL) CFLAGS=-O2 -G -Z -m$(MODEL)
CC=tcc -I\tc\include CC=tcc -I\tc\include
LD=tcc -L\tc\lib LD=tcc -L\tc\lib
LIB=tlib AR=tlib
LDFLAGS=$(MODEL) -f- LDFLAGS=-m$(MODEL) -f-
O=.obj O=.obj
# variables # variables
@ -32,69 +32,72 @@ OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \
OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\
infutil$(O)+inffast$(O) infutil$(O)+inffast$(O)
ZLIB_H = zlib.h zconf.h
ZUTIL_H = zutil.h $(ZLIB_H)
ZLIB_LIB = zlib_$(MODEL).lib
all: test all: test
adler32.obj: adler32.c zutil.h zlib.h zconf.h adler32.obj: adler32.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
compress.obj: compress.c zlib.h zconf.h compress.obj: compress.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
crc32.obj: crc32.c zutil.h zlib.h zconf.h crc32.obj: crc32.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h deflate.obj: deflate.c deflate.h $(ZUTIL_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
gzio.obj: gzio.c zutil.h zlib.h zconf.h gzio.obj: gzio.c $(ZUTIL_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h\ infblock.obj: infblock.c $(ZUTIL_H) infblock.h inftrees.h infcodes.h infutil.h
infcodes.h infutil.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h\ infcodes.obj: infcodes.c $(ZUTIL_H) inftrees.h infutil.h infcodes.h inffast.h
infcodes.h inffast.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h inflate.obj: inflate.c $(ZUTIL_H) infblock.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h inftrees.obj: inftrees.c $(ZUTIL_H) inftrees.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h infutil.obj: infutil.c $(ZUTIL_H) inftrees.h infutil.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h inffast.obj: inffast.c $(ZUTIL_H) inftrees.h infutil.h inffast.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h trees.obj: trees.c deflate.h $(ZUTIL_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
uncompr.obj: uncompr.c zlib.h zconf.h uncompr.obj: uncompr.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
zutil.obj: zutil.c zutil.h zlib.h zconf.h zutil.obj: zutil.c $(ZUTIL_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
example.obj: example.c zlib.h zconf.h example.obj: example.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
minigzip.obj: minigzip.c zlib.h zconf.h minigzip.obj: minigzip.c $(ZLIB_H)
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
# we must cut the command line to fit in the MS/DOS 128 byte limit: # we must cut the command line to fit in the MS/DOS 128 byte limit:
zlib.lib: $(OBJ1) $(OBJ2) $(ZLIB_LIB): $(OBJ1) $(OBJ2)
del zlib.lib del $(ZLIB_LIB)
$(LIB) zlib +$(OBJP1) $(AR) $(ZLIB_LIB) +$(OBJP1)
$(LIB) zlib +$(OBJP2) $(AR) $(ZLIB_LIB) +$(OBJP2)
example.exe: example.obj zlib.lib example.exe: example.obj $(ZLIB_LIB)
$(LD) $(LDFLAGS) -eexample.exe example.obj zlib.lib $(LD) $(LDFLAGS) -eexample.exe example.obj $(ZLIB_LIB)
minigzip.exe: minigzip.obj zlib.lib minigzip.exe: minigzip.obj $(ZLIB_LIB)
$(LD) $(LDFLAGS) -eminigzip.exe minigzip.obj zlib.lib $(LD) $(LDFLAGS) -eminigzip.exe minigzip.obj $(ZLIB_LIB)
test: example.exe minigzip.exe test: example.exe minigzip.exe
example example

@ -28,13 +28,13 @@ OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\
all: zlib.lib example.exe minigzip.exe all: zlib.lib example.exe minigzip.exe
adler32.obj: adler32.c zutil.h zlib.h zconf.h adler32.obj: adler32.c zlib.h zconf.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
compress.obj: compress.c zlib.h zconf.h compress.obj: compress.c zlib.h zconf.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
crc32.obj: crc32.c zutil.h zlib.h zconf.h crc32.obj: crc32.c zlib.h zconf.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h

@ -30,13 +30,13 @@ OBJP3=infutil$(O)+inffast$(O)
all: test all: test
adler32.obj: adler32.c zutil.h zlib.h zconf.h adler32.obj: adler32.c zlib.h zconf.h
$(CC) $(CFLAGS) $*.c $(CC) $(CFLAGS) $*.c
compress.obj: compress.c zlib.h zconf.h compress.obj: compress.c zlib.h zconf.h
$(CC) $(CFLAGS) $*.c $(CC) $(CFLAGS) $*.c
crc32.obj: crc32.c zutil.h zlib.h zconf.h crc32.obj: crc32.c zlib.h zconf.h
$(CC) $(CFLAGS) $*.c $(CC) $(CFLAGS) $*.c
deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h

@ -8,7 +8,7 @@ SUBSYSTEM WINDOWS
STUB 'WINSTUB.EXE' STUB 'WINSTUB.EXE'
VERSION 1.11 VERSION 1.13
CODE EXECUTE READ CODE EXECUTE READ

@ -2,8 +2,8 @@
#define IDR_VERSION1 1 #define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1,1,2,0 FILEVERSION 1,1,3,0
PRODUCTVERSION 1,1,2,0 PRODUCTVERSION 1,1,3,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0 FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32 FILEOS VOS_DOS_WINDOWS32
@ -17,7 +17,7 @@ BEGIN
BEGIN BEGIN
VALUE "FileDescription", "zlib data compression library\0" VALUE "FileDescription", "zlib data compression library\0"
VALUE "FileVersion", "1.1.2\0" VALUE "FileVersion", "1.1.3\0"
VALUE "InternalName", "zlib\0" VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlib.dll\0" VALUE "OriginalFilename", "zlib.dll\0"
VALUE "ProductName", "ZLib.DLL\0" VALUE "ProductName", "ZLib.DLL\0"

@ -0,0 +1,138 @@
# Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98.
# Copyright (C) 1995-1998 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile, or to compile and test, type:
#
# make -fmakefile.emx; make test -fmakefile.emx
#
CC=gcc -Zwin32
#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-MMD -g -DDEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes
# If cp.exe is available, replace "copy /Y" with "cp -fp" .
CP=copy /Y
# If gnu install.exe is available, replace $(CP) with ginstall.
INSTALL=$(CP)
# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
RM=del
LDLIBS=-L. -lzlib
LD=$(CC) -s -o
LDSHARED=$(CC)
INCL=zlib.h zconf.h
LIBS=zlib.a
AR=ar rcs
prefix=/usr/local
exec_prefix = $(prefix)
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
TEST_OBJS = example.o minigzip.o
all: example.exe minigzip.exe
test: all
./example
echo hello world | .\minigzip | .\minigzip -d
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
zlib.a: $(OBJS)
$(AR) $@ $(OBJS)
%.exe : %.o $(LIBS)
$(LD) $@ $< $(LDLIBS)
.PHONY : clean
clean:
$(RM) *.d
$(RM) *.o
$(RM) *.exe
$(RM) zlib.a
$(RM) foo.gz
DEPS := $(wildcard *.d)
ifneq ($(DEPS),)
include $(DEPS)
endif
# Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98.
# Copyright (C) 1995-1998 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile, or to compile and test, type:
#
# make -fmakefile.emx; make test -fmakefile.emx
#
CC=gcc
#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-MMD -g -DDEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes
# If cp.exe is available, replace "copy /Y" with "cp -fp" .
CP=copy /Y
# If gnu install.exe is available, replace $(CP) with ginstall.
INSTALL=$(CP)
# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
RM=del
LDLIBS=-L. -lzlib
LD=$(CC) -s -o
LDSHARED=$(CC)
INCL=zlib.h zconf.h
LIBS=zlib.a
AR=ar rcs
prefix=/usr/local
exec_prefix = $(prefix)
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
TEST_OBJS = example.o minigzip.o
all: example.exe minigzip.exe
test: all
./example
echo hello world | .\minigzip | .\minigzip -d
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
zlib.a: $(OBJS)
$(AR) $@ $(OBJS)
%.exe : %.o $(LIBS)
$(LD) $@ $< $(LDLIBS)
.PHONY : clean
clean:
$(RM) *.d
$(RM) *.o
$(RM) *.exe
$(RM) zlib.a
$(RM) foo.gz
DEPS := $(wildcard *.d)
ifneq ($(DEPS),)
include $(DEPS)
endif

@ -0,0 +1,87 @@
# Makefile for zlib. Modified for mingw32 by C. Spieler, 6/16/98.
# (This Makefile is directly derived from Makefile.dj2)
# Copyright (C) 1995-1998 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile, or to compile and test, type:
#
# make -fmakefile.gcc; make test -fmakefile.gcc
#
# To install libz.a, zconf.h and zlib.h in the mingw32 directories, type:
#
# make install -fmakefile.gcc
#
CC=gcc
#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-MMD -g -DDEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes
# If cp.exe is available, replace "copy /Y" with "cp -fp" .
CP=copy /Y
# If gnu install.exe is available, replace $(CP) with ginstall.
INSTALL=$(CP)
# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
RM=del
LDLIBS=-L. -lz
LD=$(CC) -s -o
LDSHARED=$(CC)
INCL=zlib.h zconf.h
LIBS=libz.a
AR=ar rcs
prefix=/usr/local
exec_prefix = $(prefix)
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
TEST_OBJS = example.o minigzip.o
all: example.exe minigzip.exe
test: all
./example
echo hello world | .\minigzip | .\minigzip -d
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
libz.a: $(OBJS)
$(AR) $@ $(OBJS)
%.exe : %.o $(LIBS)
$(LD) $@ $< $(LDLIBS)
# INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env .
.PHONY : uninstall clean
install: $(INCL) $(LIBS)
-@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH)
-@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH)
$(INSTALL) zlib.h $(INCLUDE_PATH)
$(INSTALL) zconf.h $(INCLUDE_PATH)
$(INSTALL) libz.a $(LIBRARY_PATH)
uninstall:
$(RM) $(INCLUDE_PATH)\zlib.h
$(RM) $(INCLUDE_PATH)\zconf.h
$(RM) $(LIBRARY_PATH)\libz.a
clean:
$(RM) *.d
$(RM) *.o
$(RM) *.exe
$(RM) libz.a
$(RM) foo.gz
DEPS := $(wildcard *.d)
ifneq ($(DEPS),)
include $(DEPS)
endif

@ -0,0 +1,136 @@
# Makefile for zlib under OS/2 using GCC (PGCC)
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile and test, type:
# cp Makefile.os2 ..
# cd ..
# make -f Makefile.os2 test
# This makefile will build a static library z.lib, a shared library
# z.dll and a import library zdll.lib. You can use either z.lib or
# zdll.lib by specifying either -lz or -lzdll on gcc's command line
CC=gcc -Zomf -s
CFLAGS=-O6 -Wall
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes
#################### BUG WARNING: #####################
## infcodes.c hits a bug in pgcc-1.0, so you have to use either
## -O# where # <= 4 or one of (-fno-ommit-frame-pointer or -fno-force-mem)
## This bug is reportedly fixed in pgcc >1.0, but this was not tested
CFLAGS+=-fno-force-mem
LDFLAGS=-s -L. -lzdll -Zcrtdll
LDSHARED=$(CC) -s -Zomf -Zdll -Zcrtdll
VER=1.1.0
ZLIB=z.lib
SHAREDLIB=z.dll
SHAREDLIBIMP=zdll.lib
LIBS=$(ZLIB) $(SHAREDLIB) $(SHAREDLIBIMP)
AR=emxomfar cr
IMPLIB=emximp
RANLIB=echo
TAR=tar
SHELL=bash
prefix=/usr/local
exec_prefix = $(prefix)
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
TEST_OBJS = example.o minigzip.o
DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \
algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \
nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \
contrib/asm386/*.asm contrib/asm386/*.c \
contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \
contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \
contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32
all: example.exe minigzip.exe
test: all
@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
echo hello world | ./minigzip | ./minigzip -d || \
echo ' *** minigzip test FAILED ***' ; \
if ./example; then \
echo ' *** zlib test OK ***'; \
else \
echo ' *** zlib test FAILED ***'; \
fi
$(ZLIB): $(OBJS)
$(AR) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
$(SHAREDLIB): $(OBJS) os2/z.def
$(LDSHARED) -o $@ $^
$(SHAREDLIBIMP): os2/z.def
$(IMPLIB) -o $@ $^
example.exe: example.o $(LIBS)
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
minigzip.exe: minigzip.o $(LIBS)
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
clean:
rm -f *.o *~ example minigzip libz.a libz.so* foo.gz
distclean: clean
zip:
mv Makefile Makefile~; cp -p Makefile.in Makefile
rm -f test.c ztest*.c
v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
zip -ul9 zlib$$v $(DISTFILES)
mv Makefile~ Makefile
dist:
mv Makefile Makefile~; cp -p Makefile.in Makefile
rm -f test.c ztest*.c
d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
rm -f $$d.tar.gz; \
if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \
files=""; \
for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \
cd ..; \
GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \
if test ! -d $$d; then rm -f $$d; fi
mv Makefile~ Makefile
tags:
etags *.[ch]
depend:
makedepend -- $(CFLAGS) -- *.[ch]
# DO NOT DELETE THIS LINE -- make depend depends on it.
adler32.o: zlib.h zconf.h
compress.o: zlib.h zconf.h
crc32.o: zlib.h zconf.h
deflate.o: deflate.h zutil.h zlib.h zconf.h
example.o: zlib.h zconf.h
gzio.o: zutil.h zlib.h zconf.h
infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h
infcodes.o: zutil.h zlib.h zconf.h
infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h
inffast.o: zutil.h zlib.h zconf.h inftrees.h
inffast.o: infblock.h infcodes.h infutil.h inffast.h
inflate.o: zutil.h zlib.h zconf.h infblock.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
minigzip.o: zlib.h zconf.h
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
uncompr.o: zlib.h zconf.h
zutil.o: zutil.h zlib.h zconf.h

@ -0,0 +1,51 @@
;
; Slightly modified version of ../nt/zlib.dnt :-)
;
LIBRARY Z
DESCRIPTION "Zlib compression library for OS/2"
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
EXPORTS
adler32
compress
crc32
deflate
deflateCopy
deflateEnd
deflateInit2_
deflateInit_
deflateParams
deflateReset
deflateSetDictionary
gzclose
gzdopen
gzerror
gzflush
gzopen
gzread
gzwrite
inflate
inflateEnd
inflateInit2_
inflateInit_
inflateReset
inflateSetDictionary
inflateSync
uncompress
zlibVersion
gzprintf
gzputc
gzgetc
gzseek
gzrewind
gztell
gzeof
gzsetparams
zError
inflateSyncPoint
get_crc_table
compress2
gzputs
gzgets

@ -250,6 +250,13 @@ local void tr_static_init()
if (static_init_done) return; if (static_init_done) return;
/* For some embedded targets, global variables are not initialized: */
static_l_desc.static_tree = static_ltree;
static_l_desc.extra_bits = extra_lbits;
static_d_desc.static_tree = static_dtree;
static_d_desc.extra_bits = extra_dbits;
static_bl_desc.extra_bits = extra_blbits;
/* Initialize the mapping length (0..255) -> length code (0..28) */ /* Initialize the mapping length (0..255) -> length code (0..28) */
length = 0; length = 0;
for (code = 0; code < LENGTH_CODES-1; code++) { for (code = 0; code < LENGTH_CODES-1; code++) {
@ -378,8 +385,6 @@ void _tr_init(s)
{ {
tr_static_init(); tr_static_init();
s->compressed_len = 0L;
s->l_desc.dyn_tree = s->dyn_ltree; s->l_desc.dyn_tree = s->dyn_ltree;
s->l_desc.stat_desc = &static_l_desc; s->l_desc.stat_desc = &static_l_desc;
@ -393,6 +398,7 @@ void _tr_init(s)
s->bi_valid = 0; s->bi_valid = 0;
s->last_eob_len = 8; /* enough lookahead for inflate */ s->last_eob_len = 8; /* enough lookahead for inflate */
#ifdef DEBUG #ifdef DEBUG
s->compressed_len = 0L;
s->bits_sent = 0L; s->bits_sent = 0L;
#endif #endif
@ -865,9 +871,10 @@ void _tr_stored_block(s, buf, stored_len, eof)
int eof; /* true if this is the last block for a file */ int eof; /* true if this is the last block for a file */
{ {
send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
#ifdef DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
s->compressed_len += (stored_len + 4) << 3; s->compressed_len += (stored_len + 4) << 3;
#endif
copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
} }
@ -887,7 +894,9 @@ void _tr_align(s)
{ {
send_bits(s, STATIC_TREES<<1, 3); send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree); send_code(s, END_BLOCK, static_ltree);
#ifdef DEBUG
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
#endif
bi_flush(s); bi_flush(s);
/* Of the 10 bits for the empty block, we have already sent /* Of the 10 bits for the empty block, we have already sent
* (10 - bi_valid) bits. The lookahead for the last real code (before * (10 - bi_valid) bits. The lookahead for the last real code (before
@ -897,7 +906,9 @@ void _tr_align(s)
if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
send_bits(s, STATIC_TREES<<1, 3); send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree); send_code(s, END_BLOCK, static_ltree);
#ifdef DEBUG
s->compressed_len += 10L; s->compressed_len += 10L;
#endif
bi_flush(s); bi_flush(s);
} }
s->last_eob_len = 7; s->last_eob_len = 7;
@ -905,10 +916,9 @@ void _tr_align(s)
/* =========================================================================== /* ===========================================================================
* Determine the best encoding for the current block: dynamic trees, static * Determine the best encoding for the current block: dynamic trees, static
* trees or store, and output the encoded block to the zip file. This function * trees or store, and output the encoded block to the zip file.
* returns the total compressed length for the file so far.
*/ */
ulg _tr_flush_block(s, buf, stored_len, eof) void _tr_flush_block(s, buf, stored_len, eof)
deflate_state *s; deflate_state *s;
charf *buf; /* input block, or NULL if too old */ charf *buf; /* input block, or NULL if too old */
ulg stored_len; /* length of input block */ ulg stored_len; /* length of input block */
@ -955,25 +965,6 @@ ulg _tr_flush_block(s, buf, stored_len, eof)
opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
} }
/* If compression failed and this is the first and last block,
* and if the .zip file can be seeked (to rewrite the local header),
* the whole file is transformed into a stored file:
*/
#ifdef STORED_FILE_OK
# ifdef FORCE_STORED_FILE
if (eof && s->compressed_len == 0L) { /* force stored file */
# else
if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) {
# endif
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (charf*)0) error ("block vanished");
copy_block(buf, (unsigned)stored_len, 0); /* without header */
s->compressed_len = stored_len << 3;
s->method = STORED;
} else
#endif /* STORED_FILE_OK */
#ifdef FORCE_STORED #ifdef FORCE_STORED
if (buf != (char*)0) { /* force stored block */ if (buf != (char*)0) { /* force stored block */
#else #else
@ -995,25 +986,32 @@ ulg _tr_flush_block(s, buf, stored_len, eof)
#endif #endif
send_bits(s, (STATIC_TREES<<1)+eof, 3); send_bits(s, (STATIC_TREES<<1)+eof, 3);
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
#ifdef DEBUG
s->compressed_len += 3 + s->static_len; s->compressed_len += 3 + s->static_len;
#endif
} else { } else {
send_bits(s, (DYN_TREES<<1)+eof, 3); send_bits(s, (DYN_TREES<<1)+eof, 3);
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
max_blindex+1); max_blindex+1);
compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
#ifdef DEBUG
s->compressed_len += 3 + s->opt_len; s->compressed_len += 3 + s->opt_len;
#endif
} }
Assert (s->compressed_len == s->bits_sent, "bad compressed size"); Assert (s->compressed_len == s->bits_sent, "bad compressed size");
/* The above check is made mod 2^32, for files larger than 512 MB
* and uLong implemented on 32 bits.
*/
init_block(s); init_block(s);
if (eof) { if (eof) {
bi_windup(s); bi_windup(s);
#ifdef DEBUG
s->compressed_len += 7; /* align on byte boundary */ s->compressed_len += 7; /* align on byte boundary */
#endif
} }
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
s->compressed_len-7*eof)); s->compressed_len-7*eof));
return s->compressed_len >> 3;
} }
/* =========================================================================== /* ===========================================================================

@ -91,8 +91,8 @@
# define NO_DUMMY_DECL # define NO_DUMMY_DECL
#endif #endif
/* Borland C incorrectly complains about missing returns: */ /* Old Borland C incorrectly complains about missing returns: */
#if defined(__BORLANDC__) #if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
# define NEED_DUMMY_RETURN # define NEED_DUMMY_RETURN
#endif #endif
@ -148,7 +148,7 @@
/* MSC small or medium model */ /* MSC small or medium model */
# define SMALL_MEDIUM # define SMALL_MEDIUM
# ifdef _MSC_VER # ifdef _MSC_VER
# define FAR __far # define FAR _far
# else # else
# define FAR far # define FAR far
# endif # endif
@ -156,12 +156,13 @@
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
# ifndef __32BIT__ # ifndef __32BIT__
# define SMALL_MEDIUM # define SMALL_MEDIUM
# define FAR __far # define FAR _far
# endif # endif
#endif #endif
/* Compile with -DZLIB_DLL for Windows DLL support */ /* Compile with -DZLIB_DLL for Windows DLL support */
#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL) #if defined(ZLIB_DLL)
# if defined(_WINDOWS) || defined(WINDOWS)
# ifdef FAR # ifdef FAR
# undef FAR # undef FAR
# endif # endif
@ -172,26 +173,51 @@
# else # else
# define ZEXPORTVA FAR _cdecl _export # define ZEXPORTVA FAR _cdecl _export
# endif # endif
#else # endif
# if defined (__BORLANDC__) && defined (_Windows) && defined (__DLL__) # if defined (__BORLANDC__)
# if (__BORLANDC__ >= 0x0500) && defined (WIN32)
# include <windows.h>
# define ZEXPORT __declspec(dllexport) WINAPI
# define ZEXPORTRVA __declspec(dllexport) WINAPIV
# else
# if defined (_Windows) && defined (__DLL__)
# define ZEXPORT _export # define ZEXPORT _export
# define ZEXPORTVA _export # define ZEXPORTVA _export
# endif
# endif
# endif
#endif
#if defined (__BEOS__)
# if defined (ZLIB_DLL)
# define ZEXTERN extern __declspec(dllexport)
# else # else
# define ZEXTERN extern __declspec(dllimport)
# endif
#endif
#ifndef ZEXPORT
# define ZEXPORT # define ZEXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA # define ZEXPORTVA
# endif #endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif #endif
#ifndef FAR #ifndef FAR
# define FAR # define FAR
#endif #endif
#if !defined(MACOS) && !defined(TARGET_OS_MAC)
typedef unsigned char Byte; /* 8 bits */ typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */ typedef unsigned long uLong; /* 32 bits or more */
#if defined(__BORLANDC__) && defined(SMALL_MEDIUM) #ifdef SMALL_MEDIUM
/* Borland C/C++ ignores FAR inside typedef */ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR # define Bytef Byte FAR
#else #else
typedef Byte FAR Bytef; typedef Byte FAR Bytef;
@ -217,6 +243,7 @@ typedef uLong FAR uLongf;
#ifndef SEEK_SET #ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif #endif
#ifndef z_off_t #ifndef z_off_t
# define z_off_t long # define z_off_t long

@ -1,4 +1,4 @@
.TH ZLIB 3 "19 March 1998" .TH ZLIB 3 "9 July 1998"
.SH NAME .SH NAME
zlib \- compression/decompression library zlib \- compression/decompression library
.SH SYNOPSIS .SH SYNOPSIS
@ -81,7 +81,7 @@ These documents are also available in other formats from:
.IP .IP
ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
.SH AUTHORS .SH AUTHORS
Version 1.1.2 Version 1.1.3
Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org) Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu). and Mark Adler (madler@alumni.caltech.edu).
.LP .LP

109
zlib.h

@ -1,5 +1,5 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library /* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.1.2, March 19th, 1998 version 1.1.3, July 9th, 1998
Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
@ -37,7 +37,7 @@
extern "C" { extern "C" {
#endif #endif
#define ZLIB_VERSION "1.1.2" #define ZLIB_VERSION "1.1.3"
/* /*
The 'zlib' compression library provides in-memory compression and The 'zlib' compression library provides in-memory compression and
@ -168,7 +168,7 @@ typedef z_stream FAR *z_streamp;
/* basic functions */ /* basic functions */
extern const char * ZEXPORT zlibVersion OF((void)); ZEXTERN const char * ZEXPORT zlibVersion OF((void));
/* The application can compare zlibVersion and ZLIB_VERSION for consistency. /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
If the first character differs, the library code actually used is If the first character differs, the library code actually used is
not compatible with the zlib.h header file used by the application. not compatible with the zlib.h header file used by the application.
@ -176,7 +176,7 @@ extern const char * ZEXPORT zlibVersion OF((void));
*/ */
/* /*
extern int ZEXPORT deflateInit OF((z_streamp strm, int level)); ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
Initializes the internal stream state for compression. The fields Initializes the internal stream state for compression. The fields
zalloc, zfree and opaque must be initialized before by the caller. zalloc, zfree and opaque must be initialized before by the caller.
@ -198,7 +198,7 @@ extern int ZEXPORT deflateInit OF((z_streamp strm, int level));
*/ */
extern int ZEXPORT deflate OF((z_streamp strm, int flush)); ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
/* /*
deflate compresses as much data as possible, and stops when the input deflate compresses as much data as possible, and stops when the input
buffer becomes empty or the output buffer becomes full. It may introduce some buffer becomes empty or the output buffer becomes full. It may introduce some
@ -271,11 +271,12 @@ extern int ZEXPORT deflate OF((z_streamp strm, int flush));
processed or more output produced), Z_STREAM_END if all input has been processed or more output produced), Z_STREAM_END if all input has been
consumed and all output has been produced (only when flush is set to consumed and all output has been produced (only when flush is set to
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible. if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
(for example avail_in or avail_out was zero).
*/ */
extern int ZEXPORT deflateEnd OF((z_streamp strm)); ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
/* /*
All dynamically allocated data structures for this stream are freed. All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any This function discards any unprocessed input and does not flush any
@ -290,7 +291,7 @@ extern int ZEXPORT deflateEnd OF((z_streamp strm));
/* /*
extern int ZEXPORT inflateInit OF((z_streamp strm)); ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
Initializes the internal stream state for decompression. The fields Initializes the internal stream state for decompression. The fields
next_in, avail_in, zalloc, zfree and opaque must be initialized before by next_in, avail_in, zalloc, zfree and opaque must be initialized before by
@ -310,7 +311,7 @@ extern int ZEXPORT inflateInit OF((z_streamp strm));
*/ */
extern int ZEXPORT inflate OF((z_streamp strm, int flush)); ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
/* /*
inflate decompresses as much data as possible, and stops when the input inflate decompresses as much data as possible, and stops when the input
buffer becomes empty or the output buffer becomes full. It may some buffer becomes empty or the output buffer becomes full. It may some
@ -379,7 +380,7 @@ extern int ZEXPORT inflate OF((z_streamp strm, int flush));
*/ */
extern int ZEXPORT inflateEnd OF((z_streamp strm)); ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
/* /*
All dynamically allocated data structures for this stream are freed. All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any This function discards any unprocessed input and does not flush any
@ -397,7 +398,7 @@ extern int ZEXPORT inflateEnd OF((z_streamp strm));
*/ */
/* /*
extern int ZEXPORT deflateInit2 OF((z_streamp strm, ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
int level, int level,
int method, int method,
int windowBits, int windowBits,
@ -440,14 +441,14 @@ extern int ZEXPORT deflateInit2 OF((z_streamp strm,
not perform any compression: this will be done by deflate(). not perform any compression: this will be done by deflate().
*/ */
extern int ZEXPORT deflateSetDictionary OF((z_streamp strm, ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
const Bytef *dictionary, const Bytef *dictionary,
uInt dictLength)); uInt dictLength));
/* /*
Initializes the compression dictionary from the given byte sequence Initializes the compression dictionary from the given byte sequence
without producing any compressed output. This function must be called without producing any compressed output. This function must be called
immediately after deflateInit or deflateInit2, before any call of immediately after deflateInit, deflateInit2 or deflateReset, before any
deflate. The compressor and decompressor must use exactly the same call of deflate. The compressor and decompressor must use exactly the same
dictionary (see inflateSetDictionary). dictionary (see inflateSetDictionary).
The dictionary should consist of strings (byte sequences) that are likely The dictionary should consist of strings (byte sequences) that are likely
@ -476,7 +477,7 @@ extern int ZEXPORT deflateSetDictionary OF((z_streamp strm,
perform any compression: this will be done by deflate(). perform any compression: this will be done by deflate().
*/ */
extern int ZEXPORT deflateCopy OF((z_streamp dest, ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
z_streamp source)); z_streamp source));
/* /*
Sets the destination stream as a complete copy of the source stream. Sets the destination stream as a complete copy of the source stream.
@ -494,7 +495,7 @@ extern int ZEXPORT deflateCopy OF((z_streamp dest,
destination. destination.
*/ */
extern int ZEXPORT deflateReset OF((z_streamp strm)); ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
/* /*
This function is equivalent to deflateEnd followed by deflateInit, This function is equivalent to deflateEnd followed by deflateInit,
but does not free and reallocate all the internal compression state. but does not free and reallocate all the internal compression state.
@ -505,7 +506,9 @@ extern int ZEXPORT deflateReset OF((z_streamp strm));
stream state was inconsistent (such as zalloc or state being NULL). stream state was inconsistent (such as zalloc or state being NULL).
*/ */
extern int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy)); ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
int level,
int strategy));
/* /*
Dynamically update the compression level and compression strategy. The Dynamically update the compression level and compression strategy. The
interpretation of level and strategy is as in deflateInit2. This can be interpretation of level and strategy is as in deflateInit2. This can be
@ -525,7 +528,7 @@ extern int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy));
*/ */
/* /*
extern int ZEXPORT inflateInit2 OF((z_streamp strm, ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
int windowBits)); int windowBits));
This is another version of inflateInit with an extra parameter. The This is another version of inflateInit with an extra parameter. The
@ -547,7 +550,7 @@ extern int ZEXPORT inflateInit2 OF((z_streamp strm,
modified, but next_out and avail_out are unchanged.) modified, but next_out and avail_out are unchanged.)
*/ */
extern int ZEXPORT inflateSetDictionary OF((z_streamp strm, ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
const Bytef *dictionary, const Bytef *dictionary,
uInt dictLength)); uInt dictLength));
/* /*
@ -566,7 +569,7 @@ extern int ZEXPORT inflateSetDictionary OF((z_streamp strm,
inflate(). inflate().
*/ */
extern int ZEXPORT inflateSync OF((z_streamp strm)); ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
/* /*
Skips invalid compressed data until a full flush point (see above the Skips invalid compressed data until a full flush point (see above the
description of deflate with Z_FULL_FLUSH) can be found, or until all description of deflate with Z_FULL_FLUSH) can be found, or until all
@ -581,7 +584,7 @@ extern int ZEXPORT inflateSync OF((z_streamp strm));
until success or end of the input data. until success or end of the input data.
*/ */
extern int ZEXPORT inflateReset OF((z_streamp strm)); ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
/* /*
This function is equivalent to inflateEnd followed by inflateInit, This function is equivalent to inflateEnd followed by inflateInit,
but does not free and reallocate all the internal decompression state. but does not free and reallocate all the internal decompression state.
@ -602,7 +605,7 @@ extern int ZEXPORT inflateReset OF((z_streamp strm));
utility functions can easily be modified if you need special options. utility functions can easily be modified if you need special options.
*/ */
extern int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen)); const Bytef *source, uLong sourceLen));
/* /*
Compresses the source buffer into the destination buffer. sourceLen is Compresses the source buffer into the destination buffer. sourceLen is
@ -617,7 +620,7 @@ extern int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
buffer. buffer.
*/ */
extern int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen, const Bytef *source, uLong sourceLen,
int level)); int level));
/* /*
@ -632,7 +635,7 @@ extern int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
Z_STREAM_ERROR if the level parameter is invalid. Z_STREAM_ERROR if the level parameter is invalid.
*/ */
extern int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen)); const Bytef *source, uLong sourceLen));
/* /*
Decompresses the source buffer into the destination buffer. sourceLen is Decompresses the source buffer into the destination buffer. sourceLen is
@ -653,7 +656,7 @@ extern int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
typedef voidp gzFile; typedef voidp gzFile;
extern gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
/* /*
Opens a gzip (.gz) file for reading or writing. The mode parameter 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 is as in fopen ("rb" or "wb") but can also include a compression level
@ -669,7 +672,7 @@ extern gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
can be checked to distinguish the two cases (if errno is zero, the can be checked to distinguish the two cases (if errno is zero, the
zlib error is Z_MEM_ERROR). */ zlib error is Z_MEM_ERROR). */
extern gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
/* /*
gzdopen() associates a gzFile with the file descriptor fd. File gzdopen() associates a gzFile with the file descriptor fd. File
descriptors are obtained from calls like open, dup, creat, pipe or descriptors are obtained from calls like open, dup, creat, pipe or
@ -682,7 +685,7 @@ extern gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
the (de)compression state. the (de)compression state.
*/ */
extern int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
/* /*
Dynamically update the compression level or strategy. See the description Dynamically update the compression level or strategy. See the description
of deflateInit2 for the meaning of these parameters. of deflateInit2 for the meaning of these parameters.
@ -690,7 +693,7 @@ extern int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
opened for writing. opened for writing.
*/ */
extern int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
/* /*
Reads the given number of uncompressed bytes from the compressed file. 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 If the input file was not in gzip format, gzread copies the given number
@ -698,28 +701,29 @@ extern int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
gzread returns the number of uncompressed bytes actually read (0 for gzread returns the number of uncompressed bytes actually read (0 for
end of file, -1 for error). */ end of file, -1 for error). */
extern int ZEXPORT gzwrite OF((gzFile file, const voidp buf, unsigned len)); ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
const voidp buf, unsigned len));
/* /*
Writes the given number of uncompressed bytes into the compressed file. Writes the given number of uncompressed bytes into the compressed file.
gzwrite returns the number of uncompressed bytes actually written gzwrite returns the number of uncompressed bytes actually written
(0 in case of error). (0 in case of error).
*/ */
extern int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
/* /*
Converts, formats, and writes the args to the compressed file under Converts, formats, and writes the args to the compressed file under
control of the format string, as in fprintf. gzprintf returns the number of control of the format string, as in fprintf. gzprintf returns the number of
uncompressed bytes actually written (0 in case of error). uncompressed bytes actually written (0 in case of error).
*/ */
extern int ZEXPORT gzputs OF((gzFile file, const char *s)); ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
/* /*
Writes the given null-terminated string to the compressed file, excluding Writes the given null-terminated string to the compressed file, excluding
the terminating null character. the terminating null character.
gzputs returns the number of characters written, or -1 in case of error. gzputs returns the number of characters written, or -1 in case of error.
*/ */
extern char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
/* /*
Reads bytes from the compressed file until len-1 characters are read, or Reads bytes from the compressed file until len-1 characters are read, or
a newline character is read and transferred to buf, or an end-of-file a newline character is read and transferred to buf, or an end-of-file
@ -728,19 +732,19 @@ extern char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
gzgets returns buf, or Z_NULL in case of error. gzgets returns buf, or Z_NULL in case of error.
*/ */
extern int ZEXPORT gzputc OF((gzFile file, int c)); ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
/* /*
Writes c, converted to an unsigned char, into the compressed file. Writes c, converted to an unsigned char, into the compressed file.
gzputc returns the value that was written, or -1 in case of error. gzputc returns the value that was written, or -1 in case of error.
*/ */
extern int ZEXPORT gzgetc OF((gzFile file)); ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
/* /*
Reads one byte from the compressed file. gzgetc returns this byte Reads one byte from the compressed file. gzgetc returns this byte
or -1 in case of end of file or error. or -1 in case of end of file or error.
*/ */
extern int ZEXPORT gzflush OF((gzFile file, int flush)); ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
/* /*
Flushes all pending output into the compressed file. The parameter Flushes all pending output into the compressed file. The parameter
flush is as in the deflate() function. The return value is the zlib flush is as in the deflate() function. The return value is the zlib
@ -750,10 +754,11 @@ extern int ZEXPORT gzflush OF((gzFile file, int flush));
degrade compression. degrade compression.
*/ */
extern z_off_t ZEXPORT gzseek OF((gzFile file, z_off_t offset, int whence)); ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
z_off_t offset, int whence));
/* /*
Sets the starting position for the next gzread or gzwrite on the given Sets the starting position for the next gzread or gzwrite on the
compressed file. The offset represents a number of bytes in the given compressed file. The offset represents a number of bytes in the
uncompressed data stream. The whence parameter is defined as in lseek(2); uncompressed data stream. The whence parameter is defined as in lseek(2);
the value SEEK_END is not supported. the value SEEK_END is not supported.
If the file is opened for reading, this function is emulated but can be If the file is opened for reading, this function is emulated but can be
@ -767,14 +772,14 @@ extern z_off_t ZEXPORT gzseek OF((gzFile file, z_off_t offset, int whence));
would be before the current position. would be before the current position.
*/ */
extern int ZEXPORT gzrewind OF((gzFile file)); ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
/* /*
Rewinds the given file. This function is supported only for reading. Rewinds the given file. This function is supported only for reading.
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
*/ */
extern z_off_t ZEXPORT gztell OF((gzFile file)); ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
/* /*
Returns the starting position for the next gzread or gzwrite on the Returns the starting position for the next gzread or gzwrite on the
given compressed file. This position represents a number of bytes in the given compressed file. This position represents a number of bytes in the
@ -783,20 +788,20 @@ extern z_off_t ZEXPORT gztell OF((gzFile file));
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
*/ */
extern int ZEXPORT gzeof OF((gzFile file)); ZEXTERN int ZEXPORT gzeof OF((gzFile file));
/* /*
Returns 1 when EOF has previously been detected reading the given Returns 1 when EOF has previously been detected reading the given
input stream, otherwise zero. input stream, otherwise zero.
*/ */
extern int ZEXPORT gzclose OF((gzFile file)); ZEXTERN int ZEXPORT gzclose OF((gzFile file));
/* /*
Flushes all pending output if necessary, closes the compressed file Flushes all pending output if necessary, closes the compressed file
and deallocates all the (de)compression state. The return value is the zlib and deallocates all the (de)compression state. The return value is the zlib
error number (see function gzerror below). error number (see function gzerror below).
*/ */
extern const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
/* /*
Returns the error message for the last error which occurred on the Returns the error message for the last error which occurred on the
given compressed file. errnum is set to zlib error number. If an given compressed file. errnum is set to zlib error number. If an
@ -813,7 +818,7 @@ extern const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
compression library. compression library.
*/ */
extern uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
/* /*
Update a running Adler-32 checksum with the bytes buf[0..len-1] and Update a running Adler-32 checksum with the bytes buf[0..len-1] and
@ -830,7 +835,7 @@ extern uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
if (adler != original_adler) error(); if (adler != original_adler) error();
*/ */
extern uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
/* /*
Update a running crc with the bytes buf[0..len-1] and return the updated 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 crc. If buf is NULL, this function returns the required initial value
@ -852,15 +857,15 @@ extern uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
/* deflateInit and inflateInit are macros to allow checking the zlib version /* deflateInit and inflateInit are macros to allow checking the zlib version
* and the compiler's view of z_stream: * and the compiler's view of z_stream:
*/ */
extern int ZEXPORT deflateInit_ OF((z_streamp strm, int level, ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
const char *version, int stream_size)); const char *version, int stream_size));
extern int ZEXPORT inflateInit_ OF((z_streamp strm, ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
const char *version, int stream_size)); const char *version, int stream_size));
extern int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
int windowBits, int memLevel, int windowBits, int memLevel,
int strategy, const char *version, int strategy, const char *version,
int stream_size)); int stream_size));
extern int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
const char *version, int stream_size)); const char *version, int stream_size));
#define deflateInit(strm, level) \ #define deflateInit(strm, level) \
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
@ -877,9 +882,9 @@ extern int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
struct internal_state {int dummy;}; /* hack for buggy compilers */ struct internal_state {int dummy;}; /* hack for buggy compilers */
#endif #endif
extern const char * ZEXPORT zError OF((int err)); ZEXTERN const char * ZEXPORT zError OF((int err));
extern int ZEXPORT inflateSyncPoint OF((z_streamp z)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
extern const uLongf * ZEXPORT get_crc_table OF((void)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -60,7 +60,7 @@ const char * ZEXPORT zError(err)
void zmemcpy(dest, source, len) void zmemcpy(dest, source, len)
Bytef* dest; Bytef* dest;
Bytef* source; const Bytef* source;
uInt len; uInt len;
{ {
if (len == 0) return; if (len == 0) return;
@ -70,8 +70,8 @@ void zmemcpy(dest, source, len)
} }
int zmemcmp(s1, s2, len) int zmemcmp(s1, s2, len)
Bytef* s1; const Bytef* s1;
Bytef* s2; const Bytef* s2;
uInt len; uInt len;
{ {
uInt j; uInt j;
@ -178,7 +178,7 @@ void zcfree (voidpf opaque, voidpf ptr)
# define MY_ZCALLOC # define MY_ZCALLOC
#if (!defined(_MSC_VER) || (_MSC_VER < 600)) #if (!defined(_MSC_VER) || (_MSC_VER <= 600))
# define _halloc halloc # define _halloc halloc
# define _hfree hfree # define _hfree hfree
#endif #endif

@ -75,7 +75,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef MSDOS #ifdef MSDOS
# define OS_CODE 0x00 # define OS_CODE 0x00
# ifdef __TURBOC__ # if defined(__TURBOC__) || defined(__BORLANDC__)
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */ /* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block ); void _Cdecl farfree( void *block );
@ -112,13 +112,12 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
#if defined(MACOS) || defined(TARGET_OS_MAC) #if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07 # define OS_CODE 0x07
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
# else
# ifndef fdopen # ifndef fdopen
# define fdopen(fd,mode) NULL /* No fdopen() */ # define fdopen(fd,mode) NULL /* No fdopen() */
# endif # endif
#endif
#if defined(__MWERKS__) && !defined(fdopen)
# if __dest_os != __be_os && __dest_os != __win32_os
# define fdopen(fd,mode) NULL
# endif # endif
#endif #endif
@ -134,7 +133,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
# define fdopen(fd,mode) NULL /* No fdopen() */ # define fdopen(fd,mode) NULL /* No fdopen() */
#endif #endif
#if (defined(_MSC_VER) && (_MSC_VER >= 600)) #if (defined(_MSC_VER) && (_MSC_VER > 600))
# define fdopen(fd,type) _fdopen(fd,type) # define fdopen(fd,type) _fdopen(fd,type)
#endif #endif
@ -182,8 +181,8 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
# define zmemzero(dest, len) memset(dest, 0, len) # define zmemzero(dest, len) memset(dest, 0, len)
# endif # endif
#else #else
extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len)); extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len)); extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
extern void zmemzero OF((Bytef* dest, uInt len)); extern void zmemzero OF((Bytef* dest, uInt len));
#endif #endif

Loading…
Cancel
Save