12 " inflate 1.2.7 Copyright 1995-2012 Mark Adler ";
33 unsigned codes, code FAR * FAR *table,
unsigned FAR *bits,
34 unsigned short FAR *work)
51 const unsigned short FAR *base;
52 const unsigned short FAR *extra;
54 unsigned short count[
MAXBITS+1];
56 static const unsigned short lbase[31] = {
57 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
58 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
59 static const unsigned short lext[31] = {
60 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
61 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 78, 68};
62 static const unsigned short dbase[32] = {
63 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
64 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
65 8193, 12289, 16385, 24577, 0, 0};
66 static const unsigned short dext[32] = {
67 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
68 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
69 28, 28, 29, 29, 64, 64};
103 for (len = 0; len <=
MAXBITS; len++)
105 for (sym = 0; sym < codes; sym++)
110 for (max =
MAXBITS; max >= 1; max--)
111 if (count[max] != 0)
break;
112 if (root > max) root =
max;
114 here.op = (
unsigned char)64;
115 here.bits = (
unsigned char)1;
116 here.val = (
unsigned short)0;
122 for (min = 1; min <
max; min++)
123 if (count[min] != 0)
break;
124 if (root < min) root =
min;
128 for (len = 1; len <=
MAXBITS; len++) {
131 if (left < 0)
return -1;
133 if (left > 0 && (type == CODES || max != 1))
138 for (len = 1; len <
MAXBITS; len++)
139 offs[len + 1] = offs[len] + count[len];
142 for (sym = 0; sym < codes; sym++)
143 if (lens[sym] != 0) work[offs[lens[sym]]++] = (
unsigned short)sym;
202 low = (unsigned)(-1);
207 if ((type == LENS && used >= ENOUGH_LENS) ||
208 (type == DISTS && used >= ENOUGH_DISTS))
214 here.bits = (
unsigned char)(len - drop);
215 if ((
int)(work[sym]) < end) {
216 here.op = (
unsigned char)0;
217 here.val = work[sym];
219 else if ((
int)(work[sym]) > end) {
220 here.op = (
unsigned char)(extra[work[sym]]);
221 here.val = base[work[sym]];
224 here.op = (
unsigned char)(32 + 64);
229 incr = 1U << (len - drop);
234 next[(huff >> drop) + fill] = here;
238 incr = 1U << (len - 1);
250 if (--(count[len]) == 0) {
251 if (len == max)
break;
252 len = lens[work[sym]];
256 if (len > root && (huff & mask) != low) {
266 left = (int)(1 << curr);
267 while (curr + drop < max) {
268 left -= count[curr + drop];
269 if (left <= 0)
break;
276 if ((type == LENS && used >= ENOUGH_LENS) ||
277 (type == DISTS && used >= ENOUGH_DISTS))
282 (*table)[low].op = (
unsigned char)curr;
283 (*table)[low].bits = (
unsigned char)root;
284 (*table)[low].val = (
unsigned short)(next - *table);
292 here.op = (
unsigned char)64;
293 here.bits = (
unsigned char)(len - drop);
294 here.val = (
unsigned short)0;
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
const char inflate_copyright[]