Fingerprint_Card
Loading...
Searching...
No Matches
ICSharpCode.SharpZipLib.Zip.Compression.Inflater Class Reference

Inflater is used to decompress data that has been compressed according to the "deflate" standard described in rfc1951. More...

Collaboration diagram for ICSharpCode.SharpZipLib.Zip.Compression.Inflater:

Public Member Functions

 Inflater ()
 Creates a new inflater or RFC1951 decompressor RFC1950/Zlib headers and footers will be expected in the input data.
 Inflater (bool noHeader)
 Creates a new inflater.
void Reset ()
 Resets the inflater so that a new stream can be decompressed. All pending input and output will be discarded.
void SetDictionary (byte[] buffer)
 Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.
void SetDictionary (byte[] buffer, int index, int count)
 Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.
void SetInput (byte[] buffer)
 Sets the input. This should only be called, if needsInput() returns true.
void SetInput (byte[] buffer, int index, int count)
 Sets the input. This should only be called, if needsInput() returns true.
int Inflate (byte[] buffer)
 Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether IsNeedingDictionary(), IsNeedingInput() or IsFinished() returns true, to determine why no further output is produced.
int Inflate (byte[] buffer, int offset, int count)
 Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether needsDictionary(), needsInput() or finished() returns true, to determine why no further output is produced.

Properties

bool IsNeedingInput [get]
 Returns true, if the input buffer is empty. You should then call setInput(). NOTE: This method also returns true when the stream is finished.
bool IsNeedingDictionary [get]
 Returns true, if a preset dictionary is needed to inflate the input.
bool IsFinished [get]
 Returns true, if the inflater has finished. This means, that no input is needed and no output can be produced.
int Adler [get]
 Gets the adler checksum. This is either the checksum of all uncompressed bytes returned by inflate(), or if needsDictionary() returns true (and thus no output was yet produced) this is the adler checksum of the expected dictionary.
long TotalOut [get]
 Gets the total number of output bytes returned by Inflate().
long TotalIn [get]
 Gets the total number of processed compressed input bytes.
int RemainingInput [get]
 Gets the number of unprocessed input bytes. Useful, if the end of the stream is reached and you want to further process the bytes after the deflate stream.

Private Member Functions

bool DecodeHeader ()
 Decodes a zlib/RFC1950 header.
bool DecodeDict ()
 Decodes the dictionary checksum after the deflate header.
bool DecodeHuffman ()
 Decodes the huffman encoded symbols in the input stream.
bool DecodeChksum ()
 Decodes the adler checksum after the deflate stream.
bool Decode ()
 Decodes the deflated stream.

Private Attributes

int mode
 This variable contains the current state.
int readAdler
 The adler checksum of the dictionary or of the decompressed stream, as it is written in the header resp. footer of the compressed stream. Only valid if mode is DECODE_DICT or DECODE_CHKSUM.
int neededBits
 The number of bits needed to complete the current state. This is valid, if mode is DECODE_DICT, DECODE_CHKSUM, DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS.
int repLength
int repDist
int uncomprLen
bool isLastBlock
 True, if the last block flag was set in the last block of the inflated stream. This means that the stream ends after the current block.
long totalOut
 The total number of inflated bytes.
long totalIn
 The total number of bytes set with setInput(). This is not the value returned by the TotalIn property, since this also includes the unprocessed input.
bool noHeader
 This variable stores the noHeader flag that was given to the constructor. True means, that the inflated stream doesn't contain a Zlib header or footer.
StreamManipulator input
OutputWindow outputWindow
InflaterDynHeader dynHeader
InflaterHuffmanTree litlenTree
InflaterHuffmanTree distTree
Adler32 adler

Static Private Attributes

static readonly int[] CPLENS
 Copy lengths for literal codes 257..285.
static readonly int[] CPLEXT
 Extra bits for literal codes 257..285.
static readonly int[] CPDIST
 Copy offsets for distance codes 0..29.
static readonly int[] CPDEXT
 Extra bits for distance codes.
const int DECODE_HEADER = 0
 These are the possible states for an inflater.
const int DECODE_DICT = 1
const int DECODE_BLOCKS = 2
const int DECODE_STORED_LEN1 = 3
const int DECODE_STORED_LEN2 = 4
const int DECODE_STORED = 5
const int DECODE_DYN_HEADER = 6
const int DECODE_HUFFMAN = 7
const int DECODE_HUFFMAN_LENBITS = 8
const int DECODE_HUFFMAN_DIST = 9
const int DECODE_HUFFMAN_DISTBITS = 10
const int DECODE_CHKSUM = 11
const int FINISHED = 12

Detailed Description

Inflater is used to decompress data that has been compressed according to the "deflate" standard described in rfc1951.

By default Zlib (rfc1950) headers and footers are expected in the input. You can use constructor

public Inflater(bool noHeader)
Inflater()
Creates a new inflater or RFC1951 decompressor RFC1950/Zlib headers and footers will be expected in t...
Definition Inflater.cs:189
bool noHeader
This variable stores the noHeader flag that was given to the constructor. True means,...
Definition Inflater.cs:175

passing true if there is no Zlib header information

The usage is as following. First you have to set some input with

void SetInput(byte[] buffer)
Sets the input. This should only be called, if needsInput() returns true.
Definition Inflater.cs:631

, then Inflate() it. If inflate doesn't inflate any bytes there may be three reasons:

Once the first output byte is produced, a dictionary will not be needed at a later stage.

author of the original java version : John Leuner, Jochen Hoenicke

Constructor & Destructor Documentation

◆ Inflater() [1/2]

ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflater ( )

Creates a new inflater or RFC1951 decompressor RFC1950/Zlib headers and footers will be expected in the input data.

◆ Inflater() [2/2]

ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflater ( bool noHeader)

Creates a new inflater.

Parameters
noHeaderTrue if no RFC1950/Zlib header and footer fields are expected in the input data

This is used for GZIPed/Zipped input.

For compatibility with Sun JDK you should provide one byte of input more than needed in this case.

Member Function Documentation

◆ Decode()

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Decode ( )
private

Decodes the deflated stream.

Returns
false if more input is needed, or if finished.
Exceptions
SharpZipBaseExceptionif deflated stream is invalid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DecodeChksum()

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DecodeChksum ( )
private

Decodes the adler checksum after the deflate stream.

Returns
false if more input is needed.
Exceptions
SharpZipBaseExceptionIf checksum doesn't match.
Here is the caller graph for this function:

◆ DecodeDict()

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DecodeDict ( )
private

Decodes the dictionary checksum after the deflate header.

Returns
False if more input is needed.
Here is the caller graph for this function:

◆ DecodeHeader()

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DecodeHeader ( )
private

Decodes a zlib/RFC1950 header.

Returns
False if more input is needed.
Exceptions
SharpZipBaseExceptionThe header is invalid.
Here is the caller graph for this function:

◆ DecodeHuffman()

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DecodeHuffman ( )
private

Decodes the huffman encoded symbols in the input stream.

Returns
false if more input is needed, true if output window is full or the current block ends.
Exceptions
SharpZipBaseExceptionif deflated stream is invalid.
Here is the caller graph for this function:

◆ Inflate() [1/2]

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflate ( byte[] buffer)

Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether IsNeedingDictionary(), IsNeedingInput() or IsFinished() returns true, to determine why no further output is produced.

Parameters
bufferthe output buffer.
Returns
The number of bytes written to the buffer, 0 if no further output can be produced.
Exceptions
System.ArgumentOutOfRangeExceptionif buffer has length 0.
System.FormatExceptionif deflated stream is invalid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Inflate() [2/2]

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflate ( byte[] buffer,
int offset,
int count )

Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether needsDictionary(), needsInput() or finished() returns true, to determine why no further output is produced.

Parameters
bufferthe output buffer.
offsetthe offset in buffer where storing starts.
countthe maximum number of bytes to output.
Returns
the number of bytes written to the buffer, 0 if no further output can be produced.
Exceptions
System.ArgumentOutOfRangeExceptionif count is less than 0.
System.ArgumentOutOfRangeExceptionif the index and / or count are wrong.
System.FormatExceptionif deflated stream is invalid.
Here is the call graph for this function:

◆ Reset()

void ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Reset ( )

Resets the inflater so that a new stream can be decompressed. All pending input and output will be discarded.

