zlib 1.2.3.7
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ce81be..ea0fa99 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,14 +59,6 @@
    add_definitions(-DNO_ERRNO_H)
 endif()
 
-#
-# Create the zlibdefs.h file.
-# Note: we create it in CMAKE_CURRENT_SOURCE_DIR instead 
-#       of CMAKE_CURRENT_BINARY_DIR because an empty zlibdefs.h
-#       is shipped with zlib in the source tree.
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlibdefs.h.cmakein
-               ${CMAKE_CURRENT_SOURCE_DIR}/zlibdefs.h)
-
 if(MSVC)
     set(CMAKE_DEBUG_POSTFIX "d")
     add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
@@ -80,7 +72,6 @@
 set(ZLIB_PUBLIC_HDRS
     zconf.h
     zlib.h
-    zlibdefs.h
 )
 set(ZLIB_PRIVATE_HDRS
     crc32.h
diff --git a/ChangeLog b/ChangeLog
index 87e4339..68305b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,28 @@
 
                 ChangeLog file for zlib
 
+Changes in 1.2.3.7 (24 Jan 2010)
+- Always gzopen() with O_LARGEFILE if available
+- Fix gzdirect() to work immediately after gzopen() or gzdopen()
+- Make gzdirect() more precise when the state changes while reading
+- Improve zlib.h documentation in many places
+- Catch memory allocation failure in gz_open()
+- Complete close operation if seek forward in gzclose_w() fails
+- Return Z_ERRNO from gzclose_r() if close() fails
+- Return Z_STREAM_ERROR instead of EOF for gzclose() being passed NULL
+- Return zero for gzwrite() errors to match zlib.h description
+- Return -1 on gzputs() error to match zlib.h description
+- Add zconf.in.h to allow recovery from configure modification [Weigelt]
+- Fix static library permissions in Makefile.in [Weigelt]
+- Avoid warnings in configure tests that hide functionality [Weigelt]
+- Add *BSD and DragonFly to Linux case in configure [gentoo 123571]
+- Change libzdll.a to libz.dll.a in win32/Makefile.gcc [gentoo 288212]
+- Avoid access of uninitialized data for first inflateReset2 call [Gomes]
+- Keep object files in subdirectories to reduce the clutter somewhat
+- Remove default Makefile and zlibdefs.h, add dummy Makefile
+- Add new external functions to Z_PREFIX, remove duplicates, z_z_ -> z_
+- Remove zlibdefs.h completely -- modify zconf.h instead
+
 Changes in 1.2.3.6 (17 Jan 2010)
 - Avoid void * arithmetic in gzread.c and gzwrite.c
 - Make compilers happier with const char * for gz_error message
diff --git a/INDEX b/INDEX
index 72684a2..e4c2133 100644
--- a/INDEX
+++ b/INDEX
@@ -2,12 +2,12 @@
 ChangeLog       history of changes
 FAQ             Frequently Asked Questions about zlib
 INDEX           this file
-Makefile        makefile for Unix (generated by configure)
-Makefile.in     makefile for Unix (template for configure)
+Makefile.in     template for Unix Makefile
 README          guess what
 configure       configure script for Unix
 make_vms.com	makefile for VMS
 treebuild.xml	XML description of source file dependencies
+zconf.in.h	zconf.h template for configure
 zlib.3		Man page for zlib
 zlib.map	Linux symbol information
 zlib.pc.in	Template for pkg-config descriptor
@@ -18,18 +18,18 @@
 doc/		documentation for formats and algorithms
 msdos/          makefiles for MSDOS
 nintendods/	makefile for Nintendo DS
+objs/		destination for object files
 old/            makefiles for various architectures and zlib documentation
                 files that have not yet been updated for zlib 1.2.x
+pics/		destination for position-independent-code object files
 projects/       projects for various Integrated Development Environments
 qnx/            makefiles for QNX
 watcom/		makefiles for OpenWatcom
 win32/          makefiles for Windows
-zlibdefs.h.cmakein      input file for cmake build
 
                 zlib public header files (required for library use):
 zconf.h
 zlib.h
-zlibdefs.h
 
                 private source files used to build the zlib library:
 adler32.c
diff --git a/Makefile b/Makefile
index 9b81f23..744c494 100644
--- a/Makefile
+++ b/Makefile
@@ -1,241 +1,2 @@
-# Makefile for zlib
-# Copyright (C) 1995-2010 Jean-loup Gailly.
-# For conditions of distribution and use, see copyright notice in zlib.h
-
-# To compile and test, type:
-#    ./configure; make test
-# Normally configure builds both a static and a shared library.
-# If you want to build just a static library, use: ./configure --static
-
-# To use the asm code, type:
-#    cp contrib/asm?86/match.S ./match.S
-#    make LOC=-DASMV OBJA=match.o
-
-# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
-#    make install
-# To install in $HOME instead of /usr/local, use:
-#    make install prefix=$HOME
-
-CC=cc
-
-CFLAGS=-O
-#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-g -DDEBUG
-#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-#           -Wstrict-prototypes -Wmissing-prototypes
-
-SFLAGS=-O
-
-LDFLAGS=-L. libz.a
-LDSHARED=$(CC)
-CPP=$(CC) -E
-
-STATICLIB=libz.a
-SHAREDLIB=libz.so
-SHAREDLIBV=libz.so.1.2.3.6
-SHAREDLIBM=libz.so.1
-LIBS=$(STATICLIB) $(SHAREDLIB) $(SHAREDLIBV)
-
-AR=ar rc
-RANLIB=ranlib
-TAR=tar
-SHELL=/bin/sh
-EXE=
-
-prefix = /usr/local
-exec_prefix = ${prefix}
-libdir = ${exec_prefix}/lib
-includedir = ${prefix}/include
-mandir = ${prefix}/share/man
-man3dir = ${mandir}/man3
-pkgconfigdir = ${libdir}/pkgconfig
-
-OBJC = adler32.o compress.o crc32.o deflate.o gzclose.o gzio.o gzlib.o gzread.o \
-	gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
-
-PIC_OBJC = adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzio.lo gzlib.lo gzread.lo \
-	gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo
-
-# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
-OBJA =
-PIC_OBJA =
-
-OBJS = $(OBJC) $(OBJA)
-
-PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
-
-all: static shared
-
-static: example$(EXE) minigzip$(EXE)
-
-shared: examplesh$(EXE) minigzipsh$(EXE)
-
-all64: example64$(EXE) minigzip64$(EXE)
-
-check: test
-
-test: all teststatic testshared
-
-teststatic: static
-	@echo hello world | ./minigzip | ./minigzip -d || \
-	  echo '		*** minigzip test FAILED ***' ; \
-	if ./example; then \
-	  echo '		*** zlib test OK ***'; \
-	else \
-	  echo '		*** zlib test FAILED ***'; \
-	fi
-
-testshared: shared
-	@LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
-	LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
-	DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
-	SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
-	echo hello world | ./minigzipsh | ./minigzipsh -d || \
-	  echo '		*** minigzip shared test FAILED ***' ; \
-	if ./examplesh; then \
-	  echo '		*** zlib shared test OK ***'; \
-	else \
-	  echo '		*** zlib shared test FAILED ***'; \
-	fi
-
-test64: all64
-	@echo hello world | ./minigzip64 | ./minigzip64 -d || \
-	  echo '		*** minigzip 64-bit test FAILED ***' ; \
-	if ./example64; then \
-	  echo '		*** zlib 64-bit test OK ***'; \
-	else \
-	  echo '		*** zlib 64-bit test FAILED ***'; \
-	fi
-
-libz.a: $(OBJS)
-	$(AR) $@ $(OBJS)
-	-@ ($(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
-
-match.lo: match.S
-	$(CPP) match.S > _match.s
-	$(CC) -c -fPIC _match.s
-	mv _match.o match.lo
-	rm -f _match.s
-
-example64.o: example.c zlib.h zconf.h zlibdefs.h
-	$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ example.c
-
-minigzip64.o: minigzip.c zlib.h zconf.h zlibdefs.h
-	$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ minigzip.c
-
-.SUFFIXES: .lo
-
-.c.lo:
-	-@if [ ! -d objs ]; then mkdir objs; fi
-	$(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
-	-@mv objs/$*.o $@
-
-$(SHAREDLIBV): $(PIC_OBJS)
-	$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) -lc
-	rm -f $(SHAREDLIB) $(SHAREDLIBM)
-	ln -s $@ $(SHAREDLIB)
-	ln -s $@ $(SHAREDLIBM)
-	-@rmdir objs
-
-example$(EXE): example.o $(STATICLIB)
-	$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
-
-minigzip$(EXE): minigzip.o $(STATICLIB)
-	$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
-
-examplesh$(EXE): example.o $(SHAREDLIBV)
-	$(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
-
-minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
-	$(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
-
-example64$(EXE): example64.o $(STATICLIB)
-	$(CC) $(CFLAGS) -o $@ example64.o $(LDFLAGS)
-
-minigzip64$(EXE): minigzip64.o $(STATICLIB)
-	$(CC) $(CFLAGS) -o $@ minigzip64.o $(LDFLAGS)
-
-install-libs: $(LIBS)
-	-@if [ ! -d $(DESTDIR)$(exec_prefix)  ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
-	-@if [ ! -d $(DESTDIR)$(libdir)       ]; then mkdir -p $(DESTDIR)$(libdir); fi
-	-@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
-	-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
-	cp $(LIBS) $(DESTDIR)$(libdir)
-	cd $(DESTDIR)$(libdir); chmod 755 $(LIBS)
-	-@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
-	cd $(DESTDIR)$(libdir); if test -f $(SHAREDLIBV); then \
-	  rm -f $(SHAREDLIB) $(SHAREDLIBM); \
-	  ln -s $(SHAREDLIBV) $(SHAREDLIB); \
-	  ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
-	  (ldconfig || true)  >/dev/null 2>&1; \
-	fi
-	cp zlib.3 $(DESTDIR)$(man3dir)
-	chmod 644 $(DESTDIR)$(man3dir)/zlib.3
-	cp zlib.pc $(DESTDIR)$(pkgconfigdir)
-	chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
-# The ranlib in install is needed on NeXTSTEP which checks file times
-# ldconfig is for Linux
-
-install: install-libs
-	-@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
-	cp zlib.h zconf.h zlibdefs.h $(DESTDIR)$(includedir)
-	chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h $(DESTDIR)$(includedir)/zlibdefs.h
-
-uninstall:
-	cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h zlibdefs.h
-	cd $(DESTDIR)$(libdir); rm -f libz.a; \
-	if test -f $(SHAREDLIBV); then \
-	  rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
-	fi
-	cd $(DESTDIR)$(man3dir); rm -f zlib.3
-	cd $(DESTDIR)$(pkgconfigdir); rm -f zlib.pc
-
-mostlyclean: clean
-clean:
-	rm -f *.o *.lo *~ \
-	   example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
-	   example64$(EXE) minigzip64$(EXE) \
-	   libz.* foo.gz so_locations \
-	   _match.s maketree contrib/infback9/*.o
-	rm -rf objs
-
-maintainer-clean: distclean
-distclean: clean
-	cp -p Makefile.in Makefile
-	rm zlibdefs.h
-	touch -r configure zlibdefs.h
-	rm -f zlib.pc .DS_Store
-
-tags:
-	etags *.[ch]
-
-depend:
-	makedepend -- $(CFLAGS) -- *.[ch]
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o gzio.o zutil.o: zutil.h zlib.h zconf.h zlibdefs.h
-gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h zlibdefs.h gzguts.h
-compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h zlibdefs.h
-crc32.o: zutil.h zlib.h zconf.h zlibdefs.h crc32.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h zlibdefs.h
-infback.o inflate.o: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
-inffast.o: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h
-inftrees.o: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
-trees.o: deflate.h zutil.h zlib.h zconf.h zlibdefs.h trees.h
-
-adler32.lo gzio.lo zutil.lo: zutil.h zlib.h zconf.h zlibdefs.h
-gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h zlibdefs.h gzguts.h
-compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h zlibdefs.h
-crc32.lo: zutil.h zlib.h zconf.h zlibdefs.h crc32.h
-deflate.lo: deflate.h zutil.h zlib.h zconf.h zlibdefs.h
-infback.lo inflate.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
-inffast.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h
-inftrees.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
-trees.lo: deflate.h zutil.h zlib.h zconf.h zlibdefs.h trees.h
+all:
+	-@echo "Use ./configure first.  Thank you."
diff --git a/Makefile.in b/Makefile.in
index 9b81f23..99945a8 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -32,7 +32,7 @@
 
 STATICLIB=libz.a
 SHAREDLIB=libz.so
-SHAREDLIBV=libz.so.1.2.3.6
+SHAREDLIBV=libz.so.1.2.3.7
 SHAREDLIBM=libz.so.1
 LIBS=$(STATICLIB) $(SHAREDLIB) $(SHAREDLIBV)
 
@@ -53,16 +53,15 @@
 OBJC = adler32.o compress.o crc32.o deflate.o gzclose.o gzio.o gzlib.o gzread.o \
 	gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
 
-PIC_OBJC = adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzio.lo gzlib.lo gzread.lo \
-	gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo
-
-# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
+# to use the asm code: make OBJA=match.o
 OBJA =
-PIC_OBJA =
 
-OBJS = $(OBJC) $(OBJA)
+objdir = objs/
+picdir = pics/
 
-PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
+OBJS = $(addprefix $(objdir), $(OBJC) $(OBJA))
+
+PIC_OBJS = $(addprefix $(picdir), $(OBJC) $(OBJA))
 
 all: static shared
 
@@ -84,6 +83,7 @@
 	else \
 	  echo '		*** zlib test FAILED ***'; \
 	fi
+	-@rm -f foo.gz
 
 testshared: shared
 	@LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
@@ -97,6 +97,7 @@
 	else \
 	  echo '		*** zlib shared test FAILED ***'; \
 	fi
+	-@rm -f foo.gz
 
 test64: all64
 	@echo hello world | ./minigzip64 | ./minigzip64 -d || \
@@ -106,60 +107,57 @@
 	else \
 	  echo '		*** zlib 64-bit test FAILED ***'; \
 	fi
+	-@rm -f foo.gz
 
 libz.a: $(OBJS)
 	$(AR) $@ $(OBJS)
 	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
 
-match.o: match.S
+objs/match.o: match.S
 	$(CPP) match.S > _match.s
-	$(CC) -c _match.s
-	mv _match.o match.o
+	$(CC) -c -o $@ _match.s
 	rm -f _match.s
 
-match.lo: match.S
+pics/match.o: match.S
 	$(CPP) match.S > _match.s
-	$(CC) -c -fPIC _match.s
-	mv _match.o match.lo
+	$(CC) -c -o $@ -fPIC _match.s
 	rm -f _match.s
 
-example64.o: example.c zlib.h zconf.h zlibdefs.h
+objs/example64.o: example.c zlib.h zconf.h
 	$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ example.c
 
-minigzip64.o: minigzip.c zlib.h zconf.h zlibdefs.h
+objs/minigzip64.o: minigzip.c zlib.h zconf.h
 	$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 -c -o $@ minigzip.c
 
-.SUFFIXES: .lo
+$(objdir)%.o: %.c
+	$(CC) $(CFLAGS) -c -o $@ $<
 
-.c.lo:
-	-@if [ ! -d objs ]; then mkdir objs; fi
-	$(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
-	-@mv objs/$*.o $@
+$(picdir)%.o: %.c
+	$(CC) $(SFLAGS) -DPIC -c -o $@ $<
 
 $(SHAREDLIBV): $(PIC_OBJS)
 	$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) -lc
 	rm -f $(SHAREDLIB) $(SHAREDLIBM)
 	ln -s $@ $(SHAREDLIB)
 	ln -s $@ $(SHAREDLIBM)
-	-@rmdir objs
 
-example$(EXE): example.o $(STATICLIB)
-	$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
+example$(EXE): objs/example.o $(STATICLIB)
+	$(CC) $(CFLAGS) -o $@ objs/example.o $(LDFLAGS)
 
-minigzip$(EXE): minigzip.o $(STATICLIB)
-	$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
+minigzip$(EXE): objs/minigzip.o $(STATICLIB)
+	$(CC) $(CFLAGS) -o $@ objs/minigzip.o $(LDFLAGS)
 
-examplesh$(EXE): example.o $(SHAREDLIBV)
-	$(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV)
+examplesh$(EXE): objs/example.o $(SHAREDLIBV)
+	$(CC) $(CFLAGS) -o $@ objs/example.o -L. $(SHAREDLIBV)
 
-minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
-	$(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV)
+minigzipsh$(EXE): objs/minigzip.o $(SHAREDLIBV)
+	$(CC) $(CFLAGS) -o $@ objs/minigzip.o -L. $(SHAREDLIBV)
 
-example64$(EXE): example64.o $(STATICLIB)
-	$(CC) $(CFLAGS) -o $@ example64.o $(LDFLAGS)
+example64$(EXE): objs/example64.o $(STATICLIB)
+	$(CC) $(CFLAGS) -o $@ objs/example64.o $(LDFLAGS)
 
-minigzip64$(EXE): minigzip64.o $(STATICLIB)
-	$(CC) $(CFLAGS) -o $@ minigzip64.o $(LDFLAGS)
+minigzip64$(EXE): objs/minigzip64.o $(STATICLIB)
+	$(CC) $(CFLAGS) -o $@ objs/minigzip64.o $(LDFLAGS)
 
 install-libs: $(LIBS)
 	-@if [ ! -d $(DESTDIR)$(exec_prefix)  ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
@@ -167,7 +165,7 @@
 	-@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
 	-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
 	cp $(LIBS) $(DESTDIR)$(libdir)
-	cd $(DESTDIR)$(libdir); chmod 755 $(LIBS)
+	cd $(DESTDIR)$(libdir); chmod 755 $(SHAREDLIB) ; chmod u=rw,go=r $(STATICLIB)
 	-@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
 	cd $(DESTDIR)$(libdir); if test -f $(SHAREDLIBV); then \
 	  rm -f $(SHAREDLIB) $(SHAREDLIBM); \
@@ -184,11 +182,11 @@
 
 install: install-libs
 	-@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
-	cp zlib.h zconf.h zlibdefs.h $(DESTDIR)$(includedir)
-	chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h $(DESTDIR)$(includedir)/zlibdefs.h
+	cp zlib.h zconf.h $(DESTDIR)$(includedir)
+	chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
 
 uninstall:
-	cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h zlibdefs.h
+	cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
 	cd $(DESTDIR)$(libdir); rm -f libz.a; \
 	if test -f $(SHAREDLIBV); then \
 	  rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
@@ -198,19 +196,18 @@
 
 mostlyclean: clean
 clean:
-	rm -f *.o *.lo *~ \
+	rm -f $(objdir)* $(picdir)* *~ \
 	   example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
 	   example64$(EXE) minigzip64$(EXE) \
 	   libz.* foo.gz so_locations \
 	   _match.s maketree contrib/infback9/*.o
-	rm -rf objs
 
 maintainer-clean: distclean
 distclean: clean
-	cp -p Makefile.in Makefile
-	rm zlibdefs.h
-	touch -r configure zlibdefs.h
+	cp -p zconf.in.h zconf.h
 	rm -f zlib.pc .DS_Store
+	-@printf 'all:\n\t-@echo "Use ./configure first.  Thank you."\n' > Makefile
+	-@ touch -r Makefile.in Makefile objs pics
 
 tags:
 	etags *.[ch]
@@ -220,22 +217,12 @@
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
-adler32.o gzio.o zutil.o: zutil.h zlib.h zconf.h zlibdefs.h
-gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h zlibdefs.h gzguts.h
-compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h zlibdefs.h
-crc32.o: zutil.h zlib.h zconf.h zlibdefs.h crc32.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h zlibdefs.h
-infback.o inflate.o: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
-inffast.o: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h
-inftrees.o: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
-trees.o: deflate.h zutil.h zlib.h zconf.h zlibdefs.h trees.h
-
-adler32.lo gzio.lo zutil.lo: zutil.h zlib.h zconf.h zlibdefs.h
-gzclose.lo gzlib.lo gzread.lo gzwrite.lo: zlib.h zconf.h zlibdefs.h gzguts.h
-compress.lo example.lo minigzip.lo uncompr.lo: zlib.h zconf.h zlibdefs.h
-crc32.lo: zutil.h zlib.h zconf.h zlibdefs.h crc32.h
-deflate.lo: deflate.h zutil.h zlib.h zconf.h zlibdefs.h
-infback.lo inflate.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h inffixed.h
-inffast.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inflate.h inffast.h
-inftrees.lo: zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
-trees.lo: deflate.h zutil.h zlib.h zconf.h zlibdefs.h trees.h
+adler32.o gzio.o zutil.o: zutil.h zlib.h zconf.h
+gzclose.o gzlib.o gzread.o gzwrite.o: zlib.h zconf.h gzguts.h
+compress.o example.o minigzip.o uncompr.o: zlib.h zconf.h
+crc32.o: zutil.h zlib.h zconf.h crc32.h
+deflate.o: deflate.h zutil.h zlib.h zconf.h
+infback.o inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
+inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
+inftrees.o: zutil.h zlib.h zconf.h inftrees.h
+trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
diff --git a/README b/README
index 741e000..f8f37f5 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 ZLIB DATA COMPRESSION LIBRARY
 
-zlib 1.2.3.6 is a general purpose data compression library.  All the code is
+zlib 1.2.3.7 is a general purpose data compression library.  All the code is
 thread safe.  The data format used by the zlib library is described by RFCs
 (Request for Comments) 1950 to 1952 in the files
 http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
@@ -33,7 +33,7 @@
 issue of  Dr. Dobb's Journal; a copy of the article is available in
 http://dogma.net/markn/articles/zlibtool/zlibtool.htm
 
-The changes made in version 1.2.3.6 are documented in the file ChangeLog.
+The changes made in version 1.2.3.7 are documented in the file ChangeLog.
 
 Unsupported third party contributions are provided in directory "contrib".
 
diff --git a/as400/zlib.inc b/as400/zlib.inc
index 7ecea98..cfcbfc8 100644
--- a/as400/zlib.inc
+++ b/as400/zlib.inc
@@ -1,7 +1,7 @@
       *  ZLIB.INC - Interface to the general purpose compression library
       *
       *  ILE RPG400 version by Patrick Monnerat, DATASPHERE.
-      *  Version 1.2.3.6
+      *  Version 1.2.3.7
       *
       *
       *  WARNING:
@@ -22,8 +22,8 @@
       *
       *  Versioning information.
       *
-     D ZLIB_VERSION    C                   '1.2.3.6'
-     D ZLIB_VERNUM     C                   X'1236'
+     D ZLIB_VERSION    C                   '1.2.3.7'
+     D ZLIB_VERNUM     C                   X'1237'
       *
       *  Other equates.
       *
diff --git a/configure b/configure
index 261efa9..5f0ed6e 100755
--- a/configure
+++ b/configure
@@ -85,7 +85,7 @@
     uname=`(uname -s || echo unknown) 2>/dev/null`
   fi
   case "$uname" in
-  Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
+  Linux | linux | GNU | GNU/* | *BSD | DragonFly) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
   CYGWIN* | Cygwin* | cygwin* | OS/2* )
              EXE='.exe' ;;
   QNX*)  # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
@@ -215,14 +215,6 @@
   TEST="all teststatic testshared"
 fi
 
-cat > zlibdefs.h << EOF
-/* zlibdefs.h -- compile-time definitions for the zlib compression library
- * Copyright (C) 1995-2006 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-EOF
-
 cat > $test.c <<EOF
 #include <sys/types.h>
 off64_t dummy = 0;
@@ -252,21 +244,15 @@
   fi
 fi
 
+cp -p zconf.in.h zconf.h
+
 cat > $test.c <<EOF
 #include <unistd.h>
 int main() { return 0; }
 EOF
 if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
-  cat >> zlibdefs.h <<EOF
-#include <sys/types.h>	/* for off_t */
-#include <unistd.h>	/* for SEEK_* and off_t */
-#ifdef VMS
-#  include <unixio.h>	/* for off_t */
-#endif
-#ifndef z_off_t
-#  define z_off_t off_t
-#endif
-EOF
+  sed < zconf.h "/#ifdef HAVE_UNISTD_H/s/def HAVE_UNISTD_H/ 1/" > zconf.temp.h
+  mv zconf.temp.h zconf.h
   echo "Checking for unistd.h... Yes."
 else
   echo "Checking for unistd.h... No."
@@ -300,7 +286,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 
-int mytest(char *fmt, ...)
+int mytest(const char *fmt, ...)
 {
   char buf[20];
   va_list ap;
@@ -364,7 +350,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 
-int mytest(char *fmt, ...)
+int mytest(const char *fmt, ...)
 {
   int n;
   char buf[20];
diff --git a/contrib/infback9/inftree9.c b/contrib/infback9/inftree9.c
index 2d42f72..2018e4d 100644
--- a/contrib/infback9/inftree9.c
+++ b/contrib/infback9/inftree9.c
@@ -9,7 +9,7 @@
 #define MAXBITS 15
 
 const char inflate9_copyright[] =
-   " inflate9 1.2.3.6 Copyright 1995-2010 Mark Adler ";
+   " inflate9 1.2.3.7 Copyright 1995-2010 Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -64,7 +64,7 @@
     static const unsigned short lext[31] = { /* Length codes 257..285 extra */
         128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
         130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
-        133, 133, 133, 133, 144, 199, 70};
+        133, 133, 133, 133, 144, 72, 193};
     static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
         65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
diff --git a/contrib/vstudio/vc7/zlib.rc b/contrib/vstudio/vc7/zlib.rc
index 418eb7a..68cb9cb 100644
--- a/contrib/vstudio/vc7/zlib.rc
+++ b/contrib/vstudio/vc7/zlib.rc
@@ -2,8 +2,8 @@
 

 #define IDR_VERSION1  1

 IDR_VERSION1	VERSIONINFO	MOVEABLE IMPURE LOADONCALL DISCARDABLE

-  FILEVERSION	 1,2,3,6

-  PRODUCTVERSION 1,2,3,6

+  FILEVERSION	 1,2,3,7

+  PRODUCTVERSION 1,2,3,7

   FILEFLAGSMASK	VS_FFI_FILEFLAGSMASK

   FILEFLAGS	0

   FILEOS	VOS_DOS_WINDOWS32

@@ -17,7 +17,7 @@
 

     BEGIN

       VALUE "FileDescription", "zlib data compression library\0"

-      VALUE "FileVersion",	"1.2.3.6\0"

+      VALUE "FileVersion",	"1.2.3.7\0"

       VALUE "InternalName",	"zlib\0"

       VALUE "OriginalFilename",	"zlib.dll\0"

       VALUE "ProductName",	"ZLib.DLL\0"

diff --git a/deflate.c b/deflate.c
index c010a89..990fe02 100644
--- a/deflate.c
+++ b/deflate.c
@@ -52,7 +52,7 @@
 #include "deflate.h"
 
 const char deflate_copyright[] =
-   " deflate 1.2.3.6 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
+   " deflate 1.2.3.7 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
diff --git a/gzclose.c b/gzclose.c
index 2cf2843..e20d404 100644
--- a/gzclose.c
+++ b/gzclose.c
@@ -17,7 +17,7 @@
     gz_statep state;
 
     if (file == NULL)
-        return EOF;
+        return Z_STREAM_ERROR;
     state = (gz_statep)file;
 
     return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
diff --git a/gzguts.h b/gzguts.h
index 8b7914d..26791b0 100644
--- a/gzguts.h
+++ b/gzguts.h
@@ -76,6 +76,11 @@
 #define GZ_WRITE 31153
 #define GZ_APPEND 1     /* mode set to GZ_WRITE after the file is opened */
 
+/* values for gz_state how */
+#define LOOK 0      /* look for a gzip header */
+#define COPY 1      /* copy input directly */
+#define GZIP 2      /* decompress a gzip stream */
+
 /* internal gzip file state data structure */
 typedef struct {
         /* used for both reading and writing */
@@ -89,17 +94,18 @@
     unsigned char *out;     /* output buffer (double-sized when reading) */
     unsigned char *next;    /* next output data to deliver or write */
         /* just for reading */
-    int how;                /* 0: get header, 1: copy, 2: decompress */
-    unsigned have;          /* amount of output data unused */
+    unsigned have;          /* amount of output data unused at next */
+    int eof;                /* true if end of input file reached */
     z_off64_t start;        /* where the gzip data started, for rewinding */
     z_off64_t raw;          /* where the raw data started, for seeking */
-    int eof;                /* true if end of input file reached */
+    int how;                /* 0: get header, 1: copy, 2: decompress */
+    int direct;             /* true if last read direct, false if gzip */
         /* just for writing */
     int level;              /* compression level */
     int strategy;           /* compression strategy */
         /* seek request */
-    int seek;               /* true if seek request pending */
     z_off64_t skip;         /* amount to skip (already rewound if backwards) */
+    int seek;               /* true if seek request pending */
         /* error information */
     int err;                /* error code */
     char *msg;              /* error message */
diff --git a/gzlib.c b/gzlib.c
index c9a82dc..e637e83 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -15,7 +15,7 @@
 
 /* Local functions */
 local void gz_reset OF((gz_statep));
-local gzFile gz_open OF((const char *, int, const char *, int));
+local gzFile gz_open OF((const char *, int, const char *));
 
 #if defined UNDER_CE && defined NO_ERRNO_H
 
@@ -73,10 +73,11 @@
 local void gz_reset(state)
     gz_statep state;
 {
-    state->how = 0;             /* look for gzip header */
     if (state->mode == GZ_READ) {   /* for reading ... */
         state->have = 0;            /* no output data available */
         state->eof = 0;             /* not at end of file */
+        state->how = LOOK;          /* look for gzip header */
+        state->direct = 1;          /* default for empty file */
     }
     state->seek = 0;                /* no seek request pending */
     gz_error(state, Z_OK, NULL);    /* clear error */
@@ -85,11 +86,10 @@
 }
 
 /* Open a gzip file either by name or file descriptor. */
-local gzFile gz_open(path, fd, mode, large)
+local gzFile gz_open(path, fd, mode)
     const char *path;
     int fd;
     const char *mode;
-    int large;
 {
     gz_statep state;
 
@@ -152,13 +152,9 @@
     /* open the file with the appropriate mode (or just use fd) */
     state->fd = fd != -1 ? fd :
         open(path,
-            (large ?
 #ifdef O_LARGEFILE
-            O_LARGEFILE
-#else
-            0
+            O_LARGEFILE |
 #endif
-            : 0) |
 #ifdef O_BINARY
             O_BINARY |
 #endif
@@ -178,6 +174,10 @@
 
     /* save the path name for error messages */
     state->path = malloc(strlen(path) + 1);
+    if (state->path == NULL) {
+        free(state);
+        return NULL;
+    }
     strcpy(state->path, path);
 
     /* save the current position for rewinding (only if reading) */
@@ -198,7 +198,7 @@
     const char *path;
     const char *mode;
 {
-    return gz_open(path, -1, mode, 0);
+    return gz_open(path, -1, mode);
 }
 
 /* -- see zlib.h -- */
@@ -206,7 +206,7 @@
     const char *path;
     const char *mode;
 {
-    return gz_open(path, -1, mode, 1);
+    return gz_open(path, -1, mode);
 }
 
 /* -- see zlib.h -- */
@@ -216,14 +216,14 @@
 {
     char path[46];      /* identifier for error messages */
 
-    if (fd < 0)
+    if (fd == -1)
         return NULL;
 #ifdef NO_snprintf
     sprintf(path, "<fd:%d>", fd);   /* big enough for 128-bit integers */
 #else
     snprintf(path, sizeof(path), "<fd:%d>", fd);
 #endif
-    return gz_open(path, fd, mode, 0);
+    return gz_open(path, fd, mode);
 }
 
 /* -- see zlib.h -- */
@@ -303,7 +303,7 @@
         offset -= state->pos;
 
     /* if within raw area while reading, just go there */
-    if (state->mode == GZ_READ && state->how == 1 &&
+    if (state->mode == GZ_READ && state->how == COPY &&
         state->pos + offset >= state->raw) {
         ret = LSEEK(state->fd, offset, SEEK_CUR);
         if (ret == -1)
diff --git a/gzread.c b/gzread.c
index 74bdc7b..74322ca 100644
--- a/gzread.c
+++ b/gzread.c
@@ -92,15 +92,16 @@
 
 /* Look for gzip header, set up for inflate or copy.  state->have must be zero.
    If this is the first time in, allocate required memory.  state->how will be
-   left unchanged if there is no more input data available, will be set to 1 if
-   there is no gzip header and direct copying will be performed, or it will be
-   set to 2 for decompression, and the gzip header will be skipped so that the
-   next available input data is the raw deflate stream.  If direct copying,
-   then leftover input data from the input buffer will be copied to the output
-   buffer.  In that case, all further file reads will be directly to either the
-   output buffer or a user buffer.  If decompressing, the inflate state and the
-   check value will be initialized.  gz_head() will return 0 on success or -1
-   on failure.  Failures may include read errors or gzip header errors. */
+   left unchanged if there is no more input data available, will be set to COPY
+   if there is no gzip header and direct copying will be performed, or it will
+   be set to GZIP for decompression, and the gzip header will be skipped so
+   that the next available input data is the raw deflate stream.  If direct
+   copying, then leftover input data from the input buffer will be copied to
+   the output buffer.  In that case, all further file reads will be directly to
+   either the output buffer or a user buffer.  If decompressing, the inflate
+   state and the check value will be initialized.  gz_head() will return 0 on
+   success or -1 on failure.  Failures may include read errors or gzip header
+   errors.  */
 local int gz_head(state)
     gz_statep state;
 {
@@ -196,7 +197,8 @@
             /* set up for decompression */
             inflateReset(strm);
             strm->adler = crc32(0L, Z_NULL, 0);
-            state->how = 2;
+            state->how = GZIP;
+            state->direct = 0;
             return 0;
         }
         else {
@@ -216,7 +218,8 @@
         state->have += strm->avail_in;
         strm->avail_in = 0;
     }
-    state->how = 1;
+    state->how = COPY;
+    state->direct = 1;
     return 0;
 }
 
@@ -224,7 +227,7 @@
    If the end of the compressed data is reached, then verify the gzip trailer
    check value and length (modulo 2^32).  state->have and state->next are set
    to point to the just decompressed data, and the crc is updated.  If the
-   trailer is verified, state->how is reset to zero to look for the next gzip
+   trailer is verified, state->how is reset to LOOK to look for the next gzip
    stream or raw data, once state->have is depleted.  Returns 0 on success, -1
    on failure.  Failures may include invalid compressed data or a failed gzip
    trailer verification. */
@@ -284,7 +287,8 @@
             gz_error(state, Z_DATA_ERROR, "incorrect length check");
             return -1;
         }
-        state->how = 0;         /* ready for next stream, once have is 0 */
+        state->how = LOOK;      /* ready for next stream, once have is 0 (leave
+                                   state->direct unchanged to remember how) */
     }
 
     /* good decompression */
@@ -293,28 +297,28 @@
 
 /* Make data and put in the output buffer.  Assumes that state->have == 0.
    Data is either copied from the input file or decompressed from the input
-   file depending on state->how.  If state->how is zero, then a gzip header is
+   file depending on state->how.  If state->how is LOOK, then a gzip header is
    looked for (and skipped if found) to determine wither to copy or decompress.
-   Returns -1 on error, otherwise 0.  gz_make() will leave state->have non-zero
-   unless the end of the input file has been reached and all data has been
-   processed. */
+   Returns -1 on error, otherwise 0.  gz_make() will leave state->have as COPY
+   or GZIP unless the end of the input file has been reached and all data has
+   been processed.  */
 local int gz_make(state)
     gz_statep state;
 {
     z_streamp strm = &(state->strm);
 
-    if (state->how == 0) {              /* look for gzip header */
+    if (state->how == LOOK) {           /* look for gzip header */
         if (gz_head(state) == -1)
             return -1;
         if (state->have)                /* got some data from gz_head() */
             return 0;
     }
-    if (state->how == 1) {              /* straight copy */
+    if (state->how == COPY) {           /* straight copy */
         if (gz_load(state, state->out, state->size << 1, &(state->have)) == -1)
             return -1;
         state->next = state->out;
     }
-    else if (state->how == 2) {         /* decompress */
+    else if (state->how == GZIP) {      /* decompress */
         strm->avail_out = state->size << 1;
         strm->next_out = state->out;
         if (gz_decomp(state) == -1)
@@ -409,7 +413,7 @@
 
         /* need output data -- for small len or new stream load up our output
            buffer */
-        else if (state->how == 0 || len < (state->size << 1)) {
+        else if (state->how == LOOK || len < (state->size << 1)) {
             /* get more output, looking for header if required */
             if (gz_make(state) == -1)
                 return -1;
@@ -419,13 +423,13 @@
         }
 
         /* large len -- read directly into user buffer */
-        else if (state->how == 1) {          /* read directly */
+        else if (state->how == COPY) {      /* read directly */
             if (gz_load(state, buf, len, &n) == -1)
                 return -1;
         }
 
         /* large len -- decompress directly into user buffer */
-        else {  /* state->how == 2 */
+        else {  /* state->how == GZIP */
             strm->avail_out = len;
             strm->next_out = buf;
             if (gz_decomp(state) == -1)
@@ -614,14 +618,20 @@
     if (state->mode != GZ_READ)
         return 0;
 
-    /* return true if reading without decompression */
-    return state->how == 1;
+    /* if the state is not known, but we can find out, then do so (this is
+       mainly for right after a gzopen() or gzdopen()) */
+    if (state->how == LOOK && state->have == 0)
+        (void)gz_head(state);
+
+    /* return 1 if reading direct, 0 if decompressing a gzip stream */
+    return state->direct;
 }
 
 /* -- see zlib.h -- */
 int ZEXPORT gzclose_r(file)
     gzFile file;
 {
+    int ret;
     gz_statep state;
 
     /* get internal structure */
@@ -640,9 +650,9 @@
         free(state->in);
     }
     gz_error(state, Z_OK, NULL);
-    close(state->fd);
+    ret = close(state->fd);
     free(state);
-    return Z_OK;
+    return ret ? Z_ERRNO : Z_OK;
 }
 
 #endif /* !OLD_GZIO */
diff --git a/gzwrite.c b/gzwrite.c
index c7c033a..f4a0a80 100644
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -152,19 +152,19 @@
 
     /* get internal structure */
     if (file == NULL)
-        return -1;
+        return 0;
     state = (gz_statep)file;
     strm = &(state->strm);
 
     /* check that we're writing and that there's no error */
     if (state->mode != GZ_WRITE || state->err != Z_OK)
-        return -1;
+        return 0;
 
     /* since an int is returned, make sure len fits in one, otherwise return
        with an error (this avoids the flaw in the interface) */
     if ((int)len < 0) {
         gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
-        return -1;
+        return 0;
     }
 
     /* if len is zero, avoid unnecessary operations */
@@ -173,13 +173,13 @@
 
     /* allocate memory if this is the first time through */
     if (state->size == 0 && gz_init(state) == -1)
-        return -1;
+        return 0;
 
     /* check for seek request */
     if (state->seek) {
         state->seek = 0;
         if (gz_zero(state, state->skip) == -1)
-            return -1;
+            return 0;
     }
 
     /* for small len, copy to input buffer, otherwise compress directly */
@@ -197,20 +197,20 @@
             buf = (char *)buf + n;
             len -= n;
             if (len && gz_comp(state, Z_NO_FLUSH) == -1)
-                return -1;
+                return 0;
         } while (len);
     }
     else {
         /* consume whatever's left in the input buffer */
         if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
-            return -1;
+            return 0;
 
         /* directly compress user buffer to file */
         strm->avail_in = len;
         strm->next_in = (voidp)buf;
         state->pos += len;
         if (gz_comp(state, Z_NO_FLUSH) == -1)
-            return -1;
+            return 0;
     }
 
     /* input was all buffered or compressed (put will fit in int) */
@@ -265,8 +265,13 @@
     gzFile file;
     const char *str;
 {
+    int ret;
+    unsigned len;
+
     /* write string */
-    return gzwrite(file, str, strlen(str));
+    len = strlen(str);
+    ret = gzwrite(file, str, len);
+    return ret == 0 && len != 0 ? -1 : ret;
 }
 
 #ifdef STDC
@@ -494,7 +499,7 @@
 int ZEXPORT gzclose_w(file)
     gzFile file;
 {
-    int ret;
+    int ret = 0;
     gz_statep state;
 
     /* get internal structure */
@@ -509,13 +514,12 @@
     /* check for seek request */
     if (state->seek) {
         state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return -1;
+        ret += gz_zero(state, state->skip);
     }
 
     /* flush, free memory, and close file */
-    ret = gz_comp(state, Z_FINISH);
-    deflateEnd(&(state->strm));
+    ret += gz_comp(state, Z_FINISH);
+    (void)deflateEnd(&(state->strm));
     free(state->out);
     free(state->in);
     ret += close(state->fd);
diff --git a/inflate.c b/inflate.c
index 40c0ec8..a8431ab 100644
--- a/inflate.c
+++ b/inflate.c
@@ -1,5 +1,5 @@
 /* inflate.c -- zlib decompression
- * Copyright (C) 1995-2009 Mark Adler
+ * Copyright (C) 1995-2010 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -154,7 +154,7 @@
     /* set number of window bits, free window if different */
     if (windowBits && (windowBits < 8 || windowBits > 15))
         return Z_STREAM_ERROR;
-    if (state->wbits != (unsigned)windowBits && state->window != Z_NULL) {
+    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
         ZFREE(strm, state->window);
         state->window = Z_NULL;
     }
diff --git a/inftrees.c b/inftrees.c
index ae89d97..d24b8d4 100644
--- a/inftrees.c
+++ b/inftrees.c
@@ -9,7 +9,7 @@
 #define MAXBITS 15
 
 const char inflate_copyright[] =
-   " inflate 1.2.3.6 Copyright 1995-2010 Mark Adler ";
+   " inflate 1.2.3.7 Copyright 1995-2010 Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -62,7 +62,7 @@
         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
     static const unsigned short lext[31] = { /* Length codes 257..285 extra */
         16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
-        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 70};
+        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 193};
     static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
diff --git a/make_vms.com b/make_vms.com
index fc5fd0c..8e5b7b5 100644
--- a/make_vms.com
+++ b/make_vms.com
@@ -137,48 +137,48 @@
 $  then
 $   dele example.obj;*,minigzip.obj;*
 $   CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" -
-                adler32.c zlib.h zconf.h zlibdefs.h
+                adler32.c zlib.h zconf.h
 $   CALL MAKE compress.OBJ "CC ''CCOPT' compress" -
-                compress.c zlib.h zconf.h zlibdefs.h
+                compress.c zlib.h zconf.h
 $   CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" -
-                crc32.c zlib.h zconf.h zlibdefs.h
+                crc32.c zlib.h zconf.h
 $   CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" -
-                deflate.c deflate.h zutil.h zlib.h zconf.h zlibdefs.h
+                deflate.c deflate.h zutil.h zlib.h zconf.h
 $   CALL MAKE gzclose.OBJ "CC ''CCOPT' gzclose" -
-                gzclose.c zutil.h zlib.h zconf.h zlibdefs.h
+                gzclose.c zutil.h zlib.h zconf.h
 $   CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" -
-                gzio.c zutil.h zlib.h zconf.h zlibdefs.h
+                gzio.c zutil.h zlib.h zconf.h
 $   CALL MAKE gzlib.OBJ "CC ''CCOPT' gzlib" -
-                gzlib.c zutil.h zlib.h zconf.h zlibdefs.h
+                gzlib.c zutil.h zlib.h zconf.h
 $   CALL MAKE gzread.OBJ "CC ''CCOPT' gzread" -
-                gzread.c zutil.h zlib.h zconf.h zlibdefs.h
+                gzread.c zutil.h zlib.h zconf.h
 $   CALL MAKE gzwrite.OBJ "CC ''CCOPT' gzwrite" -
-                gzwrite.c zutil.h zlib.h zconf.h zlibdefs.h
+                gzwrite.c zutil.h zlib.h zconf.h
 $   CALL MAKE infback.OBJ "CC ''CCOPT' infback" -
                 infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
 $   CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" -
-                inffast.c zutil.h zlib.h zconf.h zlibdefs.h inffast.h
+                inffast.c zutil.h zlib.h zconf.h inffast.h
 $   CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" -
-                inflate.c zutil.h zlib.h zconf.h zlibdefs.h infblock.h
+                inflate.c zutil.h zlib.h zconf.h infblock.h
 $   CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" -
-                inftrees.c zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
+                inftrees.c zutil.h zlib.h zconf.h inftrees.h
 $   CALL MAKE trees.OBJ "CC ''CCOPT' trees" -
-                trees.c deflate.h zutil.h zlib.h zconf.h zlibdefs.h
+                trees.c deflate.h zutil.h zlib.h zconf.h
 $   CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" -
-                uncompr.c zlib.h zconf.h zlibdefs.h
+                uncompr.c zlib.h zconf.h
 $   CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" -
-                zutil.c zutil.h zlib.h zconf.h zlibdefs.h
+                zutil.c zutil.h zlib.h zconf.h
 $   write sys$output "Building Zlib ..."
 $   CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ
 $   write sys$output "Building example..."
 $   CALL MAKE example.OBJ "CC ''CCOPT' example" -
-                example.c zlib.h zconf.h zlibdefs.h
+                example.c zlib.h zconf.h
 $   call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb
 $   if f$search("x11vms:xvmsutils.olb") .nes. ""
 $   then
 $     write sys$output "Building minigzip..."
 $     CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" -
-                minigzip.c zlib.h zconf.h zlibdefs.h
+                minigzip.c zlib.h zconf.h
 $     call make minigzip.exe -
                 "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" -
                 minigzip.obj libz.olb
@@ -424,23 +424,23 @@
 
 
 # Other dependencies.
-adler32.obj  : adler32.c zutil.h zlib.h zconf.h zlibdefs.h
-compress.obj : compress.c zlib.h zconf.h zlibdefs.h
-crc32.obj    : crc32.c zutil.h zlib.h zconf.h zlibdefs.h
-deflate.obj  : deflate.c deflate.h zutil.h zlib.h zconf.h zlibdefs.h
-example.obj  : example.c zlib.h zconf.h zlibdefs.h
-gzclose.obj  : gzclose.c zutil.h zlib.h zconf.h zlibdefs.h
-gzio.obj     : gzio.c zutil.h zlib.h zconf.h zlibdefs.h
-gzlib.obj    : gzlib.c zutil.h zlib.h zconf.h zlibdefs.h
-gzread.obj   : gzread.c zutil.h zlib.h zconf.h zlibdefs.h
-gzwrite.obj  : gzwrite.c zutil.h zlib.h zconf.h zlibdefs.h
-inffast.obj  : inffast.c zutil.h zlib.h zconf.h zlibdefs.h inftrees.h inffast.h
-inflate.obj  : inflate.c zutil.h zlib.h zconf.h zlibdefs.h
-inftrees.obj : inftrees.c zutil.h zlib.h zconf.h zlibdefs.h inftrees.h
-minigzip.obj : minigzip.c zlib.h zconf.h zlibdefs.h
-trees.obj    : trees.c deflate.h zutil.h zlib.h zconf.h zlibdefs.h
-uncompr.obj  : uncompr.c zlib.h zconf.h zlibdefs.h
-zutil.obj    : zutil.c zutil.h zlib.h zconf.h zlibdefs.h
+adler32.obj  : adler32.c zutil.h zlib.h zconf.h
+compress.obj : compress.c zlib.h zconf.h
+crc32.obj    : crc32.c zutil.h zlib.h zconf.h
+deflate.obj  : deflate.c deflate.h zutil.h zlib.h zconf.h
+example.obj  : example.c zlib.h zconf.h
+gzclose.obj  : gzclose.c zutil.h zlib.h zconf.h
+gzio.obj     : gzio.c zutil.h zlib.h zconf.h
+gzlib.obj    : gzlib.c zutil.h zlib.h zconf.h
+gzread.obj   : gzread.c zutil.h zlib.h zconf.h
+gzwrite.obj  : gzwrite.c zutil.h zlib.h zconf.h
+inffast.obj  : inffast.c zutil.h zlib.h zconf.h inftrees.h inffast.h
+inflate.obj  : inflate.c zutil.h zlib.h zconf.h
+inftrees.obj : inftrees.c zutil.h zlib.h zconf.h inftrees.h
+minigzip.obj : minigzip.c zlib.h zconf.h
+trees.obj    : trees.c deflate.h zutil.h zlib.h zconf.h
+uncompr.obj  : uncompr.c zlib.h zconf.h
+zutil.obj    : zutil.c zutil.h zlib.h zconf.h
 infback.obj  : infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
 $ eod
 $ close out
diff --git a/qnx/package.qpg b/qnx/package.qpg
index 384bcf2..74bdb21 100644
--- a/qnx/package.qpg
+++ b/qnx/package.qpg
@@ -25,10 +25,10 @@
       <QPG:Files>
          <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
          <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
-         <QPG:Add file="../libz.so.1.2.3.6" install="/opt/lib/" user="root:bin" permission="644"/>
-         <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.3.6"/>
+         <QPG:Add file="../libz.so.1.2.3.7" install="/opt/lib/" user="root:bin" permission="644"/>
+         <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.3.7"/>
          <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.3.6"/>
-         <QPG:Add file="../libz.so.1.2.3.6" install="/opt/lib/" component="slib"/>
+         <QPG:Add file="../libz.so.1.2.3.7" install="/opt/lib/" component="slib"/>
       </QPG:Files>
 
       <QPG:PackageFilter>
@@ -63,7 +63,7 @@
             </QPM:ProductDescription>
 
             <QPM:ReleaseDescription>
-               <QPM:ReleaseVersion>1.2.3.6</QPM:ReleaseVersion>
+               <QPM:ReleaseVersion>1.2.3.7</QPM:ReleaseVersion>
                <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
                <QPM:ReleaseStability>Stable</QPM:ReleaseStability>
                <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
diff --git a/treebuild.xml b/treebuild.xml
index 679570d..387336e 100644
--- a/treebuild.xml
+++ b/treebuild.xml
@@ -9,70 +9,58 @@
 
 	<include-file name="zlib.h" scope="public" mode="644" />
 	<include-file name="zconf.h" scope="public" mode="644" />
-	<include-file name="zlibdefs.h" scope="public" mode="644" />
 
 	<source name="adler32.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	</source>
 	<source name="compress.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	</source>
 	<source name="crc32.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="crc32.h" />
 	</source>
 	<source name="gzclose.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="gzguts.h" /> 
 	</source>
 	<source name="gzio.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="zutil.h" /> 
 	</source>
 	<source name="gzlib.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="gzguts.h" /> 
 	</source>
 	<source name="gzread.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="gzguts.h" /> 
 	</source>
 	<source name="gzwrite.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="gzguts.h" /> 
 	</source>
 	<source name="uncompr.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	</source>
 	<source name="deflate.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="zutil.h" /> 
 	    <depend name="deflate.h" /> 
 	</source>
 	<source name="trees.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="zutil.h" /> 
 	    <depend name="deflate.h" /> 
 	    <depend name="trees.h" /> 
@@ -80,13 +68,11 @@
 	<source name="zutil.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="zutil.h" /> 
 	</source>
 	<source name="inflate.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="zutil.h" /> 
 	    <depend name="inftrees.h" /> 
 	    <depend name="inflate.h" />
@@ -95,7 +81,6 @@
 	<source name="infback.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="zutil.h" /> 
 	    <depend name="inftrees.h" /> 
 	    <depend name="inflate.h" />
@@ -104,14 +89,12 @@
 	<source name="inftrees.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="zutil.h" /> 
 	    <depend name="inftrees.h" /> 
 	</source>
 	<source name="inffast.c">
 	    <depend name="zlib.h" /> 
 	    <depend name="zconf.h" /> 
-	    <depend name="zlibdefs.h" /> 
 	    <depend name="zutil.h" /> 
 	    <depend name="inftrees.h" /> 
 	    <depend name="inflate.h" />
diff --git a/win32/Makefile.gcc b/win32/Makefile.gcc
index 4cc8625..4e3d1f2 100644
--- a/win32/Makefile.gcc
+++ b/win32/Makefile.gcc
@@ -25,7 +25,7 @@
 
 STATICLIB = libz.a
 SHAREDLIB = zlib1.dll
-IMPLIB    = libzdll.a
+IMPLIB    = libz.dll.a
 
 #LOC = -DASMV
 #LOC = -DDEBUG -g
diff --git a/zconf.h b/zconf.h
index 0661898..df24759 100644
--- a/zconf.h
+++ b/zconf.h
@@ -1,5 +1,5 @@
 /* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2007 Jean-loup Gailly.
+ * Copyright (C) 1995-2010 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -26,11 +26,13 @@
 #  define _tr_tally             z__tr_tally
 #  define adler32               z_adler32
 #  define adler32_combine       z_adler32_combine
+#  define adler32_combine64     z_adler32_combine64
 #  define compress              z_compress
 #  define compress2             z_compress2
 #  define compressBound         z_compressBound
 #  define crc32                 z_crc32
 #  define crc32_combine         z_crc32_combine
+#  define crc32_combine64       z_crc32_combine64
 #  define deflate               z_deflate
 #  define deflateBound          z_deflateBound
 #  define deflateCopy           z_deflateCopy
@@ -45,6 +47,8 @@
 #  define deflateTune           z_deflateTune
 #  define deflate_copyright     z_deflate_copyright
 #  define get_crc_table         z_get_crc_table
+#  define gz_error              z_gz_error
+#  define gz_strwinerror        z_gz_strwinerror
 #  define gzbuffer              z_gzbuffer
 #  define gzclearerr            z_gzclearerr
 #  define gzclose               z_gzclose
@@ -58,15 +62,19 @@
 #  define gzgetc                z_gzgetc
 #  define gzgets                z_gzgets
 #  define gzoffset              z_gzoffset
+#  define gzoffset64            z_gzoffset64
 #  define gzopen                z_gzopen
+#  define gzopen64              z_gzopen64
 #  define gzprintf              z_gzprintf
 #  define gzputc                z_gzputc
 #  define gzputs                z_gzputs
 #  define gzread                z_gzread
 #  define gzrewind              z_gzrewind
 #  define gzseek                z_gzseek
+#  define gzseek64              z_gzseek64
 #  define gzsetparams           z_gzsetparams
 #  define gztell                z_gztell
+#  define gztell64              z_gztell64
 #  define gzungetc              z_gzungetc
 #  define gzwrite               z_gzwrite
 #  define inflate               z_inflate
@@ -85,12 +93,12 @@
 #  define inflateSetDictionary  z_inflateSetDictionary
 #  define inflateSync           z_inflateSync
 #  define inflateSyncPoint      z_inflateSyncPoint
+#  define inflateUndermine      z_inflateUndermine
 #  define inflate_copyright     z_inflate_copyright
 #  define inflate_fast          z_inflate_fast
 #  define inflate_table         z_inflate_table
 #  define uncompress            z_uncompress
 #  define zError                z_zError
-#  define z_errmsg              z_z_errmsg
 #  define zcalloc               z_zcalloc
 #  define zcfree                z_zcfree
 #  define zlibCompileFlags      z_zlibCompileFlags
@@ -113,18 +121,12 @@
 #  define uLong                 z_uLong
 #  define uLongf                z_uLongf
 #  define voidp                 z_voidp
-#  define voidp                 z_voidp
-#  define voidpc                z_voidpc
 #  define voidpc                z_voidpc
 #  define voidpf                z_voidpf
-#  define voidpf                z_voidpf
-#  define z_stream              z_z_stream
-#  define z_streamp             z_z_streamp
 
 /* all zlib structs in zlib.h and zconf.h */
 #  define gz_header_s           z_gz_header_s
 #  define internal_state        z_internal_state
-#  define z_stream_s            z_z_stream_s
 
 #endif
 
@@ -357,7 +359,16 @@
    typedef Byte       *voidp;
 #endif
 
-#include "zlibdefs.h"       /* created by configure */
+#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
+#  include <sys/types.h>    /* for off_t */
+#  include <unistd.h>       /* for SEEK_* and off_t */
+#  ifdef VMS
+#    include <unixio.h>     /* for off_t */
+#  endif
+#  ifndef z_off_t
+#    define z_off_t off_t
+#  endif
+#endif
 
 #ifdef _LARGEFILE64_SOURCE
 #  include <sys/types.h>
diff --git a/zconf.in.h b/zconf.in.h
new file mode 100644
index 0000000..df24759
--- /dev/null
+++ b/zconf.in.h
@@ -0,0 +1,411 @@
+/* zconf.h -- configuration of the zlib compression library
+ * Copyright (C) 1995-2010 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#ifndef ZCONF_H
+#define ZCONF_H
+
+/*
+ * If you *really* need a unique prefix for all types and library functions,
+ * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
+ * Even better than compiling with -DZ_PREFIX would be to use configure to set
+ * this permanently in zconf.h using "./configure --zprefix".
+ */
+#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
+
+/* all linked symbols */
+#  define _dist_code            z__dist_code
+#  define _length_code          z__length_code
+#  define _tr_align             z__tr_align
+#  define _tr_flush_block       z__tr_flush_block
+#  define _tr_init              z__tr_init
+#  define _tr_stored_block      z__tr_stored_block
+#  define _tr_tally             z__tr_tally
+#  define adler32               z_adler32
+#  define adler32_combine       z_adler32_combine
+#  define adler32_combine64     z_adler32_combine64
+#  define compress              z_compress
+#  define compress2             z_compress2
+#  define compressBound         z_compressBound
+#  define crc32                 z_crc32
+#  define crc32_combine         z_crc32_combine
+#  define crc32_combine64       z_crc32_combine64
+#  define deflate               z_deflate
+#  define deflateBound          z_deflateBound
+#  define deflateCopy           z_deflateCopy
+#  define deflateEnd            z_deflateEnd
+#  define deflateInit2_         z_deflateInit2_
+#  define deflateInit_          z_deflateInit_
+#  define deflateParams         z_deflateParams
+#  define deflatePrime          z_deflatePrime
+#  define deflateReset          z_deflateReset
+#  define deflateSetDictionary  z_deflateSetDictionary
+#  define deflateSetHeader      z_deflateSetHeader
+#  define deflateTune           z_deflateTune
+#  define deflate_copyright     z_deflate_copyright
+#  define get_crc_table         z_get_crc_table
+#  define gz_error              z_gz_error
+#  define gz_strwinerror        z_gz_strwinerror
+#  define gzbuffer              z_gzbuffer
+#  define gzclearerr            z_gzclearerr
+#  define gzclose               z_gzclose
+#  define gzclose_r             z_gzclose_r
+#  define gzclose_w             z_gzclose_w
+#  define gzdirect              z_gzdirect
+#  define gzdopen               z_gzdopen
+#  define gzeof                 z_gzeof
+#  define gzerror               z_gzerror
+#  define gzflush               z_gzflush
+#  define gzgetc                z_gzgetc
+#  define gzgets                z_gzgets
+#  define gzoffset              z_gzoffset
+#  define gzoffset64            z_gzoffset64
+#  define gzopen                z_gzopen
+#  define gzopen64              z_gzopen64
+#  define gzprintf              z_gzprintf
+#  define gzputc                z_gzputc
+#  define gzputs                z_gzputs
+#  define gzread                z_gzread
+#  define gzrewind              z_gzrewind
+#  define gzseek                z_gzseek
+#  define gzseek64              z_gzseek64
+#  define gzsetparams           z_gzsetparams
+#  define gztell                z_gztell
+#  define gztell64              z_gztell64
+#  define gzungetc              z_gzungetc
+#  define gzwrite               z_gzwrite
+#  define inflate               z_inflate
+#  define inflateBack           z_inflateBack
+#  define inflateBackEnd        z_inflateBackEnd
+#  define inflateBackInit_      z_inflateBackInit_
+#  define inflateCopy           z_inflateCopy
+#  define inflateEnd            z_inflateEnd
+#  define inflateGetHeader      z_inflateGetHeader
+#  define inflateInit2_         z_inflateInit2_
+#  define inflateInit_          z_inflateInit_
+#  define inflateMark           z_inflateMark
+#  define inflatePrime          z_inflatePrime
+#  define inflateReset          z_inflateReset
+#  define inflateReset2         z_inflateReset2
+#  define inflateSetDictionary  z_inflateSetDictionary
+#  define inflateSync           z_inflateSync
+#  define inflateSyncPoint      z_inflateSyncPoint
+#  define inflateUndermine      z_inflateUndermine
+#  define inflate_copyright     z_inflate_copyright
+#  define inflate_fast          z_inflate_fast
+#  define inflate_table         z_inflate_table
+#  define uncompress            z_uncompress
+#  define zError                z_zError
+#  define zcalloc               z_zcalloc
+#  define zcfree                z_zcfree
+#  define zlibCompileFlags      z_zlibCompileFlags
+#  define zlibVersion           z_zlibVersion
+
+/* all zlib typedefs in zlib.h and zconf.h */
+#  define Byte                  z_Byte
+#  define Bytef                 z_Bytef
+#  define alloc_func            z_alloc_func
+#  define charf                 z_charf
+#  define free_func             z_free_func
+#  define gzFile                z_gzFile
+#  define gz_header             z_gz_header
+#  define gz_headerp            z_gz_headerp
+#  define in_func               z_in_func
+#  define intf                  z_intf
+#  define out_func              z_out_func
+#  define uInt                  z_uInt
+#  define uIntf                 z_uIntf
+#  define uLong                 z_uLong
+#  define uLongf                z_uLongf
+#  define voidp                 z_voidp
+#  define voidpc                z_voidpc
+#  define voidpf                z_voidpf
+
+/* all zlib structs in zlib.h and zconf.h */
+#  define gz_header_s           z_gz_header_s
+#  define internal_state        z_internal_state
+
+#endif
+
+#if defined(__MSDOS__) && !defined(MSDOS)
+#  define MSDOS
+#endif
+#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
+#  define OS2
+#endif
+#if defined(_WINDOWS) && !defined(WINDOWS)
+#  define WINDOWS
+#endif
+#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
+#  ifndef WIN32
+#    define WIN32
+#  endif
+#endif
+#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
+#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
+#    ifndef SYS16BIT
+#      define SYS16BIT
+#    endif
+#  endif
+#endif
+
+/*
+ * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
+ * than 64k bytes at a time (needed on systems with 16-bit int).
+ */
+#ifdef SYS16BIT
+#  define MAXSEG_64K
+#endif
+#ifdef MSDOS
+#  define UNALIGNED_OK
+#endif
+
+#ifdef __STDC_VERSION__
+#  ifndef STDC
+#    define STDC
+#  endif
+#  if __STDC_VERSION__ >= 199901L
+#    ifndef STDC99
+#      define STDC99
+#    endif
+#  endif
+#endif
+#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
+#  define STDC
+#endif
+#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
+#  define STDC
+#endif
+#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
+#  define STDC
+#endif
+#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
+#  define STDC
+#endif
+
+#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
+#  define STDC
+#endif
+
+#ifndef STDC
+#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
+#    define const       /* note: need a more gentle solution here */
+#  endif
+#endif
+
+/* Some Mac compilers merge all .h files incorrectly: */
+#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
+#  define NO_DUMMY_DECL
+#endif
+
+/* Maximum value for memLevel in deflateInit2 */
+#ifndef MAX_MEM_LEVEL
+#  ifdef MAXSEG_64K
+#    define MAX_MEM_LEVEL 8
+#  else
+#    define MAX_MEM_LEVEL 9
+#  endif
+#endif
+
+/* Maximum value for windowBits in deflateInit2 and inflateInit2.
+ * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
+ * created by gzip. (Files created by minigzip can still be extracted by
+ * gzip.)
+ */
+#ifndef MAX_WBITS
+#  define MAX_WBITS   15 /* 32K LZ77 window */
+#endif
+
+/* The memory requirements for deflate are (in bytes):
+            (1 << (windowBits+2)) +  (1 << (memLevel+9))
+ that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
+ plus a few kilobytes for small objects. For example, if you want to reduce
+ the default memory requirements from 256K to 128K, compile with
+     make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
+ Of course this will generally degrade compression (there's no free lunch).
+
+   The memory requirements for inflate are (in bytes) 1 << windowBits
+ that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ for small objects.
+*/
+
+                        /* Type declarations */
+
+#ifndef OF /* function prototypes */
+#  ifdef STDC
+#    define OF(args)  args
+#  else
+#    define OF(args)  ()
+#  endif
+#endif
+
+/* The following definitions for FAR are needed only for MSDOS mixed
+ * model programming (small or medium model with some far allocations).
+ * This was tested only with MSC; for other MSDOS compilers you may have
+ * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
+ * just define FAR to be empty.
+ */
+#ifdef SYS16BIT
+#  if defined(M_I86SM) || defined(M_I86MM)
+     /* MSC small or medium model */
+#    define SMALL_MEDIUM
+#    ifdef _MSC_VER
+#      define FAR _far
+#    else
+#      define FAR far
+#    endif
+#  endif
+#  if (defined(__SMALL__) || defined(__MEDIUM__))
+     /* Turbo C small or medium model */
+#    define SMALL_MEDIUM
+#    ifdef __BORLANDC__
+#      define FAR _far
+#    else
+#      define FAR far
+#    endif
+#  endif
+#endif
+
+#if defined(WINDOWS) || defined(WIN32)
+   /* If building or using zlib as a DLL, define ZLIB_DLL.
+    * This is not mandatory, but it offers a little performance increase.
+    */
+#  ifdef ZLIB_DLL
+#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
+#      ifdef ZLIB_INTERNAL
+#        define ZEXTERN extern __declspec(dllexport)
+#      else
+#        define ZEXTERN extern __declspec(dllimport)
+#      endif
+#    endif
+#  endif  /* ZLIB_DLL */
+   /* If building or using zlib with the WINAPI/WINAPIV calling convention,
+    * define ZLIB_WINAPI.
+    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
+    */
+#  ifdef ZLIB_WINAPI
+#    ifdef FAR
+#      undef FAR
+#    endif
+#    include <windows.h>
+     /* No need for _export, use ZLIB.DEF instead. */
+     /* For complete Windows compatibility, use WINAPI, not __stdcall. */
+#    define ZEXPORT WINAPI
+#    ifdef WIN32
+#      define ZEXPORTVA WINAPIV
+#    else
+#      define ZEXPORTVA FAR CDECL
+#    endif
+#  endif
+#endif
+
+#if defined (__BEOS__)
+#  ifdef ZLIB_DLL
+#    ifdef ZLIB_INTERNAL
+#      define ZEXPORT   __declspec(dllexport)
+#      define ZEXPORTVA __declspec(dllexport)
+#    else
+#      define ZEXPORT   __declspec(dllimport)
+#      define ZEXPORTVA __declspec(dllimport)
+#    endif
+#  endif
+#endif
+
+#ifdef HAVE_VISIBILITY_PRAGMA
+#  define ZEXTERN __attribute__((visibility ("default"))) extern
+#endif
+
+#ifndef ZEXTERN
+#  define ZEXTERN extern
+#endif
+#ifndef ZEXPORT
+#  define ZEXPORT
+#endif
+#ifndef ZEXPORTVA
+#  define ZEXPORTVA
+#endif
+
+#ifndef FAR
+#  define FAR
+#endif
+
+#if !defined(__MACTYPES__)
+typedef unsigned char  Byte;  /* 8 bits */
+#endif
+typedef unsigned int   uInt;  /* 16 bits or more */
+typedef unsigned long  uLong; /* 32 bits or more */
+
+#ifdef SMALL_MEDIUM
+   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
+#  define Bytef Byte FAR
+#else
+   typedef Byte  FAR Bytef;
+#endif
+typedef char  FAR charf;
+typedef int   FAR intf;
+typedef uInt  FAR uIntf;
+typedef uLong FAR uLongf;
+
+#ifdef STDC
+   typedef void const *voidpc;
+   typedef void FAR   *voidpf;
+   typedef void       *voidp;
+#else
+   typedef Byte const *voidpc;
+   typedef Byte FAR   *voidpf;
+   typedef Byte       *voidp;
+#endif
+
+#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
+#  include <sys/types.h>    /* for off_t */
+#  include <unistd.h>       /* for SEEK_* and off_t */
+#  ifdef VMS
+#    include <unixio.h>     /* for off_t */
+#  endif
+#  ifndef z_off_t
+#    define z_off_t off_t
+#  endif
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#  include <sys/types.h>
+#endif
+
+#ifndef SEEK_SET
+#  define SEEK_SET        0       /* Seek from beginning of file.  */
+#  define SEEK_CUR        1       /* Seek from current position.  */
+#  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
+#endif
+#ifndef z_off_t
+#  define z_off_t long
+#endif
+
+#if defined(__OS400__)
+#  define NO_vsnprintf
+#endif
+
+#if defined(__MVS__)
+#  define NO_vsnprintf
+#endif
+
+/* MVS linker does not support external names larger than 8 bytes */
+#if defined(__MVS__)
+  #pragma map(deflateInit_,"DEIN")
+  #pragma map(deflateInit2_,"DEIN2")
+  #pragma map(deflateEnd,"DEEND")
+  #pragma map(deflateBound,"DEBND")
+  #pragma map(inflateInit_,"ININ")
+  #pragma map(inflateInit2_,"ININ2")
+  #pragma map(inflateEnd,"INEND")
+  #pragma map(inflateSync,"INSY")
+  #pragma map(inflateSetDictionary,"INSEDI")
+  #pragma map(compressBound,"CMBND")
+  #pragma map(inflate_table,"INTABL")
+  #pragma map(inflate_fast,"INFA")
+  #pragma map(inflate_copyright,"INCOPY")
+#endif
+
+#endif /* ZCONF_H */
diff --git a/zlib.3 b/zlib.3
index 802db88..b96d959 100644
--- a/zlib.3
+++ b/zlib.3
@@ -1,4 +1,4 @@
-.TH ZLIB 3 "17 January 2010"
+.TH ZLIB 3 "24 January 2010"
 .SH NAME
 zlib \- compression/decompression library
 .SH SYNOPSIS
@@ -132,7 +132,7 @@
 Send questions and/or comments to zlib@gzip.org,
 or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
 .SH AUTHORS
-Version 1.2.3.6
+Version 1.2.3.7
 Copyright (C) 1995-2010 Jean-loup Gailly (jloup@gzip.org)
 and Mark Adler (madler@alumni.caltech.edu).
 .LP
diff --git a/zlib.h b/zlib.h
index a751b30..86a67f8 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1,5 +1,5 @@
 /* zlib.h -- interface of the 'zlib' general purpose compression library
-  version 1.2.3.6, Jan 17th, 2010
+  version 1.2.3.7, Jan 24th, 2010
 
   Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
 
@@ -37,8 +37,8 @@
 extern "C" {
 #endif
 
-#define ZLIB_VERSION "1.2.3.6"
-#define ZLIB_VERNUM 0x1236
+#define ZLIB_VERSION "1.2.3.7"
+#define ZLIB_VERNUM 0x1237
 #define ZLIB_VER_MAJOR 1
 #define ZLIB_VER_MINOR 2
 #define ZLIB_VER_REVISION 3
@@ -209,6 +209,7 @@
 #define zlib_version zlibVersion()
 /* for compatibility with versions < 1.0.2 */
 
+
                         /* basic functions */
 
 ZEXTERN const char * ZEXPORT zlibVersion OF((void));
@@ -232,8 +233,8 @@
    requests a default compromise between speed and compression (currently
    equivalent to level 6).
 
-     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_STREAM_ERROR if level is not a valid compression level,
+     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_STREAM_ERROR if level is not a valid compression level, or
    Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
    with the version assumed by the caller (ZLIB_VERSION).  msg is set to null
    if there is no error message.  deflateInit does not perform any compression:
@@ -505,6 +506,7 @@
    static string (which must not be deallocated).
 */
 
+
                         /* Advanced functions */
 
 /*
@@ -565,9 +567,11 @@
    decoder for special applications.
 
      deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
-   method).  msg is set to null if there is no error message.  deflateInit2
-   does not perform any compression: this will be done by deflate().
+   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
+   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
+   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is
+   set to null if there is no error message.  deflateInit2 does not perform any
+   compression: this will be done by deflate().
 */
 
 ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
@@ -1087,11 +1091,11 @@
                         /* utility functions */
 
 /*
-     The following utility functions are implemented on top of the
-   basic stream-oriented functions.  To simplify the interface, some default
-   options are assumed (compression level and memory usage, standard memory
-   allocation functions).  The source code of these utility functions can
-   easily be modified if you need special options.
+     The following utility functions are implemented on top of the basic
+   stream-oriented functions.  To simplify the interface, some default options
+   are assumed (compression level and memory usage, standard memory allocation
+   functions).  The source code of these utility functions can be modified if
+   you need special options.
 */
 
 ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
@@ -1147,14 +1151,17 @@
    buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
 */
 
+
+                        /* gzip file access functions */
+
 /*
-     This library supports reading and writing files in gzip (.gz) format
-   with an interface similar to that of stdio using the functions that start
-   with "gz".  The gzip format is different from the zlib format.  gzip is a
-   gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
+     This library supports reading and writing files in gzip (.gz) format with
+   an interface similar to that of stdio, using the functions that start with
+   "gz".  The gzip format is different from the zlib format.  gzip is a gzip
+   wrapper, documented in RFC 1952, wrapped around a deflate stream.
 */
 
-typedef voidp gzFile;
+typedef voidp gzFile;       /* opaque gzip file descriptor */
 
 /*
 ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
@@ -1172,25 +1179,30 @@
      gzopen can be used to read a file which is not in gzip format; in this
    case gzread will directly read from the file without decompression.
 
-     gzopen returns NULL if the file could not be opened or if there was
-   insufficient memory to allocate the (de)compression state; errno can be
-   checked to distinguish the two cases (if errno is zero, the zlib error is
-   Z_MEM_ERROR).
+     gzopen returns NULL if the file could not be opened, if there was
+   insufficient memory to allocate the gzFile state, or if an invalid mode was
+   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
+   errno can be checked to determine if the reason gzopen failed was that the
+   file could not be opened.
 */
 
 ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
 /*
-     gzdopen() associates a gzFile with the file descriptor fd.  File
-   descriptors are obtained from calls like open, dup, creat, pipe or fileno
-   (in the file has been previously opened with fopen).  The mode parameter is
-   as in gzopen.
+     gzdopen associates a gzFile with the file descriptor fd.  File descriptors
+   are obtained from calls like open, dup, creat, pipe or fileno (if the file
+   has been previously opened with fopen).  The mode parameter is as in gzopen.
 
      The next call of gzclose on the returned gzFile will also close the file
-   descriptor fd, just like fclose(fdopen(fd), mode) closes the file descriptor
-   fd.  If you want to keep fd open, use gzdopen(dup(fd), mode).
+   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
+   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
+   mode);.  The duplicated descriptor should be saved to avoid a leak, since
+   gzdopen does not close fd if it fails.
 
      gzdopen returns NULL if there was insufficient memory to allocate the
-   (de)compression state.
+   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
+   provided, or '+' was provided), or if fd is -1.  The file descriptor is not
+   used until the next gz* read, write, seek, or close operation, so gzdopen
+   will not detect if fd is invalid (unless fd is -1).
 */
 
 ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
@@ -1231,16 +1243,16 @@
    will be read if gzread is called until it returns less than the requested
    len.
 
-     gzread returns the number of uncompressed bytes actually read (less than
-   len for end of file, -1 for error).
+     gzread returns the number of uncompressed bytes actually read, less than
+   len for end of file, or -1 for error.
 */
 
 ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
                                 voidpc buf, unsigned len));
 /*
      Writes the given number of uncompressed bytes into the compressed file.
-   gzwrite returns the number of uncompressed bytes actually written (0 in case
-   of error).
+   gzwrite returns the number of uncompressed bytes written or 0 in case of
+   error.
 */
 
 ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
@@ -1254,7 +1266,7 @@
    nothing written.  In this case, there may also be a buffer overflow with
    unpredictable consequences, which is possible only if zlib was compiled with
    the insecure functions sprintf() or vsprintf() because the secure snprintf()
-   or vsnprintf() functions were not available.  This can be checked for using
+   or vsnprintf() functions were not available.  This can be determined using
    zlibCompileFlags().
 */
 
@@ -1273,7 +1285,7 @@
    condition is encountered.  The string is then terminated with a null
    character.
 
-     gzgets returns buf, or Z_NULL in case of error.
+     gzgets returns buf, or NULL in case of error.
 */
 
 ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
@@ -1290,11 +1302,14 @@
 
 ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
 /*
-     Push one character back onto the stream to be read again later.  At least
-   one character of push-back is allowed.  gzungetc() returns the character
-   pushed, or -1 on failure.  gzungetc() will fail if c is -1, and may fail if
-   a character has been pushed but not read yet.  The pushed character will be
-   discarded if the stream is repositioned with gzseek() or gzrewind().
+     Push one character back onto the stream to be read as the first character
+   on the next read.  At least one character of push-back is allowed.
+   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will
+   fail if c is -1, and may fail if a character has been pushed but not read
+   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the
+   output buffer size of pushed characters is allowed.  (See gzbuffer above.)
+   The pushed character will be discarded if the stream is repositioned with
+   gzseek() or gzrewind().
 */
 
 ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
@@ -1356,43 +1371,63 @@
      Returns the current offset in the file being read or written.  This offset
    includes the count of bytes that precede the gzip stream, for example when
    appending or when using gzdopen() for reading.  When reading, the offset
-   includes data that has been used to generate what has been provided as
-   uncompressed data so far, but does not include as yet unused buffered input.
-   On error, gzoffset() returns -1.
+   does not include as yet unused buffered input.  This information can be used
+   for a progress indicator.  On error, gzoffset() returns -1.
 */
 
 ZEXTERN int ZEXPORT gzeof OF((gzFile file));
 /*
-     Returns 1 when EOF has previously been detected reading the given input
-   stream, otherwise zero.
+     Returns true (1) if the end-of-file indicator has been set while reading,
+   false (0) otherwise.  Note that the end-of-file indicator is set only if the
+   read tried to go past the end of the input, but came up short.  Therefore,
+   just like feof(), gzeof() may return false even if there is no more data to
+   read, in the event that the last read request was for the exact number of
+   bytes remaining in the input file.  This will happen if the input file size
+   is an exact multiple of the buffer size.
+
+     If gzeof() returns true, then the read functions will return no more data,
+   unless the end-of-file indicator is reset by gzclearerr() and the input file
+   has grown since the previous end of file was detected.
 */
 
 ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
 /*
-     Returns 1 if file is being read directly without decompression, otherwise
-   zero.  gzdirect() called immediately after gzopen() will always return zero,
-   since nothing has been read yet.  Whether to read the file with
-   decompression or not is not determined until after the first read operation
-   (e.g.  gzread(), gzgetc(), etc.).
+     Returns true (1) if file is being copied directly while reading, or false
+   (0) if file is a gzip stream being decompressed.  This state can change from
+   false to true while reading the input file if the end of a gzip stream is
+   reached, but is followed by data that is not another gzip stream.
+
+     If the input file is empty, gzdirect() will return true, since the input
+   does not contain a gzip stream.
+
+     If gzdirect() is used immediately after gzopen() or gzdopen() it will
+   cause buffers to be allocated to allow reading the file to determine if it
+   is a gzip file.  Therefore if gzbuffer() is used, it should be called before
+   gzdirect().
 */
 
 ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
 /*
      Flushes all pending output if necessary, closes the compressed file and
-   deallocates all the (de)compression state.  The return value is the zlib
-   error number.  Note that once file is closed, you cannot call gzerror with
-   file, since its structures have been deallocated.
+   deallocates the (de)compression state.  Note that once file is closed, you
+   cannot call gzerror with file, since its structures have been deallocated.
+   gzclose must not be called more than once on the same file, just as free
+   must not be called more than once on the same allocation.
+
+     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
+   file operation error, or Z_OK on success.
 */
 
 ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
 ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
 /*
      Same as gzclose(), but gzclose_r() is only for use when reading, and
-   gzclose_w() is only for use when writing.  The advantage to using these
-   instead of gzclose() is that they avoid linking in zlib compression or
-   decompression code that is not used when only reading or only writing
-   respectively.  If gzclose() is used, then both compression and decompression
-   code will be included the application when linking to a static zlib library.
+   gzclose_w() is only for use when writing or appending.  The advantage to
+   using these instead of gzclose() is that they avoid linking in zlib
+   compression or decompression code that is not used when only reading or only
+   writing respectively.  If gzclose() is used, then both compression and
+   decompression code will be included the application when linking to a static
+   zlib library.
 */
 
 ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
@@ -1415,6 +1450,7 @@
    file that is being written concurrently.
 */
 
+
                         /* checksum functions */
 
 /*
diff --git a/zlibdefs.h b/zlibdefs.h
deleted file mode 100644
index e69de29..0000000
--- a/zlibdefs.h
+++ /dev/null
diff --git a/zlibdefs.h.cmakein b/zlibdefs.h.cmakein
deleted file mode 100644
index 418bb6b..0000000
--- a/zlibdefs.h.cmakein
+++ /dev/null
@@ -1,16 +0,0 @@
-/* zlibdefs.h -- compile-time definitions for the zlib compression library
- * Copyright (C) 1995-2006 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#cmakedefine HAVE_UNISTD_H
-#ifdef HAVE_UNISTD_H
-   #include <sys/types.h>	/* for off_t */
-   #include <unistd.h>	/* for SEEK_* and off_t */
-   #ifdef VMS
-   #  include <unixio.h>	/* for off_t */
-   #endif
-   #ifndef z_off_t
-   #  define z_off_t off_t
-   #endif
-#endif