]>
git.saurik.com Git - apple/security.git/blob - SecurityServer/MacYarrow/zlib/infutil.c
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
19 /* inflate_util.c -- data and routines common to blocks and codes
20 * Copyright (C) 1995-1998 Mark Adler
21 * For conditions of distribution and use, see copyright notice in zlib.h
30 struct inflate_codes_state
{int dummy
;}; /* for buggy compilers */
32 /* And'ing with mask[n] masks the lower n bits */
33 uInt inflate_mask
[17] = {
35 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
36 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
40 /* copy as much as possible from the sliding window to the output area */
41 int inflate_flush(s
, z
, r
)
42 inflate_blocks_statef
*s
;
50 /* local copies of source and destination pointers */
54 /* compute number of bytes to copy as far as end of window */
55 n
= (uInt
)((q
<= s
->write
? s
->write
: s
->end
) - q
);
56 if (n
> z
->avail_out
) n
= z
->avail_out
;
57 if (n
&& r
== Z_BUF_ERROR
) r
= Z_OK
;
63 /* update check information */
64 if (s
->checkfn
!= Z_NULL
)
65 z
->adler
= s
->check
= (*s
->checkfn
)(s
->check
, q
, n
);
67 /* copy as far as end of window */
72 /* see if more to copy at beginning of window */
77 if (s
->write
== s
->end
)
80 /* compute bytes to copy */
81 n
= (uInt
)(s
->write
- q
);
82 if (n
> z
->avail_out
) n
= z
->avail_out
;
83 if (n
&& r
== Z_BUF_ERROR
) r
= Z_OK
;
89 /* update check information */
90 if (s
->checkfn
!= Z_NULL
)
91 z
->adler
= s
->check
= (*s
->checkfn
)(s
->check
, q
, n
);