Common Lisp Package: DEFLATE

README:

FUNCTION

Public

INFLATE-GZIP-STREAM (INPUT-STREAM OUTPUT-STREAM &KEY CHECK-CHECKSUM)

Inflate the RFC 1952 gzip data from the given input stream into the given output stream, which are required to have an element-type of (unsigned-byte 8). This returns the CRC-32 checksum of the file as its first return value, with any filename, modification time, and comment fields as further return values or nil if not present. Note that it is the responsibility of the caller to check whether the expanded data matches the CRC-32 checksum, unless the check-checksum keyword argument is set to true, in which case the checksum is checked internally and a gzip-decompression-error is signalled if they don't match.

INFLATE-STREAM (INPUT-STREAM OUTPUT-STREAM &KEY CHECKSUM)

Inflate the RFC 1951 data from the given input stream into the given output stream, which are required to have an element-type of (unsigned-byte 8). If checksum is given, it indicates the checksumming algorithm to employ in calculating a checksum of the expanded content, which is then returned from this function. Valid values are :adler-32 for Adler-32 checksum (see RFC 1950), or :crc-32 for CRC-32 as per ISO 3309 (see RFC 1952, ZIP).

INFLATE-ZLIB-STREAM (INPUT-STREAM OUTPUT-STREAM &KEY CHECK-CHECKSUM)

Inflate the RFC 1950 zlib data from the given input stream into the given output stream, which are required to have an element-type of (unsigned-byte 8). This returns the Adler-32 checksum of the file as its first return value, with the compression level as its second return value. Note that it is the responsibility of the caller to check whether the expanded data matches the Adler-32 checksum, unless the check-checksum keyword argument is set to true, in which case the checksum is checked internally and a zlib-decompression-error is signalled if they don't match.

PARSE-GZIP-HEADER (INPUT-STREAM)

Parse a GZIP-style header as per RFC 1952 from the input-stream and return the compression-method, text-flag, modification time, XFLAGS, OS, FEXTRA flags, filename, comment and CRC16 fields of the header as return values (or nil if any given field is not present). Checks the header for magic values and correct flags settings and signals a gzip-decompression-error in case of incorrect or unsupported magic values or flags.

PARSE-ZLIB-HEADER (INPUT-STREAM)

Parse a ZLIB-style header as per RFC 1950 from the input-stream and return the compression-method, compression-level dictionary-id and flags fields of the header as return values. Checks the header for corruption and signals a zlib-decompression-error in case of corruption.

Private

