zlib 1.2.5.1

This commit is contained in:
Mark Adler 2011-09-11 11:04:49 -07:00
parent 9712272c78
commit 10daf0d4d7
55 changed files with 1003 additions and 521 deletions

View File

@ -1,12 +1,57 @@
ChangeLog file for zlib ChangeLog file for zlib
Changes in 1.2.5.1 (10 Sep 2011)
- Update FAQ entry on shared builds (#13)
- Avoid symbolic argument to chmod in Makefile.in
- Fix bug and add consts in contrib/puff [Oberhumer]
- Update contrib/puff/zeros.raw test file to have all block types
- Add full coverage test for puff in contrib/puff/Makefile
- Fix static-only-build install in Makefile.in
- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno]
- Add libz.a dependency to shared in Makefile.in for parallel builds
- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out
- Replace $(...) with `...` in configure for non-bash sh [Bowler]
- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen]
- Add solaris* to Linux* in configure to allow gcc use [Groffen]
- Add *bsd* to Linux* case in configure [Bar-Lev]
- Add inffast.obj to dependencies in win32/Makefile.msc
- Correct spelling error in deflate.h [Kohler]
- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc
- Add test to configure for GNU C looking for gcc in output of $cc -v
- Add zlib.pc generation to win32/Makefile.gcc [Weigelt]
- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not
- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense
- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser)
- Make stronger test in zconf.h to include unistd.h for LFS
- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack]
- Fix zlib.h LFS support when Z_PREFIX used
- Add updated as400 support (removed from old) [Monnerat]
- Avoid deflate sensitivity to volatile input data
- Avoid division in adler32_combine for NO_DIVIDE
- Clarify the use of Z_FINISH with deflateBound() amount of space
- Set binary for output file in puff.c
- Use u4 type for crc_table to avoid conversion warnings
- Apply casts in zlib.h to avoid conversion warnings
- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller]
- Improve inflateSync() documentation to note indeterminancy
- Add deflatePending() function to return the amount of pending output
- Correct the spelling of "specification" in FAQ [Randers-Pehrson]
- Add a check in configure for stdarg.h, use for gzprintf()
- Check that pointers fit in ints when gzprint() compiled old style
- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler]
- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt]
- Add debug records in assmebler code [Londer]
- Update RFC references to use http://tools.ietf.org/html/... [Li]
- Add --archs option, use of libtool to configure for Mac OS X [Borstel]
Changes in 1.2.5 (19 Apr 2010) Changes in 1.2.5 (19 Apr 2010)
- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] - Disable visibility attribute in win32/Makefile.gcc [Bar-Lev]
- Default to libdir as sharedlibdir in configure [Nieder] - Default to libdir as sharedlibdir in configure [Nieder]
- Update copyright dates on modified source files - Update copyright dates on modified source files
- Update trees.c to be able to generate modified trees.h - Update trees.c to be able to generate modified trees.h
- Exit configure for MinGW, suggesting win32/Makefile.gcc - Exit configure for MinGW, suggesting win32/Makefile.gcc
- Check for NULL path in gz_open [Homurlu]
Changes in 1.2.4.5 (18 Apr 2010) Changes in 1.2.4.5 (18 Apr 2010)
- Set sharedlibdir in configure [Torok] - Set sharedlibdir in configure [Torok]
@ -261,7 +306,7 @@ Changes in 1.2.3.4 (21 Dec 2009)
- Clear bytes after deflate lookahead to avoid use of uninitialized data - Clear bytes after deflate lookahead to avoid use of uninitialized data
- Change a limit in inftrees.c to be more transparent to Coverity Prevent - Change a limit in inftrees.c to be more transparent to Coverity Prevent
- Update win32/zlib.def with exported symbols from zlib.h - Update win32/zlib.def with exported symbols from zlib.h
- Correct spelling error in zlib.h [Willem] - Correct spelling errors in zlib.h [Willem, Sobrado]
- Allow Z_BLOCK for deflate() to force a new block - Allow Z_BLOCK for deflate() to force a new block
- Allow negative bits in inflatePrime() to delete existing bit buffer - Allow negative bits in inflatePrime() to delete existing bit buffer
- Add Z_TREES flush option to inflate() to return at end of trees - Add Z_TREES flush option to inflate() to return at end of trees

8
FAQ
View File

@ -84,8 +84,10 @@ The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
13. How can I make a Unix shared library? 13. How can I make a Unix shared library?
make clean By default a shared (and a static) library is built for Unix. So:
./configure -s
make distclean
./configure
make make
14. How do I install a shared zlib library on Unix? 14. How do I install a shared zlib library on Unix?
@ -325,7 +327,7 @@ The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
correctly points to the zlib specification in RFC 1950 for the "deflate" correctly points to the zlib specification in RFC 1950 for the "deflate"
transfer encoding, there have been reports of servers and browsers that transfer encoding, there have been reports of servers and browsers that
incorrectly produce or expect raw deflate data per the deflate incorrectly produce or expect raw deflate data per the deflate
specficiation in RFC 1951, most notably Microsoft. So even though the specification in RFC 1951, most notably Microsoft. So even though the
"deflate" transfer encoding using the zlib format would be the more "deflate" transfer encoding using the zlib format would be the more
efficient approach (and in fact exactly what the zlib format was designed efficient approach (and in fact exactly what the zlib format was designed
for), using the "gzip" transfer encoding is probably more reliable due to for), using the "gzip" transfer encoding is probably more reliable due to

1
INDEX
View File

@ -17,6 +17,7 @@ zlib.pc.in Template for pkg-config descriptor
zlib2ansi perl script to convert source files for C++ compilation zlib2ansi perl script to convert source files for C++ compilation
amiga/ makefiles for Amiga SAS C amiga/ makefiles for Amiga SAS C
as400/ makefiles for AS/400
doc/ documentation for formats and algorithms doc/ documentation for formats and algorithms
msdos/ makefiles for MSDOS msdos/ makefiles for MSDOS
nintendods/ makefile for Nintendo DS nintendods/ makefile for Nintendo DS

View File

@ -1,5 +1,5 @@
# Makefile for zlib # Makefile for zlib
# Copyright (C) 1995-2010 Jean-loup Gailly. # Copyright (C) 1995-2011 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h # For conditions of distribution and use, see copyright notice in zlib.h
# To compile and test, type: # To compile and test, type:
@ -32,7 +32,7 @@ CPP=$(CC) -E
STATICLIB=libz.a STATICLIB=libz.a
SHAREDLIB=libz.so SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.2.5 SHAREDLIBV=libz.so.1.2.5.1
SHAREDLIBM=libz.so.1 SHAREDLIBM=libz.so.1
LIBS=$(STATICLIB) $(SHAREDLIBV) LIBS=$(STATICLIB) $(SHAREDLIBV)
@ -136,7 +136,7 @@ minigzip64.o: minigzip.c zlib.h zconf.h
$(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $< $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
-@mv objs/$*.o $@ -@mv objs/$*.o $@
$(SHAREDLIBV): $(PIC_OBJS) placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS) $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
rm -f $(SHAREDLIB) $(SHAREDLIBM) rm -f $(SHAREDLIB) $(SHAREDLIBM)
ln -s $@ $(SHAREDLIB) ln -s $@ $(SHAREDLIB)
@ -168,14 +168,16 @@ install-libs: $(LIBS)
-@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
cp $(STATICLIB) $(DESTDIR)$(libdir) cp $(STATICLIB) $(DESTDIR)$(libdir)
cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir) chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
cd $(DESTDIR)$(libdir); chmod u=rw,go=r $(STATICLIB) -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
-@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1 -@if test -n "$(SHAREDLIBV)"; then \
-@cd $(DESTDIR)$(sharedlibdir); if test "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
chmod 755 $(SHAREDLIBV); \ echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
rm -f $(SHAREDLIB) $(SHAREDLIBM); \ chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
ln -s $(SHAREDLIBV) $(SHAREDLIB); \ echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
ln -s $(SHAREDLIBV) $(SHAREDLIBM); \ rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
ln -s $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
ln -s $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
($(LDCONFIG) || true) >/dev/null 2>&1; \ ($(LDCONFIG) || true) >/dev/null 2>&1; \
fi fi
cp zlib.3 $(DESTDIR)$(man3dir) cp zlib.3 $(DESTDIR)$(man3dir)
@ -193,7 +195,7 @@ install: install-libs
uninstall: uninstall:
cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
cd $(DESTDIR)$(libdir); rm -f libz.a; \ cd $(DESTDIR)$(libdir); rm -f libz.a; \
if test "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
fi fi
cd $(DESTDIR)$(man3dir); rm -f zlib.3 cd $(DESTDIR)$(man3dir); rm -f zlib.3

10
README
View File

@ -1,10 +1,10 @@
ZLIB DATA COMPRESSION LIBRARY ZLIB DATA COMPRESSION LIBRARY
zlib 1.2.5 is a general purpose data compression library. All the code is zlib 1.2.5.1 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 thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files (Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
and rfc1952.txt (gzip format). rfc1952 (gzip format).
All functions of the compression library are documented in the file zlib.h All functions of the compression library are documented in the file zlib.h
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
@ -31,7 +31,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at issue of Dr. Dobb's Journal; a copy of the article is available at
http://marknelson.us/1997/01/01/zlib-engine/ . http://marknelson.us/1997/01/01/zlib-engine/ .
The changes made in version 1.2.5 are documented in the file ChangeLog. The changes made in version 1.2.5.1 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ . Unsupported third party contributions are provided in directory contrib/ .
@ -84,7 +84,7 @@ Acknowledgments:
Copyright notice: Copyright notice:
(C) 1995-2010 Jean-loup Gailly and Mark Adler (C) 1995-2011 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@ -1,5 +1,5 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream /* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-2007 Mark Adler * Copyright (C) 1995-2011 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -9,9 +9,9 @@
#define local static #define local static
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#define BASE 65521UL /* largest prime smaller than 65536 */ #define BASE 65521 /* largest prime smaller than 65536 */
#define NMAX 5552 #define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
@ -21,39 +21,44 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO16(buf) DO8(buf,0); DO8(buf,8); #define DO16(buf) DO8(buf,0); DO8(buf,8);
/* use NO_DIVIDE if your processor does not do division in hardware */ /* use NO_DIVIDE if your processor does not do division in hardware --
try it both ways to see which is faster */
#ifdef NO_DIVIDE #ifdef NO_DIVIDE
# define MOD(a) \ /* note that this assumes BASE is 65521, where 65536 % 65521 == 15
(thank you to John Reiser for pointing this out) */
# define CHOP(a) \
do { \ do { \
if (a >= (BASE << 16)) a -= (BASE << 16); \ unsigned long tmp = a >> 16; \
if (a >= (BASE << 15)) a -= (BASE << 15); \ a &= 0xffffUL; \
if (a >= (BASE << 14)) a -= (BASE << 14); \ a += (tmp << 4) - tmp; \
if (a >= (BASE << 13)) a -= (BASE << 13); \ } while (0)
if (a >= (BASE << 12)) a -= (BASE << 12); \ # define MOD28(a) \
if (a >= (BASE << 11)) a -= (BASE << 11); \ do { \
if (a >= (BASE << 10)) a -= (BASE << 10); \ CHOP(a); \
if (a >= (BASE << 9)) a -= (BASE << 9); \
if (a >= (BASE << 8)) a -= (BASE << 8); \
if (a >= (BASE << 7)) a -= (BASE << 7); \
if (a >= (BASE << 6)) a -= (BASE << 6); \
if (a >= (BASE << 5)) a -= (BASE << 5); \
if (a >= (BASE << 4)) a -= (BASE << 4); \
if (a >= (BASE << 3)) a -= (BASE << 3); \
if (a >= (BASE << 2)) a -= (BASE << 2); \
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \ if (a >= BASE) a -= BASE; \
} while (0) } while (0)
# define MOD4(a) \ # define MOD(a) \
do { \ do { \
if (a >= (BASE << 4)) a -= (BASE << 4); \ CHOP(a); \
if (a >= (BASE << 3)) a -= (BASE << 3); \ MOD28(a); \
if (a >= (BASE << 2)) a -= (BASE << 2); \ } while (0)
if (a >= (BASE << 1)) a -= (BASE << 1); \ # define MOD63(a) \
do { /* this assumes a is not negative */ \
z_off64_t tmp = a >> 32; \
a &= 0xffffffffL; \
a += (tmp << 8) - (tmp << 5) + tmp; \
tmp = a >> 16; \
a &= 0xffffL; \
a += (tmp << 4) - tmp; \
tmp = a >> 16; \
a &= 0xffffL; \
a += (tmp << 4) - tmp; \
if (a >= BASE) a -= BASE; \ if (a >= BASE) a -= BASE; \
} while (0) } while (0)
#else #else
# define MOD(a) a %= BASE # define MOD(a) a %= BASE
# define MOD4(a) a %= BASE # define MOD28(a) a %= BASE
# define MOD63(a) a %= BASE
#endif #endif
/* ========================================================================= */ /* ========================================================================= */
@ -92,7 +97,7 @@ uLong ZEXPORT adler32(adler, buf, len)
} }
if (adler >= BASE) if (adler >= BASE)
adler -= BASE; adler -= BASE;
MOD4(sum2); /* only added so many BASE's */ MOD28(sum2); /* only added so many BASE's */
return adler | (sum2 << 16); return adler | (sum2 << 16);
} }
@ -137,8 +142,13 @@ local uLong adler32_combine_(adler1, adler2, len2)
unsigned long sum2; unsigned long sum2;
unsigned rem; unsigned rem;
/* for negative len, return invalid adler32 as a clue for debugging */
if (len2 < 0)
return 0xffffffffUL;
/* the derivation of this formula is left as an exercise for the reader */ /* the derivation of this formula is left as an exercise for the reader */
rem = (unsigned)(len2 % BASE); MOD63(len2); /* assumes len2 >= 0 */
rem = (unsigned)len2;
sum1 = adler1 & 0xffff; sum1 = adler1 & 0xffff;
sum2 = rem * sum1; sum2 = rem * sum1;
MOD(sum2); MOD(sum2);

