78 while (
s->bitcnt < need) {
80 s->left =
s->infun(
s->inhow, &(
s->in));
81 if (
s->left == 0) longjmp(
s->env, 1);
83 val |= (
int)(*(
s->in)++) <<
s->bitcnt;
89 s->bitbuf =
val >> need;
93 return val & ((1 << need) - 1);
142 code = first = index = 0;
147 code |= (bitbuf & 1) ^ 1;
152 s->bitcnt = (
s->bitcnt -
len) & 7;
153 return h->symbol[index + (
code - first)];
162 if (left == 0)
break;
164 s->left =
s->infun(
s->inhow, &(
s->in));
165 if (
s->left == 0) longjmp(
s->env, 1);
169 if (left > 8) left = 8;
203 left = (
len >> 4) + 1;
214 for (symbol = 0; symbol <
n; symbol++)
216 if (
h->count[0] ==
n)
223 left -=
h->count[
len];
224 if (left < 0)
return left;
236 for (symbol = 0; symbol <
n; symbol++)
238 h->symbol[offs[
length[symbol]]++] = symbol;
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;
342 if (
s->first && dist >
s->next)
347 to =
s->out +
s->next;
350 if (
s->next < dist) {
355 if (copy >
len) copy =
len;
362 if (
s->outfun(
s->outhow,
s->out,
s->next))
return 1;
373 if (
s->outfun(
s->outhow,
s->out,
s->next))
return 1;
384 unsigned *left,
unsigned char **
in)
408 if (setjmp(
s.env) != 0)
420 if (
err != 1 &&
s.next &&
s.outfun(
s.outhow,
s.out,
s.next) &&
err == 0)
434 static unsigned char hold[
CHUNK];
437 return fread(hold, 1,
CHUNK, (
FILE *)how);
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)
const lzma_allocator const uint8_t * in
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
int main(int argc, char **argv)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
unsigned char out[MAXWIN]
int inf(FILE *source, FILE *dest)