ObjFW
OFLHADecompressingStream.h
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFStream.h"
17 #import "OFHuffmanTree.h"
18 
19 OF_ASSUME_NONNULL_BEGIN
20 
21 #define OFLHADecompressingStreamBufferSize 4096
22 
23 OF_DIRECT_MEMBERS
24 @interface OFLHADecompressingStream: OFStream
25 {
26  OFStream *_stream;
27  uint8_t _distanceBits, _dictionaryBits;
28  unsigned char _buffer[OFLHADecompressingStreamBufferSize];
29  uint32_t _bytesConsumed;
30  uint16_t _bufferIndex, _bufferLength;
31  uint8_t _byte;
32  uint8_t _bitIndex, _savedBitsLength;
33  uint16_t _savedBits;
34  unsigned char *_slidingWindow;
35  uint32_t _slidingWindowIndex, _slidingWindowMask;
36  int _state;
37  uint16_t _symbolsLeft;
38  OFHuffmanTree _Nullable _codeLenTree;
39  OFHuffmanTree _Nullable _litLenTree;
40  OFHuffmanTree _Nullable _distTree;
41  OFHuffmanTree _Nullable _treeIter;
42  uint16_t _codesCount, _codesReceived;
43  bool _currentIsExtendedLength, _skip;
44  uint8_t *_Nullable _codesLengths;
45  uint16_t _length;
46  uint32_t _distance;
47 }
48 
49 @property (readonly, nonatomic) uint32_t bytesConsumed;
50 
51 - (instancetype)of_initWithStream: (OFStream *)stream
52  distanceBits: (uint8_t)distanceBits
53  dictionaryBits: (uint8_t)dictionaryBits;
54 @end
55 
56 OF_ASSUME_NONNULL_END
A base class for different types of streams.
Definition: OFStream.h:186