ObjFW
OFLHADecompressingStream.h
1 /*
2  * Copyright (c) 2008-2021 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 
18 OF_ASSUME_NONNULL_BEGIN
19 
20 #define OF_LHA_DECOMPRESSING_STREAM_BUFFER_SIZE 4096
21 
22 OF_DIRECT_MEMBERS
23 @interface OFLHADecompressingStream: OFStream
24 {
25  OFStream *_stream;
26  uint8_t _distanceBits, _dictionaryBits;
27  unsigned char _buffer[OF_LHA_DECOMPRESSING_STREAM_BUFFER_SIZE];
28  uint32_t _bytesConsumed;
29  uint16_t _bufferIndex, _bufferLength;
30  uint8_t _byte;
31  uint8_t _bitIndex, _savedBitsLength;
32  uint16_t _savedBits;
33  unsigned char *_slidingWindow;
34  uint32_t _slidingWindowIndex, _slidingWindowMask;
35  int _state;
36  uint16_t _symbolsLeft;
37  struct of_huffman_tree *_Nullable _codeLenTree, *_Nullable _litLenTree;
38  struct of_huffman_tree *_Nullable _distTree, *_Nullable _treeIter;
39  uint16_t _codesCount, _codesReceived;
40  bool _currentIsExtendedLength, _skip;
41  uint8_t *_Nullable _codesLengths;
42  uint16_t _length;
43  uint32_t _distance;
44 }
45 
46 @property (readonly, nonatomic) uint32_t bytesConsumed;
47 
48 - (instancetype)of_initWithStream: (OFStream *)stream
49  distanceBits: (uint8_t)distanceBits
50  dictionaryBits: (uint8_t)dictionaryBits;
51 @end
52 
53 OF_ASSUME_NONNULL_END
A base class for different types of streams.
Definition: OFStream.h:191