View File

@ -34,6 +34,7 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
EXPORT SYMBOL("deflateCopy") EXPORT SYMBOL("deflateCopy")
EXPORT SYMBOL("deflateReset") EXPORT SYMBOL("deflateReset")
EXPORT SYMBOL("deflateParams") EXPORT SYMBOL("deflateParams")
EXPORT SYMBOL("deflatePending")
EXPORT SYMBOL("deflatePrime") EXPORT SYMBOL("deflatePrime")
EXPORT SYMBOL("deflateInit_") EXPORT SYMBOL("deflateInit_")
EXPORT SYMBOL("deflateInit2_") EXPORT SYMBOL("deflateInit2_")
@ -129,4 +130,54 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
EXPORT SYMBOL("zlibCompileFlags") EXPORT SYMBOL("zlibCompileFlags")
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/* Version 1.2.5 additional entry points. */
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/********************************************************************/
/* *MODULE ADLER32 ZLIB 01/02/01 00:15:09 */
/********************************************************************/
EXPORT SYMBOL("adler32_combine")
EXPORT SYMBOL("adler32_combine64")
/********************************************************************/
/* *MODULE CRC32 ZLIB 01/02/01 00:15:09 */
/********************************************************************/
EXPORT SYMBOL("crc32_combine")
EXPORT SYMBOL("crc32_combine64")
/********************************************************************/
/* *MODULE GZLIB ZLIB 01/02/01 00:15:09 */
/********************************************************************/
EXPORT SYMBOL("gzbuffer")
EXPORT SYMBOL("gzoffset")
EXPORT SYMBOL("gzoffset64")
EXPORT SYMBOL("gzopen64")
EXPORT SYMBOL("gzseek64")
EXPORT SYMBOL("gztell64")
/********************************************************************/
/* *MODULE GZREAD ZLIB 01/02/01 00:15:09 */
/********************************************************************/
EXPORT SYMBOL("gzclose_r")
/********************************************************************/
/* *MODULE GZWRITE ZLIB 01/02/01 00:15:09 */
/********************************************************************/
EXPORT SYMBOL("gzclose_w")
/********************************************************************/
/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
/********************************************************************/
EXPORT SYMBOL("inflateMark")
EXPORT SYMBOL("inflatePrime")
EXPORT SYMBOL("inflateReset2")
EXPORT SYMBOL("inflateUndermine")
ENDPGMEXP ENDPGMEXP

110
as400/compile.clp Normal file
View File