◆ SetDictionary() [1/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Inflater.SetDictionary ( byte[] buffer)

Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.

Parameters
bufferThe dictionary.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDictionary() [2/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Inflater.SetDictionary ( byte[] buffer,
int index,
int count )

Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.

Parameters
bufferThe dictionary.
indexThe index into buffer where the dictionary starts.
countThe number of bytes in the dictionary.
Exceptions
System.InvalidOperationExceptionNo dictionary is needed.
SharpZipBaseExceptionThe adler checksum for the buffer is invalid

◆ SetInput() [1/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Inflater.SetInput ( byte[] buffer)

Sets the input. This should only be called, if needsInput() returns true.

Parameters
bufferthe input.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetInput() [2/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Inflater.SetInput ( byte[] buffer,
int index,
int count )

Sets the input. This should only be called, if needsInput() returns true.

Parameters
bufferThe source of input data
indexThe index into buffer where the input starts.
countThe number of bytes of input to use.
Exceptions
System.InvalidOperationExceptionNo input is needed.
System.ArgumentOutOfRangeExceptionThe index and/or count are wrong.

Member Data Documentation

◆ adler

Adler32 ICSharpCode.SharpZipLib.Zip.Compression.Inflater.adler
private

◆ CPDEXT

readonly int [] ICSharpCode.SharpZipLib.Zip.Compression.Inflater.CPDEXT
staticprivate
Initial value:
= {
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
}

Extra bits for distance codes.

◆ CPDIST

readonly int [] ICSharpCode.SharpZipLib.Zip.Compression.Inflater.CPDIST
staticprivate
Initial value:
= {
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
}

Copy offsets for distance codes 0..29.

◆ CPLENS

readonly int [] ICSharpCode.SharpZipLib.Zip.Compression.Inflater.CPLENS
staticprivate
Initial value:
= {
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
}

Copy lengths for literal codes 257..285.

◆ CPLEXT

readonly int [] ICSharpCode.SharpZipLib.Zip.Compression.Inflater.CPLEXT
staticprivate
Initial value:
= {
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
}

Extra bits for literal codes 257..285.

◆ DECODE_BLOCKS

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_BLOCKS = 2
staticprivate

◆ DECODE_CHKSUM

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_CHKSUM = 11
staticprivate

◆ DECODE_DICT

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_DICT = 1
staticprivate

◆ DECODE_DYN_HEADER

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_DYN_HEADER = 6
staticprivate

◆ DECODE_HEADER

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_HEADER = 0
staticprivate

These are the possible states for an inflater.

◆ DECODE_HUFFMAN

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_HUFFMAN = 7
staticprivate

◆ DECODE_HUFFMAN_DIST

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_HUFFMAN_DIST = 9
staticprivate

◆ DECODE_HUFFMAN_DISTBITS

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_HUFFMAN_DISTBITS = 10
staticprivate

◆ DECODE_HUFFMAN_LENBITS

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_HUFFMAN_LENBITS = 8
staticprivate

◆ DECODE_STORED

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_STORED = 5
staticprivate

◆ DECODE_STORED_LEN1

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_STORED_LEN1 = 3
staticprivate

◆ DECODE_STORED_LEN2

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DECODE_STORED_LEN2 = 4
staticprivate

◆ distTree

InflaterHuffmanTree ICSharpCode.SharpZipLib.Zip.Compression.Inflater.distTree
private

◆ dynHeader

InflaterDynHeader ICSharpCode.SharpZipLib.Zip.Compression.Inflater.dynHeader
private

◆ FINISHED

const int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.FINISHED = 12
staticprivate

◆ input

StreamManipulator ICSharpCode.SharpZipLib.Zip.Compression.Inflater.input
private

◆ isLastBlock

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.isLastBlock
private

True, if the last block flag was set in the last block of the inflated stream. This means that the stream ends after the current block.

◆ litlenTree

InflaterHuffmanTree ICSharpCode.SharpZipLib.Zip.Compression.Inflater.litlenTree
private

◆ mode

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.mode
private

This variable contains the current state.

◆ neededBits

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.neededBits
private

The number of bits needed to complete the current state. This is valid, if mode is DECODE_DICT, DECODE_CHKSUM, DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS.

◆ noHeader

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.noHeader
private

This variable stores the noHeader flag that was given to the constructor. True means, that the inflated stream doesn't contain a Zlib header or footer.

◆ outputWindow

OutputWindow ICSharpCode.SharpZipLib.Zip.Compression.Inflater.outputWindow
private

◆ readAdler

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.readAdler
private

The adler checksum of the dictionary or of the decompressed stream, as it is written in the header resp. footer of the compressed stream. Only valid if mode is DECODE_DICT or DECODE_CHKSUM.

◆ repDist

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.repDist
private

◆ repLength

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.repLength
private

◆ totalIn

long ICSharpCode.SharpZipLib.Zip.Compression.Inflater.totalIn
private

The total number of bytes set with setInput(). This is not the value returned by the TotalIn property, since this also includes the unprocessed input.

◆ totalOut

long ICSharpCode.SharpZipLib.Zip.Compression.Inflater.totalOut
private

The total number of inflated bytes.

◆ uncomprLen

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.uncomprLen
private

Property Documentation

◆ Adler

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Adler
get

Gets the adler checksum. This is either the checksum of all uncompressed bytes returned by inflate(), or if needsDictionary() returns true (and thus no output was yet produced) this is the adler checksum of the expected dictionary.

Returns
the adler checksum.

◆ IsFinished

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.IsFinished
get

Returns true, if the inflater has finished. This means, that no input is needed and no output can be produced.

◆ IsNeedingDictionary

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.IsNeedingDictionary
get

Returns true, if a preset dictionary is needed to inflate the input.

◆ IsNeedingInput

bool ICSharpCode.SharpZipLib.Zip.Compression.Inflater.IsNeedingInput
get

Returns true, if the input buffer is empty. You should then call setInput(). NOTE: This method also returns true when the stream is finished.

◆ RemainingInput

int ICSharpCode.SharpZipLib.Zip.Compression.Inflater.RemainingInput
get

Gets the number of unprocessed input bytes. Useful, if the end of the stream is reached and you want to further process the bytes after the deflate stream.

Returns
The number of bytes of the input which have not been processed.

◆ TotalIn

long ICSharpCode.SharpZipLib.Zip.Compression.Inflater.TotalIn
get

Gets the total number of processed compressed input bytes.

Returns
The total number of bytes of processed input bytes.

◆ TotalOut

long ICSharpCode.SharpZipLib.Zip.Compression.Inflater.TotalOut
get

Gets the total number of output bytes returned by Inflate().

Returns
the total number of output bytes.

The documentation for this class was generated from the following file: