summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog47
-rw-r--r--FAQ8
-rw-r--r--INDEX1
-rw-r--r--Makefile.in26
-rw-r--r--README10
-rw-r--r--adler32.c68
-rw-r--r--as400/bndsrc (renamed from old/as400/bndsrc)51
-rw-r--r--as400/compile.clp110
-rw-r--r--as400/readme.txt (renamed from old/as400/readme.txt)10
-rw-r--r--as400/zlib.inc (renamed from old/as400/zlib.inc)102
-rwxr-xr-xconfigure41
-rw-r--r--contrib/asm686/match.S16
-rw-r--r--contrib/delphi/ZLib.pas2
-rw-r--r--contrib/dotzlib/DotZLib/UnitTests.cs2
-rw-r--r--contrib/infback9/inftree9.c4
-rw-r--r--contrib/masmx86/inffas32.asm9
-rw-r--r--contrib/masmx86/match686.asm1
-rw-r--r--contrib/minizip/ioapi.c18
-rw-r--r--contrib/minizip/ioapi.h3
-rw-r--r--contrib/minizip/miniunz.c38
-rw-r--r--contrib/minizip/minizip.c39
-rw-r--r--contrib/minizip/unzip.c2
-rw-r--r--contrib/pascal/zlibpas.pas4
-rw-r--r--contrib/puff/Makefile40
-rw-r--r--contrib/puff/puff.c252
-rw-r--r--contrib/puff/puff.h8
-rw-r--r--contrib/puff/pufftest.c165
-rw-r--r--contrib/puff/zeros.rawbin1213 -> 2517 bytes
-rw-r--r--contrib/vstudio/vc10/zlib.rc6
-rw-r--r--contrib/vstudio/vc10/zlibvc.def1
-rw-r--r--contrib/vstudio/vc9/zlib.rc6
-rw-r--r--contrib/vstudio/vc9/zlibvc.def1
-rw-r--r--crc32.c31
-rw-r--r--crc32.h2
-rw-r--r--deflate.c24
-rw-r--r--deflate.h2
-rw-r--r--doc/algorithm.txt2
-rw-r--r--example.c6
-rw-r--r--gzlib.c4
-rw-r--r--gzwrite.c10
-rw-r--r--inftrees.c4
-rw-r--r--old/as400/compile.clp123
-rw-r--r--qnx/package.qpg10
-rw-r--r--treebuild.xml4
-rw-r--r--win32/Makefile.gcc14
-rw-r--r--win32/Makefile.msc2
-rw-r--r--win32/zlib.def1
-rw-r--r--zconf.h22
-rw-r--r--zconf.h.cmakein22
-rw-r--r--zconf.h.in22
-rw-r--r--zlib.312
-rw-r--r--zlib.3.pdfbin8686 -> 8713 bytes
-rw-r--r--zlib.h110
-rw-r--r--zlib.map4
-rw-r--r--zutil.c4
55 files changed, 1004 insertions, 522 deletions
diff --git a/ChangeLog b/ChangeLog
index f310bb0..a4e5384 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,57 @@
1 1
2 ChangeLog file for zlib 2 ChangeLog file for zlib
3 3
4Changes in 1.2.5.1 (10 Sep 2011)
5- Update FAQ entry on shared builds (#13)
6- Avoid symbolic argument to chmod in Makefile.in
7- Fix bug and add consts in contrib/puff [Oberhumer]
8- Update contrib/puff/zeros.raw test file to have all block types
9- Add full coverage test for puff in contrib/puff/Makefile
10- Fix static-only-build install in Makefile.in
11- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno]
12- Add libz.a dependency to shared in Makefile.in for parallel builds
13- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out
14- Replace $(...) with `...` in configure for non-bash sh [Bowler]
15- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen]
16- Add solaris* to Linux* in configure to allow gcc use [Groffen]
17- Add *bsd* to Linux* case in configure [Bar-Lev]
18- Add inffast.obj to dependencies in win32/Makefile.msc
19- Correct spelling error in deflate.h [Kohler]
20- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc
21- Add test to configure for GNU C looking for gcc in output of $cc -v
22- Add zlib.pc generation to win32/Makefile.gcc [Weigelt]
23- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not
24- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense
25- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser)
26- Make stronger test in zconf.h to include unistd.h for LFS
27- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack]
28- Fix zlib.h LFS support when Z_PREFIX used
29- Add updated as400 support (removed from old) [Monnerat]
30- Avoid deflate sensitivity to volatile input data
31- Avoid division in adler32_combine for NO_DIVIDE
32- Clarify the use of Z_FINISH with deflateBound() amount of space
33- Set binary for output file in puff.c
34- Use u4 type for crc_table to avoid conversion warnings
35- Apply casts in zlib.h to avoid conversion warnings
36- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller]
37- Improve inflateSync() documentation to note indeterminancy
38- Add deflatePending() function to return the amount of pending output
39- Correct the spelling of "specification" in FAQ [Randers-Pehrson]
40- Add a check in configure for stdarg.h, use for gzprintf()
41- Check that pointers fit in ints when gzprint() compiled old style
42- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler]
43- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt]
44- Add debug records in assmebler code [Londer]
45- Update RFC references to use http://tools.ietf.org/html/... [Li]
46- Add --archs option, use of libtool to configure for Mac OS X [Borstel]
47
4Changes in 1.2.5 (19 Apr 2010) 48Changes in 1.2.5 (19 Apr 2010)
5- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] 49- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev]
6- Default to libdir as sharedlibdir in configure [Nieder] 50- Default to libdir as sharedlibdir in configure [Nieder]
7- Update copyright dates on modified source files 51- Update copyright dates on modified source files
8- Update trees.c to be able to generate modified trees.h 52- Update trees.c to be able to generate modified trees.h
9- Exit configure for MinGW, suggesting win32/Makefile.gcc 53- Exit configure for MinGW, suggesting win32/Makefile.gcc
54- Check for NULL path in gz_open [Homurlu]
10 55
11Changes in 1.2.4.5 (18 Apr 2010) 56Changes in 1.2.4.5 (18 Apr 2010)
12- Set sharedlibdir in configure [Torok] 57- Set sharedlibdir in configure [Torok]
@@ -261,7 +306,7 @@ Changes in 1.2.3.4 (21 Dec 2009)
261- Clear bytes after deflate lookahead to avoid use of uninitialized data 306- Clear bytes after deflate lookahead to avoid use of uninitialized data
262- Change a limit in inftrees.c to be more transparent to Coverity Prevent 307- Change a limit in inftrees.c to be more transparent to Coverity Prevent
263- Update win32/zlib.def with exported symbols from zlib.h 308- Update win32/zlib.def with exported symbols from zlib.h
264- Correct spelling error in zlib.h [Willem] 309- Correct spelling errors in zlib.h [Willem, Sobrado]
265- Allow Z_BLOCK for deflate() to force a new block 310- Allow Z_BLOCK for deflate() to force a new block
266- Allow negative bits in inflatePrime() to delete existing bit buffer 311- Allow negative bits in inflatePrime() to delete existing bit buffer
267- Add Z_TREES flush option to inflate() to return at end of trees 312- Add Z_TREES flush option to inflate() to return at end of trees
diff --git a/FAQ b/FAQ
index 1a22750..03676dd 100644
--- a/FAQ
+++ b/FAQ
@@ -84,8 +84,10 @@ The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
84 84
8513. How can I make a Unix shared library? 8513. How can I make a Unix shared library?
86 86
87 make clean 87 By default a shared (and a static) library is built for Unix. So:
88 ./configure -s 88
89 make distclean
90 ./configure
89 make 91 make
90 92
9114. How do I install a shared zlib library on Unix? 9314. 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
325 correctly points to the zlib specification in RFC 1950 for the "deflate" 327 correctly points to the zlib specification in RFC 1950 for the "deflate"
326 transfer encoding, there have been reports of servers and browsers that 328 transfer encoding, there have been reports of servers and browsers that
327 incorrectly produce or expect raw deflate data per the deflate 329 incorrectly produce or expect raw deflate data per the deflate
328 specficiation in RFC 1951, most notably Microsoft. So even though the 330 specification in RFC 1951, most notably Microsoft. So even though the
329 "deflate" transfer encoding using the zlib format would be the more 331 "deflate" transfer encoding using the zlib format would be the more
330 efficient approach (and in fact exactly what the zlib format was designed 332 efficient approach (and in fact exactly what the zlib format was designed
331 for), using the "gzip" transfer encoding is probably more reliable due to 333 for), using the "gzip" transfer encoding is probably more reliable due to
diff --git a/INDEX b/INDEX
index f6c51ca..791f6ab 100644
--- a/INDEX
+++ b/INDEX
@@ -17,6 +17,7 @@ zlib.pc.in Template for pkg-config descriptor
17zlib2ansi perl script to convert source files for C++ compilation 17zlib2ansi perl script to convert source files for C++ compilation
18 18
19amiga/ makefiles for Amiga SAS C 19amiga/ makefiles for Amiga SAS C
20as400/ makefiles for AS/400
20doc/ documentation for formats and algorithms 21doc/ documentation for formats and algorithms
21msdos/ makefiles for MSDOS 22msdos/ makefiles for MSDOS
22nintendods/ makefile for Nintendo DS 23nintendods/ makefile for Nintendo DS
diff --git a/Makefile.in b/Makefile.in
index 5b15bd0..861970d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,5 +1,5 @@
1# Makefile for zlib 1# Makefile for zlib
2# Copyright (C) 1995-2010 Jean-loup Gailly. 2# Copyright (C) 1995-2011 Jean-loup Gailly.
3# For conditions of distribution and use, see copyright notice in zlib.h 3# For conditions of distribution and use, see copyright notice in zlib.h
4 4
5# To compile and test, type: 5# To compile and test, type:
@@ -32,7 +32,7 @@ CPP=$(CC) -E
32 32
33STATICLIB=libz.a 33STATICLIB=libz.a
34SHAREDLIB=libz.so 34SHAREDLIB=libz.so
35SHAREDLIBV=libz.so.1.2.5 35SHAREDLIBV=libz.so.1.2.5.1
36SHAREDLIBM=libz.so.1 36SHAREDLIBM=libz.so.1
37LIBS=$(STATICLIB) $(SHAREDLIBV) 37LIBS=$(STATICLIB) $(SHAREDLIBV)
38 38
@@ -136,7 +136,7 @@ minigzip64.o: minigzip.c zlib.h zconf.h
136 $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $< 136 $(CC) $(SFLAGS) -DPIC -c -o objs/$*.o $<
137 -@mv objs/$*.o $@ 137 -@mv objs/$*.o $@
138 138
139$(SHAREDLIBV): $(PIC_OBJS) 139placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
140 $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS) 140 $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
141 rm -f $(SHAREDLIB) $(SHAREDLIBM) 141 rm -f $(SHAREDLIB) $(SHAREDLIBM)
142 ln -s $@ $(SHAREDLIB) 142 ln -s $@ $(SHAREDLIB)
@@ -168,14 +168,16 @@ install-libs: $(LIBS)
168 -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi 168 -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
169 -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi 169 -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
170 cp $(STATICLIB) $(DESTDIR)$(libdir) 170 cp $(STATICLIB) $(DESTDIR)$(libdir)
171 cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir) 171 chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
172 cd $(DESTDIR)$(libdir); chmod u=rw,go=r $(STATICLIB) 172 -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
173 -@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1 173 -@if test -n "$(SHAREDLIBV)"; then \
174 -@cd $(DESTDIR)$(sharedlibdir); if test "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ 174 cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
175 chmod 755 $(SHAREDLIBV); \ 175 echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
176 rm -f $(SHAREDLIB) $(SHAREDLIBM); \ 176 chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
177 ln -s $(SHAREDLIBV) $(SHAREDLIB); \ 177 echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
178 ln -s $(SHAREDLIBV) $(SHAREDLIBM); \ 178 rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
179 ln -s $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
180 ln -s $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
179 ($(LDCONFIG) || true) >/dev/null 2>&1; \ 181 ($(LDCONFIG) || true) >/dev/null 2>&1; \
180 fi 182 fi
181 cp zlib.3 $(DESTDIR)$(man3dir) 183 cp zlib.3 $(DESTDIR)$(man3dir)
@@ -193,7 +195,7 @@ install: install-libs
193uninstall: 195uninstall:
194 cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h 196 cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
195 cd $(DESTDIR)$(libdir); rm -f libz.a; \ 197 cd $(DESTDIR)$(libdir); rm -f libz.a; \
196 if test "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ 198 if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
197 rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ 199 rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
198 fi 200 fi
199 cd $(DESTDIR)$(man3dir); rm -f zlib.3 201 cd $(DESTDIR)$(man3dir); rm -f zlib.3
diff --git a/README b/README
index d4219bf..7870cc2 100644
--- a/README
+++ b/README
@@ -1,10 +1,10 @@
1ZLIB DATA COMPRESSION LIBRARY 1ZLIB DATA COMPRESSION LIBRARY
2 2
3zlib 1.2.5 is a general purpose data compression library. All the code is 3zlib 1.2.5.1 is a general purpose data compression library. All the code is
4thread safe. The data format used by the zlib library is described by RFCs 4thread safe. The data format used by the zlib library is described by RFCs
5(Request for Comments) 1950 to 1952 in the files 5(Request for Comments) 1950 to 1952 in the files
6http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) 6http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
7and rfc1952.txt (gzip format). 7rfc1952 (gzip format).
8 8
9All functions of the compression library are documented in the file zlib.h 9All functions of the compression library are documented in the file zlib.h
10(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example 10(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
31issue of Dr. Dobb's Journal; a copy of the article is available at 31issue of Dr. Dobb's Journal; a copy of the article is available at
32http://marknelson.us/1997/01/01/zlib-engine/ . 32http://marknelson.us/1997/01/01/zlib-engine/ .
33 33
34The changes made in version 1.2.5 are documented in the file ChangeLog. 34The changes made in version 1.2.5.1 are documented in the file ChangeLog.
35 35
36Unsupported third party contributions are provided in directory contrib/ . 36Unsupported third party contributions are provided in directory contrib/ .
37 37
@@ -84,7 +84,7 @@ Acknowledgments:
84 84
85Copyright notice: 85Copyright notice:
86 86
87 (C) 1995-2010 Jean-loup Gailly and Mark Adler 87 (C) 1995-2011 Jean-loup Gailly and Mark Adler
88 88
89 This software is provided 'as-is', without any express or implied 89 This software is provided 'as-is', without any express or implied
90 warranty. In no event will the authors be held liable for any damages 90 warranty. In no event will the authors be held liable for any damages
diff --git a/adler32.c b/adler32.c
index 65ad6a5..a868f07 100644
--- a/adler32.c
+++ b/adler32.c
@@ -1,5 +1,5 @@
1/* adler32.c -- compute the Adler-32 checksum of a data stream 1/* adler32.c -- compute the Adler-32 checksum of a data stream
2 * Copyright (C) 1995-2007 Mark Adler 2 * Copyright (C) 1995-2011 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -9,9 +9,9 @@
9 9
10#define local static 10#define local static
11 11
12local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); 12local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
13 13
14#define BASE 65521UL /* largest prime smaller than 65536 */ 14#define BASE 65521 /* largest prime smaller than 65536 */
15#define NMAX 5552 15#define NMAX 5552
16/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 16/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
17 17
@@ -21,39 +21,44 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
21#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 21#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
22#define DO16(buf) DO8(buf,0); DO8(buf,8); 22#define DO16(buf) DO8(buf,0); DO8(buf,8);
23 23
24/* use NO_DIVIDE if your processor does not do division in hardware */ 24/* use NO_DIVIDE if your processor does not do division in hardware --
25 try it both ways to see which is faster */
25#ifdef NO_DIVIDE 26#ifdef NO_DIVIDE
26# define MOD(a) \ 27/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
28 (thank you to John Reiser for pointing this out) */
29# define CHOP(a) \
30 do { \
31 unsigned long tmp = a >> 16; \
32 a &= 0xffffUL; \
33 a += (tmp << 4) - tmp; \
34 } while (0)
35# define MOD28(a) \
27 do { \ 36 do { \
28 if (a >= (BASE << 16)) a -= (BASE << 16); \ 37 CHOP(a); \
29 if (a >= (BASE << 15)) a -= (BASE << 15); \
30 if (a >= (BASE << 14)) a -= (BASE << 14); \
31 if (a >= (BASE << 13)) a -= (BASE << 13); \
32 if (a >= (BASE << 12)) a -= (BASE << 12); \
33 if (a >= (BASE << 11)) a -= (BASE << 11); \
34 if (a >= (BASE << 10)) a -= (BASE << 10); \
35 if (a >= (BASE << 9)) a -= (BASE << 9); \
36 if (a >= (BASE << 8)) a -= (BASE << 8); \
37 if (a >= (BASE << 7)) a -= (BASE << 7); \
38 if (a >= (BASE << 6)) a -= (BASE << 6); \
39 if (a >= (BASE << 5)) a -= (BASE << 5); \
40 if (a >= (BASE << 4)) a -= (BASE << 4); \
41 if (a >= (BASE << 3)) a -= (BASE << 3); \
42 if (a >= (BASE << 2)) a -= (BASE << 2); \
43 if (a >= (BASE << 1)) a -= (BASE << 1); \
44 if (a >= BASE) a -= BASE; \ 38 if (a >= BASE) a -= BASE; \
45 } while (0) 39 } while (0)
46# define MOD4(a) \ 40# define MOD(a) \
47 do { \ 41 do { \
48 if (a >= (BASE << 4)) a -= (BASE << 4); \ 42 CHOP(a); \
49 if (a >= (BASE << 3)) a -= (BASE << 3); \ 43 MOD28(a); \
50 if (a >= (BASE << 2)) a -= (BASE << 2); \ 44 } while (0)
51 if (a >= (BASE << 1)) a -= (BASE << 1); \ 45# define MOD63(a) \
46 do { /* this assumes a is not negative */ \
47 z_off64_t tmp = a >> 32; \
48 a &= 0xffffffffL; \
49 a += (tmp << 8) - (tmp << 5) + tmp; \
50 tmp = a >> 16; \
51 a &= 0xffffL; \
52 a += (tmp << 4) - tmp; \
53 tmp = a >> 16; \
54 a &= 0xffffL; \
55 a += (tmp << 4) - tmp; \
52 if (a >= BASE) a -= BASE; \ 56 if (a >= BASE) a -= BASE; \
53 } while (0) 57 } while (0)
54#else 58#else
55# define MOD(a) a %= BASE 59# define MOD(a) a %= BASE
56# define MOD4(a) a %= BASE 60# define MOD28(a) a %= BASE
61# define MOD63(a) a %= BASE
57#endif 62#endif
58 63
59/* ========================================================================= */ 64/* ========================================================================= */
@@ -92,7 +97,7 @@ uLong ZEXPORT adler32(adler, buf, len)
92 } 97 }
93 if (adler >= BASE) 98 if (adler >= BASE)
94 adler -= BASE; 99 adler -= BASE;
95 MOD4(sum2); /* only added so many BASE's */ 100 MOD28(sum2); /* only added so many BASE's */
96 return adler | (sum2 << 16); 101 return adler | (sum2 << 16);
97 } 102 }
98 103
@@ -137,8 +142,13 @@ local uLong adler32_combine_(adler1, adler2, len2)
137 unsigned long sum2; 142 unsigned long sum2;
138 unsigned rem; 143 unsigned rem;
139 144
145 /* for negative len, return invalid adler32 as a clue for debugging */
146 if (len2 < 0)
147 return 0xffffffffUL;
148
140 /* the derivation of this formula is left as an exercise for the reader */ 149 /* the derivation of this formula is left as an exercise for the reader */
141 rem = (unsigned)(len2 % BASE); 150 MOD63(len2); /* assumes len2 >= 0 */
151 rem = (unsigned)len2;
142 sum1 = adler1 & 0xffff; 152 sum1 = adler1 & 0xffff;
143 sum2 = rem * sum1; 153 sum2 = rem * sum1;
144 MOD(sum2); 154 MOD(sum2);
diff --git a/old/as400/bndsrc b/as400/bndsrc
index 9cf94bb..06c3f43 100644
--- a/old/as400/bndsrc
+++ b/as400/bndsrc
@@ -34,6 +34,7 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
34 EXPORT SYMBOL("deflateCopy") 34 EXPORT SYMBOL("deflateCopy")
35 EXPORT SYMBOL("deflateReset") 35 EXPORT SYMBOL("deflateReset")
36 EXPORT SYMBOL("deflateParams") 36 EXPORT SYMBOL("deflateParams")
37 EXPORT SYMBOL("deflatePending")
37 EXPORT SYMBOL("deflatePrime") 38 EXPORT SYMBOL("deflatePrime")
38 EXPORT SYMBOL("deflateInit_") 39 EXPORT SYMBOL("deflateInit_")
39 EXPORT SYMBOL("deflateInit2_") 40 EXPORT SYMBOL("deflateInit2_")
@@ -129,4 +130,54 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
129 130
130 EXPORT SYMBOL("zlibCompileFlags") 131 EXPORT SYMBOL("zlibCompileFlags")
131 132
133/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
134/* Version 1.2.5 additional entry points. */
135/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
136
137/********************************************************************/
138/* *MODULE ADLER32 ZLIB 01/02/01 00:15:09 */
139/********************************************************************/
140
141 EXPORT SYMBOL("adler32_combine")
142 EXPORT SYMBOL("adler32_combine64")
143
144/********************************************************************/
145/* *MODULE CRC32 ZLIB 01/02/01 00:15:09 */
146/********************************************************************/
147
148 EXPORT SYMBOL("crc32_combine")
149 EXPORT SYMBOL("crc32_combine64")
150
151/********************************************************************/
152/* *MODULE GZLIB ZLIB 01/02/01 00:15:09 */
153/********************************************************************/
154
155 EXPORT SYMBOL("gzbuffer")
156 EXPORT SYMBOL("gzoffset")
157 EXPORT SYMBOL("gzoffset64")
158 EXPORT SYMBOL("gzopen64")
159 EXPORT SYMBOL("gzseek64")
160 EXPORT SYMBOL("gztell64")
161
162/********************************************************************/
163/* *MODULE GZREAD ZLIB 01/02/01 00:15:09 */
164/********************************************************************/
165
166 EXPORT SYMBOL("gzclose_r")
167
168/********************************************************************/
169/* *MODULE GZWRITE ZLIB 01/02/01 00:15:09 */
170/********************************************************************/
171
172 EXPORT SYMBOL("gzclose_w")
173
174/********************************************************************/
175/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
176/********************************************************************/
177
178 EXPORT SYMBOL("inflateMark")
179 EXPORT SYMBOL("inflatePrime")
180 EXPORT SYMBOL("inflateReset2")
181 EXPORT SYMBOL("inflateUndermine")
182
132ENDPGMEXP 183ENDPGMEXP
diff --git a/as400/compile.clp b/as400/compile.clp
new file mode 100644
index 0000000..2f34936
--- /dev/null
+++ b/as400/compile.clp
@@ -0,0 +1,110 @@
1/******************************************************************************/
2/* */
3/* ZLIB */
4/* */
5/* Compile sources into modules and link them into a service program. */
6/* */
7/******************************************************************************/
8
9 PGM
10
11/* Configuration adjustable parameters. */
12
13 DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10) +
14 VALUE('ZLIB') /* Source library. */
15 DCL VAR(&SRCFILE) TYPE(*CHAR) LEN(10) +
16 VALUE('SOURCES') /* Source member file. */
17 DCL VAR(&CTLFILE) TYPE(*CHAR) LEN(10) +
18 VALUE('TOOLS') /* Control member file. */
19
20 DCL VAR(&MODLIB) TYPE(*CHAR) LEN(10) +
21 VALUE('ZLIB') /* Module library. */
22
23 DCL VAR(&SRVLIB) TYPE(*CHAR) LEN(10) +
24 VALUE('LGPL') /* Service program library. */
25
26 DCL VAR(&CFLAGS) TYPE(*CHAR) +
27 VALUE('OPTIMIZE(40)') /* Compile options. */
28
29 DCL VAR(&TGTRLS) TYPE(*CHAR) +
30 VALUE('V5R3M0') /* Target release. */
31
32
33/* Working storage. */
34
35 DCL VAR(&CMDLEN) TYPE(*DEC) LEN(15 5) VALUE(300) /* Command length. */
36 DCL VAR(&CMD) TYPE(*CHAR) LEN(512)
37 DCL VAR(&FIXDCMD) TYPE(*CHAR) LEN(512)
38
39
40/* Compile sources into modules. */
41
42 CHGVAR VAR(&FIXDCMD) VALUE('CRTCMOD' *BCAT &CFLAGS *BCAT +
43 'SYSIFCOPT(*IFS64IO)' *BCAT +
44 'DEFINE(''_LARGEFILE64_SOURCE''' *BCAT +
45 '''_LFS64_LARGEFILE=1'') TGTRLS(' *TCAT &TGTRLS *TCAT +
46 ') SRCFILE(' *TCAT &SRCLIB *TCAT '/' *TCAT +
47 &SRCFILE *TCAT ') MODULE(' *TCAT &MODLIB *TCAT '/')
48
49
50 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'ADLER32)')
51 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
52
53 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'COMPRESS)')
54 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
55
56 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'CRC32)')
57 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
58
59 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'DEFLATE)')
60 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
61
62 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZCLOSE)')
63 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
64
65 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZLIB)')
66 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
67
68 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZREAD)')
69 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
70
71 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZWRITE)')
72 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
73
74 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFBACK)')
75 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
76
77 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFFAST)')
78 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
79
80 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFLATE)')
81 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
82
83 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFTREES)')
84 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
85
86 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'TREES)')
87 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
88
89 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'UNCOMPR)')
90 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
91
92 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'ZUTIL)')
93 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
94
95
96/* Link modules into a service program. */
97
98 CRTSRVPGM SRVPGM(&SRVLIB/ZLIB) +
99 MODULE(&MODLIB/ADLER32 &MODLIB/COMPRESS +
100 &MODLIB/CRC32 &MODLIB/DEFLATE +
101 &MODLIB/GZCLOSE &MODLIB/GZLIB +
102 &MODLIB/GZREAD &MODLIB/GZWRITE +
103 &MODLIB/INFBACK &MODLIB/INFFAST +
104 &MODLIB/INFLATE &MODLIB/INFTREES +
105 &MODLIB/TREES &MODLIB/UNCOMPR +
106 &MODLIB/ZUTIL) +
107 SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) +
108 TEXT('ZLIB 1.2.5.1') TGTRLS(&TGTRLS)
109
110 ENDPGM
diff --git a/old/as400/readme.txt b/as400/readme.txt
index beae13f..5b96cec 100644
--- a/old/as400/readme.txt
+++ b/as400/readme.txt
@@ -1,4 +1,4 @@
1 ZLIB version 1.2.3 for AS400 installation instructions 1 ZLIB version 1.2.5.1 for AS400 installation instructions
2 2
3I) From an AS400 *SAVF file: 3I) From an AS400 *SAVF file:
4 4
@@ -70,7 +70,10 @@ II) From the original source distribution:
70 compress.c COMPRESS C ZLIB - Compress a memory buffer 70 compress.c COMPRESS C ZLIB - Compress a memory buffer
71 crc32.c CRC32 C ZLIB - Compute the CRC-32 of a data stream 71 crc32.c CRC32 C ZLIB - Compute the CRC-32 of a data stream
72 deflate.c DEFLATE C ZLIB - Compress data using the deflation algorithm 72 deflate.c DEFLATE C ZLIB - Compress data using the deflation algorithm
73 gzio.c GZIO C ZLIB - IO on .gz files 73 gzclose.c GZCLOSE C ZLIB - Close .gz files
74 gzlib.c GZLIB C ZLIB - Miscellaneous .gz files IO support
75 gzread.c GZREAD C ZLIB - Read .gz files
76 gzwrite.c GZWRITE C ZLIB - Write .gz files
74 infback.c INFBACK C ZLIB - Inflate using a callback interface 77 infback.c INFBACK C ZLIB - Inflate using a callback interface
75 inffast.c INFFAST C ZLIB - Fast proc. literals & length/distance pairs 78 inffast.c INFFAST C ZLIB - Fast proc. literals & length/distance pairs
76 inflate.c INFLATE C ZLIB - Interface to inflate modules 79 inflate.c INFLATE C ZLIB - Interface to inflate modules
@@ -81,6 +84,7 @@ II) From the original source distribution:
81 H Original ZLIB C and ILE/RPG include files 84 H Original ZLIB C and ILE/RPG include files
82 crc32.h CRC32 C ZLIB - CRC32 tables 85 crc32.h CRC32 C ZLIB - CRC32 tables
83 deflate.h DEFLATE C ZLIB - Internal compression state 86 deflate.h DEFLATE C ZLIB - Internal compression state
87 gzguts.h GZGUTS C ZLIB - Definitions for the gzclose module
84 inffast.h INFFAST C ZLIB - Header to use inffast.c 88 inffast.h INFFAST C ZLIB - Header to use inffast.c
85 inffixed.h INFFIXED C ZLIB - Table for decoding fixed codes 89 inffixed.h INFFIXED C ZLIB - Table for decoding fixed codes
86 inflate.h INFLATE C ZLIB - Internal inflate state definitions 90 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
108 implementation does not handle conversion from/to ASCII, so 112 implementation does not handle conversion from/to ASCII, so
109 text data code conversions must be done explicitely. 113 text data code conversions must be done explicitely.
110 114
111 Always open zipped files in binary mode. 115 Mainly for the reason above, always open zipped files in binary mode.
diff --git a/old/as400/zlib.inc b/as400/zlib.inc
index a9a4f5c..d492ef3 100644
--- a/old/as400/zlib.inc
+++ b/as400/zlib.inc
@@ -1,7 +1,7 @@
1 * ZLIB.INC - Interface to the general purpose compression library 1 * ZLIB.INC - Interface to the general purpose compression library
2 * 2 *
3 * ILE RPG400 version by Patrick Monnerat, DATASPHERE. 3 * ILE RPG400 version by Patrick Monnerat, DATASPHERE.
4 * Version 1.2.3.9 4 * Version 1.2.5.1
5 * 5 *
6 * 6 *
7 * WARNING: 7 * WARNING:
@@ -22,16 +22,25 @@
22 * 22 *
23 * Versioning information. 23 * Versioning information.
24 * 24 *
25 D ZLIB_VERSION C '1.2.3.9' 25 D ZLIB_VERSION C '1.2.5.1'
26 D ZLIB_VERNUM C X'1239' 26 D ZLIB_VERNUM C X'1251'
27 D ZLIB_VER_MAJOR C 1
28 D ZLIB_VER_MINOR C 2
29 D ZLIB_VER_REVISION...
30 D C 5
31 D ZLIB_VER_SUBREVISION...
32 D C 0
27 * 33 *
28 * Other equates. 34 * Other equates.
29 * 35 *
30 D Z_NO_FLUSH C 0 36 D Z_NO_FLUSH C 0
37 D Z_PARTIAL_FLUSH...
38 D C 1
31 D Z_SYNC_FLUSH C 2 39 D Z_SYNC_FLUSH C 2
32 D Z_FULL_FLUSH C 3 40 D Z_FULL_FLUSH C 3
33 D Z_FINISH C 4 41 D Z_FINISH C 4
34 D Z_BLOCK C 5 42 D Z_BLOCK C 5
43 D Z_TREES C 6
35 * 44 *
36 D Z_OK C 0 45 D Z_OK C 0
37 D Z_STREAM_END C 1 46 D Z_STREAM_END C 1
@@ -72,6 +81,7 @@
72 D z_streamp S * Stream struct ptr 81 D z_streamp S * Stream struct ptr
73 D gzFile S * File pointer 82 D gzFile S * File pointer
74 D z_off_t S 10i 0 Stream offsets 83 D z_off_t S 10i 0 Stream offsets
84 D z_off64_t S 20i 0 Stream offsets
75 * 85 *
76 ************************************************************************** 86 **************************************************************************
77 * Structures 87 * Structures
@@ -122,20 +132,36 @@
122 D source 32767 const options(*varsize) Source buffer 132 D source 32767 const options(*varsize) Source buffer
123 D sourceLen 10U 0 value Source length 133 D sourceLen 10U 0 value Source length
124 * 134 *
135 /if not defined(LARGE_FILES)
125 D gzopen PR extproc('gzopen') 136 D gzopen PR extproc('gzopen')
126 D like(gzFile) 137 D like(gzFile)
127 D path * value options(*string) File pathname 138 D path * value options(*string) File pathname
128 D mode * value options(*string) Open mode 139 D mode * value options(*string) Open mode
140 /else
141 D gzopen PR extproc('gzopen64')
142 D like(gzFile)
143 D path * value options(*string) File pathname
144 D mode * value options(*string) Open mode
145 *
146 D gzopen64 PR extproc('gzopen64')
147 D like(gzFile)
148 D path * value options(*string) File pathname
149 D mode * value options(*string) Open mode
150 /endif
129 * 151 *
130 D gzdopen PR extproc('gzdopen') 152 D gzdopen PR extproc('gzdopen')
131 D like(gzFile) 153 D like(gzFile)
132 D fd 10i 0 value File descriptor 154 D fd 10I 0 value File descriptor
133 D mode * value options(*string) Open mode 155 D mode * value options(*string) Open mode
134 * 156 *
157 D gzbuffer PR 10I 0 extproc('gzbuffer')
158 D file value like(gzFile) File pointer
159 D size 10U 0 value
160 *
135 D gzsetparams PR 10I 0 extproc('gzsetparams') 161 D gzsetparams PR 10I 0 extproc('gzsetparams')
136 D file value like(gzFile) File pointer 162 D file value like(gzFile) File pointer
137 D level 10I 0 value 163 D level 10I 0 value
138 D strategy 10i 0 value 164 D strategy 10I 0 value
139 * 165 *
140 D gzread PR 10I 0 extproc('gzread') 166 D gzread PR 10I 0 extproc('gzread')
141 D file value like(gzFile) File pointer 167 D file value like(gzFile) File pointer
@@ -160,22 +186,66 @@
160 D file value like(gzFile) File pointer 186 D file value like(gzFile) File pointer
161 D flush 10I 0 value Type of flush 187 D flush 10I 0 value Type of flush
162 * 188 *
189 /if not defined(LARGE_FILES)
163 D gzseek PR extproc('gzseek') 190 D gzseek PR extproc('gzseek')
164 D like(z_off_t) 191 D like(z_off_t)
165 D file value like(gzFile) File pointer 192 D file value like(gzFile) File pointer
166 D offset value like(z_off_t) Offset 193 D offset value like(z_off_t) Offset
167 D whence 10i 0 value Origin 194 D whence 10i 0 value Origin
195 /else
196 D gzseek PR extproc('gzseek64')
197 D like(z_off_t)
198 D file value like(gzFile) File pointer
199 D offset value like(z_off_t) Offset
200 D whence 10i 0 value Origin
201 *
202 D gzseek64 PR extproc('gzseek64')
203 D like(z_off64_t)
204 D file value like(gzFile) File pointer
205 D offset value like(z_off64_t) Offset
206 D whence 10i 0 value Origin
207 /endif
168 * 208 *
169 D gzrewind PR 10i 0 extproc('gzrewind') 209 D gzrewind PR 10i 0 extproc('gzrewind')
170 D file value like(gzFile) File pointer 210 D file value like(gzFile) File pointer
171 * 211 *
212 /if not defined(LARGE_FILES)
172 D gztell PR extproc('gztell') 213 D gztell PR extproc('gztell')
173 D like(z_off_t) 214 D like(z_off_t)
174 D file value like(gzFile) File pointer 215 D file value like(gzFile) File pointer
216 /else
217 D gztell PR extproc('gztell64')
218 D like(z_off_t)
219 D file value like(gzFile) File pointer
220 *
221 D gztell64 PR extproc('gztell64')
222 D like(z_off64_t)
223 D file value like(gzFile) File pointer
224 /endif
225 *
226 /if not defined(LARGE_FILES)
227 D gzoffset PR extproc('gzoffset')
228 D like(z_off_t)
229 D file value like(gzFile) File pointer
230 /else
231 D gzoffset PR extproc('gzoffset64')
232 D like(z_off_t)
233 D file value like(gzFile) File pointer
234 *
235 D gzoffset64 PR extproc('gzoffset64')
236 D like(z_off64_t)
237 D file value like(gzFile) File pointer
238 /endif
175 * 239 *
176 D gzeof PR 10i 0 extproc('gzeof') 240 D gzeof PR 10i 0 extproc('gzeof')
177 D file value like(gzFile) File pointer 241 D file value like(gzFile) File pointer
178 * 242 *
243 D gzclose_r PR 10i 0 extproc('gzclose_r')
244 D file value like(gzFile) File pointer
245 *
246 D gzclose_w PR 10i 0 extproc('gzclose_w')
247 D file value like(gzFile) File pointer
248 *
179 D gzclose PR 10i 0 extproc('gzclose') 249 D gzclose PR 10i 0 extproc('gzclose')
180 D file value like(gzFile) File pointer 250 D file value like(gzFile) File pointer
181 * 251 *
@@ -253,6 +323,11 @@
253 D strm like(z_stream) Compression stream 323 D strm like(z_stream) Compression stream
254 D sourcelen 10U 0 value Compression level 324 D sourcelen 10U 0 value Compression level
255 * 325 *
326 D deflatePending PR 10I 0 extproc('deflatePending') Change level & strat
327 D strm like(z_stream) Compression stream
328 D pending 10U 0 Pending bytes
329 D bits 10I 0 Pending bits
330 *
256 D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat 331 D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat
257 D strm like(z_stream) Compression stream 332 D strm like(z_stream) Compression stream
258 D bits 10I 0 value Number of bits to insert 333 D bits 10I 0 value Number of bits to insert
@@ -280,6 +355,18 @@
280 D inflateReset PR 10I 0 extproc('inflateReset') End and init. stream 355 D inflateReset PR 10I 0 extproc('inflateReset') End and init. stream
281 D strm like(z_stream) Expansion stream 356 D strm like(z_stream) Expansion stream
282 * 357 *
358 D inflateReset2 PR 10I 0 extproc('inflateReset2') End and init. stream
359 D strm like(z_stream) Expansion stream
360 D windowBits 10I 0 value Log2(buffer size)
361 *
362 D inflatePrime PR 10I 0 extproc('inflatePrime') Insert bits
363 D strm like(z_stream) Expansion stream
364 D bits 10I 0 value Bit count
365 D value 10I 0 value Bits to insert
366 *
367 D inflateMark PR 10I 0 extproc('inflateMark') Get inflate info
368 D strm like(z_stream) Expansion stream
369 *
283 D inflateBackInit... 370 D inflateBackInit...
284 D PR 10I 0 extproc('inflateBackInit_') 371 D PR 10I 0 extproc('inflateBackInit_')
285 D strm like(z_stream) Expansion stream 372 D strm like(z_stream) Expansion stream
@@ -328,4 +415,9 @@
328 * 415 *
329 D get_crc_table PR * extproc('get_crc_table') Ptr to ulongs 416 D get_crc_table PR * extproc('get_crc_table') Ptr to ulongs
330 * 417 *
418 D inflateUndermine...
419 D PR 10I 0 extproc('inflateUndermine')
420 D strm like(z_stream) Expansion stream
421 D arg 10I 0 value Error code
422 *
331 /endif 423 /endif
diff --git a/configure b/configure
index bd9edd2..1838846 100755
--- a/configure
+++ b/configure
@@ -14,12 +14,11 @@
14# an error. 14# an error.
15 15
16if [ -n "${CHOST}" ]; then 16if [ -n "${CHOST}" ]; then
17 uname="$(echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/')" 17 uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`"
18 CROSS_PREFIX="${CHOST}-" 18 CROSS_PREFIX="${CHOST}-"
19fi 19fi
20 20
21STATICLIB=libz.a 21STATICLIB=libz.a
22LDFLAGS="${LDFLAGS} -L. ${STATICLIB}"
23VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` 22VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
24VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h` 23VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
25VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h` 24VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
@@ -46,6 +45,7 @@ else
46fi 45fi
47LDCONFIG=${LDCONFIG-"ldconfig"} 46LDCONFIG=${LDCONFIG-"ldconfig"}
48LDSHAREDLIBC="${LDSHAREDLIBC--lc}" 47LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
48ARCHS=
49prefix=${prefix-/usr/local} 49prefix=${prefix-/usr/local}
50exec_prefix=${exec_prefix-'${prefix}'} 50exec_prefix=${exec_prefix-'${prefix}'}
51libdir=${libdir-'${exec_prefix}/lib'} 51libdir=${libdir-'${exec_prefix}/lib'}
@@ -67,7 +67,7 @@ case "$1" in
67 echo 'usage:' 67 echo 'usage:'
68 echo ' configure [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' 68 echo ' configure [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]'
69 echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' 69 echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]'
70 echo ' [--includedir=INCLUDEDIR]' 70 echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]'
71 exit 0 ;; 71 exit 0 ;;
72 -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;; 72 -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
73 -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;; 73 -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
@@ -83,6 +83,7 @@ case "$1" in
83 -t | --static) shared=0; shift ;; 83 -t | --static) shared=0; shift ;;
84 -z* | --zprefix) zprefix=1; shift ;; 84 -z* | --zprefix) zprefix=1; shift ;;
85 -6* | --64) build64=1; shift ;; 85 -6* | --64) build64=1; shift ;;
86 -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
86 --sysconfdir=*) echo "ignored option: --sysconfdir"; shift ;; 87 --sysconfdir=*) echo "ignored option: --sysconfdir"; shift ;;
87 --localstatedir=*) echo "ignored option: --localstatedir"; shift ;; 88 --localstatedir=*) echo "ignored option: --localstatedir"; shift ;;
88 *) echo "unknown option: $1"; echo "$0 --help for help"; exit 1 ;; 89 *) echo "unknown option: $1"; echo "$0 --help for help"; exit 1 ;;
@@ -102,11 +103,15 @@ cflags=${CFLAGS-"-O3"}
102case "$cc" in 103case "$cc" in
103 *gcc*) gcc=1 ;; 104 *gcc*) gcc=1 ;;
104esac 105esac
106case `$cc -v 2>&1` in
107 *gcc*) gcc=1 ;;
108esac
105 109
106if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then 110if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
107 CC="$cc" 111 CC="$cc"
112 CFLAGS="${CFLAGS--O3} ${ARCHS}"
108 SFLAGS="${CFLAGS--O3} -fPIC" 113 SFLAGS="${CFLAGS--O3} -fPIC"
109 CFLAGS="${CFLAGS--O3}" 114 LDFLAGS="${LDFLAGS} ${ARCHS}"
110 if test $build64 -eq 1; then 115 if test $build64 -eq 1; then
111 CFLAGS="${CFLAGS} -m64" 116 CFLAGS="${CFLAGS} -m64"
112 SFLAGS="${SFLAGS} -m64" 117 SFLAGS="${SFLAGS} -m64"
@@ -118,10 +123,11 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
118 uname=`(uname -s || echo unknown) 2>/dev/null` 123 uname=`(uname -s || echo unknown) 2>/dev/null`
119 fi 124 fi
120 case "$uname" in 125 case "$uname" in
121 Linux* | linux* | GNU | GNU/* | *BSD | DragonFly) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;; 126 Linux* | linux* | GNU | GNU/* | *BSD | *bsd* | DragonFly | solaris*)
127 LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
122 CYGWIN* | Cygwin* | cygwin* | OS/2*) 128 CYGWIN* | Cygwin* | cygwin* | OS/2*)
123 EXE='.exe' ;; 129 EXE='.exe' ;;
124 MINGW*|mingw*) 130 MINGW* | mingw*)
125# temporary bypass 131# temporary bypass
126 rm -f $test.[co] $test $test$shared_ext 132 rm -f $test.[co] $test $test$shared_ext
127 echo "Please use win32/Makefile.gcc instead." 133 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
142 shared_ext='.sl' 148 shared_ext='.sl'
143 SHAREDLIB='libz.sl' ;; 149 SHAREDLIB='libz.sl' ;;
144 esac ;; 150 esac ;;
145 Darwin*) shared_ext='.dylib' 151 Darwin* | darwin*)
152 shared_ext='.dylib'
146 SHAREDLIB=libz$shared_ext 153 SHAREDLIB=libz$shared_ext
147 SHAREDLIBV=libz.$VER$shared_ext 154 SHAREDLIBV=libz.$VER$shared_ext
148 SHAREDLIBM=libz.$VER1$shared_ext 155 SHAREDLIBM=libz.$VER1$shared_ext
149 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} ;; 156 LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
157 AR="libtool"
158 AR_RC="${AR} -o" ;;
150 *) LDSHARED=${LDSHARED-"$cc -shared"} ;; 159 *) LDSHARED=${LDSHARED-"$cc -shared"} ;;
151 esac 160 esac
152else 161else
@@ -187,7 +196,8 @@ else
187 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} 196 SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
188 CFLAGS=${CFLAGS-"-O3"} 197 CFLAGS=${CFLAGS-"-O3"}
189 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;; 198 LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
190 SunOS\ 5*) LDSHARED=${LDSHARED-"cc -G"} 199 SunOS\ 5* | solaris*)
200 LDSHARED=${LDSHARED-"cc -G"}
191 case `(uname -m || echo unknown) 2>/dev/null` in 201 case `(uname -m || echo unknown) 2>/dev/null` in
192 i86*) 202 i86*)
193 SFLAGS=${CFLAGS-"-xpentium -fast -KPIC -R."} 203 SFLAGS=${CFLAGS-"-xpentium -fast -KPIC -R."}
@@ -303,6 +313,18 @@ else
303 echo "Checking for unistd.h... No." 313 echo "Checking for unistd.h... No."
304fi 314fi
305 315
316cat > $test.c <<EOF
317#include <stdarg.h>
318int main() { return 0; }
319EOF
320if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
321 sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
322 mv zconf.temp.h zconf.h
323 echo "Checking for stdarg.h... Yes."
324else
325 echo "Checking for stdarg.h... No."
326fi
327
306if test $zprefix -eq 1; then 328if test $zprefix -eq 1; then
307 sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h 329 sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
308 mv zconf.temp.h zconf.h 330 mv zconf.temp.h zconf.h
@@ -347,7 +369,6 @@ int main()
347 return (mytest("Hello%d\n", 1)); 369 return (mytest("Hello%d\n", 1));
348} 370}
349EOF 371EOF
350
351 if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then 372 if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
352 echo "Checking for vsnprintf() in stdio.h... Yes." 373 echo "Checking for vsnprintf() in stdio.h... Yes."
353 374
diff --git a/contrib/asm686/match.S b/contrib/asm686/match.S
index 06817e1..fa42109 100644
--- a/contrib/asm686/match.S
+++ b/contrib/asm686/match.S
@@ -83,17 +83,25 @@
83.text 83.text
84 84
85/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ 85/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */
86.cfi_sections .debug_frame
86 87
87longest_match: 88longest_match:
88 89
90.cfi_startproc
89/* Save registers that the compiler may be using, and adjust %esp to */ 91/* Save registers that the compiler may be using, and adjust %esp to */
90/* make room for our stack frame. */ 92/* make room for our stack frame. */
91 93
92 pushl %ebp 94 pushl %ebp
95 .cfi_def_cfa_offset 8
96 .cfi_offset ebp, -8
93 pushl %edi 97 pushl %edi
98 .cfi_def_cfa_offset 12
94 pushl %esi 99 pushl %esi
100 .cfi_def_cfa_offset 16
95 pushl %ebx 101 pushl %ebx
102 .cfi_def_cfa_offset 20
96 subl $LocalVarsSize, %esp 103 subl $LocalVarsSize, %esp
104 .cfi_def_cfa_offset LocalVarsSize+20
97 105
98/* Retrieve the function arguments. %ecx will hold cur_match */ 106/* Retrieve the function arguments. %ecx will hold cur_match */
99/* throughout the entire function. %edx will hold the pointer to the */ 107/* throughout the entire function. %edx will hold the pointer to the */
@@ -108,7 +116,7 @@ longest_match:
108/* if (s->prev_length >= s->good_match) { */ 116/* if (s->prev_length >= s->good_match) { */
109/* chain_length >>= 2; */ 117/* chain_length >>= 2; */
110/* } */ 118/* } */
111 119
112 movl dsPrevLen(%edx), %eax 120 movl dsPrevLen(%edx), %eax
113 movl dsGoodMatch(%edx), %ebx 121 movl dsGoodMatch(%edx), %ebx
114 cmpl %ebx, %eax 122 cmpl %ebx, %eax
@@ -336,8 +344,14 @@ LookaheadRet:
336/* Restore the stack and return from whence we came. */ 344/* Restore the stack and return from whence we came. */
337 345
338 addl $LocalVarsSize, %esp 346 addl $LocalVarsSize, %esp
347 .cfi_def_cfa_offset 20
339 popl %ebx 348 popl %ebx
349 .cfi_def_cfa_offset 16
340 popl %esi 350 popl %esi
351 .cfi_def_cfa_offset 12
341 popl %edi 352 popl %edi
353 .cfi_def_cfa_offset 8
342 popl %ebp 354 popl %ebp
355 .cfi_def_cfa_offset 4
356.cfi_endproc
343match_init: ret 357match_init: ret
diff --git a/contrib/delphi/ZLib.pas b/contrib/delphi/ZLib.pas
index 0d86fb5..8690594 100644
--- a/contrib/delphi/ZLib.pas
+++ b/contrib/delphi/ZLib.pas
@@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
152 const OutBuf: Pointer; BufSize: Integer); 152 const OutBuf: Pointer; BufSize: Integer);
153 153
154const 154const
155 zlib_version = '1.2.5'; 155 zlib_version = '1.2.5.1';
156 156
157type 157type
158 EZlibError = class(Exception); 158 EZlibError = class(Exception);
diff --git a/contrib/dotzlib/DotZLib/UnitTests.cs b/contrib/dotzlib/DotZLib/UnitTests.cs
index 3bbcc8c..e004833 100644
--- a/contrib/dotzlib/DotZLib/UnitTests.cs
+++ b/contrib/dotzlib/DotZLib/UnitTests.cs
@@ -156,7 +156,7 @@ namespace DotZLibTests
156 public void Info_Version() 156 public void Info_Version()
157 { 157 {
158 Info info = new Info(); 158 Info info = new Info();
159 Assert.AreEqual("1.2.5", Info.Version); 159 Assert.AreEqual("1.2.5.1", Info.Version);
160 Assert.AreEqual(32, info.SizeOfUInt); 160 Assert.AreEqual(32, info.SizeOfUInt);
161 Assert.AreEqual(32, info.SizeOfULong); 161 Assert.AreEqual(32, info.SizeOfULong);
162 Assert.AreEqual(32, info.SizeOfPointer); 162 Assert.AreEqual(32, info.SizeOfPointer);
diff --git a/contrib/infback9/inftree9.c b/contrib/infback9/inftree9.c
index 306c5f1..dfd0030 100644
--- a/contrib/infback9/inftree9.c
+++ b/contrib/infback9/inftree9.c
@@ -9,7 +9,7 @@
9#define MAXBITS 15 9#define MAXBITS 15
10 10
11const char inflate9_copyright[] = 11const char inflate9_copyright[] =
12 " inflate9 1.2.5 Copyright 1995-2010 Mark Adler "; 12 " inflate9 1.2.5.1 Copyright 1995-2010 Mark Adler ";
13/* 13/*
14 If you use the zlib library in a product, an acknowledgment is welcome 14 If you use the zlib library in a product, an acknowledgment is welcome
15 in the documentation of your product. If for some reason you cannot 15 in the documentation of your product. If for some reason you cannot
@@ -64,7 +64,7 @@ unsigned short FAR *work;
64 static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 64 static const unsigned short lext[31] = { /* Length codes 257..285 extra */
65 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 65 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
66 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, 66 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
67 133, 133, 133, 133, 144, 73, 195}; 67 133, 133, 133, 133, 144, 205, 203};
68 static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ 68 static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
69 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 69 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
70 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 70 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
diff --git a/contrib/masmx86/inffas32.asm b/contrib/masmx86/inffas32.asm
index 92ac22a..03d20f8 100644
--- a/contrib/masmx86/inffas32.asm
+++ b/contrib/masmx86/inffas32.asm
@@ -73,11 +73,6 @@ inflate_fast_use_mmx:
73 73
74 74
75_TEXT segment 75_TEXT segment
76PUBLIC _inflate_fast
77
78ALIGN 4
79_inflate_fast:
80 jmp inflate_fast_entry
81 76
82 77
83 78
@@ -163,7 +158,8 @@ distbits_state equ (76+4+zlib1222sup) ;/* state->distbits */
163;SECTION .text 158;SECTION .text
164 159
165ALIGN 4 160ALIGN 4
166inflate_fast_entry: 161_inflate_fast proc near
162.FPO (16, 4, 0, 0, 1, 0)
167 push edi 163 push edi
168 push esi 164 push esi
169 push ebp 165 push ebp
@@ -1078,6 +1074,7 @@ L_done:
1078 pop esi 1074 pop esi
1079 pop edi 1075 pop edi
1080 ret 1076 ret
1077_inflate_fast endp
1081 1078
1082_TEXT ends 1079_TEXT ends
1083end 1080end
diff --git a/contrib/masmx86/match686.asm b/contrib/masmx86/match686.asm
index 1eaf555..3b09212 100644
--- a/contrib/masmx86/match686.asm
+++ b/contrib/masmx86/match686.asm
@@ -195,6 +195,7 @@ dsNiceMatch equ 136+zlib1222add
195 ELSE 195 ELSE
196 _longest_match proc near 196 _longest_match proc near
197 ENDIF 197 ENDIF
198.FPO (9, 4, 0, 0, 1, 0)
198 199
199;;; Save registers that the compiler may be using, and adjust esp to 200;;; Save registers that the compiler may be using, and adjust esp to
200;;; make room for our stack frame. 201;;; make room for our stack frame.
diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c
index 49958f6..d4bc020 100644
--- a/contrib/minizip/ioapi.c
+++ b/contrib/minizip/ioapi.c
@@ -14,6 +14,18 @@
14 #define _CRT_SECURE_NO_WARNINGS 14 #define _CRT_SECURE_NO_WARNINGS
15#endif 15#endif
16 16
17#ifdef __APPLE__
18// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
19#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
20#define FTELLO_FUNC(stream) ftello(stream)
21#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
22#else
23#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
24#define FTELLO_FUNC(stream) ftello64(stream)
25#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
26#endif
27
28
17#include "ioapi.h" 29#include "ioapi.h"
18 30
19voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) 31voidpf 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,
112 mode_fopen = "wb"; 124 mode_fopen = "wb";
113 125
114 if ((filename!=NULL) && (mode_fopen != NULL)) 126 if ((filename!=NULL) && (mode_fopen != NULL))
115 file = fopen64((const char*)filename, mode_fopen); 127 file = FOPEN_FUNC((const char*)filename, mode_fopen);
116 return file; 128 return file;
117} 129}
118 130
@@ -142,7 +154,7 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
142static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) 154static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
143{ 155{
144 ZPOS64_T ret; 156 ZPOS64_T ret;
145 ret = ftello64((FILE *)stream); 157 ret = FTELLO_FUNC((FILE *)stream);
146 return ret; 158 return ret;
147} 159}
148 160
@@ -188,7 +200,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
188 } 200 }
189 ret = 0; 201 ret = 0;
190 202
191 if(fseeko64((FILE *)stream, offset, fseek_origin) != 0) 203 if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
192 ret = -1; 204 ret = -1;
193 205
194 return ret; 206 return ret;
diff --git a/contrib/minizip/ioapi.h b/contrib/minizip/ioapi.h
index 8309c4c..f6dce26 100644
--- a/contrib/minizip/ioapi.h
+++ b/contrib/minizip/ioapi.h
@@ -21,7 +21,7 @@
21#ifndef _ZLIBIOAPI64_H 21#ifndef _ZLIBIOAPI64_H
22#define _ZLIBIOAPI64_H 22#define _ZLIBIOAPI64_H
23 23
24#if (!defined(_WIN32)) && (!defined(WIN32)) 24#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
25 25
26 // Linux needs this to support file operation on files larger then 4+GB 26 // Linux needs this to support file operation on files larger then 4+GB
27 // But might need better if/def to select just the platforms that needs them. 27 // But might need better if/def to select just the platforms that needs them.
@@ -38,6 +38,7 @@
38 #ifndef _FILE_OFFSET_BIT 38 #ifndef _FILE_OFFSET_BIT
39 #define _FILE_OFFSET_BIT 64 39 #define _FILE_OFFSET_BIT 64
40 #endif 40 #endif
41
41#endif 42#endif
42 43
43#include <stdio.h> 44#include <stdio.h>
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c
index 9ed009f..3d65401 100644
--- a/contrib/minizip/miniunz.c
+++ b/contrib/minizip/miniunz.c
@@ -12,7 +12,7 @@
12 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 12 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
13*/ 13*/
14 14
15#ifndef _WIN32 15#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
16 #ifndef __USE_FILE_OFFSET64 16 #ifndef __USE_FILE_OFFSET64
17 #define __USE_FILE_OFFSET64 17 #define __USE_FILE_OFFSET64
18 #endif 18 #endif
@@ -27,6 +27,18 @@
27 #endif 27 #endif
28#endif 28#endif
29 29
30#ifdef __APPLE__
31// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
32#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
33#define FTELLO_FUNC(stream) ftello(stream)
34#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
35#else
36#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
37#define FTELLO_FUNC(stream) ftello64(stream)
38#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
39#endif
40
41
30#include <stdio.h> 42#include <stdio.h>
31#include <stdlib.h> 43#include <stdlib.h>
32#include <string.h> 44#include <string.h>
@@ -34,14 +46,15 @@
34#include <errno.h> 46#include <errno.h>
35#include <fcntl.h> 47#include <fcntl.h>
36 48
37#ifdef unix 49#ifdef _WIN32
38# include <unistd.h>
39# include <utime.h>
40#else
41# include <direct.h> 50# include <direct.h>
42# include <io.h> 51# include <io.h>
52#else
53# include <unistd.h>
54# include <utime.h>
43#endif 55#endif
44 56
57
45#include "unzip.h" 58#include "unzip.h"
46 59
47#define CASESENSITIVITY (0) 60#define CASESENSITIVITY (0)
@@ -84,7 +97,7 @@ void change_file_date(filename,dosdate,tmu_date)
84 SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); 97 SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
85 CloseHandle(hFile); 98 CloseHandle(hFile);
86#else 99#else
87#ifdef unix 100#ifdef unix || __APPLE__
88 struct utimbuf ut; 101 struct utimbuf ut;
89 struct tm newdate; 102 struct tm newdate;
90 newdate.tm_sec = tmu_date.tm_sec; 103 newdate.tm_sec = tmu_date.tm_sec;
@@ -114,10 +127,10 @@ int mymkdir(dirname)
114 int ret=0; 127 int ret=0;
115#ifdef _WIN32 128#ifdef _WIN32
116 ret = _mkdir(dirname); 129 ret = _mkdir(dirname);
117#else 130#elif unix
118#ifdef unix 131 ret = mkdir (dirname,0775);
132#elif __APPLE__
119 ret = mkdir (dirname,0775); 133 ret = mkdir (dirname,0775);
120#endif
121#endif 134#endif
122 return ret; 135 return ret;
123} 136}
@@ -364,7 +377,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
364 { 377 {
365 char rep=0; 378 char rep=0;
366 FILE* ftestexist; 379 FILE* ftestexist;
367 ftestexist = fopen64(write_filename,"rb"); 380 ftestexist = FOPEN_FUNC(write_filename,"rb");
368 if (ftestexist!=NULL) 381 if (ftestexist!=NULL)
369 { 382 {
370 fclose(ftestexist); 383 fclose(ftestexist);
@@ -395,8 +408,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
395 408
396 if ((skip==0) && (err==UNZ_OK)) 409 if ((skip==0) && (err==UNZ_OK))
397 { 410 {
398 fout=fopen64(write_filename,"wb"); 411 fout=FOPEN_FUNC(write_filename,"wb");
399
400 /* some zipfile don't contain directory alone before file */ 412 /* some zipfile don't contain directory alone before file */
401 if ((fout==NULL) && ((*popt_extract_without_path)==0) && 413 if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
402 (filename_withoutpath!=(char*)filename_inzip)) 414 (filename_withoutpath!=(char*)filename_inzip))
@@ -405,7 +417,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
405 *(filename_withoutpath-1)='\0'; 417 *(filename_withoutpath-1)='\0';
406 makedir(write_filename); 418 makedir(write_filename);
407 *(filename_withoutpath-1)=c; 419 *(filename_withoutpath-1)=c;
408 fout=fopen64(write_filename,"wb"); 420 fout=FOPEN_FUNC(write_filename,"wb");
409 } 421 }
410 422
411 if (fout==NULL) 423 if (fout==NULL)
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c
index 7a4fa5a..de63e37 100644
--- a/contrib/minizip/minizip.c
+++ b/contrib/minizip/minizip.c
@@ -13,7 +13,7 @@
13*/ 13*/
14 14
15 15
16#ifndef _WIN32 16#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
17 #ifndef __USE_FILE_OFFSET64 17 #ifndef __USE_FILE_OFFSET64
18 #define __USE_FILE_OFFSET64 18 #define __USE_FILE_OFFSET64
19 #endif 19 #endif
@@ -28,6 +28,19 @@
28 #endif 28 #endif
29#endif 29#endif
30 30
31#ifdef __APPLE__
32// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
33#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
34#define FTELLO_FUNC(stream) ftello(stream)
35#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
36#else
37#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
38#define FTELLO_FUNC(stream) ftello64(stream)
39#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
40#endif
41
42
43
31#include <stdio.h> 44#include <stdio.h>
32#include <stdlib.h> 45#include <stdlib.h>
33#include <string.h> 46#include <string.h>
@@ -35,14 +48,14 @@
35#include <errno.h> 48#include <errno.h>
36#include <fcntl.h> 49#include <fcntl.h>
37 50
38#ifdef unix 51#ifdef _WIN32
52# include <direct.h>
53# include <io.h>
54#else
39# include <unistd.h> 55# include <unistd.h>
40# include <utime.h> 56# include <utime.h>
41# include <sys/types.h> 57# include <sys/types.h>
42# include <sys/stat.h> 58# include <sys/stat.h>
43#else
44# include <direct.h>
45# include <io.h>
46#endif 59#endif
47 60
48#include "zip.h" 61#include "zip.h"
@@ -81,7 +94,7 @@ uLong filetime(f, tmzip, dt)
81 return ret; 94 return ret;
82} 95}
83#else 96#else
84#ifdef unix 97#ifdef unix || __APPLE__
85uLong filetime(f, tmzip, dt) 98uLong filetime(f, tmzip, dt)
86 char *f; /* name of file to get info on */ 99 char *f; /* name of file to get info on */
87 tm_zip *tmzip; /* return value: access, modific. and creation times */ 100 tm_zip *tmzip; /* return value: access, modific. and creation times */
@@ -142,7 +155,7 @@ int check_exist_file(filename)
142{ 155{
143 FILE* ftestexist; 156 FILE* ftestexist;
144 int ret = 1; 157 int ret = 1;
145 ftestexist = fopen64(filename,"rb"); 158 ftestexist = FOPEN_FUNC(filename,"rb");
146 if (ftestexist==NULL) 159 if (ftestexist==NULL)
147 ret = 0; 160 ret = 0;
148 else 161 else
@@ -173,7 +186,8 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
173{ 186{
174 unsigned long calculate_crc=0; 187 unsigned long calculate_crc=0;
175 int err=ZIP_OK; 188 int err=ZIP_OK;
176 FILE * fin = fopen64(filenameinzip,"rb"); 189 FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
190
177 unsigned long size_read = 0; 191 unsigned long size_read = 0;
178 unsigned long total_read = 0; 192 unsigned long total_read = 0;
179 if (fin==NULL) 193 if (fin==NULL)
@@ -211,13 +225,12 @@ int isLargeFile(const char* filename)
211{ 225{
212 int largeFile = 0; 226 int largeFile = 0;
213 ZPOS64_T pos = 0; 227 ZPOS64_T pos = 0;
214 FILE* pFile = fopen64(filename, "rb"); 228 FILE* pFile = FOPEN_FUNC(filename, "rb");
215 229
216 if(pFile != NULL) 230 if(pFile != NULL)
217 { 231 {
218 int n = fseeko64(pFile, 0, SEEK_END); 232 int n = FSEEKO_FUNC(pFile, 0, SEEK_END);
219 233 pos = FTELLO_FUNC(pFile);
220 pos = ftello64(pFile);
221 234
222 printf("File : %s is %lld bytes\n", filename, pos); 235 printf("File : %s is %lld bytes\n", filename, pos);
223 236
@@ -447,7 +460,7 @@ int main(argc,argv)
447 printf("error in opening %s in zipfile\n",filenameinzip); 460 printf("error in opening %s in zipfile\n",filenameinzip);
448 else 461 else
449 { 462 {
450 fin = fopen64(filenameinzip,"rb"); 463 fin = FOPEN_FUNC(filenameinzip,"rb");
451 if (fin==NULL) 464 if (fin==NULL)
452 { 465 {
453 err=ZIP_ERRNO; 466 err=ZIP_ERRNO;
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c
index 7617f41..587a2a1 100644
--- a/contrib/minizip/unzip.c
+++ b/contrib/minizip/unzip.c
@@ -1145,7 +1145,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
1145 szFileName,fileNameBufferSize, 1145 szFileName,fileNameBufferSize,
1146 extraField,extraFieldBufferSize, 1146 extraField,extraFieldBufferSize,
1147 szComment,commentBufferSize); 1147 szComment,commentBufferSize);
1148 if (err==UNZ_OK) 1148 if ((err==UNZ_OK) && (pfile_info != NULL))
1149 { 1149 {
1150 pfile_info->version = file_info64.version; 1150 pfile_info->version = file_info64.version;
1151 pfile_info->version_needed = file_info64.version_needed; 1151 pfile_info->version_needed = file_info64.version_needed;
diff --git a/contrib/pascal/zlibpas.pas b/contrib/pascal/zlibpas.pas
index 637ae3a..6f49482 100644
--- a/contrib/pascal/zlibpas.pas
+++ b/contrib/pascal/zlibpas.pas
@@ -10,7 +10,7 @@ unit zlibpas;
10interface 10interface
11 11
12const 12const
13 ZLIB_VERSION = '1.2.5'; 13 ZLIB_VERSION = '1.2.5.1';
14 14
15type 15type
16 alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; 16 alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
@@ -97,6 +97,7 @@ function deflateCopy(var dest, source: z_stream): Integer;
97function deflateReset(var strm: z_stream): Integer; 97function deflateReset(var strm: z_stream): Integer;
98function deflateParams(var strm: z_stream; level, strategy: Integer): Integer; 98function deflateParams(var strm: z_stream; level, strategy: Integer): Integer;
99function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt; 99function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt;
100function deflatePending(var strm: z_stream; var pending: Integer; var bits: Integer): Integer;
100function deflatePrime(var strm: z_stream; bits, value: Integer): Integer; 101function deflatePrime(var strm: z_stream; bits, value: Integer): Integer;
101function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; 102function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
102function inflateSetDictionary(var strm: z_stream; const dictionary: PChar; 103function inflateSetDictionary(var strm: z_stream; const dictionary: PChar;
@@ -166,6 +167,7 @@ function deflateEnd; external;
166function deflateInit_; external; 167function deflateInit_; external;
167function deflateInit2_; external; 168function deflateInit2_; external;
168function deflateParams; external; 169function deflateParams; external;
170function deflatePending; external;
169function deflatePrime; external; 171function deflatePrime; external;
170function deflateReset; external; 172function deflateReset; external;
171function deflateSetDictionary; external; 173function deflateSetDictionary; external;
diff --git a/contrib/puff/Makefile b/contrib/puff/Makefile
index b6b6940..0e2594c 100644
--- a/contrib/puff/Makefile
+++ b/contrib/puff/Makefile
@@ -1,8 +1,42 @@
1puff: puff.c puff.h 1CFLAGS=-O
2 cc -DTEST -o puff puff.c 2
3puff: puff.o pufftest.o
4
5puff.o: puff.h
6
7pufftest.o: puff.h
3 8
4test: puff 9test: puff
5 puff zeros.raw 10 puff zeros.raw
6 11
12puft: puff.c puff.h pufftest.o
13 cc -fprofile-arcs -ftest-coverage -o puft puff.c pufftest.o
14
15# puff full coverage test (should say 100%)
16cov: puft
17 @rm -f *.gcov *.gcda
18 @puft -w zeros.raw 2>&1 | cat > /dev/null
19 @echo '04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
20 @echo '00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
21 @echo '00 00 00 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 254
22 @echo '00 01 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
23 @echo '01 01 00 fe ff 0a' | xxd -r -p | puft -f 2>&1 | cat > /dev/null
24 @echo '02 7e ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246
25 @echo '02' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
26 @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
27 @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
28 @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
29 @echo '0b 00 00' | xxd -r -p | puft -f 2>&1 | cat > /dev/null
30 @echo '1a 07' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246
31 @echo '0c c0 81 00 00 00 00 00 90 ff 6b 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 245
32 @puft -f zeros.raw 2>&1 | cat > /dev/null
33 @echo 'fc 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 253
34 @echo '04 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 252
35 @echo '04 00 24 49' | xxd -r -p | puft 2> /dev/null || test $$? -eq 251
36 @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
37 @echo '04 00 24 e9 ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 250
38 @echo '04 00 24 e9 ff 6d' | xxd -r -p | puft 2> /dev/null || test $$? -eq 247
39 @gcov -n puff.c
40
7clean: 41clean:
8 rm -f puff puff.o 42 rm -f puff puft *.o *.gc*
diff --git a/contrib/puff/puff.c b/contrib/puff/puff.c
index 650694e..df8470c 100644
--- a/contrib/puff/puff.c
+++ b/contrib/puff/puff.c
@@ -2,7 +2,7 @@
2 * puff.c 2 * puff.c
3 * Copyright (C) 2002-2010 Mark Adler 3 * Copyright (C) 2002-2010 Mark Adler
4 * For conditions of distribution and use, see copyright notice in puff.h 4 * For conditions of distribution and use, see copyright notice in puff.h
5 * version 2.1, 4 Apr 2010 5 * version 2.2, 25 Apr 2010
6 * 6 *
7 * puff.c is a simple inflate written to be an unambiguous way to specify the 7 * puff.c is a simple inflate written to be an unambiguous way to specify the
8 * deflate format. It is not written for speed but rather simplicity. As a 8 * deflate format. It is not written for speed but rather simplicity. As a
@@ -49,9 +49,9 @@
49 * - Fix fixed codes table error 49 * - Fix fixed codes table error
50 * - Provide a scanning mode for determining size of 50 * - Provide a scanning mode for determining size of
51 * uncompressed data 51 * uncompressed data
52 * 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Jean-loup] 52 * 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Gailly]
53 * - Add a puff.h file for the interface 53 * - Add a puff.h file for the interface
54 * - Add braces in puff() for else do [Jean-loup] 54 * - Add braces in puff() for else do [Gailly]
55 * - Use indexes instead of pointers for readability 55 * - Use indexes instead of pointers for readability
56 * 1.4 31 Mar 2002 - Simplify construct() code set check 56 * 1.4 31 Mar 2002 - Simplify construct() code set check
57 * - Fix some comments 57 * - Fix some comments
@@ -69,13 +69,19 @@
69 * - Allow TEST code to read from piped stdin 69 * - Allow TEST code to read from piped stdin
70 * 2.1 4 Apr 2010 - Avoid variable initialization for happier compilers 70 * 2.1 4 Apr 2010 - Avoid variable initialization for happier compilers
71 * - Avoid unsigned comparisons for even happier compilers 71 * - Avoid unsigned comparisons for even happier compilers
72 * 2.2 25 Apr 2010 - Fix bug in variable initializations [Oberhumer]
73 * - Add const where appropriate [Oberhumer]
74 * - Split if's and ?'s for coverage testing
75 * - Break out test code to separate file
76 * - Move NIL to puff.h
77 * - Allow incomplete code only if single code length is 1
78 * - Add full code coverage test to Makefile
72 */ 79 */
73 80
74#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */ 81#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
75#include "puff.h" /* prototype for puff() */ 82#include "puff.h" /* prototype for puff() */
76 83
77#define local static /* for local function definitions */ 84#define local static /* for local function definitions */
78#define NIL ((unsigned char *)0) /* for no output option */
79 85
80/* 86/*
81 * Maximums for allocations and loops. It is not useful to change these -- 87 * Maximums for allocations and loops. It is not useful to change these --
@@ -95,7 +101,7 @@ struct state {
95 unsigned long outcnt; /* bytes written to out so far */ 101 unsigned long outcnt; /* bytes written to out so far */
96 102
97 /* input state */ 103 /* input state */
98 unsigned char *in; /* input buffer */ 104 const unsigned char *in; /* input buffer */
99 unsigned long inlen; /* available input at in */ 105 unsigned long inlen; /* available input at in */
100 unsigned long incnt; /* bytes read so far */ 106 unsigned long incnt; /* bytes read so far */
101 int bitbuf; /* bit buffer */ 107 int bitbuf; /* bit buffer */
@@ -123,7 +129,8 @@ local int bits(struct state *s, int need)
123 /* load at least need bits into val */ 129 /* load at least need bits into val */
124 val = s->bitbuf; 130 val = s->bitbuf;
125 while (s->bitcnt < need) { 131 while (s->bitcnt < need) {
126 if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */ 132 if (s->incnt == s->inlen)
133 longjmp(s->env, 1); /* out of input */
127 val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */ 134 val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */
128 s->bitcnt += 8; 135 s->bitcnt += 8;
129 } 136 }
@@ -162,7 +169,8 @@ local int stored(struct state *s)
162 s->bitcnt = 0; 169 s->bitcnt = 0;
163 170
164 /* get length and check against its one's complement */ 171 /* get length and check against its one's complement */
165 if (s->incnt + 4 > s->inlen) return 2; /* not enough input */ 172 if (s->incnt + 4 > s->inlen)
173 return 2; /* not enough input */
166 len = s->in[s->incnt++]; 174 len = s->in[s->incnt++];
167 len |= s->in[s->incnt++] << 8; 175 len |= s->in[s->incnt++] << 8;
168 if (s->in[s->incnt++] != (~len & 0xff) || 176 if (s->in[s->incnt++] != (~len & 0xff) ||
@@ -170,7 +178,8 @@ local int stored(struct state *s)
170 return -2; /* didn't match complement! */ 178 return -2; /* didn't match complement! */
171 179
172 /* copy len bytes from in to out */ 180 /* copy len bytes from in to out */
173 if (s->incnt + len > s->inlen) return 2; /* not enough input */ 181 if (s->incnt + len > s->inlen)
182 return 2; /* not enough input */
174 if (s->out != NIL) { 183 if (s->out != NIL) {
175 if (s->outcnt + len > s->outlen) 184 if (s->outcnt + len > s->outlen)
176 return 1; /* not enough output space */ 185 return 1; /* not enough output space */
@@ -222,7 +231,7 @@ struct huffman {
222 * in the deflate format. See the format notes for fixed() and dynamic(). 231 * in the deflate format. See the format notes for fixed() and dynamic().
223 */ 232 */
224#ifdef SLOW 233#ifdef SLOW
225local int decode(struct state *s, struct huffman *h) 234local int decode(struct state *s, const struct huffman *h)
226{ 235{
227 int len; /* current number of bits in code */ 236 int len; /* current number of bits in code */
228 int code; /* len bits being decoded */ 237 int code; /* len bits being decoded */
@@ -250,7 +259,7 @@ local int decode(struct state *s, struct huffman *h)
250 * a few percent larger. 259 * a few percent larger.
251 */ 260 */
252#else /* !SLOW */ 261#else /* !SLOW */
253local int decode(struct state *s, struct huffman *h) 262local int decode(struct state *s, const struct huffman *h)
254{ 263{
255 int len; /* current number of bits in code */ 264 int len; /* current number of bits in code */
256 int code; /* len bits being decoded */ 265 int code; /* len bits being decoded */
@@ -283,10 +292,13 @@ local int decode(struct state *s, struct huffman *h)
283 len++; 292 len++;
284 } 293 }
285 left = (MAXBITS+1) - len; 294 left = (MAXBITS+1) - len;
286 if (left == 0) break; 295 if (left == 0)
287 if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */ 296 break;
297 if (s->incnt == s->inlen)
298 longjmp(s->env, 1); /* out of input */
288 bitbuf = s->in[s->incnt++]; 299 bitbuf = s->in[s->incnt++];
289 if (left > 8) left = 8; 300 if (left > 8)
301 left = 8;
290 } 302 }
291 return -10; /* ran out of codes */ 303 return -10; /* ran out of codes */
292} 304}
@@ -324,7 +336,7 @@ local int decode(struct state *s, struct huffman *h)
324 * - Within a given code length, the symbols are kept in ascending order for 336 * - Within a given code length, the symbols are kept in ascending order for
325 * the code bits definition. 337 * the code bits definition.
326 */ 338 */
327local int construct(struct huffman *h, short *length, int n) 339local int construct(struct huffman *h, const short *length, int n)
328{ 340{
329 int symbol; /* current symbol when stepping through length[] */ 341 int symbol; /* current symbol when stepping through length[] */
330 int len; /* current length when stepping through h->count[] */ 342 int len; /* current length when stepping through h->count[] */
@@ -344,7 +356,8 @@ local int construct(struct huffman *h, short *length, int n)
344 for (len = 1; len <= MAXBITS; len++) { 356 for (len = 1; len <= MAXBITS; len++) {
345 left <<= 1; /* one more bit, double codes left */ 357 left <<= 1; /* one more bit, double codes left */
346 left -= h->count[len]; /* deduct count from possible codes */ 358 left -= h->count[len]; /* deduct count from possible codes */
347 if (left < 0) return left; /* over-subscribed--return negative */ 359 if (left < 0)
360 return left; /* over-subscribed--return negative */
348 } /* left > 0 means incomplete */ 361 } /* left > 0 means incomplete */
349 362
350 /* generate offsets into symbol table for each length for sorting */ 363 /* generate offsets into symbol table for each length for sorting */
@@ -420,8 +433,8 @@ local int construct(struct huffman *h, short *length, int n)
420 * defined to do the wrong thing in this case. 433 * defined to do the wrong thing in this case.
421 */ 434 */
422local int codes(struct state *s, 435local int codes(struct state *s,
423 struct huffman *lencode, 436 const struct huffman *lencode,
424 struct huffman *distcode) 437 const struct huffman *distcode)
425{ 438{
426 int symbol; /* decoded symbol */ 439 int symbol; /* decoded symbol */
427 int len; /* length for copy */ 440 int len; /* length for copy */
@@ -444,11 +457,13 @@ local int codes(struct state *s,
444 /* decode literals and length/distance pairs */ 457 /* decode literals and length/distance pairs */
445 do { 458 do {
446 symbol = decode(s, lencode); 459 symbol = decode(s, lencode);
447 if (symbol < 0) return symbol; /* invalid symbol */ 460 if (symbol < 0)
461 return symbol; /* invalid symbol */
448 if (symbol < 256) { /* literal: symbol is the byte */ 462 if (symbol < 256) { /* literal: symbol is the byte */
449 /* write out the literal */ 463 /* write out the literal */
450 if (s->out != NIL) { 464 if (s->out != NIL) {
451 if (s->outcnt == s->outlen) return 1; 465 if (s->outcnt == s->outlen)
466 return 1;
452 s->out[s->outcnt] = symbol; 467 s->out[s->outcnt] = symbol;
453 } 468 }
454 s->outcnt++; 469 s->outcnt++;
@@ -456,12 +471,14 @@ local int codes(struct state *s,
456 else if (symbol > 256) { /* length */ 471 else if (symbol > 256) { /* length */
457 /* get and compute length */ 472 /* get and compute length */
458 symbol -= 257; 473 symbol -= 257;
459 if (symbol >= 29) return -10; /* invalid fixed code */ 474 if (symbol >= 29)
475 return -10; /* invalid fixed code */
460 len = lens[symbol] + bits(s, lext[symbol]); 476 len = lens[symbol] + bits(s, lext[symbol]);
461 477
462 /* get and check distance */ 478 /* get and check distance */
463 symbol = decode(s, distcode); 479 symbol = decode(s, distcode);
464 if (symbol < 0) return symbol; /* invalid symbol */ 480 if (symbol < 0)
481 return symbol; /* invalid symbol */
465 dist = dists[symbol] + bits(s, dext[symbol]); 482 dist = dists[symbol] + bits(s, dext[symbol]);
466#ifndef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR 483#ifndef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
467 if (dist > s->outcnt) 484 if (dist > s->outcnt)
@@ -470,13 +487,15 @@ local int codes(struct state *s,
470 487
471 /* copy length bytes from distance bytes back */ 488 /* copy length bytes from distance bytes back */
472 if (s->out != NIL) { 489 if (s->out != NIL) {
473 if (s->outcnt + len > s->outlen) return 1; 490 if (s->outcnt + len > s->outlen)
491 return 1;
474 while (len--) { 492 while (len--) {
475 s->out[s->outcnt] = 493 s->out[s->outcnt] =
476#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR 494#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
477 dist > s->outcnt ? 0 : 495 dist > s->outcnt ?
496 0 :
478#endif 497#endif
479 s->out[s->outcnt - dist]; 498 s->out[s->outcnt - dist];
480 s->outcnt++; 499 s->outcnt++;
481 } 500 }
482 } 501 }
@@ -525,6 +544,12 @@ local int fixed(struct state *s)
525 int symbol; 544 int symbol;
526 short lengths[FIXLCODES]; 545 short lengths[FIXLCODES];
527 546
547 /* construct lencode and distcode */
548 lencode.count = lencnt;
549 lencode.symbol = lensym;
550 distcode.count = distcnt;
551 distcode.symbol = distsym;
552
528 /* literal/length table */ 553 /* literal/length table */
529 for (symbol = 0; symbol < 144; symbol++) 554 for (symbol = 0; symbol < 144; symbol++)
530 lengths[symbol] = 8; 555 lengths[symbol] = 8;
@@ -541,12 +566,6 @@ local int fixed(struct state *s)
541 lengths[symbol] = 5; 566 lengths[symbol] = 5;
542 construct(&distcode, lengths, MAXDCODES); 567 construct(&distcode, lengths, MAXDCODES);
543 568
544 /* construct lencode and distcode */
545 lencode.count = lencnt;
546 lencode.symbol = lensym;
547 distcode.count = distcnt;
548 distcode.symbol = distsym;
549
550 /* do this just once */ 569 /* do this just once */
551 virgin = 0; 570 virgin = 0;
552 } 571 }
@@ -675,7 +694,8 @@ local int dynamic(struct state *s)
675 694
676 /* build huffman table for code lengths codes (use lencode temporarily) */ 695 /* build huffman table for code lengths codes (use lencode temporarily) */
677 err = construct(&lencode, lengths, 19); 696 err = construct(&lencode, lengths, 19);
678 if (err != 0) return -4; /* require complete code set here */ 697 if (err != 0) /* require complete code set here */
698 return -4;
679 699
680 /* read length/literal and distance code length tables */ 700 /* read length/literal and distance code length tables */
681 index = 0; 701 index = 0;
@@ -689,7 +709,8 @@ local int dynamic(struct state *s)
689 else { /* repeat instruction */ 709 else { /* repeat instruction */
690 len = 0; /* assume repeating zeros */ 710 len = 0; /* assume repeating zeros */
691 if (symbol == 16) { /* repeat last length 3..6 times */ 711 if (symbol == 16) { /* repeat last length 3..6 times */
692 if (index == 0) return -5; /* no last length! */ 712 if (index == 0)
713 return -5; /* no last length! */
693 len = lengths[index - 1]; /* last length */ 714 len = lengths[index - 1]; /* last length */
694 symbol = 3 + bits(s, 2); 715 symbol = 3 + bits(s, 2);
695 } 716 }
@@ -710,13 +731,13 @@ local int dynamic(struct state *s)
710 731
711 /* build huffman table for literal/length codes */ 732 /* build huffman table for literal/length codes */
712 err = construct(&lencode, lengths, nlen); 733 err = construct(&lencode, lengths, nlen);
713 if (err < 0 || (err > 0 && nlen - lencode.count[0] != 1)) 734 if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1]))
714 return -7; /* only allow incomplete codes if just one code */ 735 return -7; /* incomplete code ok only for single length 1 code */
715 736
716 /* build huffman table for distance codes */ 737 /* build huffman table for distance codes */
717 err = construct(&distcode, lengths + nlen, ndist); 738 err = construct(&distcode, lengths + nlen, ndist);
718 if (err < 0 || (err > 0 && ndist - distcode.count[0] != 1)) 739 if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1]))
719 return -8; /* only allow incomplete codes if just one code */ 740 return -8; /* incomplete code ok only for single length 1 code */
720 741
721 /* decode data until end-of-block code */ 742 /* decode data until end-of-block code */
722 return codes(s, &lencode, &distcode); 743 return codes(s, &lencode, &distcode);
@@ -768,7 +789,7 @@ local int dynamic(struct state *s)
768 */ 789 */
769int puff(unsigned char *dest, /* pointer to destination pointer */ 790int puff(unsigned char *dest, /* pointer to destination pointer */
770 unsigned long *destlen, /* amount of output space */ 791 unsigned long *destlen, /* amount of output space */
771 unsigned char *source, /* pointer to source data pointer */ 792 const unsigned char *source, /* pointer to source data pointer */
772 unsigned long *sourcelen) /* amount of input available */ 793 unsigned long *sourcelen) /* amount of input available */
773{ 794{
774 struct state s; /* input/output state */ 795 struct state s; /* input/output state */
@@ -795,11 +816,15 @@ int puff(unsigned char *dest, /* pointer to destination pointer */
795 do { 816 do {
796 last = bits(&s, 1); /* one if last block */ 817 last = bits(&s, 1); /* one if last block */
797 type = bits(&s, 2); /* block type 0..3 */ 818 type = bits(&s, 2); /* block type 0..3 */
798 err = type == 0 ? stored(&s) : 819 err = type == 0 ?
799 (type == 1 ? fixed(&s) : 820 stored(&s) :
800 (type == 2 ? dynamic(&s) : 821 (type == 1 ?
801 -1)); /* type == 3, invalid */ 822 fixed(&s) :
802 if (err != 0) break; /* return with error */ 823 (type == 2 ?
824 dynamic(&s) :
825 -1)); /* type == 3, invalid */
826 if (err != 0)
827 break; /* return with error */
803 } while (!last); 828 } while (!last);
804 } 829 }
805 830
@@ -810,146 +835,3 @@ int puff(unsigned char *dest, /* pointer to destination pointer */
810 } 835 }
811 return err; 836 return err;
812} 837}
813
814#ifdef TEST
815/* Examples of how to use puff().
816
817 Usage: puff [-w] [-nnn] file
818 ... | puff [-w] [-nnn]
819
820 where file is the input file with deflate data, nnn is the number of bytes
821 of input to skip before inflating (e.g. to skip a zlib or gzip header), and
822 -w is used to write the decompressed data to stdout */
823
824#include <stdio.h>
825#include <stdlib.h>
826
827/* Return size times approximately the cube root of 2, keeping the result as 1,
828 3, or 5 times a power of 2 -- the result is always > size, until the result
829 is the maximum value of an unsigned long, where it remains. This is useful
830 to keep reallocations less than ~33% over the actual data. */
831local size_t bythirds(size_t size)
832{
833 int n;
834 size_t m;
835
836 m = size;
837 for (n = 0; m; n++)
838 m >>= 1;
839 if (n < 3)
840 return size + 1;
841 n -= 3;
842 m = size >> n;
843 m += m == 6 ? 2 : 1;
844 m <<= n;
845 return m > size ? m : (size_t)(-1);
846}
847
848/* Read the input file *name, or stdin if name is NULL, into allocated memory.
849 Reallocate to larger buffers until the entire file is read in. Return a
850 pointer to the allocated data, or NULL if there was a memory allocation
851 failure. *len is the number of bytes of data read from the input file (even
852 if load() returns NULL). If the input file was empty or could not be opened
853 or read, *len is zero. */
854local void *load(char *name, size_t *len)
855{
856 size_t size;
857 void *buf, *swap;
858 FILE *in;
859
860 *len = 0;
861 buf = malloc(size = 4096);
862 if (buf == NULL)
863 return NULL;
864 in = name == NULL ? stdin : fopen(name, "rb");
865 if (in != NULL) {
866 for (;;) {
867 *len += fread((char *)buf + *len, 1, size - *len, in);
868 if (*len < size) break;
869 size = bythirds(size);
870 if (size == *len || (swap = realloc(buf, size)) == NULL) {
871 free(buf);
872 buf = NULL;
873 break;
874 }
875 buf = swap;
876 }
877 fclose(in);
878 }
879 return buf;
880}
881
882int main(int argc, char **argv)
883{
884 int ret, put = 0;
885 unsigned skip = 0;
886 char *arg, *name = NULL;
887 unsigned char *source = NULL, *dest;
888 size_t len = 0;
889 unsigned long sourcelen, destlen;
890
891 /* process arguments */
892 while (arg = *++argv, --argc)
893 if (arg[0] == '-') {
894 if (arg[1] == 'w' && arg[2] == 0)
895 put = 1;
896 else if (arg[1] >= '0' && arg[1] <= '9')
897 skip = (unsigned)atoi(arg + 1);
898 else {
899 fprintf(stderr, "invalid option %s\n", arg);
900 return 3;
901 }
902 }
903 else if (name != NULL) {
904 fprintf(stderr, "only one file name allowed\n");
905 return 3;
906 }
907 else
908 name = arg;
909 source = load(name, &len);
910 if (source == NULL) {
911 fprintf(stderr, "memory allocation failure\n");
912 return 4;
913 }
914 if (len == 0) {
915 fprintf(stderr, "could not read %s, or it was empty\n",
916 name == NULL ? "<stdin>" : name);
917 free(source);
918 return 3;
919 }
920 if (skip >= len) {
921 fprintf(stderr, "skip request of %d leaves no input\n", skip);
922 free(source);
923 return 3;
924 }
925
926 /* test inflate data with offset skip */
927 len -= skip;
928 sourcelen = (unsigned long)len;
929 ret = puff(NIL, &destlen, source + skip, &sourcelen);
930 if (ret)
931 fprintf(stderr, "puff() failed with return code %d\n", ret);
932 else {
933 fprintf(stderr, "puff() succeeded uncompressing %lu bytes\n", destlen);
934 if (sourcelen < len) fprintf(stderr, "%lu compressed bytes unused\n",
935 len - sourcelen);
936 }
937
938 /* if requested, inflate again and write decompressd data to stdout */
939 if (put) {
940 dest = malloc(destlen);
941 if (dest == NULL) {
942 fprintf(stderr, "memory allocation failure\n");
943 free(source);
944 return 4;
945 }
946 puff(dest, &destlen, source + skip, &sourcelen);
947 fwrite(dest, 1, destlen, stdout);
948 free(dest);
949 }
950
951 /* clean up */
952 free(source);
953 return ret;
954}
955#endif
diff --git a/contrib/puff/puff.h b/contrib/puff/puff.h
index 88d1b38..6a0080a 100644
--- a/contrib/puff/puff.h
+++ b/contrib/puff/puff.h
@@ -1,6 +1,6 @@
1/* puff.h 1/* puff.h
2 Copyright (C) 2002-2010 Mark Adler, all rights reserved 2 Copyright (C) 2002-2010 Mark Adler, all rights reserved
3 version 2.1, 4 Apr 2010 3 version 2.2, 25 Apr 2010
4 4
5 This software is provided 'as-is', without any express or implied 5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the author be held liable for any damages 6 warranty. In no event will the author be held liable for any damages
@@ -25,7 +25,11 @@
25/* 25/*
26 * See puff.c for purpose and usage. 26 * See puff.c for purpose and usage.
27 */ 27 */
28#ifndef NIL
29# define NIL ((unsigned char *)0) /* for no output option */
30#endif
31
28int puff(unsigned char *dest, /* pointer to destination pointer */ 32int puff(unsigned char *dest, /* pointer to destination pointer */
29 unsigned long *destlen, /* amount of output space */ 33 unsigned long *destlen, /* amount of output space */
30 unsigned char *source, /* pointer to source data pointer */ 34 const unsigned char *source, /* pointer to source data pointer */
31 unsigned long *sourcelen); /* amount of input available */ 35 unsigned long *sourcelen); /* amount of input available */
diff --git a/contrib/puff/pufftest.c b/contrib/puff/pufftest.c
new file mode 100644
index 0000000..76e35f6
--- /dev/null
+++ b/contrib/puff/pufftest.c
@@ -0,0 +1,165 @@
1/*
2 * pufftest.c
3 * Copyright (C) 2002-2010 Mark Adler
4 * For conditions of distribution and use, see copyright notice in puff.h
5 * version 2.2, 25 Apr 2010
6 */
7
8/* Example of how to use puff().
9
10 Usage: puff [-w] [-f] [-nnn] file
11 ... | puff [-w] [-f] [-nnn]
12
13 where file is the input file with deflate data, nnn is the number of bytes
14 of input to skip before inflating (e.g. to skip a zlib or gzip header), and
15 -w is used to write the decompressed data to stdout. -f is for coverage
16 testing, and causes pufftest to fail with not enough output space (-f does
17 a write like -w, so -w is not required). */
18
19#include <stdio.h>
20#include <stdlib.h>
21#include "puff.h"
22
23#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
24# include <fcntl.h>
25# include <io.h>
26# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
27#else
28# define SET_BINARY_MODE(file)
29#endif
30
31#define local static
32
33/* Return size times approximately the cube root of 2, keeping the result as 1,
34 3, or 5 times a power of 2 -- the result is always > size, until the result
35 is the maximum value of an unsigned long, where it remains. This is useful
36 to keep reallocations less than ~33% over the actual data. */
37local size_t bythirds(size_t size)
38{
39 int n;
40 size_t m;
41
42 m = size;
43 for (n = 0; m; n++)
44 m >>= 1;
45 if (n < 3)
46 return size + 1;
47 n -= 3;
48 m = size >> n;
49 m += m == 6 ? 2 : 1;
50 m <<= n;
51 return m > size ? m : (size_t)(-1);
52}
53
54/* Read the input file *name, or stdin if name is NULL, into allocated memory.
55 Reallocate to larger buffers until the entire file is read in. Return a
56 pointer to the allocated data, or NULL if there was a memory allocation
57 failure. *len is the number of bytes of data read from the input file (even
58 if load() returns NULL). If the input file was empty or could not be opened
59 or read, *len is zero. */
60local void *load(const char *name, size_t *len)
61{
62 size_t size;
63 void *buf, *swap;
64 FILE *in;
65
66 *len = 0;
67 buf = malloc(size = 4096);
68 if (buf == NULL)
69 return NULL;
70 in = name == NULL ? stdin : fopen(name, "rb");
71 if (in != NULL) {
72 for (;;) {
73 *len += fread((char *)buf + *len, 1, size - *len, in);
74 if (*len < size) break;
75 size = bythirds(size);
76 if (size == *len || (swap = realloc(buf, size)) == NULL) {
77 free(buf);
78 buf = NULL;
79 break;
80 }
81 buf = swap;
82 }
83 fclose(in);
84 }
85 return buf;
86}
87
88int main(int argc, char **argv)
89{
90 int ret, put = 0, fail = 0;
91 unsigned skip = 0;
92 char *arg, *name = NULL;
93 unsigned char *source = NULL, *dest;
94 size_t len = 0;
95 unsigned long sourcelen, destlen;
96
97 /* process arguments */
98 while (arg = *++argv, --argc)
99 if (arg[0] == '-') {
100 if (arg[1] == 'w' && arg[2] == 0)
101 put = 1;
102 else if (arg[1] == 'f' && arg[2] == 0)
103 fail = 1, put = 1;
104 else if (arg[1] >= '0' && arg[1] <= '9')
105 skip = (unsigned)atoi(arg + 1);
106 else {
107 fprintf(stderr, "invalid option %s\n", arg);
108 return 3;
109 }
110 }
111 else if (name != NULL) {
112 fprintf(stderr, "only one file name allowed\n");
113 return 3;
114 }
115 else
116 name = arg;
117 source = load(name, &len);
118 if (source == NULL) {
119 fprintf(stderr, "memory allocation failure\n");
120 return 4;
121 }
122 if (len == 0) {
123 fprintf(stderr, "could not read %s, or it was empty\n",
124 name == NULL ? "<stdin>" : name);
125 free(source);
126 return 3;
127 }
128 if (skip >= len) {
129 fprintf(stderr, "skip request of %d leaves no input\n", skip);
130 free(source);
131 return 3;
132 }
133
134 /* test inflate data with offset skip */
135 len -= skip;
136 sourcelen = (unsigned long)len;
137 ret = puff(NIL, &destlen, source + skip, &sourcelen);
138 if (ret)
139 fprintf(stderr, "puff() failed with return code %d\n", ret);
140 else {
141 fprintf(stderr, "puff() succeeded uncompressing %lu bytes\n", destlen);
142 if (sourcelen < len) fprintf(stderr, "%lu compressed bytes unused\n",
143 len - sourcelen);
144 }
145
146 /* if requested, inflate again and write decompressd data to stdout */
147 if (put && ret == 0) {
148 if (fail)
149 destlen >>= 1;
150 dest = malloc(destlen);
151 if (dest == NULL) {
152 fprintf(stderr, "memory allocation failure\n");
153 free(source);
154 return 4;
155 }
156 puff(dest, &destlen, source + skip, &sourcelen);
157 SET_BINARY_MODE(stdout);
158 fwrite(dest, 1, destlen, stdout);
159 free(dest);
160 }
161
162 /* clean up */
163 free(source);
164 return ret;
165}
diff --git a/contrib/puff/zeros.raw b/contrib/puff/zeros.raw
index 637b7be..0a90e76 100644
--- a/contrib/puff/zeros.raw
+++ b/contrib/puff/zeros.raw
Binary files differ
diff --git a/contrib/vstudio/vc10/zlib.rc b/contrib/vstudio/vc10/zlib.rc
index f822450..00034ea 100644
--- a/contrib/vstudio/vc10/zlib.rc
+++ b/contrib/vstudio/vc10/zlib.rc
@@ -2,8 +2,8 @@
2 2
3#define IDR_VERSION1 1 3#define IDR_VERSION1 1
4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
5 FILEVERSION 1,2,5,0 5 FILEVERSION 1.2.5.1,1
6 PRODUCTVERSION 1,2,5,0 6 PRODUCTVERSION 1.2.5.1,1
7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
8 FILEFLAGS 0 8 FILEFLAGS 0
9 FILEOS VOS_DOS_WINDOWS32 9 FILEOS VOS_DOS_WINDOWS32
@@ -17,7 +17,7 @@ BEGIN
17 17
18 BEGIN 18 BEGIN
19 VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 19 VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
20 VALUE "FileVersion", "1.2.5\0" 20 VALUE "FileVersion", "1.2.5.1\0"
21 VALUE "InternalName", "zlib\0" 21 VALUE "InternalName", "zlib\0"
22 VALUE "OriginalFilename", "zlib.dll\0" 22 VALUE "OriginalFilename", "zlib.dll\0"
23 VALUE "ProductName", "ZLib.DLL\0" 23 VALUE "ProductName", "ZLib.DLL\0"
diff --git a/contrib/vstudio/vc10/zlibvc.def b/contrib/vstudio/vc10/zlibvc.def
index 0269ef7..ad8b4af 100644
--- a/contrib/vstudio/vc10/zlibvc.def
+++ b/contrib/vstudio/vc10/zlibvc.def
@@ -55,6 +55,7 @@ EXPORTS
55 gzungetc @49 55 gzungetc @49
56 zlibCompileFlags @50 56 zlibCompileFlags @50
57 deflatePrime @51 57 deflatePrime @51
58 deflatePending @52
58 59
59 unzOpen @61 60 unzOpen @61
60 unzClose @62 61 unzClose @62
diff --git a/contrib/vstudio/vc9/zlib.rc b/contrib/vstudio/vc9/zlib.rc
index f822450..00034ea 100644
--- a/contrib/vstudio/vc9/zlib.rc
+++ b/contrib/vstudio/vc9/zlib.rc
@@ -2,8 +2,8 @@
2 2
3#define IDR_VERSION1 1 3#define IDR_VERSION1 1
4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
5 FILEVERSION 1,2,5,0 5 FILEVERSION 1.2.5.1,1
6 PRODUCTVERSION 1,2,5,0 6 PRODUCTVERSION 1.2.5.1,1
7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
8 FILEFLAGS 0 8 FILEFLAGS 0
9 FILEOS VOS_DOS_WINDOWS32 9 FILEOS VOS_DOS_WINDOWS32
@@ -17,7 +17,7 @@ BEGIN
17 17
18 BEGIN 18 BEGIN
19 VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 19 VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
20 VALUE "FileVersion", "1.2.5\0" 20 VALUE "FileVersion", "1.2.5.1\0"
21 VALUE "InternalName", "zlib\0" 21 VALUE "InternalName", "zlib\0"
22 VALUE "OriginalFilename", "zlib.dll\0" 22 VALUE "OriginalFilename", "zlib.dll\0"
23 VALUE "ProductName", "ZLib.DLL\0" 23 VALUE "ProductName", "ZLib.DLL\0"
diff --git a/contrib/vstudio/vc9/zlibvc.def b/contrib/vstudio/vc9/zlibvc.def
index 0269ef7..ad8b4af 100644
--- a/contrib/vstudio/vc9/zlibvc.def
+++ b/contrib/vstudio/vc9/zlibvc.def
@@ -55,6 +55,7 @@ EXPORTS
55 gzungetc @49 55 gzungetc @49
56 zlibCompileFlags @50 56 zlibCompileFlags @50
57 deflatePrime @51 57 deflatePrime @51
58 deflatePending @52
58 59
59 unzOpen @61 60 unzOpen @61
60 unzClose @62 61 unzClose @62
diff --git a/crc32.c b/crc32.c
index 91be372..c12471e 100644
--- a/crc32.c
+++ b/crc32.c
@@ -1,5 +1,5 @@
1/* crc32.c -- compute the CRC-32 of a data stream 1/* crc32.c -- compute the CRC-32 of a data stream
2 * Copyright (C) 1995-2006, 2010 Mark Adler 2 * Copyright (C) 1995-2006, 2010, 2011 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 * 4 *
5 * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster 5 * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
@@ -17,6 +17,8 @@
17 of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should 17 of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
18 first call get_crc_table() to initialize the tables before allowing more than 18 first call get_crc_table() to initialize the tables before allowing more than
19 one thread to use crc32(). 19 one thread to use crc32().
20
21 DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
20 */ 22 */
21 23
22#ifdef MAKECRCH 24#ifdef MAKECRCH
@@ -53,6 +55,7 @@
53 55
54/* Definitions for doing the crc four data bytes at a time. */ 56/* Definitions for doing the crc four data bytes at a time. */
55#ifdef BYFOUR 57#ifdef BYFOUR
58 typedef u4 crc_table_t;
56# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \ 59# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
57 (((w)&0xff00)<<8)+(((w)&0xff)<<24)) 60 (((w)&0xff00)<<8)+(((w)&0xff)<<24))
58 local unsigned long crc32_little OF((unsigned long, 61 local unsigned long crc32_little OF((unsigned long,
@@ -61,6 +64,7 @@
61 const unsigned char FAR *, unsigned)); 64 const unsigned char FAR *, unsigned));
62# define TBLS 8 65# define TBLS 8
63#else 66#else
67 typedef unsigned long crc_table_t;
64# define TBLS 1 68# define TBLS 1
65#endif /* BYFOUR */ 69#endif /* BYFOUR */
66 70
@@ -68,16 +72,16 @@
68local unsigned long gf2_matrix_times OF((unsigned long *mat, 72local unsigned long gf2_matrix_times OF((unsigned long *mat,
69 unsigned long vec)); 73 unsigned long vec));
70local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); 74local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
71local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2); 75local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
72 76
73 77
74#ifdef DYNAMIC_CRC_TABLE 78#ifdef DYNAMIC_CRC_TABLE
75 79
76local volatile int crc_table_empty = 1; 80local volatile int crc_table_empty = 1;
77local unsigned long FAR crc_table[TBLS][256]; 81local crc_table_t FAR crc_table[TBLS][256];
78local void make_crc_table OF((void)); 82local void make_crc_table OF((void));
79#ifdef MAKECRCH 83#ifdef MAKECRCH
80 local void write_table OF((FILE *, const unsigned long FAR *)); 84 local void write_table OF((FILE *, const crc_table_t FAR *));
81#endif /* MAKECRCH */ 85#endif /* MAKECRCH */
82/* 86/*
83 Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: 87 Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
@@ -107,9 +111,9 @@ local void make_crc_table OF((void));
107*/ 111*/
108local void make_crc_table() 112local void make_crc_table()
109{ 113{
110 unsigned long c; 114 crc_table_t c;
111 int n, k; 115 int n, k;
112 unsigned long poly; /* polynomial exclusive-or pattern */ 116 crc_table_t poly; /* polynomial exclusive-or pattern */
113 /* terms of polynomial defining this crc (except x^32): */ 117 /* terms of polynomial defining this crc (except x^32): */
114 static volatile int first = 1; /* flag to limit concurrent making */ 118 static volatile int first = 1; /* flag to limit concurrent making */
115 static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; 119 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()
121 first = 0; 125 first = 0;
122 126
123 /* make exclusive-or pattern from polynomial (0xedb88320UL) */ 127 /* make exclusive-or pattern from polynomial (0xedb88320UL) */
124 poly = 0UL; 128 poly = 0;
125 for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) 129 for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
126 poly |= 1UL << (31 - p[n]); 130 poly |= (crc_table_t)1 << (31 - p[n]);
127 131
128 /* generate a crc for every 8-bit value */ 132 /* generate a crc for every 8-bit value */
129 for (n = 0; n < 256; n++) { 133 for (n = 0; n < 256; n++) {
130 c = (unsigned long)n; 134 c = (crc_table_t)n;
131 for (k = 0; k < 8; k++) 135 for (k = 0; k < 8; k++)
132 c = c & 1 ? poly ^ (c >> 1) : c >> 1; 136 c = c & 1 ? poly ^ (c >> 1) : c >> 1;
133 crc_table[0][n] = c; 137 crc_table[0][n] = c;
@@ -164,7 +168,7 @@ local void make_crc_table()
164 if (out == NULL) return; 168 if (out == NULL) return;
165 fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); 169 fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
166 fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); 170 fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
167 fprintf(out, "local const unsigned long FAR "); 171 fprintf(out, "local const crc_table_t FAR ");
168 fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); 172 fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
169 write_table(out, crc_table[0]); 173 write_table(out, crc_table[0]);
170# ifdef BYFOUR 174# ifdef BYFOUR
@@ -184,12 +188,13 @@ local void make_crc_table()
184#ifdef MAKECRCH 188#ifdef MAKECRCH
185local void write_table(out, table) 189local void write_table(out, table)
186 FILE *out; 190 FILE *out;
187 const unsigned long FAR *table; 191 const crc_table_t FAR *table;
188{ 192{
189 int n; 193 int n;
190 194
191 for (n = 0; n < 256; n++) 195 for (n = 0; n < 256; n++)
192 fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], 196 fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ",
197 (unsigned long)(table[n]),
193 n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); 198 n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
194} 199}
195#endif /* MAKECRCH */ 200#endif /* MAKECRCH */
diff --git a/crc32.h b/crc32.h
index 8053b61..c3e7171 100644
--- a/crc32.h
+++ b/crc32.h
@@ -2,7 +2,7 @@
2 * Generated automatically by crc32.c 2 * Generated automatically by crc32.c
3 */ 3 */
4 4
5local const unsigned long FAR crc_table[TBLS][256] = 5local const crc_table_t FAR crc_table[TBLS][256] =
6{ 6{
7 { 7 {
8 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 8 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
diff --git a/deflate.c b/deflate.c
index 5c4022f..01d094e 100644
--- a/deflate.c
+++ b/deflate.c
@@ -1,5 +1,5 @@
1/* deflate.c -- compress data using the deflation algorithm 1/* deflate.c -- compress data using the deflation algorithm
2 * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler 2 * Copyright (C) 1995-2011 Jean-loup Gailly and Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -37,7 +37,7 @@
37 * REFERENCES 37 * REFERENCES
38 * 38 *
39 * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". 39 * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
40 * Available in http://www.ietf.org/rfc/rfc1951.txt 40 * Available in http://tools.ietf.org/html/rfc1951
41 * 41 *
42 * A description of the Rabin and Karp algorithm is given in the book 42 * A description of the Rabin and Karp algorithm is given in the book
43 * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. 43 * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
@@ -52,7 +52,7 @@
52#include "deflate.h" 52#include "deflate.h"
53 53
54const char deflate_copyright[] = 54const char deflate_copyright[] =
55 " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler "; 55 " deflate 1.2.5.1 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
56/* 56/*
57 If you use the zlib library in a product, an acknowledgment is welcome 57 If you use the zlib library in a product, an acknowledgment is welcome
58 in the documentation of your product. If for some reason you cannot 58 in the documentation of your product. If for some reason you cannot
@@ -397,6 +397,18 @@ int ZEXPORT deflateSetHeader (strm, head)
397} 397}
398 398
399/* ========================================================================= */ 399/* ========================================================================= */
400int ZEXPORT deflatePending (strm, pending, bits)
401 unsigned *pending;
402 int *bits;
403 z_streamp strm;
404{
405 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
406 *pending = strm->state->pending;
407 *bits = strm->state->bi_valid;
408 return Z_OK;
409}
410
411/* ========================================================================= */
400int ZEXPORT deflatePrime (strm, bits, value) 412int ZEXPORT deflatePrime (strm, bits, value)
401 z_streamp strm; 413 z_streamp strm;
402 int bits; 414 int bits;
@@ -1001,15 +1013,15 @@ local int read_buf(strm, buf, size)
1001 1013
1002 strm->avail_in -= len; 1014 strm->avail_in -= len;
1003 1015
1016 zmemcpy(buf, strm->next_in, len);
1004 if (strm->state->wrap == 1) { 1017 if (strm->state->wrap == 1) {
1005 strm->adler = adler32(strm->adler, strm->next_in, len); 1018 strm->adler = adler32(strm->adler, buf, len);
1006 } 1019 }
1007#ifdef GZIP 1020#ifdef GZIP
1008 else if (strm->state->wrap == 2) { 1021 else if (strm->state->wrap == 2) {
1009 strm->adler = crc32(strm->adler, strm->next_in, len); 1022 strm->adler = crc32(strm->adler, buf, len);
1010 } 1023 }
1011#endif 1024#endif
1012 zmemcpy(buf, strm->next_in, len);
1013 strm->next_in += len; 1025 strm->next_in += len;
1014 strm->total_in += len; 1026 strm->total_in += len;
1015 1027
diff --git a/deflate.h b/deflate.h
index cbf0d1e..442e14a 100644
--- a/deflate.h
+++ b/deflate.h
@@ -188,7 +188,7 @@ typedef struct internal_state {
188 int nice_match; /* Stop searching when current match exceeds this */ 188 int nice_match; /* Stop searching when current match exceeds this */
189 189
190 /* used by trees.c: */ 190 /* used by trees.c: */
191 /* Didn't use ct_data typedef below to supress compiler warning */ 191 /* Didn't use ct_data typedef below to suppress compiler warning */
192 struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ 192 struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
193 struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ 193 struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
194 struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ 194 struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
diff --git a/doc/algorithm.txt b/doc/algorithm.txt
index 34960bd..c97f495 100644
--- a/doc/algorithm.txt
+++ b/doc/algorithm.txt
@@ -206,4 +206,4 @@ Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3,
206pp. 337-343. 206pp. 337-343.
207 207
208``DEFLATE Compressed Data Format Specification'' available in 208``DEFLATE Compressed Data Format Specification'' available in
209http://www.ietf.org/rfc/rfc1951.txt 209http://tools.ietf.org/html/rfc1951
diff --git a/example.c b/example.c
index 604736f..c15cc03 100644
--- a/example.c
+++ b/example.c
@@ -1,5 +1,5 @@
1/* example.c -- usage example of the zlib compression library 1/* example.c -- usage example of the zlib compression library
2 * Copyright (C) 1995-2006 Jean-loup Gailly. 2 * Copyright (C) 1995-2006, 2011 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -438,7 +438,7 @@ void test_dict_deflate(compr, comprLen)
438 CHECK_ERR(err, "deflateInit"); 438 CHECK_ERR(err, "deflateInit");
439 439
440 err = deflateSetDictionary(&c_stream, 440 err = deflateSetDictionary(&c_stream,
441 (const Bytef*)dictionary, sizeof(dictionary)); 441 (const Bytef*)dictionary, (int)sizeof(dictionary));
442 CHECK_ERR(err, "deflateSetDictionary"); 442 CHECK_ERR(err, "deflateSetDictionary");
443 443
444 dictId = c_stream.adler; 444 dictId = c_stream.adler;
@@ -491,7 +491,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
491 exit(1); 491 exit(1);
492 } 492 }
493 err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary, 493 err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
494 sizeof(dictionary)); 494 (int)sizeof(dictionary));
495 } 495 }
496 CHECK_ERR(err, "inflate with dict"); 496 CHECK_ERR(err, "inflate with dict");
497 } 497 }
diff --git a/gzlib.c b/gzlib.c
index 603e60e..d16b249 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -91,6 +91,10 @@ local gzFile gz_open(path, fd, mode)
91{ 91{
92 gz_statep state; 92 gz_statep state;
93 93
94 /* check input */
95 if (path == NULL)
96 return NULL;
97
94 /* allocate gzFile structure to return */ 98 /* allocate gzFile structure to return */
95 state = malloc(sizeof(gz_state)); 99 state = malloc(sizeof(gz_state));
96 if (state == NULL) 100 if (state == NULL)
diff --git a/gzwrite.c b/gzwrite.c
index e8defc6..0ea2994 100644
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -1,5 +1,5 @@
1/* gzwrite.c -- zlib functions for writing gzip files 1/* gzwrite.c -- zlib functions for writing gzip files
2 * Copyright (C) 2004, 2005, 2010 Mark Adler 2 * Copyright (C) 2004, 2005, 2010, 2011 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -274,7 +274,7 @@ int ZEXPORT gzputs(file, str)
274 return ret == 0 && len != 0 ? -1 : ret; 274 return ret == 0 && len != 0 ? -1 : ret;
275} 275}
276 276
277#ifdef STDC 277#if defined(STDC) || defined(Z_HAVE_STDARG_H)
278#include <stdarg.h> 278#include <stdarg.h>
279 279
280/* -- see zlib.h -- */ 280/* -- see zlib.h -- */
@@ -346,7 +346,7 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
346 return len; 346 return len;
347} 347}
348 348
349#else /* !STDC */ 349#else /* !STDC && !Z_HAVE_STDARG_H */
350 350
351/* -- see zlib.h -- */ 351/* -- see zlib.h -- */
352int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, 352int 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,
366 state = (gz_statep)file; 366 state = (gz_statep)file;
367 strm = &(state->strm); 367 strm = &(state->strm);
368 368
369 /* check that can really pass pointer in ints */
370 if (sizeof(int) != sizeof(void *))
371 return 0;
372
369 /* check that we're writing and that there's no error */ 373 /* check that we're writing and that there's no error */
370 if (state->mode != GZ_WRITE || state->err != Z_OK) 374 if (state->mode != GZ_WRITE || state->err != Z_OK)
371 return 0; 375 return 0;
diff --git a/inftrees.c b/inftrees.c
index 11e9c52..2022e96 100644
--- a/inftrees.c
+++ b/inftrees.c
@@ -9,7 +9,7 @@
9#define MAXBITS 15 9#define MAXBITS 15
10 10
11const char inflate_copyright[] = 11const char inflate_copyright[] =
12 " inflate 1.2.5 Copyright 1995-2010 Mark Adler "; 12 " inflate 1.2.5.1 Copyright 1995-2010 Mark Adler ";
13/* 13/*
14 If you use the zlib library in a product, an acknowledgment is welcome 14 If you use the zlib library in a product, an acknowledgment is welcome
15 in the documentation of your product. If for some reason you cannot 15 in the documentation of your product. If for some reason you cannot
@@ -62,7 +62,7 @@ unsigned short FAR *work;
62 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; 62 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
63 static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 63 static const unsigned short lext[31] = { /* Length codes 257..285 extra */
64 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 64 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
65 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195}; 65 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 205, 203};
66 static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 66 static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
67 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 67 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
68 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 68 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
diff --git a/old/as400/compile.clp b/old/as400/compile.clp
deleted file mode 100644
index 8554951..0000000
--- a/old/as400/compile.clp
+++ /dev/null
@@ -1,123 +0,0 @@
1/******************************************************************************/
2/* */
3/* ZLIB */
4/* */
5/* Compile sources into modules and link them into a service program. */
6/* */
7/******************************************************************************/
8
9 PGM
10
11/* Configuration adjustable parameters. */
12
13 DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10) +
14 VALUE('ZLIB') /* Source library. */
15 DCL VAR(&SRCFILE) TYPE(*CHAR) LEN(10) +
16 VALUE('SOURCES') /* Source member file. */
17 DCL VAR(&CTLFILE) TYPE(*CHAR) LEN(10) +
18 VALUE('TOOLS') /* Control member file. */
19
20 DCL VAR(&MODLIB) TYPE(*CHAR) LEN(10) +
21 VALUE('ZLIB') /* Module library. */
22
23 DCL VAR(&SRVLIB) TYPE(*CHAR) LEN(10) +
24 VALUE('LGPL') /* Service program library. */
25
26 DCL VAR(&CFLAGS) TYPE(*CHAR) +
27 VALUE('OPTIMIZE(40)') /* Compile options. */
28
29
30/* Working storage. */
31
32 DCL VAR(&CMDLEN) TYPE(*DEC) LEN(15 5) VALUE(300) /* Command length. */
33 DCL VAR(&CMD) TYPE(*CHAR) LEN(512)
34
35
36/* Compile sources into modules. */
37
38 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
39 '/ADLER32) SRCFILE(' *TCAT +
40 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
41 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
42 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
43
44 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
45 '/COMPRESS) SRCFILE(' *TCAT +
46 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
47 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
48 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
49
50 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
51 '/CRC32) SRCFILE(' *TCAT +
52 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
53 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
54 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
55
56 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
57 '/DEFLATE) SRCFILE(' *TCAT +
58 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
59 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
60 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
61
62 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
63 '/GZIO) SRCFILE(' *TCAT +
64 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
65 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
66 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
67
68 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
69 '/INFBACK) SRCFILE(' *TCAT +
70 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
71 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
72 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
73
74 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
75 '/INFFAST) SRCFILE(' *TCAT +
76 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
77 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
78 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
79
80 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
81 '/INFLATE) SRCFILE(' *TCAT +
82 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
83 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
84 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
85
86 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
87 '/INFTREES) SRCFILE(' *TCAT +
88 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
89 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
90 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
91
92 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
93 '/TREES) SRCFILE(' *TCAT +
94 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
95 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
96 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
97
98 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
99 '/UNCOMPR) SRCFILE(' *TCAT +
100 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
101 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
102 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
103
104 CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT +
105 '/ZUTIL) SRCFILE(' *TCAT +
106 &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT +
107 ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS)
108 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
109
110
111/* Link modules into a service program. */
112
113 CRTSRVPGM SRVPGM(&SRVLIB/ZLIB) +
114 MODULE(&MODLIB/ADLER32 &MODLIB/COMPRESS +
115 &MODLIB/CRC32 &MODLIB/DEFLATE +
116 &MODLIB/GZIO &MODLIB/INFBACK +
117 &MODLIB/INFFAST &MODLIB/INFLATE +
118 &MODLIB/INFTREES &MODLIB/TREES +
119 &MODLIB/UNCOMPR &MODLIB/ZUTIL) +
120 SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) +
121 TEXT('ZLIB 1.2.3') TGTRLS(V4R4M0)
122
123 ENDPGM
diff --git a/qnx/package.qpg b/qnx/package.qpg
index 2bc63b2..c75c4b3 100644
--- a/qnx/package.qpg
+++ b/qnx/package.qpg
@@ -25,10 +25,10 @@
25 <QPG:Files> 25 <QPG:Files>
26 <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/> 26 <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
27 <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/> 27 <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
28 <QPG:Add file="../libz.so.1.2.5" install="/opt/lib/" user="root:bin" permission="644"/> 28 <QPG:Add file="../libz.so.1.2.5.1" install="/opt/lib/" user="root:bin" permission="644"/>
29 <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.5"/> 29 <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.5.1"/>
30 <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.5"/> 30 <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.5.1"/>
31 <QPG:Add file="../libz.so.1.2.5" install="/opt/lib/" component="slib"/> 31 <QPG:Add file="../libz.so.1.2.5.1" install="/opt/lib/" component="slib"/>
32 </QPG:Files> 32 </QPG:Files>
33 33
34 <QPG:PackageFilter> 34 <QPG:PackageFilter>
@@ -63,7 +63,7 @@
63 </QPM:ProductDescription> 63 </QPM:ProductDescription>
64 64
65 <QPM:ReleaseDescription> 65 <QPM:ReleaseDescription>
66 <QPM:ReleaseVersion>1.2.5</QPM:ReleaseVersion> 66 <QPM:ReleaseVersion>1.2.5.1</QPM:ReleaseVersion>
67 <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> 67 <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
68 <QPM:ReleaseStability>Stable</QPM:ReleaseStability> 68 <QPM:ReleaseStability>Stable</QPM:ReleaseStability>
69 <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> 69 <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
diff --git a/treebuild.xml b/treebuild.xml
index 6b8f542..b966b2b 100644
--- a/treebuild.xml
+++ b/treebuild.xml
@@ -1,6 +1,6 @@
1<?xml version="1.0" ?> 1<?xml version="1.0" ?>
2<package name="zlib" version="1.2.5"> 2<package name="zlib" version="1.2.5.1">
3 <library name="zlib" dlversion="1.2.5" dlname="z"> 3 <library name="zlib" dlversion="1.2.5.1" dlname="z">
4 <property name="description"> zip compression library </property> 4 <property name="description"> zip compression library </property>
5 <property name="include-target-dir" value="$(@PACKAGE/install-includedir)" /> 5 <property name="include-target-dir" value="$(@PACKAGE/install-includedir)" />
6 6
diff --git a/win32/Makefile.gcc b/win32/Makefile.gcc
index 0a33bf6..43825c0 100644
--- a/win32/Makefile.gcc
+++ b/win32/Makefile.gcc
@@ -25,7 +25,7 @@
25 25
26STATICLIB = libz.a 26STATICLIB = libz.a
27SHAREDLIB = zlib1.dll 27SHAREDLIB = zlib1.dll
28IMPLIB = libzdll.a 28IMPLIB = libz.dll.a
29 29
30# 30#
31# Set to 1 if shared object needs to be installed 31# Set to 1 if shared object needs to be installed
@@ -59,7 +59,7 @@ CP = cp -fp
59INSTALL = $(CP) 59INSTALL = $(CP)
60RM = rm -f 60RM = rm -f
61 61
62prefix = /usr/local 62prefix ?= /usr/local
63exec_prefix = $(prefix) 63exec_prefix = $(prefix)
64 64
65OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ 65OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \
@@ -118,7 +118,7 @@ zlibrc.o: win32/zlib1.rc
118 118
119install: zlib.h zconf.h $(STATICLIB) $(IMPLIB) 119install: zlib.h zconf.h $(STATICLIB) $(IMPLIB)
120 -@mkdir -p $(INCLUDE_PATH) 120 -@mkdir -p $(INCLUDE_PATH)
121 -@mkdir -p $(LIBRARY_PATH) 121 -@mkdir -p $(LIBRARY_PATH) $(LIBRARY_PATH)/pkgconfig
122 -if [ "$(SHARED_MODE)" = "1" ]; then \ 122 -if [ "$(SHARED_MODE)" = "1" ]; then \
123 mkdir -p $(BINARY_PATH); \ 123 mkdir -p $(BINARY_PATH); \
124 $(INSTALL) $(SHAREDLIB) $(BINARY_PATH); \ 124 $(INSTALL) $(SHAREDLIB) $(BINARY_PATH); \
@@ -127,6 +127,14 @@ install: zlib.h zconf.h $(STATICLIB) $(IMPLIB)
127 -$(INSTALL) zlib.h $(INCLUDE_PATH) 127 -$(INSTALL) zlib.h $(INCLUDE_PATH)
128 -$(INSTALL) zconf.h $(INCLUDE_PATH) 128 -$(INSTALL) zconf.h $(INCLUDE_PATH)
129 -$(INSTALL) $(STATICLIB) $(LIBRARY_PATH) 129 -$(INSTALL) $(STATICLIB) $(LIBRARY_PATH)
130 sed \
131 -e 's|@prefix@|${prefix}|g' \
132 -e 's|@exec_prefix@|${exec_prefix}|g' \
133 -e 's|@libdir@|$(LIBRARY_PATH)|g' \
134 -e 's|@sharedlibdir@|$(LIBRARY_PATH)|g' \
135 -e 's|@includedir@|$(INCLUDE_PATH)|g' \
136 -e 's|@VERSION@|'`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' zlib.h`'|g' \
137 zlib.pc.in > $(LIBRARY_PATH)/pkgconfig/zlib.pc
130 138
131uninstall: 139uninstall:
132 -if [ "$(SHARED_MODE)" = "1" ]; then \ 140 -if [ "$(SHARED_MODE)" = "1" ]; then \
diff --git a/win32/Makefile.msc b/win32/Makefile.msc
index fa10a1a..2714b45 100644
--- a/win32/Makefile.msc
+++ b/win32/Makefile.msc
@@ -30,7 +30,7 @@ ARFLAGS = -nologo
30RCFLAGS = /dWIN32 /r 30RCFLAGS = /dWIN32 /r
31 31
32OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj \ 32OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj \
33 gzwrite.obj infback.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj 33 gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj
34OBJA = 34OBJA =
35 35
36 36
diff --git a/win32/zlib.def b/win32/zlib.def
index 03df8bf..d2e09f2 100644
--- a/win32/zlib.def
+++ b/win32/zlib.def
@@ -15,6 +15,7 @@ EXPORTS
15 deflateParams 15 deflateParams
16 deflateTune 16 deflateTune
17 deflateBound 17 deflateBound
18 deflatePending
18 deflatePrime 19 deflatePrime
19 deflateSetHeader 20 deflateSetHeader
20 inflateSetDictionary 21 inflateSetDictionary
diff --git a/zconf.h b/zconf.h
index 02ce56c..1c06556 100644
--- a/zconf.h
+++ b/zconf.h
@@ -1,5 +1,5 @@
1/* zconf.h -- configuration of the zlib compression library 1/* zconf.h -- configuration of the zlib compression library
2 * Copyright (C) 1995-2010 Jean-loup Gailly. 2 * Copyright (C) 1995-2011 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -15,6 +15,7 @@
15 * this permanently in zconf.h using "./configure --zprefix". 15 * this permanently in zconf.h using "./configure --zprefix".
16 */ 16 */
17#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ 17#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
18# define Z_PREFIX_SET
18 19
19/* all linked symbols */ 20/* all linked symbols */
20# define _dist_code z__dist_code 21# define _dist_code z__dist_code
@@ -40,6 +41,7 @@
40# define deflateInit2_ z_deflateInit2_ 41# define deflateInit2_ z_deflateInit2_
41# define deflateInit_ z_deflateInit_ 42# define deflateInit_ z_deflateInit_
42# define deflateParams z_deflateParams 43# define deflateParams z_deflateParams
44# define deflatePending z_deflatePending
43# define deflatePrime z_deflatePrime 45# define deflatePrime z_deflatePrime
44# define deflateReset z_deflateReset 46# define deflateReset z_deflateReset
45# define deflateSetDictionary z_deflateSetDictionary 47# define deflateSetDictionary z_deflateSetDictionary
@@ -243,6 +245,14 @@
243# endif 245# endif
244#endif 246#endif
245 247
248#ifndef ON /* function prototypes for stdarg */
249# if defined(STDC) || defined(Z_HAVE_STDARG_H)
250# define ON(args) args
251# else
252# define ON(args) ()
253# endif
254#endif
255
246/* The following definitions for FAR are needed only for MSDOS mixed 256/* The following definitions for FAR are needed only for MSDOS mixed
247 * model programming (small or medium model with some far allocations). 257 * model programming (small or medium model with some far allocations).
248 * This was tested only with MSC; for other MSDOS compilers you may have 258 * This was tested only with MSC; for other MSDOS compilers you may have
@@ -360,6 +370,10 @@ typedef uLong FAR uLongf;
360# define Z_HAVE_UNISTD_H 370# define Z_HAVE_UNISTD_H
361#endif 371#endif
362 372
373#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
374# define Z_HAVE_STDARG_H
375#endif
376
363#ifdef STDC 377#ifdef STDC
364# include <sys/types.h> /* for off_t */ 378# include <sys/types.h> /* for off_t */
365#endif 379#endif
@@ -374,7 +388,11 @@ typedef uLong FAR uLongf;
374# undef _LARGEFILE64_SOURCE 388# undef _LARGEFILE64_SOURCE
375#endif 389#endif
376 390
377#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) 391#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
392# define Z_LARGE
393#endif
394
395#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)
378# include <unistd.h> /* for SEEK_* and off_t */ 396# include <unistd.h> /* for SEEK_* and off_t */
379# ifdef VMS 397# ifdef VMS
380# include <unixio.h> /* for off_t */ 398# include <unixio.h> /* for off_t */
diff --git a/zconf.h.cmakein b/zconf.h.cmakein
index a2f71b1..4a5d9ea 100644
--- a/zconf.h.cmakein
+++ b/zconf.h.cmakein
@@ -1,5 +1,5 @@
1/* zconf.h -- configuration of the zlib compression library 1/* zconf.h -- configuration of the zlib compression library
2 * Copyright (C) 1995-2010 Jean-loup Gailly. 2 * Copyright (C) 1995-2011 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -17,6 +17,7 @@
17 * this permanently in zconf.h using "./configure --zprefix". 17 * this permanently in zconf.h using "./configure --zprefix".
18 */ 18 */
19#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ 19#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
20# define Z_PREFIX_SET
20 21
21/* all linked symbols */ 22/* all linked symbols */
22# define _dist_code z__dist_code 23# define _dist_code z__dist_code
@@ -42,6 +43,7 @@
42# define deflateInit2_ z_deflateInit2_ 43# define deflateInit2_ z_deflateInit2_
43# define deflateInit_ z_deflateInit_ 44# define deflateInit_ z_deflateInit_
44# define deflateParams z_deflateParams 45# define deflateParams z_deflateParams
46# define deflatePending z_deflatePending
45# define deflatePrime z_deflatePrime 47# define deflatePrime z_deflatePrime
46# define deflateReset z_deflateReset 48# define deflateReset z_deflateReset
47# define deflateSetDictionary z_deflateSetDictionary 49# define deflateSetDictionary z_deflateSetDictionary
@@ -245,6 +247,14 @@
245# endif 247# endif
246#endif 248#endif
247 249
250#ifndef ON /* function prototypes for stdarg */
251# if defined(STDC) || defined(Z_HAVE_STDARG_H)
252# define ON(args) args
253# else
254# define ON(args) ()
255# endif
256#endif
257
248/* The following definitions for FAR are needed only for MSDOS mixed 258/* The following definitions for FAR are needed only for MSDOS mixed
249 * model programming (small or medium model with some far allocations). 259 * model programming (small or medium model with some far allocations).
250 * This was tested only with MSC; for other MSDOS compilers you may have 260 * This was tested only with MSC; for other MSDOS compilers you may have
@@ -362,6 +372,10 @@ typedef uLong FAR uLongf;
362# define Z_HAVE_UNISTD_H 372# define Z_HAVE_UNISTD_H
363#endif 373#endif
364 374
375#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
376# define Z_HAVE_STDARG_H
377#endif
378
365#ifdef STDC 379#ifdef STDC
366# include <sys/types.h> /* for off_t */ 380# include <sys/types.h> /* for off_t */
367#endif 381#endif
@@ -376,7 +390,11 @@ typedef uLong FAR uLongf;
376# undef _LARGEFILE64_SOURCE 390# undef _LARGEFILE64_SOURCE
377#endif 391#endif
378 392
379#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) 393#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
394# define Z_LARGE
395#endif
396
397#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)
380# include <unistd.h> /* for SEEK_* and off_t */ 398# include <unistd.h> /* for SEEK_* and off_t */
381# ifdef VMS 399# ifdef VMS
382# include <unixio.h> /* for off_t */ 400# include <unixio.h> /* for off_t */
diff --git a/zconf.h.in b/zconf.h.in
index 02ce56c..1c06556 100644
--- a/zconf.h.in
+++ b/zconf.h.in
@@ -1,5 +1,5 @@
1/* zconf.h -- configuration of the zlib compression library 1/* zconf.h -- configuration of the zlib compression library
2 * Copyright (C) 1995-2010 Jean-loup Gailly. 2 * Copyright (C) 1995-2011 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -15,6 +15,7 @@
15 * this permanently in zconf.h using "./configure --zprefix". 15 * this permanently in zconf.h using "./configure --zprefix".
16 */ 16 */
17#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ 17#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
18# define Z_PREFIX_SET
18 19
19/* all linked symbols */ 20/* all linked symbols */
20# define _dist_code z__dist_code 21# define _dist_code z__dist_code
@@ -40,6 +41,7 @@
40# define deflateInit2_ z_deflateInit2_ 41# define deflateInit2_ z_deflateInit2_
41# define deflateInit_ z_deflateInit_ 42# define deflateInit_ z_deflateInit_
42# define deflateParams z_deflateParams 43# define deflateParams z_deflateParams
44# define deflatePending z_deflatePending
43# define deflatePrime z_deflatePrime 45# define deflatePrime z_deflatePrime
44# define deflateReset z_deflateReset 46# define deflateReset z_deflateReset
45# define deflateSetDictionary z_deflateSetDictionary 47# define deflateSetDictionary z_deflateSetDictionary
@@ -243,6 +245,14 @@
243# endif 245# endif
244#endif 246#endif
245 247
248#ifndef ON /* function prototypes for stdarg */
249# if defined(STDC) || defined(Z_HAVE_STDARG_H)
250# define ON(args) args
251# else
252# define ON(args) ()
253# endif
254#endif
255
246/* The following definitions for FAR are needed only for MSDOS mixed 256/* The following definitions for FAR are needed only for MSDOS mixed
247 * model programming (small or medium model with some far allocations). 257 * model programming (small or medium model with some far allocations).
248 * This was tested only with MSC; for other MSDOS compilers you may have 258 * This was tested only with MSC; for other MSDOS compilers you may have
@@ -360,6 +370,10 @@ typedef uLong FAR uLongf;
360# define Z_HAVE_UNISTD_H 370# define Z_HAVE_UNISTD_H
361#endif 371#endif
362 372
373#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
374# define Z_HAVE_STDARG_H
375#endif
376
363#ifdef STDC 377#ifdef STDC
364# include <sys/types.h> /* for off_t */ 378# include <sys/types.h> /* for off_t */
365#endif 379#endif
@@ -374,7 +388,11 @@ typedef uLong FAR uLongf;
374# undef _LARGEFILE64_SOURCE 388# undef _LARGEFILE64_SOURCE
375#endif 389#endif
376 390
377#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) 391#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
392# define Z_LARGE
393#endif
394
395#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)
378# include <unistd.h> /* for SEEK_* and off_t */ 396# include <unistd.h> /* for SEEK_* and off_t */
379# ifdef VMS 397# ifdef VMS
380# include <unixio.h> /* for off_t */ 398# include <unixio.h> /* for off_t */
diff --git a/zlib.3 b/zlib.3
index 27adc4c..66100be 100644
--- a/zlib.3
+++ b/zlib.3
@@ -1,4 +1,4 @@
1.TH ZLIB 3 "19 Apr 2010" 1.TH ZLIB 3 "10 Sep 2011"
2.SH NAME 2.SH NAME
3zlib \- compression/decompression library 3zlib \- compression/decompression library
4.SH SYNOPSIS 4.SH SYNOPSIS
@@ -95,11 +95,11 @@ http://zlib.net/
95The data format used by the zlib library is described by RFC 95The data format used by the zlib library is described by RFC
96(Request for Comments) 1950 to 1952 in the files: 96(Request for Comments) 1950 to 1952 in the files:
97.IP 97.IP
98http://www.ietf.org/rfc/rfc1950.txt (for the zlib header and trailer format) 98http://tools.ietf.org/html/rfc1950 (for the zlib header and trailer format)
99.br 99.br
100http://www.ietf.org/rfc/rfc1951.txt (for the deflate compressed data format) 100http://tools.ietf.org/html/rfc1951 (for the deflate compressed data format)
101.br 101.br
102http://www.ietf.org/rfc/rfc1952.txt (for the gzip header and trailer format) 102http://tools.ietf.org/html/rfc1952 (for the gzip header and trailer format)
103.LP 103.LP
104Mark Nelson wrote an article about 104Mark Nelson wrote an article about
105.I zlib 105.I zlib
@@ -125,8 +125,8 @@ before asking for help.
125Send questions and/or comments to zlib@gzip.org, 125Send questions and/or comments to zlib@gzip.org,
126or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). 126or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
127.SH AUTHORS 127.SH AUTHORS
128Version 1.2.5 128Version 1.2.5.1
129Copyright (C) 1995-2010 Jean-loup Gailly (jloup@gzip.org) 129Copyright (C) 1995-2011 Jean-loup Gailly (jloup@gzip.org)
130and Mark Adler (madler@alumni.caltech.edu). 130and Mark Adler (madler@alumni.caltech.edu).
131.LP 131.LP
132This software is provided "as-is," 132This software is provided "as-is,"
diff --git a/zlib.3.pdf b/zlib.3.pdf
index 9f8a2c3..b253797 100644
--- a/zlib.3.pdf
+++ b/zlib.3.pdf
Binary files differ
diff --git a/zlib.h b/zlib.h
index bfbba83..7c0a2d8 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1,7 +1,7 @@
1/* zlib.h -- interface of the 'zlib' general purpose compression library 1/* zlib.h -- interface of the 'zlib' general purpose compression library
2 version 1.2.5, April 19th, 2010 2 version 1.2.5.1, September 10th, 2011
3 3
4 Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler 4 Copyright (C) 1995-2011 Jean-loup Gailly and Mark Adler
5 5
6 This software is provided 'as-is', without any express or implied 6 This software is provided 'as-is', without any express or implied
7 warranty. In no event will the authors be held liable for any damages 7 warranty. In no event will the authors be held liable for any damages
@@ -24,8 +24,8 @@
24 24
25 25
26 The data format used by the zlib library is described by RFCs (Request for 26 The data format used by the zlib library is described by RFCs (Request for
27 Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt 27 Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
28 (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). 28 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
29*/ 29*/
30 30
31#ifndef ZLIB_H 31#ifndef ZLIB_H
@@ -37,12 +37,12 @@
37extern "C" { 37extern "C" {
38#endif 38#endif
39 39
40#define ZLIB_VERSION "1.2.5" 40#define ZLIB_VERSION "1.2.5.1"
41#define ZLIB_VERNUM 0x1250 41#define ZLIB_VERNUM 0x1251
42#define ZLIB_VER_MAJOR 1 42#define ZLIB_VER_MAJOR 1
43#define ZLIB_VER_MINOR 2 43#define ZLIB_VER_MINOR 2
44#define ZLIB_VER_REVISION 5 44#define ZLIB_VER_REVISION 5
45#define ZLIB_VER_SUBREVISION 0 45#define ZLIB_VER_SUBREVISION 1
46 46
47/* 47/*
48 The 'zlib' compression library provides in-memory compression and 48 The 'zlib' compression library provides in-memory compression and
@@ -85,11 +85,11 @@ struct internal_state;
85typedef struct z_stream_s { 85typedef struct z_stream_s {
86 Bytef *next_in; /* next input byte */ 86 Bytef *next_in; /* next input byte */
87 uInt avail_in; /* number of bytes available at next_in */ 87 uInt avail_in; /* number of bytes available at next_in */
88 uLong total_in; /* total nb of input bytes read so far */ 88 uLong total_in; /* total number of input bytes read so far */
89 89
90 Bytef *next_out; /* next output byte should be put there */ 90 Bytef *next_out; /* next output byte should be put there */
91 uInt avail_out; /* remaining free space at next_out */ 91 uInt avail_out; /* remaining free space at next_out */
92 uLong total_out; /* total nb of bytes output so far */ 92 uLong total_out; /* total number of bytes output so far */
93 93
94 char *msg; /* last error message, NULL if no error */ 94 char *msg; /* last error message, NULL if no error */
95 struct internal_state FAR *state; /* not visible by applications */ 95 struct internal_state FAR *state; /* not visible by applications */
@@ -327,8 +327,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
327 327
328 Z_FINISH can be used immediately after deflateInit if all the compression 328 Z_FINISH can be used immediately after deflateInit if all the compression
329 is to be done in a single step. In this case, avail_out must be at least the 329 is to be done in a single step. In this case, avail_out must be at least the
330 value returned by deflateBound (see below). If deflate does not return 330 value returned by deflateBound (see below). Then deflate is guaranteed to
331 Z_STREAM_END, then it must be called again as described above. 331 return Z_STREAM_END. If not enough output space is provided, deflate will
332 not return Z_STREAM_END, and it must be called again as described above.
332 333
333 deflate() sets strm->adler to the adler32 checksum of all input read 334 deflate() sets strm->adler to the adler32 checksum of all input read
334 so far (that is, total_in bytes). 335 so far (that is, total_in bytes).
@@ -688,8 +689,27 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
688 deflation of sourceLen bytes. It must be called after deflateInit() or 689 deflation of sourceLen bytes. It must be called after deflateInit() or
689 deflateInit2(), and after deflateSetHeader(), if used. This would be used 690 deflateInit2(), and after deflateSetHeader(), if used. This would be used
690 to allocate an output buffer for deflation in a single pass, and so would be 691 to allocate an output buffer for deflation in a single pass, and so would be
691 called before deflate(). 692 called before deflate(). If that first deflate() call is provided the
692*/ 693 sourceLen input bytes, an output buffer allocated to the size returned by
694 deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
695 to return Z_STREAM_END. Note that it is possible for the compressed size to
696 be larger than the value returned by deflateBound() if flush options other
697 than Z_FINISH or Z_NO_FLUSH are used.
698*/
699
700ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
701 unsigned *pending,
702 int *bits));
703/*
704 deflatePending() returns the number of bytes and bits of output that have
705 been generated, but not yet provided in the available output. The bytes not
706 provided would be due to the available output space having being consumed.
707 The number of bits of output not provided are between 0 and 7, where they
708 await more bits to join them in order to fill out a full byte.
709
710 deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
711 stream state was inconsistent.
712 */
693 713
694ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, 714ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
695 int bits, 715 int bits,
@@ -805,17 +825,21 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
805 825
806ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); 826ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
807/* 827/*
808 Skips invalid compressed data until a full flush point (see above the 828 Skips invalid compressed data until a possible full flush point (see above
809 description of deflate with Z_FULL_FLUSH) can be found, or until all 829 for the description of deflate with Z_FULL_FLUSH) can be found, or until all
810 available input is skipped. No output is provided. 830 available input is skipped. No output is provided.
811 831
812 inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR 832 inflateSync searches for a 00 00 FF FF pattern in the compressed data.
813 if no more input was provided, Z_DATA_ERROR if no flush point has been 833 All full flush points have this pattern, but not all occurences of this
814 found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the 834 pattern are full flush points.
815 success case, the application may save the current current value of total_in 835
816 which indicates where valid compressed data was found. In the error case, 836 inflateSync returns Z_OK if a possible full flush point has been found,
817 the application may repeatedly call inflateSync, providing more input each 837 Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
818 time, until success or end of the input data. 838 has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
839 In the success case, the application may save the current current value of
840 total_in which indicates where valid compressed data was found. In the
841 error case, the application may repeatedly call inflateSync, providing more
842 input each time, until success or end of the input data.
819*/ 843*/
820 844
821ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, 845ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
@@ -962,7 +986,7 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
962 See inflateBack() for the usage of these routines. 986 See inflateBack() for the usage of these routines.
963 987
964 inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of 988 inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
965 the paramaters are invalid, Z_MEM_ERROR if the internal state could not be 989 the parameters are invalid, Z_MEM_ERROR if the internal state could not be
966 allocated, or Z_VERSION_ERROR if the version of the library does not match 990 allocated, or Z_VERSION_ERROR if the version of the library does not match
967 the version of the header file. 991 the version of the header file.
968*/ 992*/
@@ -1256,7 +1280,7 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
1256 error. 1280 error.
1257*/ 1281*/
1258 1282
1259ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); 1283ZEXTERN int ZEXPORTVA gzprintf ON((gzFile file, const char *format, ...));
1260/* 1284/*
1261 Converts, formats, and writes the arguments to the compressed file under 1285 Converts, formats, and writes the arguments to the compressed file under
1262 control of the format string, as in fprintf. gzprintf returns the number of 1286 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,
1492 Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 1516 Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
1493 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for 1517 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
1494 each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of 1518 each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
1495 seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. 1519 seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note
1520 that the z_off_t type (like off_t) is a signed integer. If len2 is
1521 negative, the result has no meaning or utility.
1496*/ 1522*/
1497 1523
1498ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); 1524ZEXTERN 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,
1544 const char *version, 1570 const char *version,
1545 int stream_size)); 1571 int stream_size));
1546#define deflateInit(strm, level) \ 1572#define deflateInit(strm, level) \
1547 deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) 1573 deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
1548#define inflateInit(strm) \ 1574#define inflateInit(strm) \
1549 inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) 1575 inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
1550#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ 1576#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
1551 deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ 1577 deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
1552 (strategy), ZLIB_VERSION, sizeof(z_stream)) 1578 (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
1553#define inflateInit2(strm, windowBits) \ 1579#define inflateInit2(strm, windowBits) \
1554 inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) 1580 inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
1581 (int)sizeof(z_stream))
1555#define inflateBackInit(strm, windowBits, window) \ 1582#define inflateBackInit(strm, windowBits, window) \
1556 inflateBackInit_((strm), (windowBits), (window), \ 1583 inflateBackInit_((strm), (windowBits), (window), \
1557 ZLIB_VERSION, sizeof(z_stream)) 1584 ZLIB_VERSION, (int)sizeof(z_stream))
1558 1585
1559/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or 1586/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
1560 * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if 1587 * 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,
1572#endif 1599#endif
1573 1600
1574#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 1601#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
1575# define gzopen gzopen64 1602# ifdef Z_PREFIX_SET
1576# define gzseek gzseek64 1603# define z_gzopen z_gzopen64
1577# define gztell gztell64 1604# define z_gzseek z_gzseek64
1578# define gzoffset gzoffset64 1605# define z_gztell z_gztell64
1579# define adler32_combine adler32_combine64 1606# define z_gzoffset z_gzoffset64
1580# define crc32_combine crc32_combine64 1607# define z_adler32_combine z_adler32_combine64
1581# ifdef _LARGEFILE64_SOURCE 1608# define z_crc32_combine z_crc32_combine64
1609# else
1610# define gzopen gzopen64
1611# define gzseek gzseek64
1612# define gztell gztell64
1613# define gzoffset gzoffset64
1614# define adler32_combine adler32_combine64
1615# define crc32_combine crc32_combine64
1616# endif
1617# ifndef _LARGEFILE64_SOURCE
1582 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); 1618 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
1583 ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); 1619 ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
1584 ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); 1620 ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
diff --git a/zlib.map b/zlib.map
index f282d36..65bcf17 100644
--- a/zlib.map
+++ b/zlib.map
@@ -66,3 +66,7 @@ ZLIB_1.2.3.5 {
66 gzclose_r; 66 gzclose_r;
67 gzclose_w; 67 gzclose_w;
68} ZLIB_1.2.3.4; 68} ZLIB_1.2.3.4;
69
70ZLIB_1.2.5.1 {
71 deflatePending;
72} ZLIB_1.2.5;
diff --git a/zutil.c b/zutil.c
index 898ed34..2ccee81 100644
--- a/zutil.c
+++ b/zutil.c
@@ -1,5 +1,5 @@
1/* zutil.c -- target dependent utility functions for the compression library 1/* zutil.c -- target dependent utility functions for the compression library
2 * Copyright (C) 1995-2005, 2010 Jean-loup Gailly. 2 * Copyright (C) 1995-2005, 2010, 2011 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -85,7 +85,7 @@ uLong ZEXPORT zlibCompileFlags()
85#ifdef FASTEST 85#ifdef FASTEST
86 flags += 1L << 21; 86 flags += 1L << 21;
87#endif 87#endif
88#ifdef STDC 88#if defined(STDC) || defined(Z_HAVE_STDARG_H)
89# ifdef NO_vsnprintf 89# ifdef NO_vsnprintf
90 flags += 1L << 25; 90 flags += 1L << 25;
91# ifdef HAS_vsprintf_void 91# ifdef HAS_vsprintf_void