ObjFW
OFGZIPStream.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
3  * Jonathan Schleifer <js@heap.zone>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFStream.h"
18 #import "OFDate.h"
19 
20 @class OFInflateStream;
21 
22 OF_ASSUME_NONNULL_BEGIN
23 
31 {
32  OFStream *_stream;
33  OFInflateStream *_Nullable _inflateStream;
34  enum of_gzip_stream_state {
35  OF_GZIP_STREAM_ID1,
36  OF_GZIP_STREAM_ID2,
37  OF_GZIP_STREAM_COMPRESSION_METHOD,
38  OF_GZIP_STREAM_FLAGS,
39  OF_GZIP_STREAM_MODIFICATION_TIME,
40  OF_GZIP_STREAM_EXTRA_FLAGS,
41  OF_GZIP_STREAM_OS,
42  OF_GZIP_STREAM_EXTRA_LENGTH,
43  OF_GZIP_STREAM_EXTRA,
44  OF_GZIP_STREAM_NAME,
45  OF_GZIP_STREAM_COMMENT,
46  OF_GZIP_STREAM_HEADER_CRC16,
47  OF_GZIP_STREAM_DATA,
48  OF_GZIP_STREAM_CRC32,
49  OF_GZIP_STREAM_UNCOMPRESSED_SIZE
50  } _state;
51  enum of_gzip_stream_flags {
52  OF_GZIP_STREAM_FLAG_TEXT = 0x01,
53  OF_GZIP_STREAM_FLAG_HEADER_CRC16 = 0x02,
54  OF_GZIP_STREAM_FLAG_EXTRA = 0x04,
55  OF_GZIP_STREAM_FLAG_NAME = 0x08,
56  OF_GZIP_STREAM_FLAG_COMMENT = 0x10
57  } _flags;
58  uint8_t _extraFlags;
59  enum of_gzip_stream_os {
60  OF_GZIP_STREAM_OS_FAT = 0,
61  OF_GZIP_STREAM_OS_AMIGA = 1,
62  OF_GZIP_STREAM_OS_VMS = 2,
63  OF_GZIP_STREAM_OS_UNIX = 3,
64  OF_GZIP_STREAM_OS_VM_CMS = 4,
65  OF_GZIP_STREAM_OS_ATARI_TOS = 5,
66  OF_GZIP_STREAM_OS_HPFS = 6,
67  OF_GZIP_STREAM_OS_MACINTOSH = 7,
68  OF_GZIP_STREAM_OS_Z_SYSTEM = 8,
69  OF_GZIP_STREAM_OS_CP_M = 9,
70  OF_GZIP_STREAM_OS_TOPS_20 = 10,
71  OF_GZIP_STREAM_OS_NTFS = 11,
72  OF_GZIP_STREAM_OS_QDOS = 12,
73  OF_GZIP_STREAM_OS_ACORN_RISCOS = 13,
74  OF_GZIP_STREAM_OS_UNKNOWN = 255
75  } _OS;
76  size_t _bytesRead;
77  uint8_t _buffer[4];
78  OFDate *_Nullable _modificationDate;
79  uint16_t _extraLength;
80  uint32_t _CRC32, _uncompressedSize;
81 }
82 
89 + (instancetype)streamWithStream: (OFStream *)stream;
90 
91 - init OF_UNAVAILABLE;
92 
100 - initWithStream: (OFStream *)stream OF_DESIGNATED_INITIALIZER;
101 @end
102 
103 OF_ASSUME_NONNULL_END
A class that handles Deflate decompression transparently for an underlying stream.
Definition: OFInflateStream.h:29
id init()
Initializes an already allocated object.
Definition: OFObject.m:488
A class that handles GZIP compression and decompression transparently for an underlying stream...
Definition: OFGZIPStream.h:30
A class for storing, accessing and comparing dates.
Definition: OFDate.h:30
A base class for different types of streams.
Definition: OFStream.h:88