@ -0,0 +1,110 @@
/******************************************************************************/
/* */
/* ZLIB */
/* */
/* Compile sources into modules and link them into a service program. */
/* */
/******************************************************************************/
PGM
/* Configuration adjustable parameters. */
DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10) +
VALUE('ZLIB') /* Source library. */
DCL VAR(&SRCFILE) TYPE(*CHAR) LEN(10) +
VALUE('SOURCES') /* Source member file. */
DCL VAR(&CTLFILE) TYPE(*CHAR) LEN(10) +
VALUE('TOOLS') /* Control member file. */
DCL VAR(&MODLIB) TYPE(*CHAR) LEN(10) +
VALUE('ZLIB') /* Module library. */
DCL VAR(&SRVLIB) TYPE(*CHAR) LEN(10) +
VALUE('LGPL') /* Service program library. */
DCL VAR(&CFLAGS) TYPE(*CHAR) +
VALUE('OPTIMIZE(40)') /* Compile options. */
DCL VAR(&TGTRLS) TYPE(*CHAR) +
VALUE('V5R3M0') /* Target release. */
/* Working storage. */
DCL VAR(&CMDLEN) TYPE(*DEC) LEN(15 5) VALUE(300) /* Command length. */
DCL VAR(&CMD) TYPE(*CHAR) LEN(512)
DCL VAR(&FIXDCMD) TYPE(*CHAR) LEN(512)
/* Compile sources into modules. */
CHGVAR VAR(&FIXDCMD) VALUE('CRTCMOD' *BCAT &CFLAGS *BCAT +
'SYSIFCOPT(*IFS64IO)' *BCAT +
'DEFINE(''_LARGEFILE64_SOURCE''' *BCAT +
'''_LFS64_LARGEFILE=1'') TGTRLS(' *TCAT &TGTRLS *TCAT +
') SRCFILE(' *TCAT &SRCLIB *TCAT '/' *TCAT +
&SRCFILE *TCAT ') MODULE(' *TCAT &MODLIB *TCAT '/')
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'ADLER32)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'COMPRESS)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'CRC32)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'DEFLATE)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZCLOSE)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZLIB)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZREAD)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZWRITE)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFBACK)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFFAST)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFLATE)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFTREES)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'TREES)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'UNCOMPR)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'ZUTIL)')
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
/* Link modules into a service program. */
CRTSRVPGM SRVPGM(&SRVLIB/ZLIB) +
MODULE(&MODLIB/ADLER32 &MODLIB/COMPRESS +
&MODLIB/CRC32 &MODLIB/DEFLATE +
&MODLIB/GZCLOSE &MODLIB/GZLIB +
&MODLIB/GZREAD &MODLIB/GZWRITE +
&MODLIB/INFBACK &MODLIB/INFFAST +
&MODLIB/INFLATE &MODLIB/INFTREES +
&MODLIB/TREES &MODLIB/UNCOMPR +
&MODLIB/ZUTIL) +
SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) +
TEXT('ZLIB 1.2.5.1') TGTRLS(&TGTRLS)
ENDPGM

View File

@ -1,4 +1,4 @@
ZLIB version 1.2.3 for AS400 installation instructions ZLIB version 1.2.5.1 for AS400 installation instructions
I) From an AS400 *SAVF file: I) From an AS400 *SAVF file:
@ -70,7 +70,10 @@ II) From the original source distribution:
compress.c COMPRESS C ZLIB - Compress a memory buffer compress.c COMPRESS C ZLIB - Compress a memory buffer
crc32.c CRC32 C ZLIB - Compute the CRC-32 of a data stream crc32.c CRC32 C ZLIB - Compute the CRC-32 of a data stream
deflate.c DEFLATE C ZLIB - Compress data using the deflation algorithm deflate.c DEFLATE C ZLIB - Compress data using the deflation algorithm
gzio.c GZIO C ZLIB - IO on .gz files gzclose.c GZCLOSE C ZLIB - Close .gz files
gzlib.c GZLIB C ZLIB - Miscellaneous .gz files IO support
gzread.c GZREAD C ZLIB - Read .gz files
gzwrite.c GZWRITE C ZLIB - Write .gz files
infback.c INFBACK C ZLIB - Inflate using a callback interface infback.c INFBACK C ZLIB - Inflate using a callback interface
inffast.c INFFAST C ZLIB - Fast proc. literals & length/distance pairs inffast.c INFFAST C ZLIB - Fast proc. literals & length/distance pairs
inflate.c INFLATE C ZLIB - Interface to inflate modules inflate.c INFLATE C ZLIB - Interface to inflate modules
@ -81,6 +84,7 @@ II) From the original source distribution:
H Original ZLIB C and ILE/RPG include files H Original ZLIB C and ILE/RPG include files
crc32.h CRC32 C ZLIB - CRC32 tables crc32.h CRC32 C ZLIB - CRC32 tables
deflate.h DEFLATE C ZLIB - Internal compression state deflate.h DEFLATE C ZLIB - Internal compression state
gzguts.h GZGUTS C ZLIB - Definitions for the gzclose module
inffast.h INFFAST C ZLIB - Header to use inffast.c inffast.h INFFAST C ZLIB - Header to use inffast.c
inffixed.h INFFIXED C ZLIB - Table for decoding fixed codes inffixed.h INFFIXED C ZLIB - Table for decoding fixed codes
inflate.h INFLATE C ZLIB - Internal inflate state definitions inflate.h INFLATE C ZLIB - Internal inflate state definitions
@ -108,4 +112,4 @@ Notes: For AS400 ILE RPG programmers, a /copy member defining the ZLIB
implementation does not handle conversion from/to ASCII, so implementation does not handle conversion from/to ASCII, so
text data code conversions must be done explicitely. text data code conversions must be done explicitely.
Always open zipped files in binary mode. Mainly for the reason above, always open zipped files in binary mode.

View File

@ -1,7 +1,7 @@
* ZLIB.INC - Interface to the general purpose compression library * ZLIB.INC - Interface to the general purpose compression library
* *
* ILE RPG400 version by Patrick Monnerat, DATASPHERE. * ILE RPG400 version by Patrick Monnerat, DATASPHERE.
* Version 1.2.3.9 * Version 1.2.5.1
* *
* *
* WARNING: * WARNING:
@ -22,16 +22,25 @@
* *
* Versioning information. * Versioning information.
* *
D ZLIB_VERSION C '1.2.3.9' D ZLIB_VERSION C '1.2.5.1'
D ZLIB_VERNUM C X'1239' D ZLIB_VERNUM C X'1251'
D ZLIB_VER_MAJOR C 1
D ZLIB_VER_MINOR C 2
D ZLIB_VER_REVISION...
D C 5
D ZLIB_VER_SUBREVISION...
D C 0
* *
* Other equates. * Other equates.
* *
D Z_NO_FLUSH C 0 D Z_NO_FLUSH C 0
D Z_PARTIAL_FLUSH...
D C 1
D Z_SYNC_FLUSH C 2 D Z_SYNC_FLUSH C 2
D Z_FULL_FLUSH C 3 D Z_FULL_FLUSH C 3
D Z_FINISH C 4 D Z_FINISH C 4
D Z_BLOCK C 5 D Z_BLOCK C 5
D Z_TREES C 6
* *
D Z_OK C 0 D Z_OK C 0
D Z_STREAM_END C 1 D Z_STREAM_END C 1
@ -72,6 +81,7 @@
D z_streamp S * Stream struct ptr D z_streamp S * Stream struct ptr
D gzFile S * File pointer D gzFile S * File pointer
D z_off_t S 10i 0 Stream offsets D z_off_t S 10i 0 Stream offsets
D z_off64_t S 20i 0 Stream offsets
* *
************************************************************************** **************************************************************************
* Structures * Structures
@ -122,20 +132,36 @@
D source 32767 const options(*varsize) Source buffer D source 32767 const options(*varsize) Source buffer
D sourceLen 10U 0 value Source length D sourceLen 10U 0 value Source length
* *
/if not defined(LARGE_FILES)
D gzopen PR extproc('gzopen') D gzopen PR extproc('gzopen')
D like(gzFile) D like(gzFile)
D path * value options(*string) File pathname D path * value options(*string) File pathname
D mode * value options(*string) Open mode D mode * value options(*string) Open mode
/else
D gzopen PR extproc('gzopen64')
D like(gzFile)
D path * value options(*string) File pathname
D mode * value options(*string) Open mode
*
D gzopen64 PR extproc('gzopen64')
D like(gzFile)
D path * value options(*string) File pathname
D mode * value options(*string) Open mode
/endif
* *
D gzdopen PR extproc('gzdopen') D gzdopen PR extproc('gzdopen')
D like(gzFile) D like(gzFile)
D fd 10i 0 value File descriptor D fd 10I 0 value File descriptor
D mode * value options(*string) Open mode D mode * value options(*string) Open mode
* *
D gzbuffer PR 10I 0 extproc('gzbuffer')
D file value like(gzFile) File pointer
D size 10U 0 value
*
D gzsetparams PR 10I 0 extproc('gzsetparams') D gzsetparams PR 10I 0 extproc('gzsetparams')
D file value like(gzFile) File pointer D file value like(gzFile) File pointer
D level 10I 0 value D level 10I 0 value
D strategy 10i 0 value D strategy 10I 0 value
* *
D gzread PR 10I 0 extproc('gzread') D gzread PR 10I 0 extproc('gzread')
D file value like(gzFile) File pointer D file value like(gzFile) File pointer
@ -160,20 +186,64 @@
D file value like(gzFile) File pointer D file value like(gzFile) File pointer
D flush 10I 0 value Type of flush D flush 10I 0 value Type of flush
* *
/if not defined(LARGE_FILES)
D gzseek PR extproc('gzseek') D gzseek PR extproc('gzseek')
D like(z_off_t) D like(z_off_t)
D file value like(gzFile) File pointer D file value like(gzFile) File pointer
D offset value like(z_off_t) Offset D offset value like(z_off_t) Offset
D whence 10i 0 value Origin D whence 10i 0 value Origin
/else
D gzseek PR extproc('gzseek64')
D like(z_off_t)
D file value like(gzFile) File pointer
D offset value like(z_off_t) Offset
D whence 10i 0 value Origin
*
D gzseek64 PR extproc('gzseek64')
D like(z_off64_t)
D file value like(gzFile) File pointer
D offset value like(z_off64_t) Offset
D whence 10i 0 value Origin
/endif
* *
D gzrewind PR 10i 0 extproc('gzrewind') D gzrewind PR 10i 0 extproc('gzrewind')
D file value like(gzFile) File pointer D file value like(gzFile) File pointer
* *
/if not defined(LARGE_FILES)
D gztell PR extproc('gztell') D gztell PR extproc('gztell')
D like(z_off_t) D like(z_off_t)
D file value like(gzFile) File pointer D file value like(gzFile) File pointer
/else
D gztell PR extproc('gztell64')
D like(z_off_t)
D file value like(gzFile) File pointer
*
D gztell64 PR extproc('gztell64')
D like(z_off64_t)
D file value like(gzFile) File pointer
/endif
*
/if not defined(LARGE_FILES)
D gzoffset PR extproc('gzoffset')
D like(z_off_t)
D file value like(gzFile) File pointer
/else
D gzoffset PR extproc('gzoffset64')
D like(z_off_t)
D file value like(gzFile) File pointer
*
D gzoffset64 PR extproc('gzoffset64')
D like(z_off64_t)
D file value like(gzFile) File pointer
/endif
* *
D gzeof PR 10i 0 extproc('gzeof') D gzeof PR 10i 0 extproc('gzeof')
D file value like(gzFile) File pointer
*
D gzclose_r PR 10i 0 extproc('gzclose_r')
D file value like(gzFile) File pointer
*
D gzclose_w PR 10i 0 extproc('gzclose_w')
D file value like(gzFile) File pointer D file value like(gzFile) File pointer
* *
D gzclose PR 10i 0 extproc('gzclose') D gzclose PR 10i 0 extproc('gzclose')
@ -253,6 +323,11 @@
D strm like(z_stream) Compression stream D strm like(z_stream) Compression stream
D sourcelen 10U 0 value Compression level D sourcelen 10U 0 value Compression level
* *
D deflatePending PR 10I 0 extproc('deflatePending') Change level & strat
D strm like(z_stream) Compression stream
D pending 10U 0 Pending bytes
D bits 10I 0 Pending bits
*
D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat
D strm like(z_stream) Compression stream D strm like(z_stream) Compression stream
D bits 10I 0 value Number of bits to insert D bits 10I 0 value Number of bits to insert
@ -278,6 +353,18 @@
D source like(z_stream) Source stream D source like(z_stream) Source stream
* *
D inflateReset PR 10I 0 extproc('inflateReset') End and init. stream D inflateReset PR 10I 0 extproc('inflateReset') End and init. stream
D strm like(z_stream) Expansion stream
*
D inflateReset2 PR 10I 0 extproc('inflateReset2') End and init. stream
D strm like(z_stream) Expansion stream
D windowBits 10I 0 value Log2(buffer size)
*
D inflatePrime PR 10I 0 extproc('inflatePrime') Insert bits
D strm like(z_stream) Expansion stream
D bits 10I 0 value Bit count
D value 10I 0 value Bits to insert
*
D inflateMark PR 10I 0 extproc('inflateMark') Get inflate info
D strm like(z_stream) Expansion stream D strm like(z_stream) Expansion stream
* *
D inflateBackInit... D inflateBackInit...
@ -328,4 +415,9 @@
* *
D get_crc_table PR * extproc('get_crc_table') Ptr to ulongs D get_crc_table PR * extproc('get_crc_table') Ptr to ulongs
* *
D inflateUndermine...
D PR 10I 0 extproc('inflateUndermine')
D strm like(z_stream) Expansion stream
D arg 10I 0 value Error code
*
/endif /endif

41
configure vendored
View File

@ -14,12 +14,11 @@
# an error. # an error.
if [ -n "${CHOST}" ]; then if [ -n "${CHOST}" ]; then
uname="$(echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/')" uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
CROSS_PREFIX="${CHOST}-" CROSS_PREFIX="${CHOST}-"
fi fi
STATICLIB=libz.a STATICLIB=libz.a
LDFLAGS="${LDFLAGS} -L. ${STATICLIB}"
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h` VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h` VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
@ -46,6 +45,7 @@ else
fi fi
LDCONFIG=${LDCONFIG-"ldconfig"} LDCONFIG=${LDCONFIG-"ldconfig"}
LDSHAREDLIBC="${LDSHAREDLIBC--lc}" LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
ARCHS=
prefix=${prefix-/usr/local} prefix=${prefix-/usr/local}
exec_prefix=${exec_prefix-'${prefix}'} exec_prefix=${exec_prefix-'${prefix}'}
libdir=${libdir-'${exec_prefix}/lib'} libdir=${libdir-'${exec_prefix}/lib'}
@ -67,7 +67,7 @@ case "$1" in
echo 'usage:' echo 'usage:'
echo ' configure [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' echo ' configure [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]'
echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]'
echo ' [--includedir=INCLUDEDIR]' echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]'
exit 0 ;; exit 0 ;;
-p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;; -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
-e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;; -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
@ -83,6 +83,7 @@ case "$1" in
-t | --static) shared=0; shift ;; -t | --static) shared=0; shift ;;
-z* | --zprefix) zprefix=1; shift ;; -z* | --zprefix) zprefix=1; shift ;;
-6* | --64) build64=1; shift ;; -6* | --64) build64=1; shift ;;
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
--sysconfdir=*) echo "ignored option: --sysconfdir"; shift ;; --sysconfdir=*) echo "ignored option: --sysconfdir"; shift ;;
--localstatedir=*) echo "ignored option: --localstatedir"; shift ;; --localstatedir=*) echo "ignored option: --localstatedir"; shift ;;
*) echo "unknown option: $1"; echo "$0 --help for help"; exit 1 ;; *) echo "unknown option: $1"; echo "$0 --help for help"; exit 1 ;;
@ -102,11 +103,15 @@ cflags=${CFLAGS-"-O3"}
case "$cc" in case "$cc" in
*gcc*) gcc=1 ;; *gcc*) gcc=1 ;;
esac esac
case `$cc -v 2>&1` in
*gcc*) gcc=1 ;;
esac
if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
CC="$cc" CC="$cc"
CFLAGS="${CFLAGS--O3} ${ARCHS}"
SFLAGS="${CFLAGS--O3} -fPIC" SFLAGS="${CFLAGS--O3} -fPIC"
CFLAGS="${CFLAGS--O3}" LDFLAGS="${LDFLAGS} ${ARCHS}"
if test $build64 -eq 1; then if test $build64 -eq 1; then
CFLAGS="${CFLAGS} -m64" CFLAGS="${CFLAGS} -m64"
SFLAGS="${SFLAGS} -m64" SFLAGS="${SFLAGS} -m64"
@ -118,10 +123,11 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
uname=`(uname -s || echo unknown) 2>/dev/null` uname=`(uname -s || echo unknown) 2>/dev/null`
fi fi
case "$uname" in case "$uname" in
Linux* | linux* | GNU | GNU/* | *BSD | DragonFly) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;; Linux* | linux* | GNU | GNU/* | *BSD | *bsd* | DragonFly | solaris*)
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
CYGWIN* | Cygwin* | cygwin* | OS/2*) CYGWIN* | Cygwin* | cygwin* | OS/2*)
EXE='.exe' ;; EXE='.exe' ;;
MINGW*|mingw*) MINGW* | mingw*)
# temporary bypass # temporary bypass
rm -f $test.[co] $test $test$shared_ext rm -f $test.[co] $test $test$shared_ext
echo "Please use win32/Makefile.gcc instead." echo "Please use win32/Makefile.gcc instead."
@ -142,11 +148,14 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
shared_ext='.sl' shared_ext='.sl'
SHAREDLIB='libz.sl' ;; SHAREDLIB='libz.sl' ;;
esac ;; esac ;;
Darwin*) shared_ext='.dylib' Darwin* | darwin*)
shared_ext='.dylib'
SHAREDLIB=libz$shared_ext SHAREDLIB=libz$shared_ext
SHAREDLIBV=libz.$VER$shared_ext SHAREDLIBV=libz.$VER$shared_ext
SHAREDLIBM=libz.$VER1$shared_ext SHAREDLIBM=libz.$VER1$shared_ext
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} ;; LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
AR="libtool"
AR_RC="${AR} -o" ;;
*) LDSHARED=${LDSHARED-"$cc -shared"} ;; *) LDSHARED=${LDSHARED-"$cc -shared"} ;;
esac esac
else else
@ -187,7 +196,8 @@ else
SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
CFLAGS=${CFLAGS-"-O3"} CFLAGS=${CFLAGS-"-O3"}
LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;; LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
SunOS\ 5*) LDSHARED=${LDSHARED-"cc -G"} SunOS\ 5* | solaris*)
LDSHARED=${LDSHARED-"cc -G"}
case `(uname -m || echo unknown) 2>/dev/null` in case `(uname -m || echo unknown) 2>/dev/null` in
i86*) i86*)
SFLAGS=${CFLAGS-"-xpentium -fast -KPIC -R."} SFLAGS=${CFLAGS-"-xpentium -fast -KPIC -R."}
@ -303,6 +313,18 @@ else
echo "Checking for unistd.h... No." echo "Checking for unistd.h... No."
fi fi
cat > $test.c <<EOF
#include <stdarg.h>
int main() { return 0; }
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
mv zconf.temp.h zconf.h
echo "Checking for stdarg.h... Yes."
else
echo "Checking for stdarg.h... No."
fi
if test $zprefix -eq 1; then if test $zprefix -eq 1; then
sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
mv zconf.temp.h zconf.h mv zconf.temp.h zconf.h
@ -347,7 +369,6 @@ int main()
return (mytest("Hello%d\n", 1)); return (mytest("Hello%d\n", 1));
} }
EOF EOF
if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
echo "Checking for vsnprintf() in stdio.h... Yes." echo "Checking for vsnprintf() in stdio.h... Yes."

View File

@ -83,17 +83,25 @@
.text .text
/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ /* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */
.cfi_sections .debug_frame
longest_match: longest_match:
.cfi_startproc
/* Save registers that the compiler may be using, and adjust %esp to */ /* Save registers that the compiler may be using, and adjust %esp to */
/* make room for our stack frame. */ /* make room for our stack frame. */
pushl %ebp pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset ebp, -8
pushl %edi pushl %edi
.cfi_def_cfa_offset 12
pushl %esi pushl %esi
.cfi_def_cfa_offset 16
pushl %ebx pushl %ebx
.cfi_def_cfa_offset 20
subl $LocalVarsSize, %esp subl $LocalVarsSize, %esp
.cfi_def_cfa_offset LocalVarsSize+20
/* Retrieve the function arguments. %ecx will hold cur_match */ /* Retrieve the function arguments. %ecx will hold cur_match */
/* throughout the entire function. %edx will hold the pointer to the */ /* throughout the entire function. %edx will hold the pointer to the */
@ -108,7 +116,7 @@ longest_match:
/* if (s->prev_length >= s->good_match) { */ /* if (s->prev_length >= s->good_match) { */
/* chain_length >>= 2; */ /* chain_length >>= 2; */
/* } */ /* } */
movl dsPrevLen(%edx), %eax movl dsPrevLen(%edx), %eax
movl dsGoodMatch(%edx), %ebx movl dsGoodMatch(%edx), %ebx
cmpl %ebx, %eax cmpl %ebx, %eax
@ -336,8 +344,14 @@ LookaheadRet:
/* Restore the stack and return from whence we came. */ /* Restore the stack and return from whence we came. */
addl $LocalVarsSize, %esp addl $LocalVarsSize, %esp
.cfi_def_cfa_offset 20
popl %ebx popl %ebx
.cfi_def_cfa_offset 16
popl %esi popl %esi
.cfi_def_cfa_offset 12
popl %edi popl %edi
.cfi_def_cfa_offset 8
popl %ebp popl %ebp
.cfi_def_cfa_offset 4
.cfi_endproc
match_init: ret match_init: ret

View File

@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
const OutBuf: Pointer; BufSize: Integer); const OutBuf: Pointer; BufSize: Integer);
const const
zlib_version = '1.2.5'; zlib_version = '1.2.5.1';
type type
EZlibError = class(Exception); EZlibError = class(Exception);

View File

@ -156,7 +156,7 @@ namespace DotZLibTests
public void Info_Version() public void Info_Version()
{ {
Info info = new Info(); Info info = new Info();
Assert.AreEqual("1.2.5", Info.Version); Assert.AreEqual("1.2.5.1", Info.Version);
Assert.AreEqual(32, info.SizeOfUInt); Assert.AreEqual(32, info.SizeOfUInt);
Assert.AreEqual(32, info.SizeOfULong); Assert.AreEqual(32, info.SizeOfULong);
Assert.AreEqual(32, info.SizeOfPointer); Assert.AreEqual(32, info.SizeOfPointer);

View File

@ -9,7 +9,7 @@
#define MAXBITS 15 #define MAXBITS 15
const char inflate9_copyright[] = const char inflate9_copyright[] =
" inflate9 1.2.5 Copyright 1995-2010 Mark Adler "; " inflate9 1.2.5.1 Copyright 1995-2010 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
@ -64,7 +64,7 @@ unsigned short FAR *work;
static const unsigned short lext[31] = { /* Length codes 257..285 extra */ static const unsigned short lext[31] = { /* Length codes 257..285 extra */
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
133, 133, 133, 133, 144, 73, 195}; 133, 133, 133, 133, 144, 205, 203};
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,

View File

@ -73,11 +73,6 @@ inflate_fast_use_mmx:
_TEXT segment _TEXT segment
PUBLIC _inflate_fast
ALIGN 4
_inflate_fast:
jmp inflate_fast_entry
@ -163,7 +158,8 @@ distbits_state equ (76+4+zlib1222sup) ;/* state->distbits */
;SECTION .text ;SECTION .text
ALIGN 4 ALIGN 4
inflate_fast_entry: _inflate_fast proc near
.FPO (16, 4, 0, 0, 1, 0)
push edi push edi
push esi push esi
push ebp push ebp
@ -1078,6 +1074,7 @@ L_done:
pop esi pop esi
pop edi pop edi
ret ret
_inflate_fast endp
_TEXT ends _TEXT ends
end end

View File

@ -195,6 +195,7 @@ dsNiceMatch equ 136+zlib1222add
ELSE ELSE
_longest_match proc near _longest_match proc near
ENDIF ENDIF
.FPO (9, 4, 0, 0, 1, 0)
;;; Save registers that the compiler may be using, and adjust esp to ;;; Save registers that the compiler may be using, and adjust esp to
;;; make room for our stack frame. ;;; make room for our stack frame.

View File

@ -14,6 +14,18 @@
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#endif #endif
#ifdef __APPLE__
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
#else
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
#define FTELLO_FUNC(stream) ftello64(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
#endif
#include "ioapi.h" #include "ioapi.h"
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
@ -112,7 +124,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
mode_fopen = "wb"; mode_fopen = "wb";
if ((filename!=NULL) && (mode_fopen != NULL)) if ((filename!=NULL) && (mode_fopen != NULL))
file = fopen64((const char*)filename, mode_fopen); file = FOPEN_FUNC((const char*)filename, mode_fopen);
return file; return file;
} }
@ -142,7 +154,7 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
{ {
ZPOS64_T ret; ZPOS64_T ret;
ret = ftello64((FILE *)stream); ret = FTELLO_FUNC((FILE *)stream);
return ret; return ret;
} }
@ -188,7 +200,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
} }
ret = 0; ret = 0;
if(fseeko64((FILE *)stream, offset, fseek_origin) != 0) if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
ret = -1; ret = -1;
return ret; return ret;

View File

@ -21,7 +21,7 @@
#ifndef _ZLIBIOAPI64_H #ifndef _ZLIBIOAPI64_H
#define _ZLIBIOAPI64_H #define _ZLIBIOAPI64_H
#if (!defined(_WIN32)) && (!defined(WIN32)) #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
// Linux needs this to support file operation on files larger then 4+GB // Linux needs this to support file operation on files larger then 4+GB
// But might need better if/def to select just the platforms that needs them. // But might need better if/def to select just the platforms that needs them.
@ -38,6 +38,7 @@
#ifndef _FILE_OFFSET_BIT #ifndef _FILE_OFFSET_BIT
#define _FILE_OFFSET_BIT 64 #define _FILE_OFFSET_BIT 64
#endif #endif
#endif #endif
#include <stdio.h> #include <stdio.h>

View File

@ -12,7 +12,7 @@
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
*/ */
#ifndef _WIN32 #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
#ifndef __USE_FILE_OFFSET64 #ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64 #define __USE_FILE_OFFSET64
#endif #endif
@ -27,6 +27,18 @@
#endif #endif
#endif #endif
#ifdef __APPLE__
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
#else
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
#define FTELLO_FUNC(stream) ftello64(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -34,14 +46,15 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef unix #ifdef _WIN32
# include <unistd.h>
# include <utime.h>
#else
# include <direct.h> # include <direct.h>
# include <io.h> # include <io.h>
#else
# include <unistd.h>
# include <utime.h>
#endif #endif
#include "unzip.h" #include "unzip.h"
#define CASESENSITIVITY (0) #define CASESENSITIVITY (0)
@ -84,7 +97,7 @@ void change_file_date(filename,dosdate,tmu_date)
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile); CloseHandle(hFile);
#else #else
#ifdef unix #ifdef unix || __APPLE__
struct utimbuf ut; struct utimbuf ut;
struct tm newdate; struct tm newdate;
newdate.tm_sec = tmu_date.tm_sec; newdate.tm_sec = tmu_date.tm_sec;
@ -114,10 +127,10 @@ int mymkdir(dirname)
int ret=0; int ret=0;
#ifdef _WIN32 #ifdef _WIN32
ret = _mkdir(dirname); ret = _mkdir(dirname);
#else #elif unix
#ifdef unix ret = mkdir (dirname,0775);
#elif __APPLE__
ret = mkdir (dirname,0775); ret = mkdir (dirname,0775);
#endif
#endif #endif
return ret; return ret;
} }
@ -364,7 +377,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
{ {
char rep=0; char rep=0;
FILE* ftestexist; FILE* ftestexist;
ftestexist = fopen64(write_filename,"rb"); ftestexist = FOPEN_FUNC(write_filename,"rb");
if (ftestexist!=NULL) if (ftestexist!=NULL)
{ {
fclose(ftestexist); fclose(ftestexist);
@ -395,8 +408,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
if ((skip==0) && (err==UNZ_OK)) if ((skip==0) && (err==UNZ_OK))
{ {
fout=fopen64(write_filename,"wb"); fout=FOPEN_FUNC(write_filename,"wb");
/* some zipfile don't contain directory alone before file */ /* some zipfile don't contain directory alone before file */
if ((fout==NULL) && ((*popt_extract_without_path)==0) && if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
(filename_withoutpath!=(char*)filename_inzip)) (filename_withoutpath!=(char*)filename_inzip))
@ -405,7 +417,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
*(filename_withoutpath-1)='\0'; *(filename_withoutpath-1)='\0';
makedir(write_filename); makedir(write_filename);
*(filename_withoutpath-1)=c; *(filename_withoutpath-1)=c;
fout=fopen64(write_filename,"wb"); fout=FOPEN_FUNC(write_filename,"wb");
} }
if (fout==NULL) if (fout==NULL)

View File

@ -13,7 +13,7 @@
*/ */
#ifndef _WIN32 #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
#ifndef __USE_FILE_OFFSET64 #ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64 #define __USE_FILE_OFFSET64
#endif #endif
@ -28,6 +28,19 @@
#endif #endif
#endif #endif
#ifdef __APPLE__
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
#else
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
#define FTELLO_FUNC(stream) ftello64(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -35,14 +48,14 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef unix #ifdef _WIN32
# include <direct.h>
# include <io.h>
#else
# include <unistd.h> # include <unistd.h>
# include <utime.h> # include <utime.h>
# include <sys/types.h> # include <sys/types.h>
# include <sys/stat.h> # include <sys/stat.h>
#else
# include <direct.h>
# include <io.h>
#endif #endif
#include "zip.h" #include "zip.h"
@ -81,7 +94,7 @@ uLong filetime(f, tmzip, dt)
return ret; return ret;
} }
#else #else
#ifdef unix #ifdef unix || __APPLE__
uLong filetime(f, tmzip, dt) uLong filetime(f, tmzip, dt)
char *f; /* name of file to get info on */ char *f; /* name of file to get info on */
tm_zip *tmzip; /* return value: access, modific. and creation times */ tm_zip *tmzip; /* return value: access, modific. and creation times */
@ -142,7 +155,7 @@ int check_exist_file(filename)
{ {
FILE* ftestexist; FILE* ftestexist;
int ret = 1; int ret = 1;
ftestexist = fopen64(filename,"rb"); ftestexist = FOPEN_FUNC(filename,"rb");
if (ftestexist==NULL) if (ftestexist==NULL)
ret = 0; ret = 0;
else else
@ -173,7 +186,8 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
{ {
unsigned long calculate_crc=0; unsigned long calculate_crc=0;
int err=ZIP_OK; int err=ZIP_OK;
FILE * fin = fopen64(filenameinzip,"rb"); FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
unsigned long size_read = 0; unsigned long size_read = 0;
unsigned long total_read = 0; unsigned long total_read = 0;
if (fin==NULL) if (fin==NULL)
@ -211,13 +225,12 @@ int isLargeFile(const char* filename)
{ {
int largeFile = 0; int largeFile = 0;
ZPOS64_T pos = 0; ZPOS64_T pos = 0;
FILE* pFile = fopen64(filename, "rb"); FILE* pFile = FOPEN_FUNC(filename, "rb");
if(pFile != NULL) if(pFile != NULL)
{ {
int n = fseeko64(pFile, 0, SEEK_END); int n = FSEEKO_FUNC(pFile, 0, SEEK_END);
pos = FTELLO_FUNC(pFile);
pos = ftello64(pFile);
printf("File : %s is %lld bytes\n", filename, pos); printf("File : %s is %lld bytes\n", filename, pos);
@ -447,7 +460,7 @@ int main(argc,argv)
printf("error in opening %s in zipfile\n",filenameinzip); printf("error in opening %s in zipfile\n",filenameinzip);
else else
{ {
fin = fopen64(filenameinzip,"rb"); fin = FOPEN_FUNC(filenameinzip,"rb");
if (fin==NULL) if (fin==NULL)
{ {
err=ZIP_ERRNO; err=ZIP_ERRNO;

View File

@ -1145,7 +1145,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
szFileName,fileNameBufferSize, szFileName,fileNameBufferSize,
extraField,extraFieldBufferSize, extraField,extraFieldBufferSize,
szComment,commentBufferSize); szComment,commentBufferSize);
if (err==UNZ_OK) if ((err==UNZ_OK) && (pfile_info != NULL))
{ {
pfile_info->version = file_info64.version; pfile_info->version = file_info64.version;
pfile_info->version_needed = file_info64.version_needed; pfile_info->version_needed = file_info64.version_needed;

View File

@ -10,7 +10,7 @@ unit zlibpas;
interface interface
const const
ZLIB_VERSION = '1.2.5'; ZLIB_VERSION = '1.2.5.1';
type type
alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
@ -97,6 +97,7 @@ function deflateCopy(var dest, source: z_stream): Integer;
function deflateReset(var strm: z_stream): Integer; function deflateReset(var strm: z_stream): Integer;
function deflateParams(var strm: z_stream; level, strategy: Integer): Integer; function deflateParams(var strm: z_stream; level, strategy: Integer): Integer;
function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt; function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt;
function deflatePending(var strm: z_stream; var pending: Integer; var bits: Integer): Integer;
function deflatePrime(var strm: z_stream; bits, value: Integer): Integer; function deflatePrime(var strm: z_stream; bits, value: Integer): Integer;
function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
function inflateSetDictionary(var strm: z_stream; const dictionary: PChar; function inflateSetDictionary(var strm: z_stream; const dictionary: PChar;
@ -166,6 +167,7 @@ function deflateEnd; external;
function deflateInit_; external; function deflateInit_; external;
function deflateInit2_; external; function deflateInit2_; external;
function deflateParams; external; function deflateParams; external;
function deflatePending; external;
function deflatePrime; external; function deflatePrime; external;
function deflateReset; external; function deflateReset; external;
function deflateSetDictionary; external; function deflateSetDictionary; external;

View File

@ -1,8 +1,42 @@
puff: puff.c puff.h CFLAGS=-O
cc -DTEST -o puff puff.c
puff: puff.o pufftest.o
puff.o: puff.h
pufftest.o: puff.h
test: puff test: puff
puff zeros.raw puff zeros.raw
puft: puff.c puff.h pufftest.o
cc -fprofile-arcs -ftest-coverage -o puft puff.c pufftest.o
# puff full coverage test (should say 100%)
cov: puft
@rm -f *.gcov *.gcda
@puft -w zeros.raw 2>&1 | cat > /dev/null
@echo '04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
@echo '00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
@echo '00 00 00 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 254
@echo '00 01 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
@echo '01 01 00 fe ff 0a' | xxd -r -p | puft -f 2>&1 | cat > /dev/null
@echo '02 7e ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246
@echo '02' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
@echo '04 80 49 92 24 49 92 24 0f b4 ff ff c3 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
@echo '04 80 49 92 24 49 92 24 71 ff ff 93 11 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 249
@echo '04 c0 81 08 00 00 00 00 20 7f eb 0b 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246
@echo '0b 00 00' | xxd -r -p | puft -f 2>&1 | cat > /dev/null
@echo '1a 07' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246
@echo '0c c0 81 00 00 00 00 00 90 ff 6b 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 245
@puft -f zeros.raw 2>&1 | cat > /dev/null
@echo 'fc 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 253
@echo '04 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 252
@echo '04 00 24 49' | xxd -r -p | puft 2> /dev/null || test $$? -eq 251
@echo '04 80 49 92 24 49 92 24 0f b4 ff ff c3 84' | xxd -r -p | puft 2> /dev/null || test $$? -eq 248
@echo '04 00 24 e9 ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 250
@echo '04 00 24 e9 ff 6d' | xxd -r -p | puft 2> /dev/null || test $$? -eq 247
@gcov -n puff.c
clean: clean:
rm -f puff puff.o rm -f puff puft *.o *.gc*

View File

@ -2,7 +2,7 @@
* puff.c * puff.c
* Copyright (C) 2002-2010 Mark Adler * Copyright (C) 2002-2010 Mark Adler
* For conditions of distribution and use, see copyright notice in puff.h * For conditions of distribution and use, see copyright notice in puff.h
* version 2.1, 4 Apr 2010 * version 2.2, 25 Apr 2010
* *
* puff.c is a simple inflate written to be an unambiguous way to specify the * puff.c is a simple inflate written to be an unambiguous way to specify the
* deflate format. It is not written for speed but rather simplicity. As a * deflate format. It is not written for speed but rather simplicity. As a
@ -49,9 +49,9 @@
* - Fix fixed codes table error * - Fix fixed codes table error
* - Provide a scanning mode for determining size of * - Provide a scanning mode for determining size of
* uncompressed data * uncompressed data
* 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Jean-loup] * 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Gailly]
* - Add a puff.h file for the interface * - Add a puff.h file for the interface
* - Add braces in puff() for else do [Jean-loup] * - Add braces in puff() for else do [Gailly]
* - Use indexes instead of pointers for readability * - Use indexes instead of pointers for readability
* 1.4 31 Mar 2002 - Simplify construct() code set check * 1.4 31 Mar 2002 - Simplify construct() code set check
* - Fix some comments * - Fix some comments
@ -69,13 +69,19 @@
* - Allow TEST code to read from piped stdin * - Allow TEST code to read from piped stdin
* 2.1 4 Apr 2010 - Avoid variable initialization for happier compilers * 2.1 4 Apr 2010 - Avoid variable initialization for happier compilers
* - Avoid unsigned comparisons for even happier compilers * - Avoid unsigned comparisons for even happier compilers
* 2.2 25 Apr 2010 - Fix bug in variable initializations [Oberhumer]
* - Add const where appropriate [Oberhumer]
* - Split if's and ?'s for coverage testing
* - Break out test code to separate file
* - Move NIL to puff.h
* - Allow incomplete code only if single code length is 1
* - Add full code coverage test to Makefile
*/ */
#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */ #include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
#include "puff.h" /* prototype for puff() */ #include "puff.h" /* prototype for puff() */
#define local static /* for local function definitions */ #define local static /* for local function definitions */
#define NIL ((unsigned char *)0) /* for no output option */
/* /*
* Maximums for allocations and loops. It is not useful to change these -- * Maximums for allocations and loops. It is not useful to change these --
@ -95,7 +101,7 @@ struct state {
unsigned long outcnt; /* bytes written to out so far */ unsigned long outcnt; /* bytes written to out so far */
/* input state */ /* input state */
unsigned char *in; /* input buffer */ const unsigned char *in; /* input buffer */
unsigned long inlen; /* available input at in */ unsigned long inlen; /* available input at in */
unsigned long incnt; /* bytes read so far */ unsigned long incnt; /* bytes read so far */
int bitbuf; /* bit buffer */ int bitbuf; /* bit buffer */
@ -123,7 +129,8 @@ local int bits(struct state *s, int need)
/* load at least need bits into val */ /* load at least need bits into val */
val = s->bitbuf; val = s->bitbuf;
while (s->bitcnt < need) { while (s->bitcnt < need) {
if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */ if (s->incnt == s->inlen)
longjmp(s->env, 1); /* out of input */
val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */ val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */
s->bitcnt += 8; s->bitcnt += 8;
} }
@ -162,7 +169,8 @@ local int stored(struct state *s)
s->bitcnt = 0; s->bitcnt = 0;
/* get length and check against its one's complement */ /* get length and check against its one's complement */
if (s->incnt + 4 > s->inlen) return 2; /* not enough input */ if (s->incnt + 4 > s->inlen)
return 2; /* not enough input */
len = s->in[s->incnt++]; len = s->in[s->incnt++];
len |= s->in[s->incnt++] << 8; len |= s->in[s->incnt++] << 8;
if (s->in[s->incnt++] != (~len & 0xff) || if (s->in[s->incnt++] != (~len & 0xff) ||
@ -170,7 +178,8 @@ local int stored(struct state *s)
return -2; /* didn't match complement! */ return -2; /* didn't match complement! */
/* copy len bytes from in to out */ /* copy len bytes from in to out */
if (s->incnt + len > s->inlen) return 2; /* not enough input */ if (s->incnt + len > s->inlen)
return 2; /* not enough input */
if (s->out != NIL) { if (s->out != NIL) {
if (s->outcnt + len > s->outlen) if (s->outcnt + len > s->outlen)
return 1; /* not enough output space */ return 1; /* not enough output space */
@ -222,7 +231,7 @@ struct huffman {
* in the deflate format. See the format notes for fixed() and dynamic(). * in the deflate format. See the format notes for fixed() and dynamic().
*/ */
#ifdef SLOW #ifdef SLOW
local int decode(struct state *s, struct huffman *h) local int decode(struct state *s, const struct huffman *h)
{ {
int len; /* current number of bits in code */ int len; /* current number of bits in code */
int code; /* len bits being decoded */ int code; /* len bits being decoded */
@ -250,7 +259,7 @@ local int decode(struct state *s, struct huffman *h)
* a few percent larger. * a few percent larger.
*/ */
#else /* !SLOW */ #else /* !SLOW */
local int decode(struct state *s, struct huffman *h) local int decode(struct state *s, const struct huffman *h)
{ {
int len; /* current number of bits in code */ int len; /* current number of bits in code */
int code; /* len bits being decoded */ int code; /* len bits being decoded */
@ -283,10 +292,13 @@ local int decode(struct state *s, struct huffman *h)
len++; len++;
} }
left = (MAXBITS+1) - len; left = (MAXBITS+1) - len;
if (left == 0) break; if (left == 0)
if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */ break;
if (s->incnt == s->inlen)
longjmp(s->env, 1); /* out of input */
bitbuf = s->in[s->incnt++]; bitbuf = s->in[s->incnt++];
if (left > 8) left = 8; if (left > 8)
left = 8;
} }
return -10; /* ran out of codes */ return -10; /* ran out of codes */
} }
@ -324,7 +336,7 @@ local int decode(struct state *s, struct huffman *h)
* - Within a given code length, the symbols are kept in ascending order for * - Within a given code length, the symbols are kept in ascending order for
* the code bits definition. * the code bits definition.
*/ */
local int construct(struct huffman *h, short *length, int n) local int construct(struct huffman *h, const short *length, int n)
{ {
int symbol; /* current symbol when stepping through length[] */ int symbol; /* current symbol when stepping through length[] */
int len; /* current length when stepping through h->count[] */ int len; /* current length when stepping through h->count[] */
@ -344,7 +356,8 @@ local int construct(struct huffman *h, short *length, int n)
for (len = 1; len <= MAXBITS; len++) { for (len = 1; len <= MAXBITS; len++) {
left <<= 1; /* one more bit, double codes left */ left <<= 1; /* one more bit, double codes left */
left -= h->count[len]; /* deduct count from possible codes */ left -= h->count[len]; /* deduct count from possible codes */
if (left < 0) return left; /* over-subscribed--return negative */ if (left < 0)
return left; /* over-subscribed--return negative */
} /* left > 0 means incomplete */ } /* left > 0 means incomplete */
/* generate offsets into symbol table for each length for sorting */ /* generate offsets into symbol table for each length for sorting */
@ -420,8 +433,8 @@ local int construct(struct huffman *h, short *length, int n)
* defined to do the wrong thing in this case. * defined to do the wrong thing in this case.
*/ */
local int codes(struct state *s, local int codes(struct state *s,
struct huffman *lencode, const struct huffman *lencode,
struct huffman *distcode) const struct huffman *distcode)
{ {
int symbol; /* decoded symbol */ int symbol; /* decoded symbol */
int len; /* length for copy */ int len; /* length for copy */
@ -444,11 +457,13 @@ local int codes(struct state *s,
/* decode literals and length/distance pairs */ /* decode literals and length/distance pairs */
do { do {
symbol = decode(s, lencode); symbol = decode(s, lencode);
if (symbol < 0) return symbol; /* invalid symbol */ if (symbol < 0)
return symbol; /* invalid symbol */
if (symbol < 256) { /* literal: symbol is the byte */ if (symbol < 256) { /* literal: symbol is the byte */
/* write out the literal */ /* write out the literal */
if (s->out != NIL) { if (s->out != NIL) {
if (s->outcnt == s->outlen) return 1; if (s->outcnt == s->outlen)
return 1;
s->out[s->outcnt] = symbol; s->out[s->outcnt] = symbol;
} }
s->outcnt++; s->outcnt++;
@ -456,12 +471,14 @@ local int codes(struct state *s,
else if (symbol > 256) { /* length */ else if (symbol > 256) { /* length */
/* get and compute length */ /* get and compute length */
symbol -= 257; symbol -= 257;
if (symbol >= 29) return -10; /* invalid fixed code */ if (symbol >= 29)
return -10; /* invalid fixed code */
len = lens[symbol] + bits(s, lext[symbol]); len = lens[symbol] + bits(s, lext[symbol]);
/* get and check distance */ /* get and check distance */
symbol = decode(s, distcode); symbol = decode(s, distcode);
if (symbol < 0) return symbol; /* invalid symbol */ if (symbol < 0)
return symbol; /* invalid symbol */
dist = dists[symbol] + bits(s, dext[symbol]); dist = dists[symbol] + bits(s, dext[symbol]);
#ifndef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR #ifndef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
if (dist > s->outcnt) if (dist > s->outcnt)
@ -470,13 +487,15 @@ local int codes(struct state *s,
/* copy length bytes from distance bytes back */ /* copy length bytes from distance bytes back */
if (s->out != NIL) { if (s->out != NIL) {
if (s->outcnt + len > s->outlen) return 1; if (s->outcnt + len > s->outlen)
return 1;
while (len--) { while (len--) {
s->out[s->outcnt] = s->out[s->outcnt] =
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
dist > s->outcnt ? 0 : dist > s->outcnt ?
0 :
#endif #endif
s->out[s->outcnt - dist]; s->out[s->outcnt - dist];
s->outcnt++; s->outcnt++;
} }
} }
@ -525,6 +544,12 @@ local int fixed(struct state *s)
int symbol; int symbol;
short lengths[FIXLCODES]; short lengths[FIXLCODES];
/* construct lencode and distcode */
lencode.count = lencnt;
lencode.symbol = lensym;
distcode.count = distcnt;
distcode.symbol = distsym;
/* literal/length table */ /* literal/length table */
for (symbol = 0; symbol < 144; symbol++) for (symbol = 0; symbol < 144; symbol++)
lengths[symbol] = 8; lengths[symbol] = 8;
@ -541,12 +566,6 @@ local int fixed(struct state *s)
lengths[symbol] = 5; lengths[symbol] = 5;
construct(&distcode, lengths, MAXDCODES); construct(&distcode, lengths, MAXDCODES);
/* construct lencode and distcode */
lencode.count = lencnt;
lencode.symbol = lensym;
distcode.count = distcnt;
distcode.symbol = distsym;
/* do this just once */ /* do this just once */
virgin = 0; virgin = 0;
} }
@ -675,7 +694,8 @@ local int dynamic(struct state *s)
/* build huffman table for code lengths codes (use lencode temporarily) */ /* build huffman table for code lengths codes (use lencode temporarily) */
err = construct(&lencode, lengths, 19); err = construct(&lencode, lengths, 19);
if (err != 0) return -4; /* require complete code set here */ if (err != 0) /* require complete code set here */
return -4;
/* read length/literal and distance code length tables */ /* read length/literal and distance code length tables */
index = 0; index = 0;
@ -689,7 +709,8 @@ local int dynamic(struct state *s)
else { /* repeat instruction */ else { /* repeat instruction */
len = 0; /* assume repeating zeros */ len = 0; /* assume repeating zeros */
if (symbol == 16) { /* repeat last length 3..6 times */ if (symbol == 16) { /* repeat last length 3..6 times */
if (index == 0) return -5; /* no last length! */ if (index == 0)
return -5; /* no last length! */
len = lengths[index - 1]; /* last length */ len = lengths[index - 1]; /* last length */
symbol = 3 + bits(s, 2); symbol = 3 + bits(s, 2);
} }
@ -710,13 +731,13 @@ local int dynamic(struct state *s)
/* build huffman table for literal/length codes */ /* build huffman table for literal/length codes */
err = construct(&lencode, lengths, nlen); err = construct(&lencode, lengths, nlen);
if (err < 0 || (err > 0 && nlen - lencode.count[0] != 1)) if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1]))
return -7; /* only allow incomplete codes if just one code */ return -7; /* incomplete code ok only for single length 1 code */
/* build huffman table for distance codes */ /* build huffman table for distance codes */
err = construct(&distcode, lengths + nlen, ndist); err = construct(&distcode, lengths + nlen, ndist);
if (err < 0 || (err > 0 && ndist - distcode.count[0] != 1)) if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1]))
return -8; /* only allow incomplete codes if just one code */ return -8; /* incomplete code ok only for single length 1 code */
/* decode data until end-of-block code */ /* decode data until end-of-block code */
return codes(s, &lencode, &distcode); return codes(s, &lencode, &distcode);
@ -768,7 +789,7 @@ local int dynamic(struct state *s)
*/ */
int puff(unsigned char *dest, /* pointer to destination pointer */ int puff(unsigned char *dest, /* pointer to destination pointer */
unsigned long *destlen, /* amount of output space */ unsigned long *destlen, /* amount of output space */
unsigned char *source, /* pointer to source data pointer */ const unsigned char *source, /* pointer to source data pointer */
unsigned long *sourcelen) /* amount of input available */ unsigned long *sourcelen) /* amount of input available */
{ {
struct state s; /* input/output state */ struct state s; /* input/output state */
@ -795,11 +816,15 @@ int puff(unsigned char *dest, /* pointer to destination pointer */
do { do {
last = bits(&s, 1); /* one if last block */ last = bits(&s, 1); /* one if last block */
type = bits(&s, 2); /* block type 0..3 */ type = bits(&s, 2); /* block type 0..3 */
err = type == 0 ? stored(&s) : err = type == 0 ?
(type == 1 ? fixed(&s) : stored(&s) :
(type == 2 ? dynamic(&s) : (type == 1 ?
-1)); /* type == 3, invalid */ fixed(&s) :
if (err != 0) break; /* return with error */ (type == 2 ?
dynamic(&s) :
-1)); /* type == 3, invalid */
if (err != 0)
break; /* return with error */
} while (!last); } while (!last);
} }
@ -810,146 +835,3 @@ int puff(unsigned char *dest, /* pointer to destination pointer */
} }
return err; return err;
} }
#ifdef TEST
/* Examples of how to use puff().
Usage: puff [-w] [-nnn] file
... | puff [-w] [-nnn]
where file is the input file with deflate data, nnn is the number of bytes
of input to skip before inflating (e.g. to skip a zlib or gzip header), and
-w is used to write the decompressed data to stdout */
#include <stdio.h>
#include <stdlib.h>
/* Return size times approximately the cube root of 2, keeping the result as 1,
3, or 5 times a power of 2 -- the result is always > size, until the result
is the maximum value of an unsigned long, where it remains. This is useful
to keep reallocations less than ~33% over the actual data. */
local size_t bythirds(size_t size)
{
int n;
size_t m;
m = size;
for (n = 0; m; n++)
m >>= 1;
if (n < 3)
return size + 1;
n -= 3;
m = size >> n;
m += m == 6 ? 2 : 1;
m <<= n;
return m > size ? m : (size_t)(-1);
}
/* Read the input file *name, or stdin if name is NULL, into allocated memory.
Reallocate to larger buffers until the entire file is read in. Return a
pointer to the allocated data, or NULL if there was a memory allocation
failure. *len is the number of bytes of data read from the input file (even
if load() returns NULL). If the input file was empty or could not be opened
or read, *len is zero. */
local void *load(char *name, size_t *len)
{
size_t size;
void *buf, *swap;
FILE *in;
*len = 0;
buf = malloc(size = 4096);
if (buf == NULL)
return NULL;
in = name == NULL ? stdin : fopen(name, "rb");
if (in != NULL) {
for (;;) {
*len += fread((char *)buf + *len, 1, size - *len, in);
if (*len < size) break;
size = bythirds(size);
if (size == *len || (swap = realloc(buf, size)) == NULL) {
free(buf);
buf = NULL;
break;
}
buf = swap;
}
fclose(in);
}
return buf;
}
int main(int argc, char **argv)
{
int ret, put = 0;
unsigned skip = 0;
char *arg, *name = NULL;
unsigned char *source = NULL, *dest;
size_t len = 0;
unsigned long sourcelen, destlen;
/* process arguments */
while (arg = *++argv, --argc)
if (arg[0] == '-') {
if (arg[1] == 'w' && arg[2] == 0)
put = 1;
else if (arg[1] >= '0' && arg[1] <= '9')
skip = (unsigned)atoi(arg + 1);
else {
fprintf(stderr, "invalid option %s\n", arg);
return 3;
}
}
else if (name != NULL) {
fprintf(stderr, "only one file name allowed\n");
return 3;
}
else
name = arg;
source = load(name, &len);
if (source == NULL) {
fprintf(stderr, "memory allocation failure\n");
return 4;
}
if (len == 0) {
fprintf(stderr, "could not read %s, or it was empty\n",
name == NULL ? "<stdin>" : name);
free(source);
return 3;
}
if (skip >= len) {
fprintf(stderr, "skip request of %d leaves no input\n", skip);
free(source);
return 3;
}
/* test inflate data with offset skip */
len -= skip;
sourcelen = (unsigned long)len;
ret = puff(NIL, &destlen, source + skip, &sourcelen);
if (ret)
fprintf(stderr, "puff() failed with return code %d\n", ret);
else {
fprintf(stderr, "puff() succeeded uncompressing %lu bytes\n", destlen);
if (sourcelen < len) fprintf(stderr, "%lu compressed bytes unused\n",
len - sourcelen);
}
/* if requested, inflate again and write decompressd data to stdout */
if (put) {
dest = malloc(destlen);
if (dest == NULL) {
fprintf(stderr, "memory allocation failure\n");
free(source);
return 4;
}
puff(dest, &destlen, source + skip, &sourcelen);
fwrite(dest, 1, destlen, stdout);
free(dest);
}
/* clean up */
free(source);
return ret;
}
#endif

View File

@ -1,6 +1,6 @@
/* puff.h /* puff.h
Copyright (C) 2002-2010 Mark Adler, all rights reserved Copyright (C) 2002-2010 Mark Adler, all rights reserved
version 2.1, 4 Apr 2010 version 2.2, 25 Apr 2010
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages warranty. In no event will the author be held liable for any damages
@ -25,7 +25,11 @@
/* /*
* See puff.c for purpose and usage. * See puff.c for purpose and usage.
*/ */
#ifndef NIL
# define NIL ((unsigned char *)0) /* for no output option */
#endif
int puff(unsigned char *dest, /* pointer to destination pointer */ int puff(unsigned char *dest, /* pointer to destination pointer */
unsigned long *destlen, /* amount of output space */ unsigned long *destlen, /* amount of output space */
unsigned char *source, /* pointer to source data pointer */ const unsigned char *source, /* pointer to source data pointer */
unsigned long *sourcelen); /* amount of input available */ unsigned long *sourcelen); /* amount of input available */

165
contrib/puff/pufftest.c Normal file
View File

@ -0,0 +1,165 @@
/*
* pufftest.c
* Copyright (C) 2002-2010 Mark Adler
* For conditions of distribution and use, see copyright notice in puff.h
* version 2.2, 25 Apr 2010
*/
/* Example of how to use puff().
Usage: puff [-w] [-f] [-nnn] file
... | puff [-w] [-f] [-nnn]
where file is the input file with deflate data, nnn is the number of bytes
of input to skip before inflating (e.g. to skip a zlib or gzip header), and
-w is used to write the decompressed data to stdout. -f is for coverage
testing, and causes pufftest to fail with not enough output space (-f does
a write like -w, so -w is not required). */
#include <stdio.h>
#include <stdlib.h>
#include "puff.h"
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
# include <fcntl.h>
# include <io.h>
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
#else
# define SET_BINARY_MODE(file)
#endif
#define local static
/* Return size times approximately the cube root of 2, keeping the result as 1,
3, or 5 times a power of 2 -- the result is always > size, until the result
is the maximum value of an unsigned long, where it remains. This is useful
to keep reallocations less than ~33% over the actual data. */
local size_t bythirds(size_t size)
{
int n;
size_t m;
m = size;
for (n = 0; m; n++)
m >>= 1;
if (n < 3)
return size + 1;
n -= 3;
m = size >> n;
m += m == 6 ? 2 : 1;
m <<= n;
return m > size ? m : (size_t)(-1);
}
/* Read the input file *name, or stdin if name is NULL, into allocated memory.
Reallocate to larger buffers until the entire file is read in. Return a
pointer to the allocated data, or NULL if there was a memory allocation
failure. *len is the number of bytes of data read from the input file (even
if load() returns NULL). If the input file was empty or could not be opened
or read, *len is zero. */
local void *load(const char *name, size_t *len)
{
size_t size;
void *buf, *swap;
FILE *in;
*len = 0;
buf = malloc(size = 4096);
if (buf == NULL)
return NULL;
in = name == NULL ? stdin : fopen(name, "rb");
if (in != NULL) {
for (;;) {
*len += fread((char *)buf + *len, 1, size - *len, in);
if (*len < size) break;
size = bythirds(size);
if (size == *len || (swap = realloc(buf, size)) == NULL) {
free(buf);
buf = NULL;
break;
}
buf = swap;
}
fclose(in);
}
return buf;
}
int main(int argc, char **argv)
{
int ret, put = 0, fail = 0;
unsigned skip = 0;
char *arg, *name = NULL;
unsigned char *source = NULL, *dest;
size_t len = 0;
unsigned long sourcelen, destlen;
/* process arguments */
while (arg = *++argv, --argc)
if (arg[0] == '-') {
if (arg[1] == 'w' && arg[2] == 0)
put = 1;
else if (arg[1] == 'f' && arg[2] == 0)
fail = 1, put = 1;
else if (arg[1] >= '0' && arg[1] <= '9')
skip = (unsigned)atoi(arg + 1);
else {
fprintf(stderr, "invalid option %s\n", arg);
return 3;
}
}
else if (name != NULL) {
fprintf(stderr, "only one file name allowed\n");
return 3;
}
else
name = arg;
source = load(name, &len);
if (source == NULL) {
fprintf(stderr, "memory allocation failure\n");
return 4;
}
if (len == 0) {
fprintf(stderr, "could not read %s, or it was empty\n",
name == NULL ? "<stdin>" : name);
free(source);
return 3;
}
if (skip >= len) {
fprintf(stderr, "skip request of %d leaves no input\n", skip);
free(source);
return 3;
}
/* test inflate data with offset skip */
len -= skip;
sourcelen = (unsigned long)len;
ret = puff(NIL, &destlen, source + skip, &sourcelen);
if (ret)
fprintf(stderr, "puff() failed with return code %d\n", ret);
else {
fprintf(stderr, "puff() succeeded uncompressing %lu bytes\n", destlen);
if (sourcelen < len) fprintf(stderr, "%lu compressed bytes unused\n",
len - sourcelen);
}
/* if requested, inflate again and write decompressd data to stdout */
if (put && ret == 0) {
if (fail)
destlen >>= 1;
dest = malloc(destlen);
if (dest == NULL) {
fprintf(stderr, "memory allocation failure\n");
free(source);
return 4;
}
puff(dest, &destlen, source + skip, &sourcelen);
SET_BINARY_MODE(stdout);
fwrite(dest, 1, destlen, stdout);
free(dest);
}
/* clean up */
free(source);
return ret;
}

Binary file not shown.

View File

@ -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,2,5,0 FILEVERSION 1.2.5.1,1
PRODUCTVERSION 1,2,5,0 PRODUCTVERSION 1.2.5.1,1
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 and ZIP file I/O library\0" VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.2.5\0" VALUE "FileVersion", "1.2.5.1\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"

View File

@ -55,6 +55,7 @@ EXPORTS
gzungetc @49 gzungetc @49
zlibCompileFlags @50 zlibCompileFlags @50
deflatePrime @51 deflatePrime @51
deflatePending @52
unzOpen @61 unzOpen @61
unzClose @62 unzClose @62

View File

@ -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,2,5,0 FILEVERSION 1.2.5.1,1
PRODUCTVERSION 1,2,5,0 PRODUCTVERSION 1.2.5.1,1
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 and ZIP file I/O library\0" VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.2.5\0" VALUE "FileVersion", "1.2.5.1\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"

View File

@ -55,6 +55,7 @@ EXPORTS
gzungetc @49 gzungetc @49
zlibCompileFlags @50 zlibCompileFlags @50
deflatePrime @51 deflatePrime @51
deflatePending @52
unzOpen @61 unzOpen @61
unzClose @62 unzClose @62

31
crc32.c
View File

@ -1,5 +1,5 @@
/* crc32.c -- compute the CRC-32 of a data stream /* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995-2006, 2010 Mark Adler * Copyright (C) 1995-2006, 2010, 2011 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
* *
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
@ -17,6 +17,8 @@
of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
first call get_crc_table() to initialize the tables before allowing more than first call get_crc_table() to initialize the tables before allowing more than
one thread to use crc32(). one thread to use crc32().
DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
*/ */
#ifdef MAKECRCH #ifdef MAKECRCH
@ -53,6 +55,7 @@
/* Definitions for doing the crc four data bytes at a time. */ /* Definitions for doing the crc four data bytes at a time. */
#ifdef BYFOUR #ifdef BYFOUR
typedef u4 crc_table_t;
# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \ # define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
(((w)&0xff00)<<8)+(((w)&0xff)<<24)) (((w)&0xff00)<<8)+(((w)&0xff)<<24))
local unsigned long crc32_little OF((unsigned long, local unsigned long crc32_little OF((unsigned long,
@ -61,6 +64,7 @@
const unsigned char FAR *, unsigned)); const unsigned char FAR *, unsigned));
# define TBLS 8 # define TBLS 8
#else #else
typedef unsigned long crc_table_t;
# define TBLS 1 # define TBLS 1
#endif /* BYFOUR */ #endif /* BYFOUR */
@ -68,16 +72,16 @@
local unsigned long gf2_matrix_times OF((unsigned long *mat, local unsigned long gf2_matrix_times OF((unsigned long *mat,
unsigned long vec)); unsigned long vec));
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2); local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
#ifdef DYNAMIC_CRC_TABLE #ifdef DYNAMIC_CRC_TABLE
local volatile int crc_table_empty = 1; local volatile int crc_table_empty = 1;
local unsigned long FAR crc_table[TBLS][256]; local crc_table_t FAR crc_table[TBLS][256];
local void make_crc_table OF((void)); local void make_crc_table OF((void));
#ifdef MAKECRCH #ifdef MAKECRCH
local void write_table OF((FILE *, const unsigned long FAR *)); local void write_table OF((FILE *, const crc_table_t FAR *));
#endif /* MAKECRCH */ #endif /* MAKECRCH */
/* /*
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
@ -107,9 +111,9 @@ local void make_crc_table OF((void));
*/ */
local void make_crc_table() local void make_crc_table()
{ {
unsigned long c; crc_table_t c;
int n, k; int n, k;
unsigned long poly; /* polynomial exclusive-or pattern */ crc_table_t poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */ /* terms of polynomial defining this crc (except x^32): */
static volatile int first = 1; /* flag to limit concurrent making */ static volatile int first = 1; /* flag to limit concurrent making */
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
@ -121,13 +125,13 @@ local void make_crc_table()
first = 0; first = 0;
/* make exclusive-or pattern from polynomial (0xedb88320UL) */ /* make exclusive-or pattern from polynomial (0xedb88320UL) */
poly = 0UL; poly = 0;
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
poly |= 1UL << (31 - p[n]); poly |= (crc_table_t)1 << (31 - p[n]);
/* generate a crc for every 8-bit value */ /* generate a crc for every 8-bit value */
for (n = 0; n < 256; n++) { for (n = 0; n < 256; n++) {
c = (unsigned long)n; c = (crc_table_t)n;
for (k = 0; k < 8; k++) for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1; c = c & 1 ? poly ^ (c >> 1) : c >> 1;
crc_table[0][n] = c; crc_table[0][n] = c;
@ -164,7 +168,7 @@ local void make_crc_table()
if (out == NULL) return; if (out == NULL) return;
fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
fprintf(out, "local const unsigned long FAR "); fprintf(out, "local const crc_table_t FAR ");
fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
write_table(out, crc_table[0]); write_table(out, crc_table[0]);
# ifdef BYFOUR # ifdef BYFOUR
@ -184,12 +188,13 @@ local void make_crc_table()
#ifdef MAKECRCH #ifdef MAKECRCH
local void write_table(out, table) local void write_table(out, table)
FILE *out; FILE *out;
const unsigned long FAR *table; const crc_table_t FAR *table;
{ {
int n; int n;
for (n = 0; n < 256; n++) for (n = 0; n < 256; n++)
fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ",
(unsigned long)(table[n]),
n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
} }
#endif /* MAKECRCH */ #endif /* MAKECRCH */

View File

@ -2,7 +2,7 @@
* Generated automatically by crc32.c * Generated automatically by crc32.c
*/ */
local const unsigned long FAR crc_table[TBLS][256] = local const crc_table_t FAR crc_table[TBLS][256] =
{ {
{ {
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,

View File

@ -1,5 +1,5 @@
/* deflate.c -- compress data using the deflation algorithm /* deflate.c -- compress data using the deflation algorithm
* Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler * Copyright (C) 1995-2011 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -37,7 +37,7 @@
* REFERENCES * REFERENCES
* *
* Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
* Available in http://www.ietf.org/rfc/rfc1951.txt * Available in http://tools.ietf.org/html/rfc1951
* *
* A description of the Rabin and Karp algorithm is given in the book * A description of the Rabin and Karp algorithm is given in the book
* "Algorithms" by R. Sedgewick, Addison-Wesley, p252. * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
@ -52,7 +52,7 @@
#include "deflate.h" #include "deflate.h"
const char deflate_copyright[] = const char deflate_copyright[] =
" deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler "; " deflate 1.2.5.1 Copyright 1995-2010 Jean-loup Gailly and 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
@ -396,6 +396,18 @@ int ZEXPORT deflateSetHeader (strm, head)
return Z_OK; return Z_OK;
} }
/* ========================================================================= */
int ZEXPORT deflatePending (strm, pending, bits)
unsigned *pending;
int *bits;
z_streamp strm;
{
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
*pending = strm->state->pending;
*bits = strm->state->bi_valid;
return Z_OK;
}
/* ========================================================================= */ /* ========================================================================= */
int ZEXPORT deflatePrime (strm, bits, value) int ZEXPORT deflatePrime (strm, bits, value)
z_streamp strm; z_streamp strm;
@ -1001,15 +1013,15 @@ local int read_buf(strm, buf, size)
strm->avail_in -= len; strm->avail_in -= len;
zmemcpy(buf, strm->next_in, len);
if (strm->state->wrap == 1) { if (strm->state->wrap == 1) {
strm->adler = adler32(strm->adler, strm->next_in, len); strm->adler = adler32(strm->adler, buf, len);
} }
#ifdef GZIP #ifdef GZIP
else if (strm->state->wrap == 2) { else if (strm->state->wrap == 2) {
strm->adler = crc32(strm->adler, strm->next_in, len); strm->adler = crc32(strm->adler, buf, len);
} }
#endif #endif
zmemcpy(buf, strm->next_in, len);
strm->next_in += len; strm->next_in += len;
strm->total_in += len; strm->total_in += len;

View File

@ -188,7 +188,7 @@ typedef struct internal_state {
int nice_match; /* Stop searching when current match exceeds this */ int nice_match; /* Stop searching when current match exceeds this */
/* used by trees.c: */ /* used by trees.c: */
/* Didn't use ct_data typedef below to supress compiler warning */ /* Didn't use ct_data typedef below to suppress compiler warning */
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */

View File

@ -206,4 +206,4 @@ Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3,
pp. 337-343. pp. 337-343.
``DEFLATE Compressed Data Format Specification'' available in ``DEFLATE Compressed Data Format Specification'' available in
http://www.ietf.org/rfc/rfc1951.txt http://tools.ietf.org/html/rfc1951

View File

@ -1,5 +1,5 @@
/* example.c -- usage example of the zlib compression library /* example.c -- usage example of the zlib compression library
* Copyright (C) 1995-2006 Jean-loup Gailly. * Copyright (C) 1995-2006, 2011 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -438,7 +438,7 @@ void test_dict_deflate(compr, comprLen)
CHECK_ERR(err, "deflateInit"); CHECK_ERR(err, "deflateInit");
err = deflateSetDictionary(&c_stream, err = deflateSetDictionary(&c_stream,
(const Bytef*)dictionary, sizeof(dictionary)); (const Bytef*)dictionary, (int)sizeof(dictionary));
CHECK_ERR(err, "deflateSetDictionary"); CHECK_ERR(err, "deflateSetDictionary");
dictId = c_stream.adler; dictId = c_stream.adler;
@ -491,7 +491,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
exit(1); exit(1);
} }
err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary, err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
sizeof(dictionary)); (int)sizeof(dictionary));
} }
CHECK_ERR(err, "inflate with dict"); CHECK_ERR(err, "inflate with dict");
} }

View File

@ -91,6 +91,10 @@ local gzFile gz_open(path, fd, mode)
{ {
gz_statep state; gz_statep state;
/* check input */
if (path == NULL)
return NULL;
/* allocate gzFile structure to return */ /* allocate gzFile structure to return */
state = malloc(sizeof(gz_state)); state = malloc(sizeof(gz_state));
if (state == NULL) if (state == NULL)

View File

@ -1,5 +1,5 @@
/* gzwrite.c -- zlib functions for writing gzip files /* gzwrite.c -- zlib functions for writing gzip files
* Copyright (C) 2004, 2005, 2010 Mark Adler * Copyright (C) 2004, 2005, 2010, 2011 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -274,7 +274,7 @@ int ZEXPORT gzputs(file, str)
return ret == 0 && len != 0 ? -1 : ret; return ret == 0 && len != 0 ? -1 : ret;
} }
#ifdef STDC #if defined(STDC) || defined(Z_HAVE_STDARG_H)
#include <stdarg.h> #include <stdarg.h>
/* -- see zlib.h -- */ /* -- see zlib.h -- */
@ -346,7 +346,7 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
return len; return len;
} }
#else /* !STDC */ #else /* !STDC && !Z_HAVE_STDARG_H */
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
@ -366,6 +366,10 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
state = (gz_statep)file; state = (gz_statep)file;
strm = &(state->strm); strm = &(state->strm);
/* check that can really pass pointer in ints */
if (sizeof(int) != sizeof(void *))
return 0;
/* check that we're writing and that there's no error */ /* check that we're writing and that there's no error */
if (state->mode != GZ_WRITE || state->err != Z_OK) if (state->mode != GZ_WRITE || state->err != Z_OK)
return 0; return 0;

View File

@ -9,7 +9,7 @@
#define MAXBITS 15 #define MAXBITS 15
const char inflate_copyright[] = const char inflate_copyright[] =
" inflate 1.2.5 Copyright 1995-2010 Mark Adler "; " inflate 1.2.5.1 Copyright 1995-2010 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
@ -62,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; 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 */ 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, 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, 73, 195}; 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 205, 203};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 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, 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, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,

View File

@ -1,123 +0,0 @@
/******************************************************************************/
/* */
/* ZLIB */
/* */
/* Compile sources into modules and link them into a service program. */
/* */
/******************************************************************************/
PGM
/* Configuration adjustable parameters. */
DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10) +
VALUE('ZLIB') /* Source library. */
DCL VAR(&SRCFILE) TYPE(*CHAR) LEN(10) +
VALUE('SOURCES') /* Source member file. */
DCL VAR(&CTLFILE) TYPE(*CHAR) LEN(10) +
VALUE('TOOLS') /* Control member file. */
DCL VAR(&MODLIB) TYPE(*CHAR) LEN(10) +
VALUE('ZLIB') /* Module library. */
DCL VAR(&SRVLIB) TYPE(*CHAR) LEN(10) +
VALUE('LGPL') /* Service program library. */
DCL VAR(&CFLAGS) TYPE(*CHAR) +
VALUE('OPTIMIZE(40)') /* Compile options. */
/* Working storage. */
DCL VAR(&CMDLEN) TYPE(*DEC) LEN(15 5) VALUE(300) /* Command length. */
DCL VAR(&CMD) TYPE(*CHAR) LEN(512)
/* Compile sources into modules. */
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/ADLER32) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/COMPRESS) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/CRC32) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/DEFLATE) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/GZIO) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/INFBACK) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/INFFAST) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/INFLATE) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/INFTREES) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/TREES) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/UNCOMPR) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
'/ZUTIL) SRCFILE(' *TCAT +
&SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
/* Link modules into a service program. */
CRTSRVPGM SRVPGM(&SRVLIB/ZLIB) +
MODULE(&MODLIB/ADLER32 &MODLIB/COMPRESS +
&MODLIB/CRC32 &MODLIB/DEFLATE +
&MODLIB/GZIO &MODLIB/INFBACK +
&MODLIB/INFFAST &MODLIB/INFLATE +
&MODLIB/INFTREES &MODLIB/TREES +
&MODLIB/UNCOMPR &MODLIB/ZUTIL) +
SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) +
TEXT('ZLIB 1.2.3') TGTRLS(V4R4M0)
ENDPGM

View File

@ -25,10 +25,10 @@
<QPG:Files> <QPG:Files>
<QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/> <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="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../libz.so.1.2.5" install="/opt/lib/" user="root:bin" permission="644"/> <QPG:Add file="../libz.so.1.2.5.1" 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.5"/> <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.5.1"/>
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.5"/> <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.5.1"/>
<QPG:Add file="../libz.so.1.2.5" install="/opt/lib/" component="slib"/> <QPG:Add file="../libz.so.1.2.5.1" install="/opt/lib/" component="slib"/>
</QPG:Files> </QPG:Files>
<QPG:PackageFilter> <QPG:PackageFilter>
@ -63,7 +63,7 @@
</QPM:ProductDescription> </QPM:ProductDescription>
<QPM:ReleaseDescription> <QPM:ReleaseDescription>
<QPM:ReleaseVersion>1.2.5</QPM:ReleaseVersion> <QPM:ReleaseVersion>1.2.5.1</QPM:ReleaseVersion>
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
<QPM:ReleaseStability>Stable</QPM:ReleaseStability> <QPM:ReleaseStability>Stable</QPM:ReleaseStability>
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<package name="zlib" version="1.2.5"> <package name="zlib" version="1.2.5.1">
<library name="zlib" dlversion="1.2.5" dlname="z"> <library name="zlib" dlversion="1.2.5.1" dlname="z">
<property name="description"> zip compression library </property> <property name="description"> zip compression library </property>
<property name="include-target-dir" value="$(@PACKAGE/install-includedir)" /> <property name="include-target-dir" value="$(@PACKAGE/install-includedir)" />

View File

@ -25,7 +25,7 @@
STATICLIB = libz.a STATICLIB = libz.a
SHAREDLIB = zlib1.dll SHAREDLIB = zlib1.dll
IMPLIB = libzdll.a IMPLIB = libz.dll.a
# #
# Set to 1 if shared object needs to be installed # Set to 1 if shared object needs to be installed
@ -59,7 +59,7 @@ CP = cp -fp
INSTALL = $(CP) INSTALL = $(CP)
RM = rm -f RM = rm -f
prefix = /usr/local prefix ?= /usr/local
exec_prefix = $(prefix) exec_prefix = $(prefix)
OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \
@ -118,7 +118,7 @@ zlibrc.o: win32/zlib1.rc
install: zlib.h zconf.h $(STATICLIB) $(IMPLIB) install: zlib.h zconf.h $(STATICLIB) $(IMPLIB)
-@mkdir -p $(INCLUDE_PATH) -@mkdir -p $(INCLUDE_PATH)
-@mkdir -p $(LIBRARY_PATH) -@mkdir -p $(LIBRARY_PATH) $(LIBRARY_PATH)/pkgconfig
-if [ "$(SHARED_MODE)" = "1" ]; then \ -if [ "$(SHARED_MODE)" = "1" ]; then \
mkdir -p $(BINARY_PATH); \ mkdir -p $(BINARY_PATH); \
$(INSTALL) $(SHAREDLIB) $(BINARY_PATH); \ $(INSTALL) $(SHAREDLIB) $(BINARY_PATH); \
@ -127,6 +127,14 @@ install: zlib.h zconf.h $(STATICLIB) $(IMPLIB)
-$(INSTALL) zlib.h $(INCLUDE_PATH) -$(INSTALL) zlib.h $(INCLUDE_PATH)
-$(INSTALL) zconf.h $(INCLUDE_PATH) -$(INSTALL) zconf.h $(INCLUDE_PATH)
-$(INSTALL) $(STATICLIB) $(LIBRARY_PATH) -$(INSTALL) $(STATICLIB) $(LIBRARY_PATH)
sed \
-e 's|@prefix@|${prefix}|g' \
-e 's|@exec_prefix@|${exec_prefix}|g' \
-e 's|@libdir@|$(LIBRARY_PATH)|g' \
-e 's|@sharedlibdir@|$(LIBRARY_PATH)|g' \
-e 's|@includedir@|$(INCLUDE_PATH)|g' \
-e 's|@VERSION@|'`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' zlib.h`'|g' \
zlib.pc.in > $(LIBRARY_PATH)/pkgconfig/zlib.pc
uninstall: uninstall:
-if [ "$(SHARED_MODE)" = "1" ]; then \ -if [ "$(SHARED_MODE)" = "1" ]; then \

View File

@ -30,7 +30,7 @@ ARFLAGS = -nologo
RCFLAGS = /dWIN32 /r RCFLAGS = /dWIN32 /r
OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj \ OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj \
gzwrite.obj infback.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj
OBJA = OBJA =

View File

@ -15,6 +15,7 @@ EXPORTS
deflateParams deflateParams
deflateTune deflateTune
deflateBound deflateBound
deflatePending
deflatePrime deflatePrime
deflateSetHeader deflateSetHeader
inflateSetDictionary inflateSetDictionary

22
zconf.h
View File

@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library /* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2010 Jean-loup Gailly. * Copyright (C) 1995-2011 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -15,6 +15,7 @@
* this permanently in zconf.h using "./configure --zprefix". * this permanently in zconf.h using "./configure --zprefix".
*/ */
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
/* all linked symbols */ /* all linked symbols */
# define _dist_code z__dist_code # define _dist_code z__dist_code
@ -40,6 +41,7 @@
# define deflateInit2_ z_deflateInit2_ # define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_ # define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams # define deflateParams z_deflateParams
# define deflatePending z_deflatePending
# define deflatePrime z_deflatePrime # define deflatePrime z_deflatePrime
# define deflateReset z_deflateReset # define deflateReset z_deflateReset
# define deflateSetDictionary z_deflateSetDictionary # define deflateSetDictionary z_deflateSetDictionary
@ -243,6 +245,14 @@
# endif # endif
#endif #endif
#ifndef ON /* function prototypes for stdarg */
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
# define ON(args) args
# else
# define ON(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed /* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations). * model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have * This was tested only with MSC; for other MSDOS compilers you may have
@ -360,6 +370,10 @@ typedef uLong FAR uLongf;
# define Z_HAVE_UNISTD_H # define Z_HAVE_UNISTD_H
#endif #endif
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_STDARG_H
#endif
#ifdef STDC #ifdef STDC
# include <sys/types.h> /* for off_t */ # include <sys/types.h> /* for off_t */
#endif #endif
@ -374,7 +388,11 @@ typedef uLong FAR uLongf;
# undef _LARGEFILE64_SOURCE # undef _LARGEFILE64_SOURCE
#endif #endif
#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
# define Z_LARGE
#endif
#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)
# include <unistd.h> /* for SEEK_* and off_t */ # include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS # ifdef VMS
# include <unixio.h> /* for off_t */ # include <unixio.h> /* for off_t */

View File

@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library /* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2010 Jean-loup Gailly. * Copyright (C) 1995-2011 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -17,6 +17,7 @@
* this permanently in zconf.h using "./configure --zprefix". * this permanently in zconf.h using "./configure --zprefix".
*/ */
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
/* all linked symbols */ /* all linked symbols */
# define _dist_code z__dist_code # define _dist_code z__dist_code
@ -42,6 +43,7 @@
# define deflateInit2_ z_deflateInit2_ # define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_ # define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams # define deflateParams z_deflateParams
# define deflatePending z_deflatePending
# define deflatePrime z_deflatePrime # define deflatePrime z_deflatePrime
# define deflateReset z_deflateReset # define deflateReset z_deflateReset
# define deflateSetDictionary z_deflateSetDictionary # define deflateSetDictionary z_deflateSetDictionary
@ -245,6 +247,14 @@
# endif # endif
#endif #endif
#ifndef ON /* function prototypes for stdarg */
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
# define ON(args) args
# else
# define ON(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed /* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations). * model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have * This was tested only with MSC; for other MSDOS compilers you may have
@ -362,6 +372,10 @@ typedef uLong FAR uLongf;
# define Z_HAVE_UNISTD_H # define Z_HAVE_UNISTD_H
#endif #endif
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_STDARG_H
#endif
#ifdef STDC #ifdef STDC
# include <sys/types.h> /* for off_t */ # include <sys/types.h> /* for off_t */
#endif #endif
@ -376,7 +390,11 @@ typedef uLong FAR uLongf;
# undef _LARGEFILE64_SOURCE # undef _LARGEFILE64_SOURCE
#endif #endif
#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
# define Z_LARGE
#endif
#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)
# include <unistd.h> /* for SEEK_* and off_t */ # include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS # ifdef VMS
# include <unixio.h> /* for off_t */ # include <unixio.h> /* for off_t */

View File

@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library /* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2010 Jean-loup Gailly. * Copyright (C) 1995-2011 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -15,6 +15,7 @@
* this permanently in zconf.h using "./configure --zprefix". * this permanently in zconf.h using "./configure --zprefix".
*/ */
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
/* all linked symbols */ /* all linked symbols */
# define _dist_code z__dist_code # define _dist_code z__dist_code
@ -40,6 +41,7 @@
# define deflateInit2_ z_deflateInit2_ # define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_ # define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams # define deflateParams z_deflateParams
# define deflatePending z_deflatePending
# define deflatePrime z_deflatePrime # define deflatePrime z_deflatePrime
# define deflateReset z_deflateReset # define deflateReset z_deflateReset
# define deflateSetDictionary z_deflateSetDictionary # define deflateSetDictionary z_deflateSetDictionary
@ -243,6 +245,14 @@
# endif # endif
#endif #endif
#ifndef ON /* function prototypes for stdarg */
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
# define ON(args) args
# else
# define ON(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed /* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations). * model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have * This was tested only with MSC; for other MSDOS compilers you may have
@ -360,6 +370,10 @@ typedef uLong FAR uLongf;
# define Z_HAVE_UNISTD_H # define Z_HAVE_UNISTD_H
#endif #endif
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_STDARG_H
#endif
#ifdef STDC #ifdef STDC
# include <sys/types.h> /* for off_t */ # include <sys/types.h> /* for off_t */
#endif #endif
@ -374,7 +388,11 @@ typedef uLong FAR uLongf;
# undef _LARGEFILE64_SOURCE # undef _LARGEFILE64_SOURCE
#endif #endif
#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
# define Z_LARGE
#endif
#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)
# include <unistd.h> /* for SEEK_* and off_t */ # include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS # ifdef VMS
# include <unixio.h> /* for off_t */ # include <unixio.h> /* for off_t */

12
zlib.3
View File

@ -1,4 +1,4 @@
.TH ZLIB 3 "19 Apr 2010" .TH ZLIB 3 "10 Sep 2011"
.SH NAME .SH NAME
zlib \- compression/decompression library zlib \- compression/decompression library
.SH SYNOPSIS .SH SYNOPSIS
@ -95,11 +95,11 @@ http://zlib.net/
The data format used by the zlib library is described by RFC The data format used by the zlib library is described by RFC
(Request for Comments) 1950 to 1952 in the files: (Request for Comments) 1950 to 1952 in the files:
.IP .IP
http://www.ietf.org/rfc/rfc1950.txt (for the zlib header and trailer format) http://tools.ietf.org/html/rfc1950 (for the zlib header and trailer format)
.br .br
http://www.ietf.org/rfc/rfc1951.txt (for the deflate compressed data format) http://tools.ietf.org/html/rfc1951 (for the deflate compressed data format)
.br .br
http://www.ietf.org/rfc/rfc1952.txt (for the gzip header and trailer format) http://tools.ietf.org/html/rfc1952 (for the gzip header and trailer format)
.LP .LP
Mark Nelson wrote an article about Mark Nelson wrote an article about
.I zlib .I zlib
@ -125,8 +125,8 @@ before asking for help.
Send questions and/or comments to zlib@gzip.org, Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
.SH AUTHORS .SH AUTHORS
Version 1.2.5 Version 1.2.5.1
Copyright (C) 1995-2010 Jean-loup Gailly (jloup@gzip.org) Copyright (C) 1995-2011 Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu). and Mark Adler (madler@alumni.caltech.edu).
.LP .LP
This software is provided "as-is," This software is provided "as-is,"

Binary file not shown.

108
zlib.h
View File

@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library /* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.5, April 19th, 2010 version 1.2.5.1, September 10th, 2011
Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler Copyright (C) 1995-2011 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -24,8 +24,8 @@
The data format used by the zlib library is described by RFCs (Request for 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 Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
*/ */
#ifndef ZLIB_H #ifndef ZLIB_H
@ -37,12 +37,12 @@
extern "C" { extern "C" {
#endif #endif
#define ZLIB_VERSION "1.2.5" #define ZLIB_VERSION "1.2.5.1"
#define ZLIB_VERNUM 0x1250 #define ZLIB_VERNUM 0x1251
#define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2 #define ZLIB_VER_MINOR 2
#define ZLIB_VER_REVISION 5 #define ZLIB_VER_REVISION 5
#define ZLIB_VER_SUBREVISION 0 #define ZLIB_VER_SUBREVISION 1
/* /*
The 'zlib' compression library provides in-memory compression and The 'zlib' compression library provides in-memory compression and
@ -85,11 +85,11 @@ struct internal_state;
typedef struct z_stream_s { typedef struct z_stream_s {
Bytef *next_in; /* next input byte */ Bytef *next_in; /* next input byte */
uInt avail_in; /* number of bytes available at next_in */ uInt avail_in; /* number of bytes available at next_in */
uLong total_in; /* total nb of input bytes read so far */ uLong total_in; /* total number of input bytes read so far */
Bytef *next_out; /* next output byte should be put there */ Bytef *next_out; /* next output byte should be put there */
uInt avail_out; /* remaining free space at next_out */ uInt avail_out; /* remaining free space at next_out */
uLong total_out; /* total nb of bytes output so far */ uLong total_out; /* total number of bytes output so far */
char *msg; /* last error message, NULL if no error */ char *msg; /* last error message, NULL if no error */
struct internal_state FAR *state; /* not visible by applications */ struct internal_state FAR *state; /* not visible by applications */
@ -327,8 +327,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
Z_FINISH can be used immediately after deflateInit if all the compression Z_FINISH can be used immediately after deflateInit if all the compression
is to be done in a single step. In this case, avail_out must be at least the is to be done in a single step. In this case, avail_out must be at least the
value returned by deflateBound (see below). If deflate does not return value returned by deflateBound (see below). Then deflate is guaranteed to
Z_STREAM_END, then it must be called again as described above. return Z_STREAM_END. If not enough output space is provided, deflate will
not return Z_STREAM_END, and it must be called again as described above.
deflate() sets strm->adler to the adler32 checksum of all input read deflate() sets strm->adler to the adler32 checksum of all input read
so far (that is, total_in bytes). so far (that is, total_in bytes).
@ -688,8 +689,27 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
deflation of sourceLen bytes. It must be called after deflateInit() or deflation of sourceLen bytes. It must be called after deflateInit() or
deflateInit2(), and after deflateSetHeader(), if used. This would be used deflateInit2(), and after deflateSetHeader(), if used. This would be used
to allocate an output buffer for deflation in a single pass, and so would be to allocate an output buffer for deflation in a single pass, and so would be
called before deflate(). called before deflate(). If that first deflate() call is provided the
sourceLen input bytes, an output buffer allocated to the size returned by
deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
to return Z_STREAM_END. Note that it is possible for the compressed size to
be larger than the value returned by deflateBound() if flush options other
than Z_FINISH or Z_NO_FLUSH are used.
*/ */
ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
unsigned *pending,
int *bits));
/*
deflatePending() returns the number of bytes and bits of output that have
been generated, but not yet provided in the available output. The bytes not
provided would be due to the available output space having being consumed.
The number of bits of output not provided are between 0 and 7, where they
await more bits to join them in order to fill out a full byte.
deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent.
*/
ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
int bits, int bits,
@ -805,17 +825,21 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
ZEXTERN 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 possible full flush point (see above
description of deflate with Z_FULL_FLUSH) can be found, or until all for the description of deflate with Z_FULL_FLUSH) can be found, or until all
available input is skipped. No output is provided. available input is skipped. No output is provided.
inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR inflateSync searches for a 00 00 FF FF pattern in the compressed data.
if no more input was provided, Z_DATA_ERROR if no flush point has been All full flush points have this pattern, but not all occurences of this
found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the pattern are full flush points.
success case, the application may save the current current value of total_in
which indicates where valid compressed data was found. In the error case, inflateSync returns Z_OK if a possible full flush point has been found,
the application may repeatedly call inflateSync, providing more input each Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
time, until success or end of the input data. has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
In the success case, the application may save the current current value of
total_in which indicates where valid compressed data was found. In the
error case, the application may repeatedly call inflateSync, providing more
input each time, until success or end of the input data.
*/ */
ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
@ -962,7 +986,7 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
See inflateBack() for the usage of these routines. See inflateBack() for the usage of these routines.
inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
the paramaters are invalid, Z_MEM_ERROR if the internal state could not be the parameters are invalid, Z_MEM_ERROR if the internal state could not be
allocated, or Z_VERSION_ERROR if the version of the library does not match allocated, or Z_VERSION_ERROR if the version of the library does not match
the version of the header file. the version of the header file.
*/ */
@ -1256,7 +1280,7 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
error. error.
*/ */
ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); ZEXTERN int ZEXPORTVA gzprintf ON((gzFile file, const char *format, ...));
/* /*
Converts, formats, and writes the arguments to the compressed file under Converts, formats, and writes the arguments 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
@ -1492,7 +1516,9 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note
that the z_off_t type (like off_t) is a signed integer. If len2 is
negative, the result has no meaning or utility.
*/ */
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
@ -1544,17 +1570,18 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
const char *version, const char *version,
int stream_size)); int stream_size));
#define deflateInit(strm, level) \ #define deflateInit(strm, level) \
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
#define inflateInit(strm) \ #define inflateInit(strm) \
inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
(strategy), ZLIB_VERSION, sizeof(z_stream)) (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
#define inflateInit2(strm, windowBits) \ #define inflateInit2(strm, windowBits) \
inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
(int)sizeof(z_stream))
#define inflateBackInit(strm, windowBits, window) \ #define inflateBackInit(strm, windowBits, window) \
inflateBackInit_((strm), (windowBits), (window), \ inflateBackInit_((strm), (windowBits), (window), \
ZLIB_VERSION, sizeof(z_stream)) ZLIB_VERSION, (int)sizeof(z_stream))
/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
* change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
@ -1572,13 +1599,22 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
#endif #endif
#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 #if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
# define gzopen gzopen64 # ifdef Z_PREFIX_SET
# define gzseek gzseek64 # define z_gzopen z_gzopen64
# define gztell gztell64 # define z_gzseek z_gzseek64
# define gzoffset gzoffset64 # define z_gztell z_gztell64
# define adler32_combine adler32_combine64 # define z_gzoffset z_gzoffset64
# define crc32_combine crc32_combine64 # define z_adler32_combine z_adler32_combine64
# ifdef _LARGEFILE64_SOURCE # define z_crc32_combine z_crc32_combine64
# else
# define gzopen gzopen64
# define gzseek gzseek64
# define gztell gztell64
# define gzoffset gzoffset64
# define adler32_combine adler32_combine64
# define crc32_combine crc32_combine64
# endif
# ifndef _LARGEFILE64_SOURCE
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));

View File

@ -66,3 +66,7 @@ ZLIB_1.2.3.5 {
gzclose_r; gzclose_r;
gzclose_w; gzclose_w;
} ZLIB_1.2.3.4; } ZLIB_1.2.3.4;
ZLIB_1.2.5.1 {
deflatePending;
} ZLIB_1.2.5;

View File

@ -1,5 +1,5 @@
/* zutil.c -- target dependent utility functions for the compression library /* zutil.c -- target dependent utility functions for the compression library
* Copyright (C) 1995-2005, 2010 Jean-loup Gailly. * Copyright (C) 1995-2005, 2010, 2011 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
@ -85,7 +85,7 @@ uLong ZEXPORT zlibCompileFlags()
#ifdef FASTEST #ifdef FASTEST
flags += 1L << 21; flags += 1L << 21;
#endif #endif
#ifdef STDC #if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifdef NO_vsnprintf # ifdef NO_vsnprintf
flags += 1L << 25; flags += 1L << 25;
# ifdef HAS_vsprintf_void # ifdef HAS_vsprintf_void