uInt
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
const uInt max = (uInt)-1;
stream.avail_out = left > (z_size_t)max ? max : (uInt)left;
(uInt)sourceLen;
uLong ZEXPORT crc32(uLong crc, const unsigned char FAR *buf, uInt len) {
uInt header = (Z_DEFLATED + ((s->w_bits - 8) << 4)) << 8;
uInt level_flags;
putShortMSB(s, (uInt)(strm->adler >> 16));
putShortMSB(s, (uInt)(strm->adler & 0xffff));
putShortMSB(s, (uInt)(strm->adler >> 16));
putShortMSB(s, (uInt)(strm->adler & 0xffff));
local uInt longest_match(deflate_state *s, IPos cur_match) {
uInt wmask = s->w_mask;
if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
local uInt longest_match(deflate_state *s, IPos cur_match) {
return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
uInt wsize = s->w_size;
uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
uInt prev; /* byte at distance one to match */
s->match_length = MAX_MATCH - (uInt)(strend - scan);
Assert(scan <= s->window + (uInt)(s->window_size - 1),
uInt wsize = s->w_size;
uInt str = s->strstart - s->insert;
s->w_bits = (uInt)windowBits;
s->hash_bits = (uInt)memLevel + 7;
uInt dictLength) {
uInt str, n;
uInt *dictLength) {
uInt len;
s->good_match = (uInt)good_length;
s->max_lazy_match = (uInt)max_lazy;
s->max_chain_length = (uInt)max_chain;
local void putShortMSB(deflate_state *s, uInt b) {
uInt w_size; /* LZ77 window size (32K by default) */
uInt w_bits; /* log2(w_size) (8..16) */
uInt w_mask; /* w_size - 1 */
uInt ins_h; /* hash index of string to be inserted */
uInt hash_size; /* number of elements in hash table */
uInt hash_bits; /* log2(hash_size) */
uInt hash_mask; /* hash_size-1 */
uInt hash_shift;
uInt match_length; /* length of best match */
uInt strstart; /* start of string to insert */
uInt match_start; /* start of matching string */
uInt lookahead; /* number of valid bytes ahead in window */
uInt prev_length;
uInt max_chain_length;
uInt max_lazy_match;
uInt good_match;
uInt lit_bufsize;
uInt sym_next; /* running index in symbol buffer */
uInt sym_end; /* symbol table full when sym_next reaches this */
uInt matches; /* number of string matches in current block */
uInt insert; /* bytes at end of window left to insert */
extern voidp malloc(uInt size);
state->wbits = (uInt)windowBits;
uInt *dictLength) {
uInt dictLength) {
if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
state->bits += (uInt)bits;
c_stream.avail_out = (uInt)comprLen;
c_stream.avail_in = (uInt)uncomprLen;
c_stream.avail_in = (uInt)uncomprLen/2;
c_stream.avail_in = (uInt)uncomprLen;
d_stream.avail_in = (uInt)comprLen;
d_stream.avail_out = (uInt)uncomprLen;
uInt len = (uInt)strlen(hello)+1;
c_stream.avail_out = (uInt)*comprLen;
d_stream.avail_out = (uInt)uncomprLen;
d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
c_stream.avail_out = (uInt)comprLen;
c_stream.avail_in = (uInt)strlen(hello)+1;
d_stream.avail_in = (uInt)comprLen;
d_stream.avail_out = (uInt)uncomprLen;
compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
const uInt max = (uInt)-1;
stream.avail_out = left > (z_size_t)max ? max : (uInt)left;
stream.avail_in = len > (z_size_t)max ? max : (uInt)len;
typedef uInt FAR uIntf;
uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
uInt extra_max; /* space at extra (only when reading header) */
uInt name_max; /* space at name (only when reading header) */
uInt comm_max; /* space at comment (only when reading header) */
ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len);
ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len);
uInt dictLength);
uInt *dictLength);
typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size);
uInt dictLength);
uInt avail_in; /* number of bytes available at next_in */
uInt *dictLength);
uInt avail_out; /* remaining free space at next_out */
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) {
extern voidp malloc(uInt size);
extern voidp calloc(uInt items, uInt size);
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
switch ((int)(sizeof(uInt))) {
uLong crc32(uLong crc, const Bytef *buf, uInt len);
local void putShortMSB (deflate_state *s, uInt b)
uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
uInt level_flags = (s->level-1) >> 1;
putShortMSB(s, (uInt)(strm->adler >> 16));
putShortMSB(s, (uInt)(strm->adler & 0xffff));
putShortMSB(s, (uInt)(strm->adler >> 16));
putShortMSB(s, (uInt)(strm->adler & 0xffff));
zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
local uInt longest_match(deflate_state *s,
uInt wmask = s->w_mask;
if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
local uInt longest_match(s, cur_match)
uInt wsize = s->w_size;
s->lookahead = (uInt)(s->strstart - max_start);
s->strstart = (uInt)max_start;
if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
extern void zmemcpy(Bytef* dest, const Bytef* source, uInt len);
extern int zmemcmp(const Bytef* s1, const Bytef* s2, uInt len);
extern void zmemzero(Bytef* dest, uInt len);
uInt len);
uInt w); /* window size */
uInt n); /* dictionary length */
uInt method; /* if FLAGS, method byte */
uInt marker; /* if BAD, inflateSync's marker bytes count */
uInt wbits; /* log2(window size) (8..15, defaults to 15) */
z->state->wbits = (uInt)w;
inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))
uInt b;
uInt dictLength)
uInt length = dictLength;
if (length >= ((uInt)1<<z->state->wbits))
uInt n; /* number of bytes to look at */
uInt m; /* number of marker bytes found in a row */
uInt pad; /* pad structure to a power of 2 (4 bytes for */
uInt base; /* literal, length base, distance base,
uInt, /* number of literal/length codes */
uInt, /* number of distance codes */
uInt w_size; /* LZ77 window size (32K by default) */
uInt w_bits; /* log2(w_size) (8..16) */
uInt w_mask; /* w_size - 1 */
uInt, uInt,
uInt left; /* if STORED, bytes left to copy */
uInt table; /* table lengths (14 bits) */
uInt index; /* index into blens (or border) */
uInt bb; /* bit length tree depth */
uInt last; /* true if this block is the last block */
uInt bitk; /* bits in bit buffer */
#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
extern uInt inflate_mask[17];
local const uInt border[] = { /* Order of the bit length code lengths */
inflate_blocks_statef *inflate_blocks_new(z_streamp z, check_func c, uInt w)
uInt t; /* temporary storage */
uInt k; /* bits in bit buffer */
uInt n; /* bytes available there */
uInt m; /* bytes to end of window or read pointer */
t = (uInt)b & 7;
uInt ins_h; /* hash index of string to be inserted */
uInt hash_size; /* number of elements in hash table */
uInt bl, bd;
uInt hash_bits; /* log2(hash_size) */
uInt hash_mask; /* hash_size-1 */
uInt hash_shift;
s->sub.left = (uInt)b & 0xffff;
s->sub.trees.table = t = (uInt)b & 0x3fff;
if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
uInt i, j, c;
h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
j += (uInt)b & inflate_mask[i];
uInt bl, bd;
uInt match_length; /* length of best match */
if (t == (uInt)Z_DATA_ERROR)
uInt strstart; /* start of string to insert */
uInt match_start; /* start of matching string */
uInt lookahead; /* number of valid bytes ahead in window */
uInt prev_length;
void inflate_set_dictionary(inflate_blocks_statef *s, const Bytef *d, uInt n)
uInt k; /* bits in bit buffer */ /* NOT USED HERE */
uInt t; /* temporary storage */
uInt n; /* bytes available there */
uInt m; /* bytes to end of window or read pointer */
uInt max_chain_length;
uInt max_lazy_match;
uInt, /* number of codes */
uInt, /* number of "simple" codes */
uInt *, /* hufts used in space */
local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */
local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */
local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */
local const uInt cpdext[30] = { /* Extra bits for distance codes */
uInt n, /* number of codes (assumed <= 288) */
uInt s, /* number of simple-valued codes (0..s-1) */
uInt *hn, /* hufts used in space */
uInt a; /* counter for codes of length k */
uInt c[BMAX+1]; /* bit length count table */
uInt f; /* i repeats in table every f entries */
uInt i; /* counter, current code */
uInt j; /* counter */
uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */
uInt x[BMAX+1]; /* bit offsets, then code stack */
uInt z; /* number of entries in current table */
if ((uInt)l < j)
uInt good_match;
if ((uInt)l > i)
z = z > (uInt)l ? l : z; /* table size upper limit */
r.base = (uInt)(q - u[h-1] - j); /* offset to this table */
uInt hn = 0; /* hufts used in space */
if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL)
int inflate_trees_dynamic(uInt nl,
uInt nd, /* number of literal/length codes */
uInt hn = 0; /* hufts used in space */
if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
local uInt fixed_bl;
local uInt fixed_bd;
local uInt fixed_bl = 9;
local uInt fixed_bd = 5;
uInt lit_bufsize;
uInt f = 0; /* number of hufts used in fixed_mem */
if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
uInt,
uInt,
uInt last_lit; /* running index in l_buf */
uInt len;
uInt need; /* bits needed */
uInt lit; /* if LIT, literal */
uInt get; /* bits to get for extra */
uInt dist; /* distance back to copy from */
inflate_codes_statef *inflate_codes_new(uInt bl, uInt bd,
uInt j; /* temporary storage */
uInt e; /* extra bits or operation */
uInt k; /* bits in bit buffer */
uInt n; /* bytes available there */
uInt m; /* bytes to end of window or read pointer */
t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
e = (uInt)(t->exop);
uInt matches; /* number of string matches in current block */
c->len += (uInt)b & inflate_mask[j];
t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
e = (uInt)(t->exop);
c->sub.copy.dist += (uInt)b & inflate_mask[j];
uInt inflate_mask[17] = {
uInt n;
n = (uInt)((q <= s->write ? s->write : s->end) - q);
n = (uInt)(s->write - q);
int inflate_fast(uInt bl, uInt bd,
uInt e; /* extra bits or operation */
uInt k; /* bits in bit buffer */
uInt n; /* bytes available there */
uInt m; /* bytes to end of window or read pointer */
uInt ml; /* mask for literal/length tree */
uInt md; /* mask for distance tree */
uInt c; /* bytes to copy */
uInt d; /* distance back to copy from */
if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
c = t->base + ((uInt)b & inflate_mask[e]);
e = (t = td + ((uInt)b & md))->exop;
d = t->base + ((uInt)b & inflate_mask[e]);
e = (t += ((uInt)b & inflate_mask[e]))->exop;
if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
uInt len;
uInt len;
uInt j;
uInt len;
extern voidp calloc(uInt items, uInt size);
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
local void putShortMSB(deflate_state *s, uInt b);
uInt longest_match(deflate_state *s, IPos cur_match);
local uInt longest_match(deflate_state *s, IPos cur_match);
uInt dictLength)
uInt length = dictLength;
uInt n;
ZEXTERN uLong ZEXPORT adler32(uLong, const Bytef *, uInt);
ZEXTERN uLong ZEXPORT crc32(uLong, const Bytef *, uInt);
typedef uInt FAR uIntf;
typedef voidpf (*alloc_func)(voidpf, uInt, uInt);
uInt avail_in; /* number of bytes available at next_in */
uInt avail_out; /* remaining free space at next_out */
ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp, const Bytef *, uInt);
ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp, const Bytef *, uInt);