Unit SFXinflt

*****************************************************************) (* Copyright 1997, Microchip Systems / Carl Bunton *) (* Email: Twojags@cris.com *) (* Web-page: http://www.concentric.net/~twojags *) (* *) (* This code is not for redistribution in whole or in part. It *) (* may be used in compiled program format only. *) (* *) (* This program was written in Delphi 2 because version 2 *) (* compiles a much smaller executable using the windows api. It *) (* should be fully compatible with Delphi 3, but will produce a *) (* noticable increase of size in the final compiled program. *) (******************************************************************) (******************) (* INFLATE METHOD *) (

Classes

Functions

inflate - Static Global

--------------------------------------------------------------------------*) { decompress an inflated entry

Types

BufPtr
BufType
PT
Thuft

Constants

cpdext
cpdist
cplens
cplext
dbits
lbits
maskr
N_MAX

Variables

bb
bk
fixed_td
fixed_tl
hufts
InBuf
InPTR
Slide
WP
ZipCount


Functions


PROCEDURE inflate;

Static Global

--------------------------------------------------------------------------*) { decompress an inflated entry


Types


BufPtr             = ^BufType

BufType            =  ARRAY[0..WSIZE] OF BYTE;

PT = ^Thuft

Thuft = record
e : shortint;
b : shortint;
n : WORD;
next : PT;
end;

Constants

cpdext = { Extra bits FOR distance codes } (0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13)

99==invalid

cpdist = { Copy offsets FOR distance codes 0..29 } (1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577)

note: see note #13 above about the 258 in this list.

cplens = { Copy lengths FOR literal codes 257..285 } (3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0)

Tables for deflate from PKZIP's appnote.txt.

cplext = { Extra bits FOR literal codes 257..285 } (0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99)

Copy offsets FOR distance codes 0..29

dbits = 6

lbits = 9

maskr = ($0000, $0001, $0003, $0007, $000f, $001f, $003f, $007f, $00ff, $01ff, $03ff, $07ff, $0fff, $1fff, $3fff, $7fff, $ffff)

AND'ing with mask[n] masks the lower n bits

N_MAX = 288


Variables

bb : LONGINT

bk : WORD

bit buffer (Static

fixed_td : PT

fixed_tl : PT

Static Global

hufts : WORD

InBuf : BufPtr

bits in bit buffer (Static

InPTR : WORD

Slide : BufPtr

WP : WORD

Count OF bytes in ZipFile input buffer

ZipCount : INTEGER

Index FOR ZipFile input buffer