• Home
  • Raw
  • Download

Lines Matching refs:dd

20   void (*crcfunc)(struct deflate *dd, char *data, int len);
130 static void output_byte(struct deflate *dd, char sym) in output_byte() argument
132 int pos = dd->pos++ & 32767; in output_byte()
134 dd->data[pos] = sym; in output_byte()
137 xwrite(dd->outfd, dd->data, 32768); in output_byte()
138 if (dd->crcfunc) dd->crcfunc(dd, dd->data, 32768); in output_byte()
194 static void inflate(struct deflate *dd, struct bitbuf *bb) in inflate() argument
196 dd->crc = ~0; in inflate()
224 while (pos--) output_byte(dd, *(p++)); in inflate()
275 lithuff = dd->fixlithuff; in inflate()
276 disthuff = dd->fixdisthuff; in inflate()
284 if (sym < 256) output_byte(dd, sym); in inflate()
291 len = dd->lenbase[sym] + bitbuf_get(bb, dd->lenbits[sym]); in inflate()
293 dist = dd->distbase[sym] + bitbuf_get(bb, dd->distbits[sym]); in inflate()
294 sym = dd->pos & 32767; in inflate()
296 while (len--) output_byte(dd, dd->data[(dd->pos-dist) & 32767]); in inflate()
307 if (dd->pos & 32767) { in inflate()
308 xwrite(dd->outfd, dd->data, dd->pos&32767); in inflate()
309 if (dd->crcfunc) dd->crcfunc(dd, dd->data, dd->pos&32767); in inflate()
315 static void deflate(struct deflate *dd, struct bitbuf *bb) in deflate() argument
317 char *data = dd->data; in deflate()
320 dd->crc = ~0; in deflate()
324 len = readall(dd->infd, data+(dd->len&32768), 32768); in deflate()
327 if (dd->crcfunc) dd->crcfunc(dd, data+(dd->len&32768), len); in deflate()
339 while (dd->pos != dd->len) { in deflate()
340 unsigned pos = dd->pos&65535; in deflate()
345 if (!(32767 & ++dd->pos) && !final) break; in deflate()
355 struct deflate *dd = xmalloc(sizeof(struct deflate)+32768*(compress ? 4 : 1)); in init_deflate() local
357 memset(dd, 0, sizeof(struct deflate)); in init_deflate()
360 dd->hashhead = (unsigned short *)(dd->data+65536); in init_deflate()
361 dd->hashchain = (unsigned short *)(dd->data+65536+32768); in init_deflate()
365 *dd->lenbase = 3; in init_deflate()
366 for (i = 0; i<sizeof(dd->lenbits)-1; i++) { in init_deflate()
369 dd->lenbits[i]++; in init_deflate()
373 else dd->lenbits[i+1] = dd->lenbits[i]; in init_deflate()
375 dd->lenbase[i+1] = n + dd->lenbase[i]; in init_deflate()
378 for (i = 0; i<sizeof(dd->distbits); i++) { in init_deflate()
379 dd->distbase[i] = 1<<n; in init_deflate()
380 if (i) dd->distbase[i] += dd->distbase[i-1]; in init_deflate()
382 dd->distbits[i] = n; in init_deflate()
388 len2huff(dd->fixlithuff = ((struct huff *)libbuf)+3, libbuf, 288); in init_deflate()
390 len2huff(dd->fixdisthuff = ((struct huff *)libbuf)+4, libbuf, 30); in init_deflate()
392 return dd; in init_deflate()
414 static void gzip_crc(struct deflate *dd, char *data, int len) in gzip_crc() argument
417 unsigned crc, *crc_table = dd->crctable; in gzip_crc()
419 crc = dd->crc; in gzip_crc()
421 dd->crc = crc; in gzip_crc()
422 dd->len += len; in gzip_crc()
428 struct deflate *dd = init_deflate(1); in gzip_fd() local
436 dd->infd = infd; in gzip_fd()
440 crc_init(dd->crctable, 1); in gzip_fd()
441 dd->crcfunc = gzip_crc; in gzip_fd()
443 deflate(dd, bb); in gzip_fd()
448 bitbuf_put(bb, ~dd->crc, 32); in gzip_fd()
449 bitbuf_put(bb, dd->len, 32); in gzip_fd()
450 rc = dd->len; in gzip_fd()
454 free(dd); in gzip_fd()
462 struct deflate *dd = init_deflate(0); in gunzip_fd() local
466 dd->outfd = outfd; in gunzip_fd()
469 crc_init(dd->crctable, 1); in gunzip_fd()
470 dd->crcfunc = gzip_crc; in gunzip_fd()
472 inflate(dd, bb); in gunzip_fd()
477 if (~dd->crc != bitbuf_get(bb, 32) || dd->len != bitbuf_get(bb, 32)) in gunzip_fd()
480 rc = dd->len; in gunzip_fd()
482 free(dd); in gunzip_fd()