10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFStream.h"
#import "OFKernelEventObserver.h"
OF_ASSUME_NONNULL_BEGIN
#define OF_INFLATE_STREAM_BUFFER_SIZE 4096
/**
* @class OFInflateStream OFInflateStream.h ObjFW/OFInflateStream.h
*
* @note This class only conforms to OFReadyForReadingObserving if the
* underlying stream does so, too.
*
* @brief A class that handles Deflate decompression transparently for an
* underlying stream.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFInflateStream: OFStream <OFReadyForReadingObserving>
{
OFStream *_stream;
unsigned char _buffer[OF_INFLATE_STREAM_BUFFER_SIZE];
uint16_t _bufferIndex, _bufferLength;
uint8_t _byte;
uint8_t _bitIndex, _savedBitsLength;
uint16_t _savedBits;
unsigned char *_Nullable _slidingWindow;
uint16_t _slidingWindowIndex, _slidingWindowMask;
int _state;
union {
struct {
uint8_t position;
uint8_t length[4];
} uncompressedHeader;
struct {
uint16_t position, length;
} uncompressed;
struct {
struct of_huffman_tree *_Nullable litLenTree;
struct of_huffman_tree *_Nullable distTree;
struct of_huffman_tree *_Nullable codeLenTree;
struct of_huffman_tree *_Nullable treeIter;
uint8_t *_Nullable lengths;
uint16_t receivedCount;
uint8_t value, litLenCodesCount, distCodesCount;
uint8_t codeLenCodesCount;
} huffmanTree;
struct {
struct of_huffman_tree *_Nullable litLenTree;
struct of_huffman_tree *_Nullable distTree;
struct of_huffman_tree *_Nullable treeIter;
int state;
uint16_t value, length, distance, extraBits;
} huffman;
} _context;
bool _inLastBlock, _atEndOfStream;
}
|
>
|
|
|
|
|
|
|
|
|
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFStream.h"
#import "OFHuffmanTree.h"
#import "OFKernelEventObserver.h"
OF_ASSUME_NONNULL_BEGIN
#define OFInflateStreamBufferSize 4096
/**
* @class OFInflateStream OFInflateStream.h ObjFW/OFInflateStream.h
*
* @note This class only conforms to OFReadyForReadingObserving if the
* underlying stream does so, too.
*
* @brief A class that handles Deflate decompression transparently for an
* underlying stream.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFInflateStream: OFStream <OFReadyForReadingObserving>
{
OFStream *_stream;
unsigned char _buffer[OFInflateStreamBufferSize];
uint16_t _bufferIndex, _bufferLength;
uint8_t _byte;
uint8_t _bitIndex, _savedBitsLength;
uint16_t _savedBits;
unsigned char *_Nullable _slidingWindow;
uint16_t _slidingWindowIndex, _slidingWindowMask;
int _state;
union {
struct {
uint8_t position;
uint8_t length[4];
} uncompressedHeader;
struct {
uint16_t position, length;
} uncompressed;
struct {
OFHuffmanTree *_Nullable litLenTree;
OFHuffmanTree *_Nullable distTree;
OFHuffmanTree *_Nullable codeLenTree;
OFHuffmanTree *_Nullable treeIter;
uint8_t *_Nullable lengths;
uint16_t receivedCount;
uint8_t value, litLenCodesCount, distCodesCount;
uint8_t codeLenCodesCount;
} huffmanTree;
struct {
OFHuffmanTree *_Nullable litLenTree;
OFHuffmanTree *_Nullable distTree;
OFHuffmanTree *_Nullable treeIter;
int state;
uint16_t value, length, distance, extraBits;
} huffman;
} _context;
bool _inLastBlock, _atEndOfStream;
}
|