ObjFW
OFGZIPStream.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 #import "OFDate.h"
18 
19 @class OFInflateStream;
20 
21 OF_ASSUME_NONNULL_BEGIN
22 
29 OF_SUBCLASSING_RESTRICTED
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_OPERATING_SYSTEM,
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_operating_system {
60  OF_GZIP_STREAM_OPERATING_SYSTEM_FAT = 0,
61  OF_GZIP_STREAM_OPERATING_SYSTEM_AMIGA = 1,
62  OF_GZIP_STREAM_OPERATING_SYSTEM_VMS = 2,
63  OF_GZIP_STREAM_OPERATING_SYSTEM_UNIX = 3,
64  OF_GZIP_STREAM_OPERATING_SYSTEM_VM_CMS = 4,
65  OF_GZIP_STREAM_OPERATING_SYSTEM_ATARI_TOS = 5,
66  OF_GZIP_STREAM_OPERATING_SYSTEM_HPFS = 6,
67  OF_GZIP_STREAM_OPERATING_SYSTEM_MACINTOSH = 7,
68  OF_GZIP_STREAM_OPERATING_SYSTEM_Z_SYSTEM = 8,
69  OF_GZIP_STREAM_OPERATING_SYSTEM_CP_M = 9,
70  OF_GZIP_STREAM_OPERATING_SYSTEM_TOPS_20 = 10,
71  OF_GZIP_STREAM_OPERATING_SYSTEM_NTFS = 11,
72  OF_GZIP_STREAM_OPERATING_SYSTEM_QDO = 12,
73  OF_GZIP_STREAM_OPERATING_SYSTEM_ACORN_RISC_OS = 13,
74  OF_GZIP_STREAM_OPERATING_SYSTEM_UNKNOWN = 255
75  } _operatingSystemMadeOn;
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 @property (readonly, nonatomic)
90  enum of_gzip_stream_operating_system operatingSystemMadeOn;
91 
98 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFDate *modificationDate;
99 
108 + (instancetype)streamWithStream: (OFStream *)stream mode: (OFString *)mode;
109 
110 - (instancetype)init OF_UNAVAILABLE;
111 
121 - (instancetype)initWithStream: (OFStream *)stream
122  mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
123 @end
124 
125 OF_ASSUME_NONNULL_END
A class for storing, accessing and comparing dates.
Definition: OFDate.h:36
A class that handles GZIP compression and decompression transparently for an underlying stream.
Definition: OFGZIPStream.h:31
OFDate * modificationDate
The modification date of the original file.
Definition: OFGZIPStream.h:98
A class that handles Deflate decompression transparently for an underlying stream.
Definition: OFInflateStream.h:35
A base class for different types of streams.
Definition: OFStream.h:191
A class for handling strings.
Definition: OFString.h:132