BIT-STREAM-BIT-COUNT (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BIT-STREAM-BITS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BIT-STREAM-COPY-BLOCK

Copy a given block of bytes directly from the underlying stream.

BIT-STREAM-GET-BYTE (STREAM)

Read another byte from the underlying stream.

BIT-STREAM-NEXT-BYTE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BIT-STREAM-READ-BITS (STREAM BITS)

Read single or multiple bits from the given bit-stream.

BIT-STREAM-STREAM (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DECODE-BLOCK (BIT-STREAM WINDOW-STREAM)

Decompress a block read from bit-stream into window-stream.

DECODE-CODE-LENGTH-ENTRIES (BIT-STREAM COUNT DECODE-TREE)

Decode the given number of code length entries from the bit-stream using the given decode-tree, and return a corresponding array of code lengths for further processing.

DECODE-DISTANCE-ENTRY (SYMBOL BIT-STREAM)

Decode the given distance symbol into a proper distance specification.

DECODE-HUFFMAN-BLOCK (BIT-STREAM WINDOW-STREAM LIT-DECODE-TREE DIST-DECODE-TREE)

Decode the huffman code block using the huffman codes given by lit-decode-tree and dist-decode-tree.

DECODE-HUFFMAN-TABLES (BIT-STREAM)

Decode the stored huffman tables from the given bit-stream, returning the corresponding decode-trees for literals/length and distance codes.

DECODE-LENGTH-ENTRY (SYMBOL BIT-STREAM)

Decode the given length symbol into a proper length specification.

DECODE-TREE-CODE-SYMBOLS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DECODE-TREE-LENGTH-COUNT (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MAKE-HUFFMAN-DECODE-TREE (CODE-LENGTHS)

Construct a huffman decode-tree for the canonical huffman code with the code lengths of each symbol given in the input array.

READ-HUFFMAN-CODE

Read the next huffman code word from the given bit-stream and return its decoded symbol, for the huffman code given by decode-tree.

SLIDING-WINDOW-STREAM-BUFFER (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SLIDING-WINDOW-STREAM-BUFFER-END (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SLIDING-WINDOW-STREAM-CHECKSUM (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SLIDING-WINDOW-STREAM-CHECKSUM-VALUE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SLIDING-WINDOW-STREAM-COPY-BYTES (STREAM DISTANCE LENGTH)

Copy a number of bytes from the current sliding window.

SLIDING-WINDOW-STREAM-FLUSH (STREAM)

Flush any remaining buffered bytes from the stream.

SLIDING-WINDOW-STREAM-STREAM (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SLIDING-WINDOW-STREAM-WRITE-BYTE (STREAM BYTE)

Write a single byte to the sliding-window-stream.

Undocumented

SETFBIT-STREAM-BIT-COUNT (NEW-VALUE INSTANCE)

SETFBIT-STREAM-BITS (NEW-VALUE INSTANCE)

SETFBIT-STREAM-NEXT-BYTE (NEW-VALUE INSTANCE)

BIT-STREAM-P (OBJECT)

COPY-BIT-STREAM (INSTANCE)

COPY-DECODE-TREE (INSTANCE)

COPY-SLIDING-WINDOW-STREAM (INSTANCE)

SETFDECODE-TREE-CODE-SYMBOLS (NEW-VALUE INSTANCE)

DECODE-TREE-P (OBJECT)

GENERATE-CRC32-TABLE

MAKE-BIT-STREAM (&KEY ((STREAM DUM280) NIL) ((NEXT-BYTE DUM281) 0) ((BITS DUM282) 0) ((BIT-COUNT DUM283) 0))

MAKE-DECODE-TREE (&KEY ((LENGTH-COUNT DUM426) (MAKE-ARRAY 16 ELEMENT-TYPE 'FIXNUM INITIAL-ELEMENT 0)) ((CODE-SYMBOLS DUM427) (MAKE-ARRAY 16 ELEMENT-TYPE 'FIXNUM INITIAL-ELEMENT 0)))

MAKE-SLIDING-WINDOW-STREAM (&KEY ((STREAM DUM124) NIL) ((BUFFER DUM125) (MAKE-ARRAY +SLIDING-WINDOW-SIZE+ ELEMENT-TYPE '(UNSIGNED-BYTE 8))) ((BUFFER-END DUM126) 0) ((CHECKSUM DUM127) NIL) ((CHECKSUM-VALUE DUM128) 0))

PARSE-GZIP-CHECKSUM (INPUT-STREAM)

PARSE-GZIP-EXTRA (INPUT-STREAM)

PARSE-GZIP-MTIME (INPUT-STREAM)

PARSE-GZIP-STRING (INPUT-STREAM)

PARSE-ZLIB-CHECKSUM (INPUT-STREAM)

SETFSLIDING-WINDOW-STREAM-BUFFER-END (NEW-VALUE INSTANCE)

SETFSLIDING-WINDOW-STREAM-CHECKSUM-VALUE (NEW-VALUE INSTANCE)

SLIDING-WINDOW-STREAM-P (OBJECT)

UPDATE-ADLER32-CHECKSUM

UPDATE-CRC32-CHECKSUM

VARIABLE

Private

*CODE-LENGTH-ENTRY-ORDER*

Order of Code Length Tree Code Lengths.

Undocumented

*STD-DIST-DECODE-TREE*

*STD-LIT-DECODE-TREE*

CLASS

Private

Undocumented

BIT-STREAM

DECODE-TREE

SLIDING-WINDOW-STREAM

CONDITION

Public

Undocumented

DECOMPRESSION-ERROR

DEFLATE-DECOMPRESSION-ERROR

GZIP-DECOMPRESSION-ERROR

ZLIB-DECOMPRESSION-ERROR

CONSTANT

Private

+ADLER-32-BASE+

Base value for Adler-32 checksums as per RFC 1950.

+ADLER-32-START-VALUE+

Start value for Adler-32 checksums as per RFC 1950.

+CRC-32-POLYNOMIAL+

CRC-32 Polynomial as per RFC 1952.

+CRC-32-START-VALUE+

Start value for CRC-32 checksums as per RFC 1952.

+GZIP-HEADER-ID1+

GZIP Header Magic Value ID1 as per RFC 1952.

+GZIP-HEADER-ID2+

GZIP Header Magic Value ID2 as per RFC 1952.

+SLIDING-WINDOW-SIZE+

Size of sliding window for RFC 1951 Deflate compression scheme.