Inflate compressed data.
Data will not be written beyond the specified end of the output data buffer, but the offset within the output data buffer will be updated to reflect the amount that should have been written. The caller can use this to find the length of the decompressed data before allocating the output data buffer.
516 "compression method %d\n",
deflate,
cm );
520 DBGC (
deflate,
"DEFLATE %p unsupported ZLIB preset " 545 DBGC (
deflate,
"DEFLATE %p found %sblock type %#x\n",
546 deflate, ( bfinal ?
"final " :
"" ), btype );
555 DBGC (
deflate,
"DEFLATE %p unsupported block type " 579 DBGC2 (
deflate,
"DEFLATE %p literal block length %#04zx\n",
610 if ( dlen > in_remaining )
636 pattern->
count ; pattern++ ) {
638 lengths += pattern->
count;
642 goto construct_alphabets;
671 DBGC2 (
deflate,
"DEFLATE %p dynamic block %d codelen, %d " 672 "litlen, %d distance\n",
deflate,
718 dynamic_litlen_distance: {
735 static const uint8_t dup_len[3] = { 3, 3, 11 };
736 static const uint8_t extra_bits[3] = { 2, 3, 7 };
737 index = ( clen - 16 );
745 dynamic_litlen_distance_extra: {
747 unsigned int dup_len;
768 goto dynamic_litlen_distance;
771 goto construct_alphabets;
774 construct_alphabets: {
813 distance_offset ) ) != 0 )
840 (
isprint (
byte ) ?
byte :
'.' ) );
863 goto lzhuf_litlen_extra;
868 lzhuf_litlen_extra: {
903 lzhuf_distance_extra: {
918 DBGCP (
deflate,
"DEFLATE %p duplicate length %zd distance " 919 "%zd\n",
deflate, dup_len, dup_distance );
922 if ( dup_distance >
out->offset ) {
923 DBGC (
deflate,
"DEFLATE %p bad distance %zd (max " 924 "%zd)\n",
deflate, dup_distance,
out->offset );
#define EINVAL
Invalid argument.
static void deflate_set_length(struct deflate *deflate, unsigned int index, unsigned int bits)
Set Huffman symbol length.
struct arbelprm_rc_send_wqe rc
unsigned int length_index
Current length index within a set of code lengths.
#define DEFLATE_DYNAMIC_HLIT_LSB
Dynamic header HLIT field LSB.
static uint16_t deflate_distance_base[32]
Distance base values.
static void deflate_copy(struct deflate_chunk *out, const void *in, size_t len)
Copy data to output buffer (if available)
#define DEFLATE_CODELEN_BITS
Dynamic header code length length (in bits)
struct deflate_alphabet distance_codelen
Distance and code length Huffman alphabet.
static int deflate_decode(struct deflate *deflate, struct deflate_alphabet *alphabet)
Attempt to decode a Huffman-coded symbol from input stream.
unsigned int length_target
Target length index within a set of code lengths.
uint8_t extra
Signature extra byte.
#define DEFLATE_DYNAMIC_HCLEN_MASK
Dynamic header HCLEN field mask.
unsigned int extra_bits
Number of extra bits required.
size_t dup_distance
Distance of a duplicated string.
#define DEFLATE_HEADER_BTYPE_STATIC
Block header type: static Huffman alphabet.
unsigned int header
Current block header.
enum deflate_format format
Format.
unsigned int length
Current length within a set of code lengths.
#define ZLIB_ADLER32_BITS
ZLIB ADLER32 length (in bits)
A Huffman-coded alphabet.
#define DEFLATE_LITLEN_END
Literal/length end of block code.
#define DEFLATE_DYNAMIC_HDIST_MASK
Dynamic header HDIST field mask.
uint8_t count
Repetition count.
static unsigned int code
Response code.
#define ENOTSUP
Operation not supported.
static int isprint(int character)
Check if character is printable.
#define DEFLATE_DYNAMIC_HCLEN_LSB
Dynamic header HCLEN field LSB.
static int deflate_accumulate(struct deflate *deflate, unsigned int target)
Attempt to accumulate bits from input stream.
#define DEFLATE_HEADER_BTYPE_LSB
Block header type LSB.
#define ZLIB_HEADER_BITS
ZLIB header length (in bits)
#define DEFLATE_LITERAL_LEN_BITS
Literal header LEN/NLEN field length (in bits)
size_t dup_len
Length of a duplicated string.
#define ZLIB_HEADER_CM_DEFLATE
ZLIB header compression method: DEFLATE.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
void * resume
Resume point.
static int deflate_extract(struct deflate *deflate, unsigned int target)
Attempt to extract a fixed number of bits from input stream.
#define DEFLATE_DYNAMIC_HLIT_MASK
Dynamic header HLIT field mask.
#define DEFLATE_CODELEN_MAX_CODE
Maximum value of a code length code.
unsigned int distance_count
Number of symbols in the distance Huffman alphabet.
static uint8_t deflate_litlen_base[28]
Literal/length base values.
struct deflate_alphabet litlen
Literal/length Huffman alphabet.
static uint8_t deflate_codelen_map[19]
Code length map.
const uint8_t * in
Current input data pointer.
#define DEFLATE_DYNAMIC_BITS
Dynamic header length (in bits)
Raw DEFLATE data (no header or footer)
static volatile void * bits
A static Huffman alphabet length pattern.
#define DEFLATE_HEADER_BTYPE_LITERAL
Block header type: literal data.
const uint8_t * end
End of input data pointer.
struct ena_llq_option header
Header locations.
#define DEFLATE_HEADER_BITS
Block header length (in bits)
uint8_t data[48]
Additional event data.
#define ZLIB_HEADER_CM_MASK
ZLIB header compression method mask.
static struct deflate_static_length_pattern deflate_static_length_patterns[]
Static Huffman alphabet length patterns.
unsigned int litlen_count
Number of symbols in the literal/length Huffman alphabet.
#define ZLIB_HEADER_CM_LSB
ZLIB header compression method LSB.
#define DEFLATE_HEADER_BFINAL_BIT
Block header final block flags bit.
uint8_t lengths[((DEFLATE_LITLEN_MAX_CODE+1)+(DEFLATE_DISTANCE_MAX_CODE+1)+1)/2]
Huffman code lengths.
static void deflate_discard_to_byte(struct deflate *deflate)
Discard bits up to the next byte boundary.
#define ZLIB_HEADER_FDICT_BIT
ZLIB header preset dictionary flag bit.
#define NULL
NULL pointer (VOID *)
#define DEFLATE_DYNAMIC_HDIST_LSB
Dynamic header HDIST field LSB.
size_t remaining
Remaining length of data (e.g.
void * memset(void *dest, int character, size_t len) __nonnull
#define DEFLATE_HEADER_BTYPE_DYNAMIC
Block header type: dynamic Huffman alphabet.