X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=common%2Fzlib.c;h=63902209d7f16f6467da52a79a1e7c21f2634053;hb=01070777efb6acb4a0b5071bcf5ece2f5e12bf78;hp=ef226b525311a8917dcc877245fd835f0156c78e;hpb=fb9ffbf550b7921e4e965e088ceacded8b2dc4dd;p=ppp.git diff --git a/common/zlib.c b/common/zlib.c index ef226b5..6390220 100644 --- a/common/zlib.c +++ b/common/zlib.c @@ -1,14 +1,25 @@ /* - * This file is a conglomeration of various .h and .c files - * from the zlib-0.95 library source, slightly hacked. + * This file is derived from various .h and .c files from the zlib-0.95 + * distribution by Jean-loup Gailly and Mark Adler, with some additions + * by Paul Mackerras to aid in implementing Deflate compression and + * decompression for PPP packets. See zlib.h for conditions of + * distribution and use. * * Changes that have been made include: * - changed functions not used outside this file to "local" * - added minCompression parameter to deflateInit2 * - added Z_PACKET_FLUSH (see zlib.h for details) * - added inflateIncomp + * + * $Id: zlib.c,v 1.5 1997/03/04 03:26:35 paulus Exp $ */ +/* + * ==FILEVERSION 960926== + * + * This marker is used by the Linux installation script to determine + * whether an up-to-date version of this file is already installed. + */ /*+++++*/ /* zutil.h -- internal interface and configuration of the compression library @@ -21,16 +32,12 @@ subject to change. Applications should only use zlib.h. */ -/* $Id: zlib.c,v 1.1 1996/01/18 03:26:49 paulus Exp $ */ +/* From: zutil.h,v 1.9 1995/05/03 17:27:12 jloup Exp */ #define _Z_UTIL_H #include "zlib.h" -#ifdef STDC -# include -#endif - #ifndef local # define local static #endif @@ -49,6 +56,10 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */ #define ERR_RETURN(strm,err) return (strm->msg=z_errmsg[1-err], err) /* To be used only when the state is known to be valid */ +#ifndef NULL +#define NULL ((void *) 0) +#endif + /* common constants */ #define DEFLATED 8 @@ -77,9 +88,20 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */ /* functions */ #if defined(KERNEL) || defined(_KERNEL) +#include +#include +#include # define zmemcpy(d, s, n) bcopy((s), (d), (n)) # define zmemzero bzero + #else +#if defined(__KERNEL__) +/* Assume this is Linux */ +#include +#define zmemcpy memcpy +#define zmemzero(dest, len) memset(dest, 0, len) + +#else /* not kernel */ #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) # define HAVE_MEMCPY #endif @@ -90,7 +112,8 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */ extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len)); extern void zmemzero OF((Bytef* dest, uInt len)); #endif -#endif +#endif /* __KERNEL__ */ +#endif /* KERNEL */ /* Diagnostic functions */ #ifdef DEBUG_ZLIB @@ -137,7 +160,7 @@ typedef uLong (*check_func) OF((uLong check, Bytef *buf, uInt len)); /*+++++*/ -/* $Id: zlib.c,v 1.1 1996/01/18 03:26:49 paulus Exp $ */ +/* From: deflate.h,v 1.5 1995/05/03 17:27:09 jloup Exp */ /* =========================================================================== * Internal compression state. @@ -461,9 +484,9 @@ local void ct_stored_type_only OF((deflate_state *s)); * */ -/* $Id: zlib.c,v 1.1 1996/01/18 03:26:49 paulus Exp $ */ +/* From: deflate.c,v 1.8 1995/05/03 17:27:08 jloup Exp */ -local char copyright[] = " deflate Copyright 1995 Jean-loup Gailly "; +local char zlib_copyright[] = " deflate Copyright 1995 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 @@ -1223,7 +1246,7 @@ local int deflate_fast(s, flush) deflate_state *s; int flush; { - IPos hash_head; /* head of the hash chain */ + IPos hash_head = NIL; /* head of the hash chain */ int bflush; /* set if current block must be flushed */ s->prev_length = MIN_MATCH-1; @@ -1319,7 +1342,7 @@ local int deflate_slow(s, flush) deflate_state *s; int flush; { - IPos hash_head; /* head of hash chain */ + IPos hash_head = NIL; /* head of hash chain */ int bflush; /* set if current block must be flushed */ /* Process the input block. */ @@ -1464,7 +1487,7 @@ local int deflate_slow(s, flush) * Addison-Wesley, 1983. ISBN 0-201-06672-6. */ -/* $Id: zlib.c,v 1.1 1996/01/18 03:26:49 paulus Exp $ */ +/* From: trees.c,v 1.5 1995/05/03 17:27:12 jloup Exp */ #ifdef DEBUG_ZLIB # include @@ -3201,7 +3224,7 @@ local uInt border[] = { /* Order of the bit length code lengths */ */ -void inflate_blocks_reset(s, z, c) +local void inflate_blocks_reset(s, z, c) inflate_blocks_statef *s; z_stream *z; uLongf *c; @@ -3226,7 +3249,7 @@ uLongf *c; } -inflate_blocks_statef *inflate_blocks_new(z, c, w) +local inflate_blocks_statef *inflate_blocks_new(z, c, w) z_stream *z; check_func c; uInt w; @@ -3250,7 +3273,7 @@ uInt w; } -int inflate_blocks(s, z, r) +local int inflate_blocks(s, z, r) inflate_blocks_statef *s; z_stream *z; int r; @@ -3513,7 +3536,7 @@ int r; } -int inflate_blocks_free(s, z, c) +local int inflate_blocks_free(s, z, c) inflate_blocks_statef *s; z_stream *z; uLongf *c; @@ -3887,7 +3910,7 @@ z_stream *zs; /* for zalloc function */ } -int inflate_trees_bits(c, bb, tb, z) +local int inflate_trees_bits(c, bb, tb, z) uIntf *c; /* 19 code lengths */ uIntf *bb; /* bits tree desired/actual depth */ inflate_huft * FAR *tb; /* bits tree result */ @@ -3908,7 +3931,7 @@ z_stream *z; /* for zfree function */ } -int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, z) +local int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, z) uInt nl; /* number of literal/length codes */ uInt nd; /* number of distance codes */ uIntf *c; /* that many (total) code lengths */ @@ -3993,7 +4016,7 @@ uInt n; } -int inflate_trees_fixed(bl, bd, tl, td) +local int inflate_trees_fixed(bl, bd, tl, td) uIntf *bl; /* literal desired/actual bit depth */ uIntf *bd; /* distance desired/actual bit depth */ inflate_huft * FAR *tl; /* literal/length tree result */ @@ -4043,7 +4066,7 @@ inflate_huft * FAR *td; /* distance tree result */ } -int inflate_trees_free(t, z) +local int inflate_trees_free(t, z) inflate_huft *t; /* table to free */ z_stream *z; /* for zfree function */ /* Free the malloc'ed tables built by huft_build(), which makes a linked @@ -4115,7 +4138,7 @@ struct inflate_codes_state { }; -inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) +local inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) uInt bl, bd; inflate_huft *tl, *td; z_stream *z; @@ -4136,7 +4159,7 @@ z_stream *z; } -int inflate_codes(s, z, r) +local int inflate_codes(s, z, r) inflate_blocks_statef *s; z_stream *z; int r; @@ -4296,7 +4319,7 @@ int r; } -void inflate_codes_free(c, z) +local void inflate_codes_free(c, z) inflate_codes_statef *c; z_stream *z; { @@ -4311,7 +4334,7 @@ z_stream *z; */ /* copy as much as possible from the sliding window to the output area */ -int inflate_flush(s, z, r) +local int inflate_flush(s, z, r) inflate_blocks_statef *s; z_stream *z; int r; @@ -4402,7 +4425,7 @@ int r; at least ten. The ten bytes are six bytes for the longest length/ distance pair plus four bytes for overloading the bit buffer. */ -int inflate_fast(bl, bd, tl, td, s, z) +local int inflate_fast(bl, bd, tl, td, s, z) uInt bl, bd; inflate_huft *tl, *td; inflate_blocks_statef *s; @@ -4548,7 +4571,7 @@ z_stream *z; * For conditions of distribution and use, see copyright notice in zlib.h */ -/* $Id: zlib.c,v 1.1 1996/01/18 03:26:49 paulus Exp $ */ +/* From: zutil.c,v 1.8 1995/05/03 17:27:12 jloup Exp */ char *zlib_version = ZLIB_VERSION; @@ -4569,7 +4592,7 @@ char *z_errmsg[] = { * For conditions of distribution and use, see copyright notice in zlib.h */ -/* $Id: zlib.c,v 1.1 1996/01/18 03:26:49 paulus Exp $ */ +/* From: adler32.c,v 1.6 1995/05/03 17:27:08 jloup Exp */ #define BASE 65521L /* largest prime smaller than 65536 */ #define NMAX 5552