diff options
| author | cvs2svn <cvs2svn@FreeBSD.org> | 1999-01-21 00:55:32 +0000 |
|---|---|---|
| committer | cvs2svn <cvs2svn@FreeBSD.org> | 1999-01-21 00:55:32 +0000 |
| commit | 76b5366091f76c9bc73570149ef5055648fc2c39 (patch) | |
| tree | 590d020e0f2a5bea6e09d66d951a674443b21d67 /lib/libz | |
| parent | 4b4d01da6f07f7754ff6a6e4f5223e9f0984d1a6 (diff) | |
Diffstat (limited to 'lib/libz')
| -rw-r--r-- | lib/libz/ChangeLog | 69 | ||||
| -rw-r--r-- | lib/libz/FAQ | 72 | ||||
| -rw-r--r-- | lib/libz/README | 77 | ||||
| -rw-r--r-- | lib/libz/adler32.c | 2 | ||||
| -rw-r--r-- | lib/libz/compress.c | 2 | ||||
| -rw-r--r-- | lib/libz/crc32.c | 2 | ||||
| -rw-r--r-- | lib/libz/deflate.c | 10 | ||||
| -rw-r--r-- | lib/libz/deflate.h | 8 | ||||
| -rw-r--r-- | lib/libz/example.c | 30 | ||||
| -rw-r--r-- | lib/libz/gzio.c | 39 | ||||
| -rw-r--r-- | lib/libz/infblock.c | 15 | ||||
| -rw-r--r-- | lib/libz/infcodes.c | 13 | ||||
| -rw-r--r-- | lib/libz/inffast.c | 12 | ||||
| -rw-r--r-- | lib/libz/inffixed.h | 151 | ||||
| -rw-r--r-- | lib/libz/inftrees.c | 31 | ||||
| -rw-r--r-- | lib/libz/inftrees.h | 14 | ||||
| -rw-r--r-- | lib/libz/maketree.c | 85 | ||||
| -rw-r--r-- | lib/libz/minigzip.c | 5 | ||||
| -rw-r--r-- | lib/libz/trees.c | 54 | ||||
| -rw-r--r-- | lib/libz/uncompr.c | 2 | ||||
| -rw-r--r-- | lib/libz/zconf.h | 73 | ||||
| -rw-r--r-- | lib/libz/zlib.3 | 6 | ||||
| -rw-r--r-- | lib/libz/zlib.h | 153 | ||||
| -rw-r--r-- | lib/libz/zutil.c | 10 | ||||
| -rw-r--r-- | lib/libz/zutil.h | 23 |
25 files changed, 248 insertions, 710 deletions
diff --git a/lib/libz/ChangeLog b/lib/libz/ChangeLog index 57386a26f485d..95d3c3b8b2e00 100644 --- a/lib/libz/ChangeLog +++ b/lib/libz/ChangeLog @@ -1,73 +1,6 @@ ChangeLog file for zlib -Changes in 1.1.3 (9 July 1998) -- fix "an inflate input buffer bug that shows up on rare but persistent - occasions" (Mark) -- fix gzread and gztell for concatenated .gz files (Didier Le Botlan) -- fix gzseek(..., SEEK_SET) in write mode -- fix crc check after a gzeek (Frank Faubert) -- fix miniunzip when the last entry in a zip file is itself a zip file - (J Lillge) -- add contrib/asm586 and contrib/asm686 (Brian Raiter) - See http://www.muppetlabs.com/~breadbox/software/assembly.html -- add support for Delphi 3 in contrib/delphi (Bob Dellaca) -- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti) -- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren) -- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks) -- added a FAQ file - -- Support gzdopen on Mac with Metrowerks (Jason Linhart) -- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart) -- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young) -- avoid some warnings with Borland C (Tom Tanner) -- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant) -- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant) -- allow several arguments to configure (Tim Mooney, Frodo Looijaard) -- use libdir and includedir in Makefile.in (Tim Mooney) -- support shared libraries on OSF1 V4 (Tim Mooney) -- remove so_locations in "make clean" (Tim Mooney) -- fix maketree.c compilation error (Glenn, Mark) -- Python interface to zlib now in Python 1.5 (Jeremy Hylton) -- new Makefile.riscos (Rich Walker) -- initialize static descriptors in trees.c for embedded targets (Nick Smith) -- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith) -- add the OS/2 files in Makefile.in too (Andrew Zabolotny) -- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane) -- fix maketree.c to allow clean compilation of inffixed.h (Mark) -- fix parameter check in deflateCopy (Gunther Nikl) -- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler) -- Many portability patches by Christian Spieler: - . zutil.c, zutil.h: added "const" for zmem* - . Make_vms.com: fixed some typos - . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists - . msdos/Makefile.msc: remove "default rtl link library" info from obj files - . msdos/Makefile.*: use model-dependent name for the built zlib library - . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc: - new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT) -- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane) -- replace __far with _far for better portability (Christian Spieler, Tom Lane) -- fix test for errno.h in configure (Tim Newsham) - -Changes in 1.1.2 (19 March 98) -- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) - See http://www.winimage.com/zLibDll/unzip.html -- preinitialize the inflate tables for fixed codes, to make the code - completely thread safe (Mark) -- some simplifications and slight speed-up to the inflate code (Mark) -- fix gzeof on non-compressed files (Allan Schrum) -- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs) -- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn) -- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny) -- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori) -- do not wrap extern "C" around system includes (Tom Lane) -- mention zlib binding for TCL in README (Andreas Kupries) -- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert) -- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson) -- allow "configure --prefix $HOME" (Tim Mooney) -- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson) -- move Makefile.sas to amiga/Makefile.sas - Changes in 1.1.1 (27 Feb 98) - fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) - remove block truncation heuristic which had very marginal effect for zlib @@ -205,7 +138,7 @@ Changes in 1.0.6 (19 Jan 1998) - allow compilation with ANSI keywords only enabled for TurboC in large model - avoid "versionString"[0] (Borland bug) - add NEED_DUMMY_RETURN for Borland -- use variable z_verbose for tracing in debug mode (L. Peter Deutsch). +- use variable z_verbose for tracing in debug mode (Peter Deutsch). - allow compilation with CC - defined STDC for OS/2 (David Charlap) - limit external names to 8 chars for MVS (Thomas Lund) diff --git a/lib/libz/FAQ b/lib/libz/FAQ deleted file mode 100644 index 0feb6d3e9bbbe..0000000000000 --- a/lib/libz/FAQ +++ /dev/null @@ -1,72 +0,0 @@ - - Frequently Asked Questions about zlib - - -If your question is not there, please check the zlib home page -http://www.cdrom.com/pub/infozip/zlib/ which may have more recent information. - - -1) I need a Windows DLL -2) I need a Visual Basic interface to zlib -3) compress() returns Z_BUF_ERROR -4) deflate or inflate returns Z_BUF_ERROR -5) Where is the zlib documentation (man pages, etc...)? -6) Why don't you use GNU autoconf, libtool, etc...? -7) There is a bug in zlib. -8) I get "undefined reference to gzputc" - - - -1) I need a Windows DLL - - The zlib sources can be compiled without change to produce a DLL. - If you want a precompiled DLL, see http://www.winimage.com/zLibDll - - -2) I need a Visual Basic interface to zlib - - See http://www.tcfb.com/dowseware/cmp-z-it.zip - http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm - and contrib/visual-basic.txt - -3) compress() returns Z_BUF_ERROR - - Make sure that before the call of compress, the length of the - compressed buffer is equal to the total size of the compressed buffer - and not zero. For Visual Basic, check that this parameter is passed - by reference ("as any"), not by value ("as long"). - - -4) deflate or inflate returns Z_BUF_ERROR - - Make sure that before the call avail_in and avail_out are not zero. - - -5) Where is the zlib documentation (man pages, etc...)? - - It's in zlib.h for the moment. Volunteers to transform this - to man pages, please contact jloup@gzip.org. Examples of zlib usage - are in the files example.c and minigzip.c. - - -6) Why don't you use GNU autoconf, libtool, etc...? - - Because we would like to keep zlib as a very small and simple package. - zlib is rather portable and doesn't need much configuration. - - -7) There is a bug in zlib. - - Most of the time, such problems are due to an incorrect usage - of zlib. Please try to reproduce the problem with a small - program and send us the corresponding source at zlib@quest.jpl.nasa.gov - Do not send multi-megabyte data files without prior agreement. - - -8) I get "undefined reference to gzputc" - - If "make test" produces something like - example.o(.text+0x174): - check that you don't have old files libz.* in /usr/lib, /usr/local/lib - or /usr/X11R6/lib. Remove old versions then do "make install". - diff --git a/lib/libz/README b/lib/libz/README index 8ff458799b957..acaea4fc8eae7 100644 --- a/lib/libz/README +++ b/lib/libz/README @@ -1,4 +1,4 @@ -zlib 1.1.3 is a general purpose data compression library. All the code +zlib 1.1.1 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate @@ -14,41 +14,26 @@ except example.c and minigzip.c. To compile all files and run the test program, follow the instructions given at the top of Makefile. In short "make test; make install" -should work for most machines. For Unix: "configure; make test; make install" -For MSDOS, use one of the special makefiles such as Makefile.msc. -For VMS, use Make_vms.com or descrip.mms. +should work for most machines. For MSDOS, use one of the special +makefiles such as Makefile.msc; for VMS, use Make_vms.com or descrip.mms. -Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov>, or to -Gilles Vollant <info@winimage.com> for the Windows DLL version. +Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov> or, +if this fails, to the addresses given below in the Copyright section. The zlib home page is http://www.cdrom.com/pub/infozip/zlib/ The official zlib ftp site is ftp://ftp.cdrom.com/pub/infozip/zlib/ -Before reporting a problem, please check those sites to verify that -you have the latest version of zlib; otherwise get the latest version and -check whether the problem still exists or not. - -Mark Nelson <markn@tiny.com> wrote an article about zlib for the Jan. 1997 -issue of Dr. Dobb's Journal; a copy of the article is available in +Mark Nelson wrote an article about zlib for the Jan. 1997 issue of +Dr. Dobb's Journal; a copy of the article is available in http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm -The changes made in version 1.1.3 are documented in the file ChangeLog. -The main changes since 1.1.2 are: - -- fix "an inflate input buffer bug that shows up on rare but persistent - occasions" (Mark) -- fix gzread and gztell for concatenated .gz files (Didier Le Botlan) -- fix gzseek(..., SEEK_SET) in write mode -- fix crc check after a gzeek (Frank Faubert) -- fix miniunzip when the last entry in a zip file is itself a zip file - (J Lillge) -- add contrib/asm586 and contrib/asm686 (Brian Raiter) - See http://www.muppetlabs.com/~breadbox/software/assembly.html -- add support for Delphi 3 in contrib/delphi (Bob Dellaca) -- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti) -- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren) -- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks) -- added a FAQ file - -plus many changes for portability. +The changes made in version 1.1.1 are documented in the file ChangeLog. +The main changes since 1.1.0 are: + +- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) +- remove block truncation heuristic which had very marginal effect for zlib + (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the + compression ratio on some files. This also allows inlining _tr_tally for + matches in deflate_slow. + Unsupported third party contributions are provided in directory "contrib". @@ -61,16 +46,12 @@ is in the CPAN (Comprehensive Perl Archive Network) sites, such as: ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib* A Python interface to zlib written by A.M. Kuchling <amk@magnet.com> -is available in Python 1.5 and later versions, see -http://www.python.org/doc/lib/module-zlib.html - -A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> -is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html +is available from the Python Software Association sites, such as: +ftp://ftp.python.org/pub/python/contrib/Encoding/zlib*.tar.gz -An experimental package to read and write files in .zip format, -written on top of zlib by Gilles Vollant <info@winimage.com>, is -available at http://www.winimage.com/zLibDll/unzip.html -and also in the contrib/minizip directory of zlib. +An experimental package to read files in .zip format, written on top of +zlib by Gilles Vollant <info@winimage.com>, is available at +http://www.winimage.com/zLibDll/unzip.html Notes for some targets: @@ -83,8 +64,8 @@ Notes for some targets: From Visual Basic, you can call the DLL functions which do not take a structure as argument: compress, uncompress and all gz* functions. - See contrib/visual-basic.txt for more information, or get - http://www.tcfb.com/dowseware/cmp-z-it.zip + See contrib/visual-basic.txt for more information. + I don't know how to handle structures in Visual Basic, sorry. - For 64-bit Irix, deflate.c must be compiled without any optimization. With -O, one libpng test fails. The test works in 32 bit mode (with @@ -93,25 +74,23 @@ Notes for some targets: - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works when compiled with cc. -- on Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 - is necessary to get gzprintf working correctly. This is done by configure. - - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with other compilers. Use "make test" to check your compiler. +- For shared memory multiprocessors, the decompression code assumes that + writes to pointers are atomic. Also the functions zalloc and zfree passed + to deflateInit must be multi-threaded in this case. + - gzdopen is not supported on RISCOS, BEOS and by some Mac compilers. - For Turbo C the small model is supported only with reduced performance to avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 -- For PalmOs, see http://www.cs.uit.no/~perm/PASTA/pilot/software.html - Per Harald Myrvang <perm@stud.cs.uit.no> - Acknowledgments: The deflate format used by zlib was defined by Phil Katz. The deflate - and zlib specifications were written by L. Peter Deutsch. Thanks to all the + and zlib specifications were written by Peter Deutsch. Thanks to all the people who reported problems and suggested various improvements in zlib; they are too numerous to cite here. diff --git a/lib/libz/adler32.c b/lib/libz/adler32.c index 16cf9a703f7cd..b1f71ce05fe69 100644 --- a/lib/libz/adler32.c +++ b/lib/libz/adler32.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id$ */ +/* $FreeBSD$ */ #include "zlib.h" diff --git a/lib/libz/compress.c b/lib/libz/compress.c index 1cee470913d75..31c51e611659d 100644 --- a/lib/libz/compress.c +++ b/lib/libz/compress.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id$ */ +/* $FreeBSD$ */ #include "zlib.h" diff --git a/lib/libz/crc32.c b/lib/libz/crc32.c index a91101a81c6ae..2e98580b0b956 100644 --- a/lib/libz/crc32.c +++ b/lib/libz/crc32.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id$ */ +/* $FreeBSD$ */ #include "zlib.h" diff --git a/lib/libz/deflate.c b/lib/libz/deflate.c index cfa05059d3ff2..dc8c76c51372a 100644 --- a/lib/libz/deflate.c +++ b/lib/libz/deflate.c @@ -47,12 +47,12 @@ * */ -/* @(#) $Id: deflate.c,v 1.1.1.3 1999/01/10 09:46:53 peter Exp $ */ +/* $FreeBSD$ */ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.1.3 Copyright 1995-1998 Jean-loup Gailly "; + " deflate 1.1.1 Copyright 1995-1998 Jean-loup Gailly "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -608,13 +608,11 @@ int ZEXPORT deflateCopy (dest, source) deflate_state *ss; ushf *overlay; + ss = source->state; - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { + if (source == Z_NULL || dest == Z_NULL || ss == Z_NULL) { return Z_STREAM_ERROR; } - - ss = source->state; - *dest = *source; ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); diff --git a/lib/libz/deflate.h b/lib/libz/deflate.h index 112a15e0f443e..5cf65ec89f1ec 100644 --- a/lib/libz/deflate.h +++ b/lib/libz/deflate.h @@ -8,7 +8,7 @@ subject to change. Applications should only use zlib.h. */ -/* @(#) $Id: deflate.h,v 1.1.1.3 1999/01/10 09:46:53 peter Exp $ */ +/* $FreeBSD$ */ #ifndef _DEFLATE_H #define _DEFLATE_H @@ -230,12 +230,12 @@ typedef struct internal_state { ulg opt_len; /* bit length of current block with optimal trees */ ulg static_len; /* bit length of current block with static trees */ + ulg compressed_len; /* total bit length of compressed file */ uInt matches; /* number of string matches in current block */ int last_eob_len; /* bit length of EOB code for last block */ #ifdef DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ + ulg bits_sent; /* bit length of the compressed data */ #endif ush bi_buf; @@ -268,7 +268,7 @@ typedef struct internal_state { /* in trees.c */ void _tr_init OF((deflate_state *s)); int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, +ulg _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, int eof)); void _tr_align OF((deflate_state *s)); void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, diff --git a/lib/libz/example.c b/lib/libz/example.c index ed718cbe5f5b5..e313c552d5812 100644 --- a/lib/libz/example.c +++ b/lib/libz/example.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id: example.c,v 1.1.1.3 1999/01/10 09:46:54 peter Exp $ */ +/* $FreeBSD$ */ #include <stdio.h> #include "zlib.h" @@ -15,12 +15,6 @@ extern void exit OF((int)); #endif -#if defined(VMS) || defined(RISCOS) -# define TESTFILE "foo-gz" -#else -# define TESTFILE "foo.gz" -#endif - #define CHECK_ERR(err, msg) { \ if (err != Z_OK) { \ fprintf(stderr, "%s error: %d\n", msg, err); \ @@ -77,7 +71,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) fprintf(stderr, "bad uncompress\n"); exit(1); } else { - printf("uncompress(): %s\n", (char *)uncompr); + printf("uncompress(): %s\n", uncompr); } } @@ -85,8 +79,8 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) * Test read/write of .gz files */ void test_gzio(out, in, uncompr, uncomprLen) - const char *out; /* compressed output file */ - const char *in; /* compressed input file */ + const char *out; /* output file */ + const char *in; /* input file */ Byte *uncompr; int uncomprLen; { @@ -127,13 +121,13 @@ void test_gzio(out, in, uncompr, uncomprLen) fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); exit(1); } else { - printf("gzread(): %s\n", (char *)uncompr); + printf("gzread(): %s\n", uncompr); } pos = gzseek(file, -8L, SEEK_CUR); if (pos != 6 || gztell(file) != pos) { fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", - (long)pos, (long)gztell(file)); + pos, gztell(file)); exit(1); } @@ -152,7 +146,7 @@ void test_gzio(out, in, uncompr, uncomprLen) fprintf(stderr, "bad gzgets after gzseek\n"); exit(1); } else { - printf("gzgets() after gzseek: %s\n", (char *)uncompr); + printf("gzgets() after gzseek: %s\n", uncompr); } gzclose(file); @@ -233,7 +227,7 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen) fprintf(stderr, "bad inflate\n"); exit(1); } else { - printf("inflate(): %s\n", (char *)uncompr); + printf("inflate(): %s\n", uncompr); } } @@ -412,7 +406,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); - printf("after inflateSync(): hel%s\n", (char *)uncompr); + printf("after inflateSync(): hel%s\n", uncompr); } /* =========================================================================== @@ -498,7 +492,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) fprintf(stderr, "bad inflate with dict\n"); exit(1); } else { - printf("inflate with dictionary: %s\n", (char *)uncompr); + printf("inflate with dictionary: %s\n", uncompr); } } @@ -534,8 +528,8 @@ int main(argc, argv) } test_compress(compr, comprLen, uncompr, uncomprLen); - test_gzio((argc > 1 ? argv[1] : TESTFILE), - (argc > 2 ? argv[2] : TESTFILE), + test_gzio((argc > 1 ? argv[1] : "foo.gz"), + (argc > 2 ? argv[2] : "foo.gz"), uncompr, (int)uncomprLen); test_deflate(compr, comprLen); diff --git a/lib/libz/gzio.c b/lib/libz/gzio.c index b2090b8094803..e3782d582712b 100644 --- a/lib/libz/gzio.c +++ b/lib/libz/gzio.c @@ -5,7 +5,7 @@ * Compile this file with -DNO_DEFLATE to avoid the compression code. */ -/* @(#) $Id: gzio.c,v 1.1.1.3 1999/01/10 09:46:54 peter Exp $ */ +/* $FreeBSD$ */ #include <stdio.h> @@ -13,16 +13,8 @@ struct internal_state {int dummy;}; /* for buggy compilers */ -#ifndef Z_BUFSIZE -# ifdef MAXSEG_64K -# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ -# else -# define Z_BUFSIZE 16384 -# endif -#endif -#ifndef Z_PRINTF_BUFSIZE -# define Z_PRINTF_BUFSIZE 4096 -#endif +#define Z_BUFSIZE 16384 +#define Z_PRINTF_BUFSIZE 4096 #define ALLOC(size) malloc(size) #define TRYFREE(p) {if (p) free(p);} @@ -140,12 +132,8 @@ local gzFile gz_open (path, mode, fd) s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); err = inflateInit2(&(s->stream), -MAX_WBITS); - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are - * present after the compressed stream. - */ + /* windowBits is passed < 0 to tell that there is no zlib header */ + if (err != Z_OK || s->inbuf == Z_NULL) { return destroy(s), (gzFile)Z_NULL; } @@ -391,7 +379,6 @@ int ZEXPORT gzread (file, buf, len) len -= s->stream.avail_out; s->stream.total_in += (uLong)len; s->stream.total_out += (uLong)len; - if (len == 0) s->z_eof = 1; return (int)len; } if (s->stream.avail_in == 0 && !s->z_eof) { @@ -414,14 +401,10 @@ int ZEXPORT gzread (file, buf, len) s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); start = s->stream.next_out; - if (getLong(s) != s->crc) { + if (getLong(s) != s->crc || getLong(s) != s->stream.total_out) { s->z_err = Z_DATA_ERROR; } else { - (void)getLong(s); - /* The uncompressed length returned by above getlong() may - * be different from s->stream.total_out) in case of - * concatenated .gz files. Check for such files: - */ + /* Check for concatenated .gz files: */ check_header(s); if (s->z_err == Z_OK) { uLong total_in = s->stream.total_in; @@ -589,7 +572,7 @@ int ZEXPORT gzputs(file, s) gzFile file; const char *s; { - return gzwrite(file, (char*)s, (unsigned)strlen(s)); + return gzwrite(file, (const voidp)s, (unsigned)strlen(s)); } @@ -674,7 +657,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence) return -1L; #else if (whence == SEEK_SET) { - offset -= s->stream.total_in; + offset -= s->stream.total_out; } if (offset < 0) return -1L; @@ -749,7 +732,6 @@ int ZEXPORT gzrewind (file) s->z_eof = 0; s->stream.avail_in = 0; s->stream.next_in = s->inbuf; - s->crc = crc32(0L, Z_NULL, 0); if (s->startpos == 0) { /* not a compressed file */ rewind(s->file); @@ -798,8 +780,7 @@ local void putLong (file, x) } /* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets z_err in case - of error. + Reads a long in LSB order from the given gz_stream. Sets */ local uLong getLong (s) gz_stream *s; diff --git a/lib/libz/infblock.c b/lib/libz/infblock.c index f4920faa5ea06..17943ab7939b9 100644 --- a/lib/libz/infblock.c +++ b/lib/libz/infblock.c @@ -11,10 +11,6 @@ struct inflate_codes_state {int dummy;}; /* for buggy compilers */ -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - /* Table for deflate from PKZIP's appnote.txt. */ local const uInt border[] = { /* Order of the bit length code lengths */ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; @@ -268,8 +264,8 @@ int r; t = s->sub.trees.bb; NEEDBITS(t) h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); - t = h->bits; - c = h->base; + t = h->word.what.Bits; + c = h->more.Base; if (c < 16) { DUMPBITS(t) @@ -345,6 +341,13 @@ int r; s->mode = TYPE; break; } + if (k > 7) /* return unused byte, if any */ + { + Assert(k < 16, "inflate_codes grabbed too many bytes") + k -= 8; + n++; + p--; /* can always return one */ + } s->mode = DRY; case DRY: FLUSH diff --git a/lib/libz/infcodes.c b/lib/libz/infcodes.c index d4e5ee9a55439..181aa53896397 100644 --- a/lib/libz/infcodes.c +++ b/lib/libz/infcodes.c @@ -11,6 +11,8 @@ #include "inffast.h" /* simplify the use of the inflate_huft type with some defines */ +#define base more.Base +#define next more.Next #define exop word.what.Exop #define bits word.what.Bits @@ -143,7 +145,7 @@ int r; if ((e & 64) == 0) /* next table */ { c->sub.code.need = e; - c->sub.code.tree = t + t->base; + c->sub.code.tree = t->next; break; } if (e & 32) /* end of block */ @@ -181,7 +183,7 @@ int r; if ((e & 64) == 0) /* next table */ { c->sub.code.need = e; - c->sub.code.tree = t + t->base; + c->sub.code.tree = t->next; break; } c->mode = BADCODE; /* invalid code */ @@ -221,13 +223,6 @@ int r; c->mode = START; break; case WASH: /* o: got eob, possibly more output */ - if (k > 7) /* return unused byte, if any */ - { - Assert(k < 16, "inflate_codes grabbed too many bytes") - k -= 8; - n++; - p--; /* can always return one */ - } FLUSH if (s->read != s->write) LEAVE diff --git a/lib/libz/inffast.c b/lib/libz/inffast.c index 61a78ee933fcd..3c6ff06f6c250 100644 --- a/lib/libz/inffast.c +++ b/lib/libz/inffast.c @@ -13,12 +13,14 @@ struct inflate_codes_state {int dummy;}; /* for buggy compilers */ /* simplify the use of the inflate_huft type with some defines */ +#define base more.Base +#define next more.Next #define exop word.what.Exop #define bits word.what.Bits /* macros for bit input with no checking and for returning unused bytes */ #define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}} -#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;} +#define UNGRAB {n+=(c=k>>3);p-=c;k&=7;} /* Called with number of bytes left to write in window at least 258 (the maximum string length) and number of input bytes available @@ -118,10 +120,7 @@ z_streamp z; break; } else if ((e & 64) == 0) - { - t += t->base; - e = (t += ((uInt)b & inflate_mask[e]))->exop; - } + e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop; else { z->msg = (char*)"invalid distance code"; @@ -134,8 +133,7 @@ z_streamp z; } if ((e & 64) == 0) { - t += t->base; - if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) + if ((e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop) == 0) { DUMPBITS(t->bits) Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? diff --git a/lib/libz/inffixed.h b/lib/libz/inffixed.h deleted file mode 100644 index 77f7e76314521..0000000000000 --- a/lib/libz/inffixed.h +++ /dev/null @@ -1,151 +0,0 @@ -/* inffixed.h -- table for decoding fixed codes - * Generated automatically by the maketree.c program - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -local uInt fixed_bl = 9; -local uInt fixed_bd = 5; -local inflate_huft fixed_tl[] = { - {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, - {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192}, - {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160}, - {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224}, - {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144}, - {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208}, - {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176}, - {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240}, - {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, - {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200}, - {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168}, - {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232}, - {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152}, - {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216}, - {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184}, - {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248}, - {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, - {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196}, - {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164}, - {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228}, - {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148}, - {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212}, - {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180}, - {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244}, - {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204}, - {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172}, - {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236}, - {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156}, - {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220}, - {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188}, - {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252}, - {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, - {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194}, - {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162}, - {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226}, - {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146}, - {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210}, - {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178}, - {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242}, - {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, - {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202}, - {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170}, - {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234}, - {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154}, - {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218}, - {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186}, - {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250}, - {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, - {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198}, - {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166}, - {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230}, - {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150}, - {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214}, - {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182}, - {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246}, - {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206}, - {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174}, - {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238}, - {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158}, - {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222}, - {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190}, - {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254}, - {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, - {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193}, - {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161}, - {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225}, - {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145}, - {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209}, - {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177}, - {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241}, - {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, - {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201}, - {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169}, - {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233}, - {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153}, - {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217}, - {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185}, - {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249}, - {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, - {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197}, - {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165}, - {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229}, - {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149}, - {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213}, - {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181}, - {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245}, - {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205}, - {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173}, - {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237}, - {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157}, - {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221}, - {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189}, - {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253}, - {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, - {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195}, - {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163}, - {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227}, - {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147}, - {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211}, - {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179}, - {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243}, - {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, - {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203}, - {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171}, - {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235}, - {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155}, - {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219}, - {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187}, - {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251}, - {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, - {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199}, - {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167}, - {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231}, - {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151}, - {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215}, - {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183}, - {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247}, - {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207}, - {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175}, - {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239}, - {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159}, - {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223}, - {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191}, - {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255} - }; -local inflate_huft fixed_td[] = { - {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097}, - {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385}, - {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193}, - {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577}, - {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145}, - {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577}, - {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289}, - {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577} - }; diff --git a/lib/libz/inftrees.c b/lib/libz/inftrees.c index ef1e0b6b87329..9f85187f0af20 100644 --- a/lib/libz/inftrees.c +++ b/lib/libz/inftrees.c @@ -6,12 +6,8 @@ #include "zutil.h" #include "inftrees.h" -#if !defined(BUILDFIXED) && !defined(STDC) -# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */ -#endif - const char inflate_copyright[] = - " inflate 1.1.3 Copyright 1995-1998 Mark Adler "; + " inflate 1.1.1 Copyright 1995-1998 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -21,6 +17,8 @@ const char inflate_copyright[] = struct internal_state {int dummy;}; /* for buggy compilers */ /* simplify the use of the inflate_huft type with some defines */ +#define base more.Base +#define next more.Next #define exop word.what.Exop #define bits word.what.Bits @@ -234,6 +232,11 @@ uIntf *v; /* working area: values in order of bit length */ return Z_MEM_ERROR; /* not enough memory */ u[h] = q = hp + *hn; *hn += z; + if (t != Z_NULL) /* first table is returned result */ + { + *t = q; + t = Z_NULL; + } /* connect to last table, if there is one */ if (h) @@ -241,12 +244,10 @@ uIntf *v; /* working area: values in order of bit length */ x[h] = i; /* save pattern for backing up */ r.bits = (Byte)l; /* bits to dump before this table */ r.exop = (Byte)j; /* bits in this table */ - j = i >> (w - l); - r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ + r.next = q; /* pointer to this table */ + j = i >> (w - l); /* (get around Turbo C bug) */ u[h-1][j] = r; /* connect to last table */ } - else - *t = q; /* first table is returned result */ } /* set up table entry in r */ @@ -383,17 +384,13 @@ z_streamp z; /* for messages */ /* build fixed tables only once--keep them here */ -#ifdef BUILDFIXED local int fixed_built = 0; -#define FIXEDH 544 /* number of hufts used by fixed tables */ +#define FIXEDH 424 /* number of hufts used by fixed tables */ local inflate_huft fixed_mem[FIXEDH]; local uInt fixed_bl; local uInt fixed_bd; local inflate_huft *fixed_tl; local inflate_huft *fixed_td; -#else -#include "inffixed.h" -#endif int inflate_trees_fixed(bl, bd, tl, td, z) @@ -403,8 +400,7 @@ inflate_huft * FAR *tl; /* literal/length tree result */ inflate_huft * FAR *td; /* distance tree result */ z_streamp z; /* for memory allocation */ { -#ifdef BUILDFIXED - /* build fixed tables if not already */ + /* build fixed tables if not already (multiple overlapped executions ok) */ if (!fixed_built) { int k; /* temporary variable */ @@ -430,7 +426,7 @@ z_streamp z; /* for memory allocation */ c[k] = 7; for (; k < 288; k++) c[k] = 8; - fixed_bl = 9; + fixed_bl = 7; huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, fixed_mem, &f, v); @@ -446,7 +442,6 @@ z_streamp z; /* for memory allocation */ ZFREE(z, c); fixed_built = 1; } -#endif *bl = fixed_bl; *bd = fixed_bd; *tl = fixed_tl; diff --git a/lib/libz/inftrees.h b/lib/libz/inftrees.h index 85853e097b373..c2513d194927a 100644 --- a/lib/libz/inftrees.h +++ b/lib/libz/inftrees.h @@ -19,15 +19,17 @@ struct inflate_huft_s { Byte Exop; /* number of extra bits or operation */ Byte Bits; /* number of bits in this code or subcode */ } what; - uInt pad; /* pad structure to a power of 2 (4 bytes for */ - } word; /* 16-bit, 8 bytes for 32-bit int's) */ - uInt base; /* literal, length base, distance base, - or table offset */ + Bytef *pad; /* pad structure to a power of 2 (4 bytes for */ + } word; /* 16-bit, 8 bytes for 32-bit machines) */ + union { + uInt Base; /* literal, length base, or distance base */ + inflate_huft *Next; /* pointer to next level of table */ + } more; }; /* Maximum size of dynamic tree. The maximum found in a long but non- - exhaustive search was 1004 huft structures (850 for length/literals - and 154 for distances, the latter actually the result of an + exhaustive search was 1041 huft structures (875 for length/literals + and 166 for distances, the latter actually the result of an exhaustive search). The actual maximum is not known, but the value below is more than safe. */ #define MANY 1440 diff --git a/lib/libz/maketree.c b/lib/libz/maketree.c deleted file mode 100644 index 949d786418513..0000000000000 --- a/lib/libz/maketree.c +++ /dev/null @@ -1,85 +0,0 @@ -/* maketree.c -- make inffixed.h table for decoding fixed codes - * Copyright (C) 1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* This program is included in the distribution for completeness. - You do not need to compile or run this program since inffixed.h - is already included in the distribution. To use this program - you need to compile zlib with BUILDFIXED defined and then compile - and link this program with the zlib library. Then the output of - this program can be piped to inffixed.h. */ - -#include <stdio.h> -#include <stdlib.h> -#include "zutil.h" -#include "inftrees.h" - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -/* generate initialization table for an inflate_huft structure array */ -void maketree(uInt b, inflate_huft *t) -{ - int i, e; - - i = 0; - while (1) - { - e = t[i].exop; - if (e && (e & (16+64)) == 0) /* table pointer */ - { - fprintf(stderr, "maketree: cannot initialize sub-tables!\n"); - exit(1); - } - if (i % 4 == 0) - printf("\n "); - printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base); - if (++i == (1<<b)) - break; - putchar(','); - } - puts(""); -} - -/* create the fixed tables in C initialization syntax */ -void main(void) -{ - int r; - uInt bl, bd; - inflate_huft *tl, *td; - z_stream z; - - z.zalloc = zcalloc; - z.opaque = (voidpf)0; - z.zfree = zcfree; - r = inflate_trees_fixed(&bl, &bd, &tl, &td, &z); - if (r) - { - fprintf(stderr, "inflate_trees_fixed error %d\n", r); - return; - } - puts("/* inffixed.h -- table for decoding fixed codes"); - puts(" * Generated automatically by the maketree.c program"); - puts(" */"); - puts(""); - puts("/* WARNING: this file should *not* be used by applications. It is"); - puts(" part of the implementation of the compression library and is"); - puts(" subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - printf("local uInt fixed_bl = %d;\n", bl); - printf("local uInt fixed_bd = %d;\n", bd); - printf("local inflate_huft fixed_tl[] = {"); - maketree(bl, tl); - puts(" };"); - printf("local inflate_huft fixed_td[] = {"); - maketree(bd, td); - puts(" };"); -} diff --git a/lib/libz/minigzip.c b/lib/libz/minigzip.c index 180b39d2ce241..487632e7f1d2f 100644 --- a/lib/libz/minigzip.c +++ b/lib/libz/minigzip.c @@ -13,7 +13,7 @@ * or in pipe mode. */ -/* @(#) $Id: minigzip.c,v 1.1.1.3 1999/01/10 09:46:57 peter Exp $ */ +/* $FreeBSD$ */ #include <stdio.h> #include "zlib.h" @@ -48,9 +48,6 @@ # define GZ_SUFFIX "-gz" # define fileno(file) file->__file #endif -#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include <unix.h> /* for fileno */ -#endif #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ extern int unlink OF((const char *)); diff --git a/lib/libz/trees.c b/lib/libz/trees.c index b02b5277f48a2..2497001742d3e 100644 --- a/lib/libz/trees.c +++ b/lib/libz/trees.c @@ -29,7 +29,7 @@ * Addison-Wesley, 1983. ISBN 0-201-06672-6. */ -/* @(#) $Id: trees.c,v 1.1.1.3 1999/01/10 09:46:57 peter Exp $ */ +/* $FreeBSD$ */ /* #define GEN_TREES_H */ @@ -250,13 +250,6 @@ local void tr_static_init() if (static_init_done) return; - /* For some embedded targets, global variables are not initialized: */ - static_l_desc.static_tree = static_ltree; - static_l_desc.extra_bits = extra_lbits; - static_d_desc.static_tree = static_dtree; - static_d_desc.extra_bits = extra_dbits; - static_bl_desc.extra_bits = extra_blbits; - /* Initialize the mapping length (0..255) -> length code (0..28) */ length = 0; for (code = 0; code < LENGTH_CODES-1; code++) { @@ -385,6 +378,8 @@ void _tr_init(s) { tr_static_init(); + s->compressed_len = 0L; + s->l_desc.dyn_tree = s->dyn_ltree; s->l_desc.stat_desc = &static_l_desc; @@ -398,7 +393,6 @@ void _tr_init(s) s->bi_valid = 0; s->last_eob_len = 8; /* enough lookahead for inflate */ #ifdef DEBUG - s->compressed_len = 0L; s->bits_sent = 0L; #endif @@ -871,10 +865,9 @@ void _tr_stored_block(s, buf, stored_len, eof) int eof; /* true if this is the last block for a file */ { send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ -#ifdef DEBUG s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len += (stored_len + 4) << 3; -#endif + copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ } @@ -894,9 +887,7 @@ void _tr_align(s) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ -#endif bi_flush(s); /* Of the 10 bits for the empty block, we have already sent * (10 - bi_valid) bits. The lookahead for the last real code (before @@ -906,9 +897,7 @@ void _tr_align(s) if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG s->compressed_len += 10L; -#endif bi_flush(s); } s->last_eob_len = 7; @@ -916,9 +905,10 @@ void _tr_align(s) /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. + * trees or store, and output the encoded block to the zip file. This function + * returns the total compressed length for the file so far. */ -void _tr_flush_block(s, buf, stored_len, eof) +ulg _tr_flush_block(s, buf, stored_len, eof) deflate_state *s; charf *buf; /* input block, or NULL if too old */ ulg stored_len; /* length of input block */ @@ -965,6 +955,25 @@ void _tr_flush_block(s, buf, stored_len, eof) opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ } + /* If compression failed and this is the first and last block, + * and if the .zip file can be seeked (to rewrite the local header), + * the whole file is transformed into a stored file: + */ +#ifdef STORED_FILE_OK +# ifdef FORCE_STORED_FILE + if (eof && s->compressed_len == 0L) { /* force stored file */ +# else + if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) { +# endif + /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ + if (buf == (charf*)0) error ("block vanished"); + + copy_block(buf, (unsigned)stored_len, 0); /* without header */ + s->compressed_len = stored_len << 3; + s->method = STORED; + } else +#endif /* STORED_FILE_OK */ + #ifdef FORCE_STORED if (buf != (char*)0) { /* force stored block */ #else @@ -986,32 +995,25 @@ void _tr_flush_block(s, buf, stored_len, eof) #endif send_bits(s, (STATIC_TREES<<1)+eof, 3); compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); -#ifdef DEBUG s->compressed_len += 3 + s->static_len; -#endif } else { send_bits(s, (DYN_TREES<<1)+eof, 3); send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, max_blindex+1); compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); -#ifdef DEBUG s->compressed_len += 3 + s->opt_len; -#endif } Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - /* The above check is made mod 2^32, for files larger than 512 MB - * and uLong implemented on 32 bits. - */ init_block(s); if (eof) { bi_windup(s); -#ifdef DEBUG s->compressed_len += 7; /* align on byte boundary */ -#endif } Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, s->compressed_len-7*eof)); + + return s->compressed_len >> 3; } /* =========================================================================== diff --git a/lib/libz/uncompr.c b/lib/libz/uncompr.c index d1033213781ee..b1bd9fc41b0f3 100644 --- a/lib/libz/uncompr.c +++ b/lib/libz/uncompr.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id$ */ +/* $FreeBSD$ */ #include "zlib.h" diff --git a/lib/libz/zconf.h b/lib/libz/zconf.h index f06124f81b7f5..5b71e4b0ad425 100644 --- a/lib/libz/zconf.h +++ b/lib/libz/zconf.h @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id: zconf.h,v 1.1.1.3 1999/01/10 09:46:58 peter Exp $ */ +/* $FreeBSD$ */ #ifndef _ZCONF_H #define _ZCONF_H @@ -91,8 +91,8 @@ # define NO_DUMMY_DECL #endif -/* Old Borland C incorrectly complains about missing returns: */ -#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +/* Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) # define NEED_DUMMY_RETURN #endif @@ -148,7 +148,7 @@ /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER -# define FAR _far +# define FAR __far # else # define FAR far # endif @@ -156,68 +156,42 @@ #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) # ifndef __32BIT__ # define SMALL_MEDIUM -# define FAR _far +# define FAR __far # endif #endif /* Compile with -DZLIB_DLL for Windows DLL support */ -#if defined(ZLIB_DLL) -# if defined(_WINDOWS) || defined(WINDOWS) -# ifdef FAR -# undef FAR -# endif -# include <windows.h> -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR _cdecl _export -# endif +#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL) +# ifdef FAR +# undef FAR # endif -# if defined (__BORLANDC__) -# if (__BORLANDC__ >= 0x0500) && defined (WIN32) -# include <windows.h> -# define ZEXPORT __declspec(dllexport) WINAPI -# define ZEXPORTRVA __declspec(dllexport) WINAPIV -# else -# if defined (_Windows) && defined (__DLL__) -# define ZEXPORT _export -# define ZEXPORTVA _export -# endif -# endif -# endif -#endif - -#if defined (__BEOS__) -# if defined (ZLIB_DLL) -# define ZEXTERN extern __declspec(dllexport) +# include <windows.h> +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV # else -# define ZEXTERN extern __declspec(dllimport) +# define ZEXPORTVA FAR _cdecl _export # endif -#endif - -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif -#ifndef ZEXTERN -# define ZEXTERN extern +#else +# if defined (__BORLANDC__) && defined (_Windows) && defined (__DLL__) +# define ZEXPORT _export +# define ZEXPORTVA _export +# else +# define ZEXPORT +# define ZEXPORTVA +# endif #endif #ifndef FAR # define FAR #endif -#if !defined(MACOS) && !defined(TARGET_OS_MAC) typedef unsigned char Byte; /* 8 bits */ -#endif typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +#if defined(__BORLANDC__) && defined(SMALL_MEDIUM) + /* Borland C/C++ ignores FAR inside typedef */ # define Bytef Byte FAR #else typedef Byte FAR Bytef; @@ -243,7 +217,6 @@ typedef uLong FAR uLongf; #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long diff --git a/lib/libz/zlib.3 b/lib/libz/zlib.3 index 25c8495d25f1f..8519184d4fb86 100644 --- a/lib/libz/zlib.3 +++ b/lib/libz/zlib.3 @@ -1,4 +1,4 @@ -.TH ZLIB 3 "9 July 1998" +.TH ZLIB 3 "27 February 1998" .SH NAME zlib \- compression/decompression library .SH SYNOPSIS @@ -81,7 +81,7 @@ These documents are also available in other formats from: .IP ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html .SH AUTHORS -Version 1.1.3 +Version 1.1.1 Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org) and Mark Adler (madler@alumni.caltech.edu). .LP @@ -96,7 +96,7 @@ The deflate format used by was defined by Phil Katz. The deflate and .I zlib -specifications were written by L. Peter Deutsch. +specifications were written by Peter Deutsch. Thanks to all the people who reported problems and suggested various improvements in .IR zlib ; diff --git a/lib/libz/zlib.h b/lib/libz/zlib.h index 49f56b43bc6c5..06f988c1f0585 100644 --- a/lib/libz/zlib.h +++ b/lib/libz/zlib.h @@ -1,5 +1,5 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.1.3, July 9th, 1998 + version 1.1.1, Feb 27th, 1998 Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler @@ -31,13 +31,13 @@ #ifndef _ZLIB_H #define _ZLIB_H -#include "zconf.h" - #ifdef __cplusplus extern "C" { #endif -#define ZLIB_VERSION "1.1.3" +#include "zconf.h" + +#define ZLIB_VERSION "1.1.1" /* The 'zlib' compression library provides in-memory compression and @@ -168,7 +168,7 @@ typedef z_stream FAR *z_streamp; /* basic functions */ -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +extern const char * ZEXPORT zlibVersion OF((void)); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. @@ -176,7 +176,7 @@ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); */ /* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); +extern int ZEXPORT deflateInit OF((z_streamp strm, int level)); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. @@ -198,7 +198,7 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); */ -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +extern int ZEXPORT deflate OF((z_streamp strm, int flush)); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some @@ -271,12 +271,11 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); processed or more output produced), Z_STREAM_END if all input has been consumed and all output has been produced (only when flush is set to Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible. */ -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +extern int ZEXPORT deflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any @@ -291,7 +290,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); +extern int ZEXPORT inflateInit OF((z_streamp strm)); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by @@ -311,7 +310,7 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); */ -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +extern int ZEXPORT inflate OF((z_streamp strm, int flush)); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may some @@ -380,7 +379,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); */ -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +extern int ZEXPORT inflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any @@ -398,12 +397,12 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); */ /* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); +extern int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); This is another version of deflateInit with more compression options. The fields next_in, zalloc, zfree and opaque must be initialized before by @@ -441,14 +440,14 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, not perform any compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); +extern int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same + immediately after deflateInit or deflateInit2, before any call of + deflate. The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary). The dictionary should consist of strings (byte sequences) that are likely @@ -477,8 +476,8 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, perform any compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); +extern int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); /* Sets the destination stream as a complete copy of the source stream. @@ -495,7 +494,7 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, destination. */ -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +extern int ZEXPORT deflateReset OF((z_streamp strm)); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate all the internal compression state. @@ -506,9 +505,7 @@ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); stream state was inconsistent (such as zalloc or state being NULL). */ -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); +extern int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy)); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2. This can be @@ -528,8 +525,8 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, */ /* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); +extern int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized @@ -550,9 +547,9 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, modified, but next_out and avail_out are unchanged.) */ -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); +extern int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate @@ -569,7 +566,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, inflate(). */ -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +extern int ZEXPORT inflateSync OF((z_streamp strm)); /* Skips invalid compressed data until a full flush point (see above the description of deflate with Z_FULL_FLUSH) can be found, or until all @@ -584,7 +581,7 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); until success or end of the input data. */ -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +extern int ZEXPORT inflateReset OF((z_streamp strm)); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate all the internal decompression state. @@ -605,8 +602,8 @@ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); utility functions can easily be modified if you need special options. */ -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); +extern int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total @@ -620,9 +617,9 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, buffer. */ -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); +extern int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte @@ -635,8 +632,8 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, Z_STREAM_ERROR if the level parameter is invalid. */ -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); +extern int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total @@ -656,7 +653,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, typedef voidp gzFile; -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +extern gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); /* Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level @@ -672,7 +669,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR). */ -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +extern gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); /* gzdopen() associates a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or @@ -685,7 +682,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); the (de)compression state. */ -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +extern int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); /* Dynamically update the compression level or strategy. See the description of deflateInit2 for the meaning of these parameters. @@ -693,7 +690,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); opened for writing. */ -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +extern int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); /* Reads the given number of uncompressed bytes from the compressed file. If the input file was not in gzip format, gzread copies the given number @@ -701,29 +698,28 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); gzread returns the number of uncompressed bytes actually read (0 for end of file, -1 for error). */ -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - const voidp buf, unsigned len)); +extern int ZEXPORT gzwrite OF((gzFile file, const voidp buf, unsigned len)); /* Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of uncompressed bytes actually written (0 in case of error). */ -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +extern int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); /* Converts, formats, and writes the args to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of uncompressed bytes actually written (0 in case of error). */ -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +extern int ZEXPORT gzputs OF((gzFile file, const char *s)); /* Writes the given null-terminated string to the compressed file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +extern char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); /* Reads bytes from the compressed file until len-1 characters are read, or a newline character is read and transferred to buf, or an end-of-file @@ -732,19 +728,19 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); gzgets returns buf, or Z_NULL in case of error. */ -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +extern int ZEXPORT gzputc OF((gzFile file, int c)); /* Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error. */ -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +extern int ZEXPORT gzgetc OF((gzFile file)); /* Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. */ -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +extern int ZEXPORT gzflush OF((gzFile file, int flush)); /* Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. The return value is the zlib @@ -754,11 +750,10 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); degrade compression. */ -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); +extern z_off_t ZEXPORT gzseek OF((gzFile file, z_off_t offset, int whence)); /* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. If the file is opened for reading, this function is emulated but can be @@ -772,14 +767,14 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, would be before the current position. */ -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +extern int ZEXPORT gzrewind OF((gzFile file)); /* Rewinds the given file. This function is supported only for reading. gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) */ -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +extern z_off_t ZEXPORT gztell OF((gzFile file)); /* Returns the starting position for the next gzread or gzwrite on the given compressed file. This position represents a number of bytes in the @@ -788,20 +783,20 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +extern int ZEXPORT gzeof OF((gzFile file)); /* Returns 1 when EOF has previously been detected reading the given input stream, otherwise zero. */ -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +extern int ZEXPORT gzclose OF((gzFile file)); /* Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. The return value is the zlib error number (see function gzerror below). */ -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +extern const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); /* Returns the error message for the last error which occurred on the given compressed file. errnum is set to zlib error number. If an @@ -818,7 +813,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); compression library. */ -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +extern uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and @@ -835,7 +830,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); if (adler != original_adler) error(); */ -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +extern uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* Update a running crc with the bytes buf[0..len-1] and return the updated crc. If buf is NULL, this function returns the required initial value @@ -857,16 +852,16 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, +extern int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +extern int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +extern int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +extern int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); #define deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit(strm) \ @@ -882,9 +877,9 @@ ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif -ZEXTERN const char * ZEXPORT zError OF((int err)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +extern const char * ZEXPORT zError OF((int err)); +extern int ZEXPORT inflateSyncPoint OF((z_streamp z)); +extern const uLongf * ZEXPORT get_crc_table OF((void)); #ifdef __cplusplus } diff --git a/lib/libz/zutil.c b/lib/libz/zutil.c index 60340c838cb98..0d12b55d28b2e 100644 --- a/lib/libz/zutil.c +++ b/lib/libz/zutil.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id: zutil.c,v 1.1.1.3 1999/01/10 09:46:59 peter Exp $ */ +/* $FreeBSD$ */ #include "zutil.h" @@ -60,7 +60,7 @@ const char * ZEXPORT zError(err) void zmemcpy(dest, source, len) Bytef* dest; - const Bytef* source; + Bytef* source; uInt len; { if (len == 0) return; @@ -70,8 +70,8 @@ void zmemcpy(dest, source, len) } int zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; + Bytef* s1; + Bytef* s2; uInt len; { uInt j; @@ -178,7 +178,7 @@ void zcfree (voidpf opaque, voidpf ptr) # define MY_ZCALLOC -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) +#if (!defined(_MSC_VER) || (_MSC_VER < 600)) # define _halloc halloc # define _hfree hfree #endif diff --git a/lib/libz/zutil.h b/lib/libz/zutil.h index 429339ff9846a..3843e0de9f2fd 100644 --- a/lib/libz/zutil.h +++ b/lib/libz/zutil.h @@ -8,7 +8,7 @@ subject to change. Applications should only use zlib.h. */ -/* @(#) $Id: zutil.h,v 1.1.1.3 1999/01/10 09:46:59 peter Exp $ */ +/* $FreeBSD$ */ #ifndef _Z_UTIL_H #define _Z_UTIL_H @@ -75,7 +75,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ #ifdef MSDOS # define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) +# ifdef __TURBOC__ # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) /* Allow compilation with ANSI keywords only enabled */ void _Cdecl farfree( void *block ); @@ -112,12 +112,13 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ #if defined(MACOS) || defined(TARGET_OS_MAC) # define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include <unix.h> /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +#endif +#if defined(__MWERKS__) && !defined(fdopen) +# if __dest_os != __be_os && __dest_os != __win32_os +# define fdopen(fd,mode) NULL # endif #endif @@ -133,7 +134,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ # define fdopen(fd,mode) NULL /* No fdopen() */ #endif -#if (defined(_MSC_VER) && (_MSC_VER > 600)) +#if (defined(_MSC_VER) && (_MSC_VER >= 600)) # define fdopen(fd,type) _fdopen(fd,type) #endif @@ -181,8 +182,8 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ # define zmemzero(dest, len) memset(dest, 0, len) # endif #else - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len)); + extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len)); extern void zmemzero OF((Bytef* dest, uInt len)); #endif |
