1 /* inflate_util.c -- data and routines common to blocks and codes
2 * Copyright (C) 1995-2002 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h
13 /* And'ing with mask[n] masks the lower n bits */
14 local const uInt inflate_mask[17] = {
16 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
17 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
21 /* copy as much as possible from the sliding window to the output area */
22 local int inflate_flush( /* s, z, r) */
23 inflate_blocks_statef *s,
31 /* local copies of source and destination pointers */
35 /* compute number of bytes to copy as far as end of window */
36 n = (uInt)((q <= s->write ? s->write : s->end) - q);
37 if (n > z->avail_out) n = z->avail_out;
38 if (n && r == Z_BUF_ERROR) r = Z_OK;
44 /* update check information */
45 if (s->checkfn != Z_NULL)
46 z->adler = s->check = (*s->checkfn)(s->check, q, n);
48 /* copy as far as end of window */
53 /* see if more to copy at beginning of window */
58 if (s->write == s->end)
61 /* compute bytes to copy */
62 n = (uInt)(s->write - q);
63 if (n > z->avail_out) n = z->avail_out;
64 if (n && r == Z_BUF_ERROR) r = Z_OK;
70 /* update check information */
71 if (s->checkfn != Z_NULL)
72 z->adler = s->check = (*s->checkfn)(s->check, q, n);