author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 02 Feb 2010 02:01:42 +0200 | |
changeset 0 | e4d67989cc36 |
permissions | -rw-r--r-- |
0
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* inffast.c -- process literals and length/distance pairs fast |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (C) 1995-1998 Mark Adler |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* For conditions of distribution and use, see copyright notice in zlib.h |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
*/ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
#include "zutil.h" |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
#include "inftrees.h" |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
#include "infblock.h" |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
#include "infcodes.h" |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
#include "infutil.h" |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
#include "inffast.h" |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
struct inflate_codes_state {int dummy;}; /* for buggy compilers */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
/* simplify the use of the inflate_huft type with some defines */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
#define exop word.what.Exop |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
#define bits word.what.Bits |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
/* macros for bit input with no checking and for returning unused bytes */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
/* Called with number of bytes left to write in window at least 258 |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
(the maximum string length) and number of input bytes available |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
at least ten. The ten bytes are six bytes for the longest length/ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
distance pair plus four bytes for overloading the bit buffer. */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
int inflate_fast(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, inflate_blocks_statef *s, z_streamp z) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
/* inflate_huft *td need separate declaration for Borland C++ */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
inflate_huft *t; /* temporary pointer */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
uInt e; /* extra bits or operation */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
uLong b; /* bit buffer */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
uInt k; /* bits in bit buffer */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
Bytef *p; /* input data pointer */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
uInt n; /* bytes available there */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
Bytef *q; /* output window write pointer */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
uInt m; /* bytes to end of window or read pointer */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
uInt ml; /* mask for literal/length tree */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
uInt md; /* mask for distance tree */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
uInt c; /* bytes to copy */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
uInt d; /* distance back to copy from */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
Bytef *r; /* copy source pointer */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
/* load input, output, bit values */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
LOAD |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
/* initialize masks */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
ml = inflate_mask[bl]; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
md = inflate_mask[bd]; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
/* do until not enough input or output space for fast loop */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
do { /* assume called with m >= 258 && n >= 10 */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
/* get literal/length code */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
GRABBITS(20) /* max bits for literal/length code */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
DUMPBITS(t->bits) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
"inflate: * literal '%c'\n" : |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
"inflate: * literal 0x%02x\n", t->base)); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
*q++ = (Byte)t->base; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
m--; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
continue; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
do { |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
DUMPBITS(t->bits) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
if (e & 16) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
/* get extra bits for length */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
e &= 15; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
c = t->base + ((uInt)b & inflate_mask[e]); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
DUMPBITS(e) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
Tracevv((stderr, "inflate: * length %u\n", c)); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
/* decode distance base of block to copy */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
GRABBITS(15); /* max bits for distance code */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
e = (t = td + ((uInt)b & md))->exop; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
do { |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
DUMPBITS(t->bits) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
81 |
if (e & 16) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
82 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
83 |
/* get extra bits to add to distance base */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
84 |
e &= 15; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
GRABBITS(e) /* get extra bits (up to 13) */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
d = t->base + ((uInt)b & inflate_mask[e]); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
87 |
DUMPBITS(e) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
88 |
Tracevv((stderr, "inflate: * distance %u\n", d)); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
89 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
90 |
/* do the copy */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
m -= c; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
if ((uInt)(q - s->window) >= d) /* offset before dest */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
93 |
{ /* just copy */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
r = q - d; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
*q++ = *r++; c--; /* minimum count is three, */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
*q++ = *r++; c--; /* so unroll loop a little */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
97 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
98 |
else /* else offset after destination */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
99 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
100 |
e = d - (uInt)(q - s->window); /* bytes from offset to end */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
101 |
r = s->end - e; /* pointer to offset */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
102 |
if (c > e) /* if source crosses, */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
103 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
104 |
c -= e; /* copy to end of window */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
105 |
do { |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
106 |
*q++ = *r++; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
107 |
} while (--e); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
108 |
r = s->window; /* copy rest from start of window */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
109 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
110 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
do { /* copy all or what's left */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
*q++ = *r++; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
113 |
} while (--c); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
114 |
break; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
115 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
116 |
else if ((e & 64) == 0) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
117 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
t += t->base; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
e = (t += ((uInt)b & inflate_mask[e]))->exop; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
120 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
else |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
z->msg = (char*)"invalid distance code"; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
124 |
UNGRAB |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
UPDATE |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
126 |
return Z_DATA_ERROR; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
127 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
} while (1); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
129 |
break; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
if ((e & 64) == 0) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
132 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
133 |
t += t->base; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
134 |
if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
135 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
136 |
DUMPBITS(t->bits) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
138 |
"inflate: * literal '%c'\n" : |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
139 |
"inflate: * literal 0x%02x\n", t->base)); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
140 |
*q++ = (Byte)t->base; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
141 |
m--; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
142 |
break; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
143 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
144 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
145 |
else if (e & 32) |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
146 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
147 |
Tracevv((stderr, "inflate: * end of block\n")); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
148 |
UNGRAB |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
149 |
UPDATE |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
150 |
return Z_STREAM_END; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
151 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
152 |
else |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
153 |
{ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
154 |
z->msg = (char*)"invalid literal/length code"; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
155 |
UNGRAB |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
156 |
UPDATE |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
157 |
return Z_DATA_ERROR; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
158 |
} |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
159 |
} while (1); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
160 |
} while (m >= 258 && n >= 10); |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
161 |
|
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
162 |
/* not enough input or output--restore pointers and return */ |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
163 |
UNGRAB |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
164 |
UPDATE |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
165 |
return Z_OK; |
e4d67989cc36
Revision: 201002
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
} |