ObjFW
OFLHADecompressingStream.h
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License version 3.0 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * version 3.0 for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 3.0 along with this program. If not, see
17  * <https://www.gnu.org/licenses/>.
18  */
19 
20 #import "OFStream.h"
21 #import "OFHuffmanTree.h"
22 
23 OF_ASSUME_NONNULL_BEGIN
24 
25 #define OFLHADecompressingStreamBufferSize 4096
26 
27 OF_DIRECT_MEMBERS
28 @interface OFLHADecompressingStream: OFStream
29 {
30  OFStream *_stream;
31  uint8_t _distanceBits, _dictionaryBits;
32  unsigned char _buffer[OFLHADecompressingStreamBufferSize];
33  uint32_t _bytesConsumed;
34  uint16_t _bufferIndex, _bufferLength;
35  uint8_t _byte;
36  uint8_t _bitIndex, _savedBitsLength;
37  uint16_t _savedBits;
38  unsigned char *_slidingWindow;
39  uint32_t _slidingWindowIndex, _slidingWindowMask;
40  int _state;
41  uint16_t _symbolsLeft;
42  OFHuffmanTree _Nullable _codeLenTree;
43  OFHuffmanTree _Nullable _litLenTree;
44  OFHuffmanTree _Nullable _distTree;
45  OFHuffmanTree _Nullable _treeIter;
46  uint16_t _codesCount, _codesReceived;
47  bool _currentIsExtendedLength, _skip;
48  uint8_t *_Nullable _codesLengths;
49  uint16_t _length;
50  uint32_t _distance;
51 }
52 
53 @property (readonly, nonatomic) uint32_t bytesConsumed;
54 
55 - (instancetype)of_initWithStream: (OFStream *)stream
56  distanceBits: (uint8_t)distanceBits
57  dictionaryBits: (uint8_t)dictionaryBits;
58 @end
59 
60 OF_ASSUME_NONNULL_END
A base class for different types of streams.
Definition: OFStream.h:278