ObjFW  Artifact [68e8c128bc]

Artifact 68e8c128bc979055a83f511f3c562c69496e5d0217b7acf49d4eda0f5e206644:

  • File src/OFGZIPStream.h — part of check-in [134a1121c7] at 2016-05-29 13:02:05 on branch trunk — Rename OFInflateStream back to OFDeflateStream

    The reason for renaming to OFInflateStream was to have one stream for
    decompression and one for compression in order to reduce memory usage if
    only one of the two is needed, as the ivar layout will be smaller then.
    However, it is more consistent with other stream classes to have one
    stream that can handle both. The increased memory footprint of having
    ivars for compression and decompression can be solved by having a
    pointer to those instead. This will not incur any performance penalty,
    as the pointer will be dereferenced instead of the ivars, meaning the
    overhead is only getting the pointer from the ivars once. (user: js, size: 2272) [annotate] [blame] [check-ins using]


/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
 *   Jonathan Schleifer <js@heap.zone>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFStream.h"
#import "OFDate.h"

@class OFDeflateStream;

OF_ASSUME_NONNULL_BEGIN

@interface OFGZIPStream: OFStream
{
	OFStream *_stream;
	OFDeflateStream *_inflateStream;
	enum {
		OF_GZIP_STREAM_ID1,
		OF_GZIP_STREAM_ID2,
		OF_GZIP_STREAM_COMPRESSION_METHOD,
		OF_GZIP_STREAM_FLAGS,
		OF_GZIP_STREAM_MODIFICATION_TIME,
		OF_GZIP_STREAM_EXTRA_FLAGS,
		OF_GZIP_STREAM_OS,
		OF_GZIP_STREAM_EXTRA_LENGTH,
		OF_GZIP_STREAM_EXTRA,
		OF_GZIP_STREAM_NAME,
		OF_GZIP_STREAM_COMMENT,
		OF_GZIP_STREAM_HEADER_CRC16,
		OF_GZIP_STREAM_DATA,
		OF_GZIP_STREAM_CRC32,
		OF_GZIP_STREAM_UNCOMPRESSED_SIZE
	} _state;
	enum {
		OF_GZIP_STREAM_FLAG_TEXT	 = 0x01,
		OF_GZIP_STREAM_FLAG_HEADER_CRC16 = 0x02,
		OF_GZIP_STREAM_FLAG_EXTRA	 = 0x04,
		OF_GZIP_STREAM_FLAG_NAME	 = 0x08,
		OF_GZIP_STREAM_FLAG_COMMENT	 = 0x10
	} _flags;
	uint8_t _extraFlags;
	enum {
		OF_GZIP_STREAM_OS_FAT	       =   0,
		OF_GZIP_STREAM_OS_AMIGA	       =   1,
		OF_GZIP_STREAM_OS_VMS	       =   2,
		OF_GZIP_STREAM_OS_UNIX	       =   3,
		OF_GZIP_STREAM_OS_VM_CMS       =   4,
		OF_GZIP_STREAM_OS_ATARI_TOS    =   5,
		OF_GZIP_STREAM_OS_HPFS	       =   6,
		OF_GZIP_STREAM_OS_MACINTOSH    =   7,
		OF_GZIP_STREAM_OS_Z_SYSTEM     =   8,
		OF_GZIP_STREAM_OS_CP_M	       =   9,
		OF_GZIP_STREAM_OS_TOPS_20      =  10,
		OF_GZIP_STREAM_OS_NTFS	       =  11,
		OF_GZIP_STREAM_OS_QDOS	       =  12,
		OF_GZIP_STREAM_OS_ACORN_RISCOS =  13,
		OF_GZIP_STREAM_OS_UNKNOWN      = 255
	} _OS;
	size_t _bytesRead;
	uint8_t _buffer[4];
	OFDate *_modificationDate;
	uint16_t _extraLength;
	uint32_t _CRC32, _uncompressedSize;
}

+ (instancetype)streamWithStream: (OFStream*)stream;
- initWithStream: (OFStream*)stream;
@end

OF_ASSUME_NONNULL_END