81 if (s->
left == 0) longjmp(s->
env, 1);
93 return val & ((1 << need) - 1);
142 code = first = index = 0;
147 code |= (bitbuf & 1) ^ 1;
162 if (left == 0)
break;
165 if (s->
left == 0) longjmp(s->
env, 1);
169 if (left > 8) left = 8;
203 left = (
len >> 4) + 1;
206 length[symbol++] =
len;
214 for (symbol = 0; symbol < n; symbol++)
215 (h->
count[length[symbol]])++;
216 if (h->
count[0] == n)
224 if (left < 0)
return left;
236 for (symbol = 0; symbol < n; symbol++)
237 if (length[symbol] != 0)
238 h->
symbol[offs[length[symbol]]++] = symbol;
290 unsigned char *from, *to;
291 static int virgin = 1;
292 static short litcnt[
MAXBITS+1], litsym[256];
293 static short lencnt[
MAXBITS+1], lensym[16];
294 static short distcnt[
MAXBITS+1], distsym[64];
295 static struct huffman litcode = {litcnt, litsym};
296 static struct huffman lencode = {lencnt, lensym};
297 static struct huffman distcode = {distcnt, distsym};
299 static const unsigned char litlen[] = {
300 11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 10, 8, 12, 10, 12, 10, 8, 23, 8,
301 9, 7, 6, 7, 8, 7, 6, 55, 8, 23, 24, 12, 11, 7, 9, 11, 12, 6, 7, 22, 5,
302 7, 24, 6, 11, 9, 6, 7, 22, 7, 11, 38, 7, 9, 8, 25, 11, 8, 11, 9, 12,
303 8, 12, 5, 38, 5, 38, 5, 11, 7, 5, 6, 21, 6, 10, 53, 8, 7, 24, 10, 27,
304 44, 253, 253, 253, 252, 252, 252, 13, 12, 45, 12, 45, 12, 61, 12, 45,
307 static const unsigned char lenlen[] = {2, 35, 36, 53, 38, 23};
309 static const unsigned char distlen[] = {2, 20, 53, 230, 247, 151, 248};
310 static const short base[16] = {
311 3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 16, 24, 40, 72, 136, 264};
312 static const char extra[16] = {
313 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8};
317 construct(&litcode, litlen,
sizeof(litlen));
318 construct(&lencode, lenlen,
sizeof(lenlen));
319 construct(&distcode, distlen,
sizeof(distlen));
325 if (lit > 1)
return -1;
327 if (dict < 4 || dict > 6)
return -2;
335 if (
len == 519)
break;
350 if (s->
next < dist) {
355 if (copy >
len) copy =
len;
384 unsigned *left,
unsigned char **
in)
408 if (setjmp(s.
env) != 0)
434 static unsigned char hold[
CHUNK];
437 return fread(hold, 1,
CHUNK, (
FILE *)how);
440local int outf(
void *how,
unsigned char *
buf,
unsigned len)
455 fprintf(stderr,
"blast error: %d\n", ret);
458 while (getchar() !=
EOF)
461 fprintf(stderr,
"blast warning: %u unused bytes of input\n",
left);
int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow, unsigned *left, unsigned char **in)
int construct(struct huffman *h, const unsigned char *rep, int n)
int decomp(struct state *s)
int decode(struct state *s, struct huffman *h)
int bits(struct state *s, int need)
int(* blast_out)(void *how, unsigned char *buf, unsigned len)
unsigned(* blast_in)(void *how, unsigned char **buf)
unsigned in(void *in_desc, z_const unsigned char **buf)
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
unsigned char out[MAXWIN]
int inf(FILE *source, FILE *dest)