56 const unsigned short FAR *base;
59 unsigned short count[
MAXBITS+1];
61 static const unsigned short lbase[31] = {
62 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
63 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
64 static const unsigned short lext[31] = {
65 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
66 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195};
67 static const unsigned short dbase[32] = {
68 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
69 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
70 8193, 12289, 16385, 24577, 0, 0};
71 static const unsigned short dext[32] = {
72 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
73 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
74 28, 28, 29, 29, 64, 64};
108 for (len = 0; len <=
MAXBITS; len++)
110 for (sym = 0; sym <
codes; sym++)
115 for (max =
MAXBITS; max >= 1; max--)
116 if (count[max] != 0)
break;
117 if (root > max) root =
max;
119 here.
op = (
unsigned char)64;
120 here.
bits = (
unsigned char)1;
121 here.
val = (
unsigned short)0;
127 for (min = 1; min <
max; min++)
128 if (count[min] != 0)
break;
129 if (root < min) root = min;
133 for (len = 1; len <=
MAXBITS; len++) {
136 if (left < 0)
return -1;
138 if (left > 0 && (type ==
CODES || max != 1))
143 for (len = 1; len <
MAXBITS; len++)
144 offs[len + 1] = offs[len] + count[len];
147 for (sym = 0; sym <
codes; sym++)
148 if (
lens[sym] != 0)
work[offs[
lens[sym]]++] = (
unsigned short)sym;
207 low = (unsigned)(-1);
219 here.
bits = (
unsigned char)(len - drop);
220 if ((
int)(
work[sym]) < end) {
221 here.
op = (
unsigned char)0;
224 else if ((
int)(
work[sym]) > end) {
225 here.
op = (
unsigned char)(extra[
work[sym]]);
229 here.
op = (
unsigned char)(32 + 64);
234 incr = 1U << (len - drop);
239 next[(huff >> drop) + fill] = here;
243 incr = 1U << (len - 1);
255 if (--(count[len]) == 0) {
256 if (len == max)
break;
257 len = lens[
work[sym]];
261 if (len > root && (huff & mask) != low) {
271 left = (int)(1 << curr);
272 while (curr + drop < max) {
273 left -= count[curr + drop];
274 if (left <= 0)
break;
287 (*table)[low].
op = (
unsigned char)curr;
288 (*table)[low].bits = (
unsigned char)root;
289 (*table)[low].val = (
unsigned short)(next - *table);
300 here.
op = (
unsigned char)64;
301 here.
bits = (
unsigned char)(len - drop);
302 here.
val = (
unsigned short)0;
305 if (drop != 0 && (huff & mask) != low) {
309 here.
bits = (
unsigned char)len;
313 next[huff >> drop] = here;
316 incr = 1U << (len - 1);
static char * bits(int n)