Commit 31710f83 authored by Shane Hathaway's avatar Shane Hathaway

Updated zlib to version 1.1.3.

parent 271cd87a
/* adler32.c -- compute the Adler-32 checksum of a data stream /* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $Id: adler32.c,v 1.1 1997/07/17 17:45:24 jim Exp $ */ /* @(#) $Id: adler32.c,v 1.2 2001/06/04 19:41:16 shane Exp $ */
#include "zlib.h" #include "zlib.h"
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#define DO16(buf) DO8(buf,0); DO8(buf,8); #define DO16(buf) DO8(buf,0); DO8(buf,8);
/* ========================================================================= */ /* ========================================================================= */
uLong adler32(adler, buf, len) uLong ZEXPORT adler32(adler, buf, len)
uLong adler; uLong adler;
const Bytef *buf; const Bytef *buf;
uInt len; uInt len;
......
/* compress.c -- compress a memory buffer /* compress.c -- compress a memory buffer
* Copyright (C) 1995-1996 Jean-loup Gailly. * Copyright (C) 1995-1998 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $Id: compress.c,v 1.1 1997/07/17 17:45:25 jim Exp $ */ /* @(#) $Id: compress.c,v 1.2 2001/06/04 19:41:16 shane Exp $ */
#include "zlib.h" #include "zlib.h"
/* =========================================================================== /* ===========================================================================
Compresses the source buffer into the destination buffer. sourceLen is Compresses the source buffer into the destination buffer. The level
the byte length of the source buffer. Upon entry, destLen is the total parameter has the same meaning as in deflateInit. sourceLen is the byte
size of the destination buffer, which must be at least 0.1% larger than length of the source buffer. Upon entry, destLen is the total size of the
sourceLen plus 8 bytes. Upon exit, destLen is the actual size of the destination buffer, which must be at least 0.1% larger than sourceLen plus
compressed buffer. 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
This function can be used to compress a whole file at once if the
input file is mmap'ed. compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
compress returns Z_OK if success, Z_MEM_ERROR if there was not memory, Z_BUF_ERROR if there was not enough room in the output buffer,
enough memory, Z_BUF_ERROR if there was not enough room in the output Z_STREAM_ERROR if the level parameter is invalid.
buffer.
*/ */
int compress (dest, destLen, source, sourceLen) int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
Bytef *dest; Bytef *dest;
uLongf *destLen; uLongf *destLen;
const Bytef *source; const Bytef *source;
uLong sourceLen; uLong sourceLen;
int level;
{ {
z_stream stream; z_stream stream;
int err; int err;
...@@ -42,7 +42,7 @@ int compress (dest, destLen, source, sourceLen) ...@@ -42,7 +42,7 @@ int compress (dest, destLen, source, sourceLen)
stream.zfree = (free_func)0; stream.zfree = (free_func)0;
stream.opaque = (voidpf)0; stream.opaque = (voidpf)0;
err = deflateInit(&stream, Z_DEFAULT_COMPRESSION); err = deflateInit(&stream, level);
if (err != Z_OK) return err; if (err != Z_OK) return err;
err = deflate(&stream, Z_FINISH); err = deflate(&stream, Z_FINISH);
...@@ -55,3 +55,14 @@ int compress (dest, destLen, source, sourceLen) ...@@ -55,3 +55,14 @@ int compress (dest, destLen, source, sourceLen)
err = deflateEnd(&stream); err = deflateEnd(&stream);
return err; return err;
} }
/* ===========================================================================
*/
int ZEXPORT compress (dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
/* Generated automatically from /usr/local/python-1.4/lib/python1.4/config/config.c.in by makesetup. */
/* -*- C -*- ***********************************************
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI or Corporation for National Research Initiatives or
CNRI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* Module configuration */
/* !!! !!! !!! This file is edited by the makesetup script !!! !!! !!! */
/* This file contains the table of built-in modules.
See init_builtin() in import.c. */
#include "Python.h"
extern void initposix();
extern void initsignal();
extern void initsocket();
extern void initthread();
extern void initmath();
extern void initregex();
extern void initstrop();
extern void inittime();
extern void initarray();
extern void initcmath();
extern void initstruct();
extern void initoperator();
extern void initfcntl();
extern void initpwd();
extern void initgrp();
extern void initcrypt();
extern void initselect();
extern void initerrno();
extern void inittermios();
extern void init_xdr();
extern void initaudioop();
extern void initimageop();
extern void initrgbimg();
extern void initmd5();
extern void inittiming();
extern void initrotor();
extern void initsyslog();
extern void initnew();
extern void initbinascii();
extern void initparser();
/* -- ADDMODULE MARKER 1 -- */
extern void PyMarshal_Init();
extern void initimp();
struct _inittab inittab[] = {
{"posix", initposix},
{"signal", initsignal},
{"socket", initsocket},
{"thread", initthread},
{"math", initmath},
{"regex", initregex},
{"strop", initstrop},
{"time", inittime},
{"array", initarray},
{"cmath", initcmath},
{"struct", initstruct},
{"operator", initoperator},
{"fcntl", initfcntl},
{"pwd", initpwd},
{"grp", initgrp},
{"crypt", initcrypt},
{"select", initselect},
{"errno", initerrno},
{"termios", inittermios},
{"_xdr", init_xdr},
{"audioop", initaudioop},
{"imageop", initimageop},
{"rgbimg", initrgbimg},
{"md5", initmd5},
{"timing", inittiming},
{"rotor", initrotor},
{"syslog", initsyslog},
{"new", initnew},
{"binascii", initbinascii},
{"parser", initparser},
/* -- ADDMODULE MARKER 2 -- */
/* This module "lives in" with marshal.c */
{"marshal", PyMarshal_Init},
/* This lives it with import.c */
{"imp", initimp},
/* These entries are here for sys.builtin_module_names */
{"__main__", NULL},
{"__builtin__", NULL},
{"sys", NULL},
/* Sentinel */
{0, 0}
};
/* crc32.c -- compute the CRC-32 of a data stream /* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $Id: crc32.c,v 1.1 1997/07/17 17:45:26 jim Exp $ */ /* @(#) $Id: crc32.c,v 1.2 2001/06/04 19:41:16 shane Exp $ */
#include "zlib.h" #include "zlib.h"
...@@ -45,7 +45,7 @@ local void make_crc_table() ...@@ -45,7 +45,7 @@ local void make_crc_table()
int n, k; int n, k;
uLong poly; /* polynomial exclusive-or pattern */ uLong poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */ /* terms of polynomial defining this crc (except x^32): */
static Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* make exclusive-or pattern from polynomial (0xedb88320L) */ /* make exclusive-or pattern from polynomial (0xedb88320L) */
poly = 0L; poly = 0L;
...@@ -65,7 +65,7 @@ local void make_crc_table() ...@@ -65,7 +65,7 @@ local void make_crc_table()
/* ======================================================================== /* ========================================================================
* Table of CRC-32's of all single-byte values (made by make_crc_table) * Table of CRC-32's of all single-byte values (made by make_crc_table)
*/ */
local uLongf crc_table[256] = { local const uLongf crc_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
...@@ -124,12 +124,12 @@ local uLongf crc_table[256] = { ...@@ -124,12 +124,12 @@ local uLongf crc_table[256] = {
/* ========================================================================= /* =========================================================================
* This function can be used by asm versions of crc32() * This function can be used by asm versions of crc32()
*/ */
uLongf *get_crc_table() const uLongf * ZEXPORT get_crc_table()
{ {
#ifdef DYNAMIC_CRC_TABLE #ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty) make_crc_table(); if (crc_table_empty) make_crc_table();
#endif #endif
return (uLongf *)crc_table; return (const uLongf *)crc_table;
} }
/* ========================================================================= */ /* ========================================================================= */
...@@ -139,7 +139,7 @@ uLongf *get_crc_table() ...@@ -139,7 +139,7 @@ uLongf *get_crc_table()
#define DO8(buf) DO4(buf); DO4(buf); #define DO8(buf) DO4(buf); DO4(buf);
/* ========================================================================= */ /* ========================================================================= */
uLong crc32(crc, buf, len) uLong ZEXPORT crc32(crc, buf, len)
uLong crc; uLong crc;
const Bytef *buf; const Bytef *buf;
uInt len; uInt len;
......
This diff is collapsed.
/* deflate.h -- internal compression state /* deflate.h -- internal compression state
* Copyright (C) 1995-1996 Jean-loup Gailly * Copyright (C) 1995-1998 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
/* $Id: deflate.h,v 1.1 1997/07/17 17:45:27 jim Exp $ */ /* @(#) $Id: deflate.h,v 1.2 2001/06/04 19:41:16 shane Exp $ */
#ifndef _DEFLATE_H #ifndef _DEFLATE_H
#define _DEFLATE_H #define _DEFLATE_H
...@@ -83,6 +83,7 @@ typedef struct internal_state { ...@@ -83,6 +83,7 @@ typedef struct internal_state {
z_streamp strm; /* pointer back to this zlib stream */ z_streamp strm; /* pointer back to this zlib stream */
int status; /* as the name implies */ int status; /* as the name implies */
Bytef *pending_buf; /* output still pending */ Bytef *pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */
Bytef *pending_out; /* next pending byte to output to the stream */ Bytef *pending_out; /* next pending byte to output to the stream */
int pending; /* nb of bytes in the pending buffer */ int pending; /* nb of bytes in the pending buffer */
int noheader; /* suppress zlib header and adler32 */ int noheader; /* suppress zlib header and adler32 */
...@@ -229,12 +230,12 @@ typedef struct internal_state { ...@@ -229,12 +230,12 @@ typedef struct internal_state {
ulg opt_len; /* bit length of current block with optimal trees */ ulg opt_len; /* bit length of current block with optimal trees */
ulg static_len; /* bit length of current block with static 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 */ uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */ int last_eob_len; /* bit length of EOB code for last block */
#ifdef DEBUG #ifdef DEBUG
ulg bits_sent; /* bit length of the compressed data */ ulg compressed_len; /* total bit length of compressed file mod 2^32 */
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif #endif
ush bi_buf; ush bi_buf;
...@@ -267,9 +268,51 @@ typedef struct internal_state { ...@@ -267,9 +268,51 @@ typedef struct internal_state {
/* in trees.c */ /* in trees.c */
void _tr_init OF((deflate_state *s)); void _tr_init OF((deflate_state *s));
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
ulg _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof)); int eof));
void _tr_align OF((deflate_state *s)); void _tr_align OF((deflate_state *s));
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof)); int eof));
#define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
/* Mapping from a distance to a distance code. dist is the distance - 1 and
* must not have side effects. _dist_code[256] and _dist_code[257] are never
* used.
*/
#ifndef DEBUG
/* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC)
extern uch _length_code[];
extern uch _dist_code[];
#else
extern const uch _length_code[];
extern const uch _dist_code[];
#endif
# define _tr_tally_lit(s, c, flush) \
{ uch cc = (c); \
s->d_buf[s->last_lit] = 0; \
s->l_buf[s->last_lit++] = cc; \
s->dyn_ltree[cc].Freq++; \
flush = (s->last_lit == s->lit_bufsize-1); \
}
# define _tr_tally_dist(s, distance, length, flush) \
{ uch len = (length); \
ush dist = (distance); \
s->d_buf[s->last_lit] = dist; \
s->l_buf[s->last_lit++] = len; \
dist--; \
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
s->dyn_dtree[d_code(dist)].Freq++; \
flush = (s->last_lit == s->lit_bufsize-1); \
}
#else
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
# define _tr_tally_dist(s, distance, length, flush) \
flush = _tr_tally(s, distance, length)
#endif
#endif #endif
This diff is collapsed.
/* infblock.c -- interpret and process block types to last block /* infblock.c -- interpret and process block types to last block
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -11,8 +11,12 @@ ...@@ -11,8 +11,12 @@
struct inflate_codes_state {int dummy;}; /* for buggy compilers */ 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. */ /* Table for deflate from PKZIP's appnote.txt. */
local uInt border[] = { /* Order of the bit length code lengths */ 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}; 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
/* /*
...@@ -66,23 +70,19 @@ inflate_blocks_statef *s; ...@@ -66,23 +70,19 @@ inflate_blocks_statef *s;
z_streamp z; z_streamp z;
uLongf *c; uLongf *c;
{ {
if (s->checkfn != Z_NULL) if (c != Z_NULL)
*c = s->check; *c = s->check;
if (s->mode == BTREE || s->mode == DTREE) if (s->mode == BTREE || s->mode == DTREE)
ZFREE(z, s->sub.trees.blens); ZFREE(z, s->sub.trees.blens);
if (s->mode == CODES) if (s->mode == CODES)
{
inflate_codes_free(s->sub.decode.codes, z); inflate_codes_free(s->sub.decode.codes, z);
inflate_trees_free(s->sub.decode.td, z);
inflate_trees_free(s->sub.decode.tl, z);
}
s->mode = TYPE; s->mode = TYPE;
s->bitk = 0; s->bitk = 0;
s->bitb = 0; s->bitb = 0;
s->read = s->write = s->window; s->read = s->write = s->window;
if (s->checkfn != Z_NULL) if (s->checkfn != Z_NULL)
z->adler = s->check = (*s->checkfn)(0L, Z_NULL, 0); z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0);
Trace((stderr, "inflate: blocks reset\n")); Tracev((stderr, "inflate: blocks reset\n"));
} }
...@@ -96,23 +96,27 @@ uInt w; ...@@ -96,23 +96,27 @@ uInt w;
if ((s = (inflate_blocks_statef *)ZALLOC if ((s = (inflate_blocks_statef *)ZALLOC
(z,1,sizeof(struct inflate_blocks_state))) == Z_NULL) (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
return s; return s;
if ((s->hufts =
(inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)
{
ZFREE(z, s);
return Z_NULL;
}
if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL) if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL)
{ {
ZFREE(z, s->hufts);
ZFREE(z, s); ZFREE(z, s);
return Z_NULL; return Z_NULL;
} }
s->end = s->window + w; s->end = s->window + w;
s->checkfn = c; s->checkfn = c;
s->mode = TYPE; s->mode = TYPE;
Trace((stderr, "inflate: blocks allocated\n")); Tracev((stderr, "inflate: blocks allocated\n"));
inflate_blocks_reset(s, z, &s->check); inflate_blocks_reset(s, z, Z_NULL);
return s; return s;
} }
#ifdef DEBUG
extern uInt inflate_hufts;
#endif
int inflate_blocks(s, z, r) int inflate_blocks(s, z, r)
inflate_blocks_statef *s; inflate_blocks_statef *s;
z_streamp z; z_streamp z;
...@@ -139,7 +143,7 @@ int r; ...@@ -139,7 +143,7 @@ int r;
switch (t >> 1) switch (t >> 1)
{ {
case 0: /* stored */ case 0: /* stored */
Trace((stderr, "inflate: stored block%s\n", Tracev((stderr, "inflate: stored block%s\n",
s->last ? " (last)" : "")); s->last ? " (last)" : ""));
DUMPBITS(3) DUMPBITS(3)
t = k & 7; /* go to byte boundary */ t = k & 7; /* go to byte boundary */
...@@ -147,27 +151,25 @@ int r; ...@@ -147,27 +151,25 @@ int r;
s->mode = LENS; /* get length of stored block */ s->mode = LENS; /* get length of stored block */
break; break;
case 1: /* fixed */ case 1: /* fixed */
Trace((stderr, "inflate: fixed codes block%s\n", Tracev((stderr, "inflate: fixed codes block%s\n",
s->last ? " (last)" : "")); s->last ? " (last)" : ""));
{ {
uInt bl, bd; uInt bl, bd;
inflate_huft *tl, *td; inflate_huft *tl, *td;
inflate_trees_fixed(&bl, &bd, &tl, &td); inflate_trees_fixed(&bl, &bd, &tl, &td, z);
s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
if (s->sub.decode.codes == Z_NULL) if (s->sub.decode.codes == Z_NULL)
{ {
r = Z_MEM_ERROR; r = Z_MEM_ERROR;
LEAVE LEAVE
} }
s->sub.decode.tl = Z_NULL; /* don't try to free these */
s->sub.decode.td = Z_NULL;
} }
DUMPBITS(3) DUMPBITS(3)
s->mode = CODES; s->mode = CODES;
break; break;
case 2: /* dynamic */ case 2: /* dynamic */
Trace((stderr, "inflate: dynamic codes block%s\n", Tracev((stderr, "inflate: dynamic codes block%s\n",
s->last ? " (last)" : "")); s->last ? " (last)" : ""));
DUMPBITS(3) DUMPBITS(3)
s->mode = TABLE; s->mode = TABLE;
...@@ -224,8 +226,6 @@ int r; ...@@ -224,8 +226,6 @@ int r;
} }
#endif #endif
t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
if (t < 19)
t = 19;
if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
{ {
r = Z_MEM_ERROR; r = Z_MEM_ERROR;
...@@ -246,9 +246,10 @@ int r; ...@@ -246,9 +246,10 @@ int r;
s->sub.trees.blens[border[s->sub.trees.index++]] = 0; s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
s->sub.trees.bb = 7; s->sub.trees.bb = 7;
t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
&s->sub.trees.tb, z); &s->sub.trees.tb, s->hufts, z);
if (t != Z_OK) if (t != Z_OK)
{ {
ZFREE(z, s->sub.trees.blens);
r = t; r = t;
if (r == Z_DATA_ERROR) if (r == Z_DATA_ERROR)
s->mode = BAD; s->mode = BAD;
...@@ -267,8 +268,8 @@ int r; ...@@ -267,8 +268,8 @@ int r;
t = s->sub.trees.bb; t = s->sub.trees.bb;
NEEDBITS(t) NEEDBITS(t)
h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
t = h->word.what.Bits; t = h->bits;
c = h->more.Base; c = h->base;
if (c < 16) if (c < 16)
{ {
DUMPBITS(t) DUMPBITS(t)
...@@ -287,6 +288,7 @@ int r; ...@@ -287,6 +288,7 @@ int r;
if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
(c == 16 && i < 1)) (c == 16 && i < 1))
{ {
ZFREE(z, s->sub.trees.blens);
s->mode = BAD; s->mode = BAD;
z->msg = (char*)"invalid bit length repeat"; z->msg = (char*)"invalid bit length repeat";
r = Z_DATA_ERROR; r = Z_DATA_ERROR;
...@@ -299,7 +301,6 @@ int r; ...@@ -299,7 +301,6 @@ int r;
s->sub.trees.index = i; s->sub.trees.index = i;
} }
} }
inflate_trees_free(s->sub.trees.tb, z);
s->sub.trees.tb = Z_NULL; s->sub.trees.tb = Z_NULL;
{ {
uInt bl, bd; uInt bl, bd;
...@@ -309,11 +310,10 @@ int r; ...@@ -309,11 +310,10 @@ int r;
bl = 9; /* must be <= 9 for lookahead assumptions */ bl = 9; /* must be <= 9 for lookahead assumptions */
bd = 6; /* must be <= 9 for lookahead assumptions */ bd = 6; /* must be <= 9 for lookahead assumptions */
t = s->sub.trees.table; t = s->sub.trees.table;
#ifdef DEBUG
inflate_hufts = 0;
#endif
t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
s->sub.trees.blens, &bl, &bd, &tl, &td, z); s->sub.trees.blens, &bl, &bd, &tl, &td,
s->hufts, z);
ZFREE(z, s->sub.trees.blens);
if (t != Z_OK) if (t != Z_OK)
{ {
if (t == (uInt)Z_DATA_ERROR) if (t == (uInt)Z_DATA_ERROR)
...@@ -321,19 +321,13 @@ int r; ...@@ -321,19 +321,13 @@ int r;
r = t; r = t;
LEAVE LEAVE
} }
Tracev((stderr, "inflate: trees ok, %d * %d bytes used\n", Tracev((stderr, "inflate: trees ok\n"));
inflate_hufts, sizeof(inflate_huft)));
if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
{ {
inflate_trees_free(td, z);
inflate_trees_free(tl, z);
r = Z_MEM_ERROR; r = Z_MEM_ERROR;
LEAVE LEAVE
} }
ZFREE(z, s->sub.trees.blens);
s->sub.decode.codes = c; s->sub.decode.codes = c;
s->sub.decode.tl = tl;
s->sub.decode.td = td;
} }
s->mode = CODES; s->mode = CODES;
case CODES: case CODES:
...@@ -342,8 +336,6 @@ int r; ...@@ -342,8 +336,6 @@ int r;
return inflate_flush(s, z, r); return inflate_flush(s, z, r);
r = Z_OK; r = Z_OK;
inflate_codes_free(s->sub.decode.codes, z); inflate_codes_free(s->sub.decode.codes, z);
inflate_trees_free(s->sub.decode.td, z);
inflate_trees_free(s->sub.decode.tl, z);
LOAD LOAD
Tracev((stderr, "inflate: codes end, %lu total out\n", Tracev((stderr, "inflate: codes end, %lu total out\n",
z->total_out + (q >= s->read ? q - s->read : z->total_out + (q >= s->read ? q - s->read :
...@@ -353,13 +345,6 @@ int r; ...@@ -353,13 +345,6 @@ int r;
s->mode = TYPE; s->mode = TYPE;
break; 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; s->mode = DRY;
case DRY: case DRY:
FLUSH FLUSH
...@@ -379,15 +364,15 @@ int r; ...@@ -379,15 +364,15 @@ int r;
} }
int inflate_blocks_free(s, z, c) int inflate_blocks_free(s, z)
inflate_blocks_statef *s; inflate_blocks_statef *s;
z_streamp z; z_streamp z;
uLongf *c;
{ {
inflate_blocks_reset(s, z, c); inflate_blocks_reset(s, z, Z_NULL);
ZFREE(z, s->window); ZFREE(z, s->window);
ZFREE(z, s->hufts);
ZFREE(z, s); ZFREE(z, s);
Trace((stderr, "inflate: blocks freed\n")); Tracev((stderr, "inflate: blocks freed\n"));
return Z_OK; return Z_OK;
} }
...@@ -397,6 +382,17 @@ inflate_blocks_statef *s; ...@@ -397,6 +382,17 @@ inflate_blocks_statef *s;
const Bytef *d; const Bytef *d;
uInt n; uInt n;
{ {
zmemcpy((charf *)s->window, d, n); zmemcpy(s->window, d, n);
s->read = s->write = s->window + n; s->read = s->write = s->window + n;
} }
/* Returns true if inflate is currently at the end of a block generated
* by Z_SYNC_FLUSH or Z_FULL_FLUSH.
* IN assertion: s != Z_NULL
*/
int inflate_blocks_sync_point(s)
inflate_blocks_statef *s;
{
return s->mode == LENS;
}
/* infblock.h -- header to use infblock.c /* infblock.h -- header to use infblock.c
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -28,10 +28,12 @@ extern void inflate_blocks_reset OF(( ...@@ -28,10 +28,12 @@ extern void inflate_blocks_reset OF((
extern int inflate_blocks_free OF(( extern int inflate_blocks_free OF((
inflate_blocks_statef *, inflate_blocks_statef *,
z_streamp , z_streamp));
uLongf *)); /* check value on output */
extern void inflate_set_dictionary OF(( extern void inflate_set_dictionary OF((
inflate_blocks_statef *s, inflate_blocks_statef *s,
const Bytef *d, /* dictionary */ const Bytef *d, /* dictionary */
uInt n)); /* dictionary length */ uInt n)); /* dictionary length */
extern int inflate_blocks_sync_point OF((
inflate_blocks_statef *s));
/* infcodes.c -- process literals and length/distance pairs /* infcodes.c -- process literals and length/distance pairs
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -11,16 +11,10 @@ ...@@ -11,16 +11,10 @@
#include "inffast.h" #include "inffast.h"
/* simplify the use of the inflate_huft type with some defines */ /* 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 exop word.what.Exop
#define bits word.what.Bits #define bits word.what.Bits
/* inflate codes private state */ typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
struct inflate_codes_state {
/* mode */
enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
START, /* x: set up for LEN */ START, /* x: set up for LEN */
LEN, /* i: get length/literal/eob next */ LEN, /* i: get length/literal/eob next */
LENEXT, /* i: getting length extra (have base) */ LENEXT, /* i: getting length extra (have base) */
...@@ -31,7 +25,13 @@ struct inflate_codes_state { ...@@ -31,7 +25,13 @@ struct inflate_codes_state {
WASH, /* o: got eob, possibly still output waiting */ WASH, /* o: got eob, possibly still output waiting */
END, /* x: got eob and all data flushed */ END, /* x: got eob and all data flushed */
BADCODE} /* x: got error */ BADCODE} /* x: got error */
mode; /* current inflate_codes mode */ inflate_codes_mode;
/* inflate codes private state */
struct inflate_codes_state {
/* mode */
inflate_codes_mode mode; /* current inflate_codes mode */
/* mode dependent information */ /* mode dependent information */
uInt len; uInt len;
...@@ -143,7 +143,7 @@ int r; ...@@ -143,7 +143,7 @@ int r;
if ((e & 64) == 0) /* next table */ if ((e & 64) == 0) /* next table */
{ {
c->sub.code.need = e; c->sub.code.need = e;
c->sub.code.tree = t->next; c->sub.code.tree = t + t->base;
break; break;
} }
if (e & 32) /* end of block */ if (e & 32) /* end of block */
...@@ -181,7 +181,7 @@ int r; ...@@ -181,7 +181,7 @@ int r;
if ((e & 64) == 0) /* next table */ if ((e & 64) == 0) /* next table */
{ {
c->sub.code.need = e; c->sub.code.need = e;
c->sub.code.tree = t->next; c->sub.code.tree = t + t->base;
break; break;
} }
c->mode = BADCODE; /* invalid code */ c->mode = BADCODE; /* invalid code */
...@@ -221,6 +221,13 @@ int r; ...@@ -221,6 +221,13 @@ int r;
c->mode = START; c->mode = START;
break; break;
case WASH: /* o: got eob, possibly more output */ 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 FLUSH
if (s->read != s->write) if (s->read != s->write)
LEAVE LEAVE
...@@ -235,6 +242,9 @@ int r; ...@@ -235,6 +242,9 @@ int r;
r = Z_STREAM_ERROR; r = Z_STREAM_ERROR;
LEAVE LEAVE
} }
#ifdef NEED_DUMMY_RETURN
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
#endif
} }
......
/* infcodes.h -- header to use infcodes.c /* infcodes.h -- header to use infcodes.c
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
......
/* inffast.c -- process literals and length/distance pairs fast /* inffast.c -- process literals and length/distance pairs fast
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -13,14 +13,12 @@ ...@@ -13,14 +13,12 @@
struct inflate_codes_state {int dummy;}; /* for buggy compilers */ struct inflate_codes_state {int dummy;}; /* for buggy compilers */
/* simplify the use of the inflate_huft type with some defines */ /* 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 exop word.what.Exop
#define bits word.what.Bits #define bits word.what.Bits
/* macros for bit input with no checking and for returning unused bytes */ /* 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 GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
#define UNGRAB {n+=(c=k>>3);p-=c;k&=7;} #define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
/* Called with number of bytes left to write in window at least 258 /* Called with number of bytes left to write in window at least 258
(the maximum string length) and number of input bytes available (the maximum string length) and number of input bytes available
...@@ -120,7 +118,10 @@ z_streamp z; ...@@ -120,7 +118,10 @@ z_streamp z;
break; break;
} }
else if ((e & 64) == 0) else if ((e & 64) == 0)
e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop; {
t += t->base;
e = (t += ((uInt)b & inflate_mask[e]))->exop;
}
else else
{ {
z->msg = (char*)"invalid distance code"; z->msg = (char*)"invalid distance code";
...@@ -133,7 +134,8 @@ z_streamp z; ...@@ -133,7 +134,8 @@ z_streamp z;
} }
if ((e & 64) == 0) if ((e & 64) == 0)
{ {
if ((e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop) == 0) t += t->base;
if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
{ {
DUMPBITS(t->bits) DUMPBITS(t->bits)
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
......
/* inffast.h -- header to use inffast.c /* inffast.h -- header to use inffast.c
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
......
/* 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}
};
/* inflate.c -- zlib interface to inflate modules /* inflate.c -- zlib interface to inflate modules
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -8,11 +8,7 @@ ...@@ -8,11 +8,7 @@
struct inflate_blocks_state {int dummy;}; /* for buggy compilers */ struct inflate_blocks_state {int dummy;}; /* for buggy compilers */
/* inflate private state */ typedef enum {
struct internal_state {
/* mode */
enum {
METHOD, /* waiting for method byte */ METHOD, /* waiting for method byte */
FLAG, /* waiting for flag byte */ FLAG, /* waiting for flag byte */
DICT4, /* four dictionary check bytes to go */ DICT4, /* four dictionary check bytes to go */
...@@ -27,7 +23,13 @@ struct internal_state { ...@@ -27,7 +23,13 @@ struct internal_state {
CHECK1, /* one check byte to go */ CHECK1, /* one check byte to go */
DONE, /* finished check, done */ DONE, /* finished check, done */
BAD} /* got an error--stay here */ BAD} /* got an error--stay here */
mode; /* current inflate mode */ inflate_mode;
/* inflate private state */
struct internal_state {
/* mode */
inflate_mode mode; /* current inflate mode */
/* mode dependent information */ /* mode dependent information */
union { union {
...@@ -48,39 +50,35 @@ struct internal_state { ...@@ -48,39 +50,35 @@ struct internal_state {
}; };
int inflateReset(z) int ZEXPORT inflateReset(z)
z_streamp z; z_streamp z;
{ {
uLong c;
if (z == Z_NULL || z->state == Z_NULL) if (z == Z_NULL || z->state == Z_NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
z->total_in = z->total_out = 0; z->total_in = z->total_out = 0;
z->msg = Z_NULL; z->msg = Z_NULL;
z->state->mode = z->state->nowrap ? BLOCKS : METHOD; z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
inflate_blocks_reset(z->state->blocks, z, &c); inflate_blocks_reset(z->state->blocks, z, Z_NULL);
Trace((stderr, "inflate: reset\n")); Tracev((stderr, "inflate: reset\n"));
return Z_OK; return Z_OK;
} }
int inflateEnd(z) int ZEXPORT inflateEnd(z)
z_streamp z; z_streamp z;
{ {
uLong c;
if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
if (z->state->blocks != Z_NULL) if (z->state->blocks != Z_NULL)
inflate_blocks_free(z->state->blocks, z, &c); inflate_blocks_free(z->state->blocks, z);
ZFREE(z, z->state); ZFREE(z, z->state);
z->state = Z_NULL; z->state = Z_NULL;
Trace((stderr, "inflate: end\n")); Tracev((stderr, "inflate: end\n"));
return Z_OK; return Z_OK;
} }
int inflateInit2_(z, w, version, stream_size) int ZEXPORT inflateInit2_(z, w, version, stream_size)
z_streamp z; z_streamp z;
int w; int w;
const char *version; const char *version;
...@@ -129,7 +127,7 @@ int stream_size; ...@@ -129,7 +127,7 @@ int stream_size;
inflateEnd(z); inflateEnd(z);
return Z_MEM_ERROR; return Z_MEM_ERROR;
} }
Trace((stderr, "inflate: allocated\n")); Tracev((stderr, "inflate: allocated\n"));
/* reset state */ /* reset state */
inflateReset(z); inflateReset(z);
...@@ -137,7 +135,7 @@ int stream_size; ...@@ -137,7 +135,7 @@ int stream_size;
} }
int inflateInit_(z, version, stream_size) int ZEXPORT inflateInit_(z, version, stream_size)
z_streamp z; z_streamp z;
const char *version; const char *version;
int stream_size; int stream_size;
...@@ -146,18 +144,19 @@ int stream_size; ...@@ -146,18 +144,19 @@ int stream_size;
} }
#define NEEDBYTE {if(z->avail_in==0)return r;r=Z_OK;} #define NEEDBYTE {if(z->avail_in==0)return r;r=f;}
#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) #define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
int inflate(z, f) int ZEXPORT inflate(z, f)
z_streamp z; z_streamp z;
int f; int f;
{ {
int r; int r;
uInt b; uInt b;
if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL || f < 0) if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
r = Z_BUF_ERROR; r = Z_BUF_ERROR;
while (1) switch (z->state->mode) while (1) switch (z->state->mode)
{ {
...@@ -188,11 +187,11 @@ int f; ...@@ -188,11 +187,11 @@ int f;
z->state->sub.marker = 5; /* can't try inflateSync */ z->state->sub.marker = 5; /* can't try inflateSync */
break; break;
} }
Trace((stderr, "inflate: zlib header ok\n")); Tracev((stderr, "inflate: zlib header ok\n"));
if (!(b & PRESET_DICT)) if (!(b & PRESET_DICT))
{ {
z->state->mode = BLOCKS; z->state->mode = BLOCKS;
break; break;
} }
z->state->mode = DICT4; z->state->mode = DICT4;
case DICT4: case DICT4:
...@@ -226,9 +225,11 @@ int f; ...@@ -226,9 +225,11 @@ int f;
z->state->sub.marker = 0; /* can try inflateSync */ z->state->sub.marker = 0; /* can try inflateSync */
break; break;
} }
if (r == Z_OK)
r = f;
if (r != Z_STREAM_END) if (r != Z_STREAM_END)
return r; return r;
r = Z_OK; r = f;
inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
if (z->state->nowrap) if (z->state->nowrap)
{ {
...@@ -259,7 +260,7 @@ int f; ...@@ -259,7 +260,7 @@ int f;
z->state->sub.marker = 5; /* can't try inflateSync */ z->state->sub.marker = 5; /* can't try inflateSync */
break; break;
} }
Trace((stderr, "inflate: zlib check ok\n")); Tracev((stderr, "inflate: zlib check ok\n"));
z->state->mode = DONE; z->state->mode = DONE;
case DONE: case DONE:
return Z_STREAM_END; return Z_STREAM_END;
...@@ -268,10 +269,13 @@ int f; ...@@ -268,10 +269,13 @@ int f;
default: default:
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
} }
#ifdef NEED_DUMMY_RETURN
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
#endif
} }
int inflateSetDictionary(z, dictionary, dictLength) int ZEXPORT inflateSetDictionary(z, dictionary, dictLength)
z_streamp z; z_streamp z;
const Bytef *dictionary; const Bytef *dictionary;
uInt dictLength; uInt dictLength;
...@@ -295,7 +299,7 @@ uInt dictLength; ...@@ -295,7 +299,7 @@ uInt dictLength;
} }
int inflateSync(z) int ZEXPORT inflateSync(z)
z_streamp z; z_streamp z;
{ {
uInt n; /* number of bytes to look at */ uInt n; /* number of bytes to look at */
...@@ -319,7 +323,8 @@ z_streamp z; ...@@ -319,7 +323,8 @@ z_streamp z;
/* search */ /* search */
while (n && m < 4) while (n && m < 4)
{ {
if (*p == (Byte)(m < 2 ? 0 : 0xff)) static const Byte mark[4] = {0, 0, 0xff, 0xff};
if (*p == mark[m])
m++; m++;
else if (*p) else if (*p)
m = 0; m = 0;
...@@ -343,3 +348,19 @@ z_streamp z; ...@@ -343,3 +348,19 @@ z_streamp z;
z->state->mode = BLOCKS; z->state->mode = BLOCKS;
return Z_OK; return Z_OK;
} }
/* Returns true if inflate is currently at the end of a block generated
* by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
* implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
* but removes the length bytes of the resulting empty stored block. When
* decompressing, PPP checks that at the end of input packet, inflate is
* waiting for these length bytes.
*/
int ZEXPORT inflateSyncPoint(z)
z_streamp z;
{
if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)
return Z_STREAM_ERROR;
return inflate_blocks_sync_point(z->state->blocks);
}
This diff is collapsed.
/* inftrees.h -- header to use inftrees.c /* inftrees.h -- header to use inftrees.c
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -19,23 +19,25 @@ struct inflate_huft_s { ...@@ -19,23 +19,25 @@ struct inflate_huft_s {
Byte Exop; /* number of extra bits or operation */ Byte Exop; /* number of extra bits or operation */
Byte Bits; /* number of bits in this code or subcode */ Byte Bits; /* number of bits in this code or subcode */
} what; } what;
Bytef *pad; /* pad structure to a power of 2 (4 bytes for */ uInt pad; /* pad structure to a power of 2 (4 bytes for */
} word; /* 16-bit, 8 bytes for 32-bit machines) */ } word; /* 16-bit, 8 bytes for 32-bit int's) */
union { uInt base; /* literal, length base, distance base,
uInt Base; /* literal, length base, or distance base */ or table offset */
inflate_huft *Next; /* pointer to next level of table */
} more;
}; };
#ifdef DEBUG /* Maximum size of dynamic tree. The maximum found in a long but non-
extern uInt inflate_hufts; exhaustive search was 1004 huft structures (850 for length/literals
#endif and 154 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
extern int inflate_trees_bits OF(( extern int inflate_trees_bits OF((
uIntf *, /* 19 code lengths */ uIntf *, /* 19 code lengths */
uIntf *, /* bits tree desired/actual depth */ uIntf *, /* bits tree desired/actual depth */
inflate_huft * FAR *, /* bits tree result */ inflate_huft * FAR *, /* bits tree result */
z_streamp )); /* for zalloc, zfree functions */ inflate_huft *, /* space for trees */
z_streamp)); /* for messages */
extern int inflate_trees_dynamic OF(( extern int inflate_trees_dynamic OF((
uInt, /* number of literal/length codes */ uInt, /* number of literal/length codes */
...@@ -45,15 +47,12 @@ extern int inflate_trees_dynamic OF(( ...@@ -45,15 +47,12 @@ extern int inflate_trees_dynamic OF((
uIntf *, /* distance desired/actual bit depth */ uIntf *, /* distance desired/actual bit depth */
inflate_huft * FAR *, /* literal/length tree result */ inflate_huft * FAR *, /* literal/length tree result */
inflate_huft * FAR *, /* distance tree result */ inflate_huft * FAR *, /* distance tree result */
z_streamp )); /* for zalloc, zfree functions */ inflate_huft *, /* space for trees */
z_streamp)); /* for messages */
extern int inflate_trees_fixed OF(( extern int inflate_trees_fixed OF((
uIntf *, /* literal desired/actual bit depth */ uIntf *, /* literal desired/actual bit depth */
uIntf *, /* distance desired/actual bit depth */ uIntf *, /* distance desired/actual bit depth */
inflate_huft * FAR *, /* literal/length tree result */ inflate_huft * FAR *, /* literal/length tree result */
inflate_huft * FAR *)); /* distance tree result */ inflate_huft * FAR *, /* distance tree result */
z_streamp)); /* for memory allocation */
extern int inflate_trees_free OF((
inflate_huft *, /* tables to free */
z_streamp )); /* for zfree function */
/* inflate_util.c -- data and routines common to blocks and codes /* inflate_util.c -- data and routines common to blocks and codes
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
......
/* infutil.h -- types and macros common to blocks and codes /* infutil.h -- types and macros common to blocks and codes
* Copyright (C) 1995-1996 Mark Adler * Copyright (C) 1995-1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -41,8 +41,6 @@ struct inflate_blocks_state { ...@@ -41,8 +41,6 @@ struct inflate_blocks_state {
inflate_huft *tb; /* bit length decoding tree */ inflate_huft *tb; /* bit length decoding tree */
} trees; /* if DTREE, decoding info for trees */ } trees; /* if DTREE, decoding info for trees */
struct { struct {
inflate_huft *tl;
inflate_huft *td; /* trees to free */
inflate_codes_statef inflate_codes_statef
*codes; *codes;
} decode; /* if CODES, current state */ } decode; /* if CODES, current state */
...@@ -52,6 +50,7 @@ struct inflate_blocks_state { ...@@ -52,6 +50,7 @@ struct inflate_blocks_state {
/* mode independent information */ /* mode independent information */
uInt bitk; /* bits in bit buffer */ uInt bitk; /* bits in bit buffer */
uLong bitb; /* bit buffer */ uLong bitb; /* bit buffer */
inflate_huft *hufts; /* single malloc for tree space */
Bytef *window; /* sliding window */ Bytef *window; /* sliding window */
Bytef *end; /* one byte after sliding window */ Bytef *end; /* one byte after sliding window */
Bytef *read; /* window read pointer */ Bytef *read; /* window read pointer */
......
/* 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(" };");
}
This diff is collapsed.
/* header created automatically with -DGEN_TREES_H */
local const ct_data static_ltree[L_CODES+2] = {
{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
};
local const ct_data static_dtree[D_CODES] = {
{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
};
const uch _dist_code[DIST_CODE_LEN] = {
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
};
const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
};
local const int base_length[LENGTH_CODES] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
64, 80, 96, 112, 128, 160, 192, 224, 0
};
local const int base_dist[D_CODES] = {
0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
};
/* uncompr.c -- decompress a memory buffer /* uncompr.c -- decompress a memory buffer
* Copyright (C) 1995-1996 Jean-loup Gailly. * Copyright (C) 1995-1998 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $Id: uncompr.c,v 1.1 1997/07/17 17:45:35 jim Exp $ */ /* @(#) $Id: uncompr.c,v 1.2 2001/06/04 19:41:16 shane Exp $ */
#include "zlib.h" #include "zlib.h"
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
enough memory, Z_BUF_ERROR if there was not enough room in the output enough memory, Z_BUF_ERROR if there was not enough room in the output
buffer, or Z_DATA_ERROR if the input data was corrupted. buffer, or Z_DATA_ERROR if the input data was corrupted.
*/ */
int uncompress (dest, destLen, source, sourceLen) int ZEXPORT uncompress (dest, destLen, source, sourceLen)
Bytef *dest; Bytef *dest;
uLongf *destLen; uLongf *destLen;
const Bytef *source; const Bytef *source;
...@@ -49,7 +49,7 @@ int uncompress (dest, destLen, source, sourceLen) ...@@ -49,7 +49,7 @@ int uncompress (dest, destLen, source, sourceLen)
err = inflate(&stream, Z_FINISH); err = inflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) { if (err != Z_STREAM_END) {
inflateEnd(&stream); inflateEnd(&stream);
return err; return err == Z_OK ? Z_BUF_ERROR : err;
} }
*destLen = stream.total_out; *destLen = stream.total_out;
......
/* zconf.h -- configuration of the zlib compression library /* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-1996 Jean-loup Gailly. * Copyright (C) 1995-1998 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $Id: zconf.h,v 1.1 1997/07/17 17:45:35 jim Exp $ */ /* @(#) $Id: zconf.h,v 1.2 2001/06/04 19:41:16 shane Exp $ */
#ifndef _ZCONF_H #ifndef _ZCONF_H
#define _ZCONF_H #define _ZCONF_H
...@@ -27,8 +27,10 @@ ...@@ -27,8 +27,10 @@
# define inflateInit2_ z_inflateInit2_ # define inflateInit2_ z_inflateInit2_
# define inflateSetDictionary z_inflateSetDictionary # define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync # define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateReset z_inflateReset # define inflateReset z_inflateReset
# define compress z_compress # define compress z_compress
# define compress2 z_compress2
# define uncompress z_uncompress # define uncompress z_uncompress
# define adler32 z_adler32 # define adler32 z_adler32
# define crc32 z_crc32 # define crc32 z_crc32
...@@ -72,8 +74,10 @@ ...@@ -72,8 +74,10 @@
#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) #if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC)
# define STDC # define STDC
#endif #endif
#if (defined(__STDC__) || defined(__cplusplus)) && !defined(STDC) #if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)
# define STDC # ifndef STDC
# define STDC
# endif
#endif #endif
#ifndef STDC #ifndef STDC
...@@ -87,6 +91,12 @@ ...@@ -87,6 +91,12 @@
# define NO_DUMMY_DECL # define NO_DUMMY_DECL
#endif #endif
/* Old Borland C incorrectly complains about missing returns: */
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
# define NEED_DUMMY_RETURN
#endif
/* Maximum value for memLevel in deflateInit2 */ /* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL #ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K # ifdef MAXSEG_64K
...@@ -96,13 +106,17 @@ ...@@ -96,13 +106,17 @@
# endif # endif
#endif #endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2 */ /* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS #ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */ # define MAX_WBITS 15 /* 32K LZ77 window */
#endif #endif
/* The memory requirements for deflate are (in bytes): /* The memory requirements for deflate are (in bytes):
1 << (windowBits+2) + 1 << (memLevel+9) (1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with the default memory requirements from 256K to 128K, compile with
...@@ -134,7 +148,7 @@ ...@@ -134,7 +148,7 @@
/* MSC small or medium model */ /* MSC small or medium model */
# define SMALL_MEDIUM # define SMALL_MEDIUM
# ifdef _MSC_VER # ifdef _MSC_VER
# define FAR __far # define FAR _far
# else # else
# define FAR far # define FAR far
# endif # endif
...@@ -142,19 +156,68 @@ ...@@ -142,19 +156,68 @@
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
# ifndef __32BIT__ # ifndef __32BIT__
# define SMALL_MEDIUM # 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
# 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)
# else
# define ZEXTERN extern __declspec(dllimport)
# endif # endif
#endif #endif
#ifndef ZEXPORT
# define ZEXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA
#endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
#ifndef FAR #ifndef FAR
# define FAR # define FAR
#endif #endif
#if !defined(MACOS) && !defined(TARGET_OS_MAC)
typedef unsigned char Byte; /* 8 bits */ typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */ typedef unsigned long uLong; /* 32 bits or more */
#if defined(__BORLANDC__) && defined(SMALL_MEDIUM) #ifdef SMALL_MEDIUM
/* Borland C/C++ ignores FAR inside typedef */ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR # define Bytef Byte FAR
#else #else
typedef Byte FAR Bytef; typedef Byte FAR Bytef;
...@@ -172,13 +235,45 @@ typedef uLong FAR uLongf; ...@@ -172,13 +235,45 @@ typedef uLong FAR uLongf;
typedef Byte *voidp; typedef Byte *voidp;
#endif #endif
#ifdef HAVE_UNISTD_H
# include <sys/types.h> /* for off_t */
# include <unistd.h> /* for SEEK_* and off_t */
# define z_off_t off_t
#endif
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
#endif
/* Compile with -DZLIB_DLL for Windows DLL support */ /* MVS linker does not support external names larger than 8 bytes */
#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL) #if defined(__MVS__)
# include <windows.h> # pragma map(deflateInit_,"DEIN")
# define EXPORT WINAPI # pragma map(deflateInit2_,"DEIN2")
#else # pragma map(deflateEnd,"DEEND")
# define EXPORT # pragma map(inflateInit_,"ININ")
# pragma map(inflateInit2_,"ININ2")
# pragma map(inflateEnd,"INEND")
# pragma map(inflateSync,"INSY")
# pragma map(inflateSetDictionary,"INSEDI")
# pragma map(inflate_blocks,"INBL")
# pragma map(inflate_blocks_new,"INBLNE")
# pragma map(inflate_blocks_free,"INBLFR")
# pragma map(inflate_blocks_reset,"INBLRE")
# pragma map(inflate_codes_free,"INCOFR")
# pragma map(inflate_codes,"INCO")
# pragma map(inflate_fast,"INFA")
# pragma map(inflate_flush,"INFLU")
# pragma map(inflate_mask,"INMA")
# pragma map(inflate_set_dictionary,"INSEDI2")
# pragma map(inflate_copyright,"INCOPY")
# pragma map(inflate_trees_bits,"INTRBI")
# pragma map(inflate_trees_dynamic,"INTRDY")
# pragma map(inflate_trees_fixed,"INTRFI")
# pragma map(inflate_trees_free,"INTRFR")
#endif #endif
#endif /* _ZCONF_H */ #endif /* _ZCONF_H */
This diff is collapsed.
This diff is collapsed.
/* zutil.c -- target dependent utility functions for the compression library /* zutil.c -- target dependent utility functions for the compression library
* Copyright (C) 1995-1996 Jean-loup Gailly. * Copyright (C) 1995-1998 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $Id: zutil.c,v 1.1 1997/07/17 17:45:37 jim Exp $ */ /* @(#) $Id: zutil.c,v 1.2 2001/06/04 19:41:16 shane Exp $ */
#include <stdio.h>
#include "zutil.h" #include "zutil.h"
...@@ -28,12 +26,18 @@ const char *z_errmsg[10] = { ...@@ -28,12 +26,18 @@ const char *z_errmsg[10] = {
""}; ""};
const char *zlibVersion() const char * ZEXPORT zlibVersion()
{ {
return ZLIB_VERSION; return ZLIB_VERSION;
} }
#ifdef DEBUG #ifdef DEBUG
# ifndef verbose
# define verbose 0
# endif
int z_verbose = verbose;
void z_error (m) void z_error (m)
char *m; char *m;
{ {
...@@ -42,11 +46,21 @@ void z_error (m) ...@@ -42,11 +46,21 @@ void z_error (m)
} }
#endif #endif
/* exported to allow conversion of error code to string for compress() and
* uncompress()
*/
const char * ZEXPORT zError(err)
int err;
{
return ERR_MSG(err);
}
#ifndef HAVE_MEMCPY #ifndef HAVE_MEMCPY
void zmemcpy(dest, source, len) void zmemcpy(dest, source, len)
Bytef* dest; Bytef* dest;
Bytef* source; const Bytef* source;
uInt len; uInt len;
{ {
if (len == 0) return; if (len == 0) return;
...@@ -56,8 +70,8 @@ void zmemcpy(dest, source, len) ...@@ -56,8 +70,8 @@ void zmemcpy(dest, source, len)
} }
int zmemcmp(s1, s2, len) int zmemcmp(s1, s2, len)
Bytef* s1; const Bytef* s1;
Bytef* s2; const Bytef* s2;
uInt len; uInt len;
{ {
uInt j; uInt j;
...@@ -164,7 +178,7 @@ void zcfree (voidpf opaque, voidpf ptr) ...@@ -164,7 +178,7 @@ void zcfree (voidpf opaque, voidpf ptr)
# define MY_ZCALLOC # define MY_ZCALLOC
#if (!defined(_MSC_VER) || (_MSC_VER < 600)) #if (!defined(_MSC_VER) || (_MSC_VER <= 600))
# define _halloc halloc # define _halloc halloc
# define _hfree hfree # define _hfree hfree
#endif #endif
......
/* zutil.h -- internal interface and configuration of the compression library /* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-1996 Jean-loup Gailly. * Copyright (C) 1995-1998 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -8,23 +8,23 @@ ...@@ -8,23 +8,23 @@
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
/* $Id: zutil.h,v 1.1 1997/07/17 17:45:37 jim Exp $ */ /* @(#) $Id: zutil.h,v 1.2 2001/06/04 19:41:16 shane Exp $ */
#ifndef _Z_UTIL_H #ifndef _Z_UTIL_H
#define _Z_UTIL_H #define _Z_UTIL_H
#include "zlib.h" #include "zlib.h"
#if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS)
# include <stddef.h>
# include <errno.h>
#else
extern int errno;
#endif
#ifdef STDC #ifdef STDC
# include <stddef.h>
# include <string.h> # include <string.h>
# include <stdlib.h> # include <stdlib.h>
#endif #endif
#ifdef NO_ERRNO_H
extern int errno;
#else
# include <errno.h>
#endif
#ifndef local #ifndef local
# define local static # define local static
...@@ -75,8 +75,14 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -75,8 +75,14 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef MSDOS #ifdef MSDOS
# define OS_CODE 0x00 # define OS_CODE 0x00
# ifdef __TURBOC__ # if defined(__TURBOC__) || defined(__BORLANDC__)
# include <alloc.h> # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes );
# else
# include <alloc.h>
# endif
# else /* MSC or DJGPP */ # else /* MSC or DJGPP */
# include <malloc.h> # include <malloc.h>
# endif # endif
...@@ -92,7 +98,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -92,7 +98,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
#if defined(VAXC) || defined(VMS) #if defined(VAXC) || defined(VMS)
# define OS_CODE 0x02 # define OS_CODE 0x02
# define FOPEN(name, mode) \ # define F_OPEN(name, mode) \
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
#endif #endif
...@@ -104,8 +110,15 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -104,8 +110,15 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
# define OS_CODE 0x05 # define OS_CODE 0x05
#endif #endif
#ifdef MACOS #if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07 # 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
# endif
#endif #endif
#ifdef __50SERIES /* Prime/PRIMOS */ #ifdef __50SERIES /* Prime/PRIMOS */
...@@ -120,14 +133,19 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -120,14 +133,19 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
# define fdopen(fd,mode) NULL /* No fdopen() */ # define fdopen(fd,mode) NULL /* No fdopen() */
#endif #endif
#if (defined(_MSC_VER) && (_MSC_VER > 600))
# define fdopen(fd,type) _fdopen(fd,type)
#endif
/* Common defaults */ /* Common defaults */
#ifndef OS_CODE #ifndef OS_CODE
# define OS_CODE 0x03 /* assume Unix */ # define OS_CODE 0x03 /* assume Unix */
#endif #endif
#ifndef FOPEN #ifndef F_OPEN
# define FOPEN(name, mode) fopen((name), (mode)) # define F_OPEN(name, mode) fopen((name), (mode))
#endif #endif
/* functions */ /* functions */
...@@ -142,9 +160,10 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -142,9 +160,10 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
#if defined(pyr) #if defined(pyr)
# define NO_MEMCPY # define NO_MEMCPY
#endif #endif
#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER) #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
/* Use our own functions for small and medium model with MSC <= 5.0. /* Use our own functions for small and medium model with MSC <= 5.0.
* You may have to use the same strategy for Borland C (untested). * You may have to use the same strategy for Borland C (untested).
* The __SC__ check is for Symantec.
*/ */
# define NO_MEMCPY # define NO_MEMCPY
#endif #endif
...@@ -162,24 +181,22 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -162,24 +181,22 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
# define zmemzero(dest, len) memset(dest, 0, len) # define zmemzero(dest, len) memset(dest, 0, len)
# endif # endif
#else #else
extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len)); extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len)); extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
extern void zmemzero OF((Bytef* dest, uInt len)); extern void zmemzero OF((Bytef* dest, uInt len));
#endif #endif
/* Diagnostic functions */ /* Diagnostic functions */
#ifdef DEBUG #ifdef DEBUG
# include <stdio.h> # include <stdio.h>
# ifndef verbose extern int z_verbose;
# define verbose 0
# endif
extern void z_error OF((char *m)); extern void z_error OF((char *m));
# define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) fprintf x # define Trace(x) {if (z_verbose>=0) fprintf x ;}
# define Tracev(x) {if (verbose) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;} # define Tracevv(x) {if (z_verbose>1) fprintf x ;}
# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
#else #else
# define Assert(cond,msg) # define Assert(cond,msg)
# define Trace(x) # define Trace(x)
...@@ -190,8 +207,8 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -190,8 +207,8 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
#endif #endif
typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len)); typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
uInt len));
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
void zcfree OF((voidpf opaque, voidpf ptr)); void zcfree OF((voidpf opaque, voidpf ptr));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment