[hackers] [flate] -callback interface, +todo || nsz

From: <hg_AT_suckless.org>
Date: Mon, 24 Aug 2009 08:47:59 +0000 (UTC)

changeset: 121:79dfbead37c3
user: nsz <nszabolcs_AT_gmail.com>
date: Mon Aug 24 10:40:22 2009 +0200
files: README TODO deflate.c flate.h inflate.c sflate.c
description:
-callback interface, +todo

diff -r 46afe3552835 -r 79dfbead37c3 README
--- a/README Mon Aug 24 08:48:26 2009 +0200
+++ b/README Mon Aug 24 10:40:22 2009 +0200
@@ -9,6 +9,7 @@
         libflate from plan 9
         deflate from halibut
         sshzlib from putty
+ deflateencoder from 7zip
 
 build:
         make
@@ -26,9 +27,9 @@
         -p pkzip
 
 files:
- adler.c: adler32 chechksum
+ adler.c: adler32 checksum
         crc.c: crc32 checksum
         deflate.c: raw deflate compression
         inflate.c: raw deflate decompression
         inflate_simple.c: minimal inflate implementation for reference
- sflate.c: deflate, zlib, gzip stream compression
+ sflate.c: deflate, zlib, gzip, pkzip stream compression
diff -r 46afe3552835 -r 79dfbead37c3 TODO
--- a/TODO Mon Aug 24 08:48:26 2009 +0200
+++ b/TODO Mon Aug 24 10:40:22 2009 +0200
@@ -1,31 +1,31 @@
 flate
 -----
-fill output entirely
+fill output entirely (s->out, s->outend ?)
+stream->err ?
+globals
 man
-globals
-error message
 inflate assumes Flate* < 0
 _init _reset _free ?
 _zlib _gzip _zip interface
+pkzip output is bugous to please unzip
 test, benchmark
 
 
 inflate
 -------
--callback interface
 return extra input
+read less than 7 bits in clen decode
+bound checks in clen decode
 (rev lookup vs revinc)
 (test/optimize uncompressed block)
-read less than 7 bits in clen decode
-bound checks in clen decode
 
 
 deflate
 -------
-block split heuristics with lfreq, dfreq + cost
+block split heuristics with lfreq, dfreq + cost (costbuf)
+match selection (entropy based cost)
 special case: last block (better optimization for short input)
 check ushort vs int
-lzbuf + costbuf
 minor mods:
         overlap rbuf/dstwin
         hufflen: overlap arrays (parent+heap only)
diff -r 46afe3552835 -r 79dfbead37c3 deflate.c
--- a/deflate.c Mon Aug 24 08:48:26 2009 +0200
+++ b/deflate.c Mon Aug 24 10:40:22 2009 +0200
@@ -655,18 +655,21 @@
         memset(s->chain, 0, sizeof(s->chain));
         memset(s->head, 0, sizeof(s->head));
         s->bits = s->nbits = 0;
- for (i = 0; i < 144; i++)
- fixllen[i] = 8;
- for (; i < 256; i++)
- fixllen[i] = 9;
- for (; i < 280; i++)
- fixllen[i] = 7;
- for (; i < Nlitlen; i++)
- fixllen[i] = 8;
- for (i = 0; i < Ndist; i++)
- fixdlen[i] = 5;
- huffcodes(fixlcode, fixllen, Nlitlen);
- huffcodes(fixdcode, fixdlen, Ndist);
+ /* TODO: globals */
+ if (fixllen[0] == 0) {
+ for (i = 0; i < 144; i++)
+ fixllen[i] = 8;
+ for (; i < 256; i++)
+ fixllen[i] = 9;
+ for (; i < 280; i++)
+ fixllen[i] = 7;
+ for (; i < Nlitlen; i++)
+ fixllen[i] = 8;
+ for (i = 0; i < Ndist; i++)
+ fixdlen[i] = 5;
+ huffcodes(fixlcode, fixllen, Nlitlen);
+ huffcodes(fixdcode, fixdlen, Ndist);
+ }
         s->state = FlateOut;
         s->in = s->inend = 0;
         s->dst = s->dstbegin = s->dstbuf;
diff -r 46afe3552835 -r 79dfbead37c3 flate.h
--- a/flate.h Mon Aug 24 08:48:26 2009 +0200
+++ b/flate.h Mon Aug 24 10:40:22 2009 +0200
@@ -20,9 +20,7 @@
 } FlateStream;
 
 int deflate(FlateStream *s);
-int deflate_callback(int (*r)(void *, int, void *), void *rdata, int (*w)(void *, int, void *), void *wdata);
 int inflate(FlateStream *s);
-int inflate_callback(int (*r)(void *, int, void *), void *rdata, int (*w)(void *, int, void *), void *wdata);
 
 uint adler32(uchar *p, int n, uint adler);
 void crc32init(void);
diff -r 46afe3552835 -r 79dfbead37c3 inflate.c
--- a/inflate.c Mon Aug 24 08:48:26 2009 +0200
+++ b/inflate.c Mon Aug 24 10:40:22 2009 +0200
@@ -642,45 +642,3 @@
         }
         return n;
 }
-
-int inflate_callback(int (*r)(void *, int, void *), void *rdata, int (*w)(void *, int, void *), void *wdata) {
- State *s;
- uchar *src;
- int len, n;
- enum {SrcSize = 4096};
-
- s = alloc_state();
- if (!s)
- return FlateErr;
- s->src = s->srcend = src = malloc(SrcSize);
- if (!s->src) {
- free(s);
- return FlateErr;
- }
- n = FlateIn;
- for (;;)
- switch (n) {
- case FlateIn:
- s->src = src;
- len = r(s->src, SrcSize, rdata);
- if (len > 0) {
- s->srcend = s->src + len;
- n = inflate_state(s);
- } else
- n = FlateErr;
- break;
- case FlateOut:
- len = w(s->win, s->pos, wdata);
- if (len == s->pos) {
- s->pos = 0;
- n = inflate_state(s);
- } else
- n = FlateErr;
- break;
- case FlateOk:
- case FlateErr:
- free(src);
- free(s);
- return n;
- }
-}
diff -r 46afe3552835 -r 79dfbead37c3 sflate.c
--- a/sflate.c Mon Aug 24 08:48:26 2009 +0200
+++ b/sflate.c Mon Aug 24 10:40:22 2009 +0200
@@ -152,7 +152,7 @@
         PKVersion = 20,
         PKFlag = 1 << 3,
         PKMethod = 8,
- PKDate = (2009 - 1980) << 25,
+ PKDate = ((2009 - 1980) << 25) | (1 << 21) | (1 << 16),
         PKHeadSize = 30,
         PKDirSize = 46,
         PKNameLen = sizeof(pkname) - 1
Received on Mon Aug 24 2009 - 08:47:59 UTC

This archive was generated by hypermail 2.2.0 : Mon Aug 24 2009 - 09:00:09 UTC