aboutsummaryrefslogtreecommitdiff
path: root/src/util/gzip.h
blob: 53e59f6ad8f7c2a6f7b2ca55cb9086cd0487aad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once

#include <cstddef>

namespace {

size_t const GZ_HEADER_SIZE = 10;

// Gzip header fields
size_t const GZ_HEADER_ID1 = 0;
size_t const GZ_HEADER_ID2 = 1;
size_t const GZ_HEADER_CM = 2;
size_t const GZ_HEADER_FLG = 3;
size_t const GZ_HEADER_MTIME = 4;
size_t const GZ_HEADER_XFL = 8;
size_t const GZ_HEADER_OS = 9;

// Gzip file magic
unsigned char const gzipId1 = 0x1f;
unsigned char const gzipId2 = 0x8b;

// Gzip compression method(s)
unsigned char const GZ_CM_DEFLATE = 8;

// Flags in GZ_HEADER_FLG
unsigned char const GZ_FLG_TEXT = 1;
unsigned char const GZ_FLG_HCRC = 1 << 1;
unsigned char const GZ_FLG_EXTRA = 1 << 2;
unsigned char const GZ_FLG_NAME = 1 << 3;
unsigned char const GZ_FLG_COMMENT = 1 << 4;

// GZ_HEADER_XFL values for deflate
unsigned char const GZ_XFL_MAX = 2;
unsigned char const GZ_XFL_FAST = 4;

// GZ_HEADER_OS values
unsigned char const GZ_OS_FAT = 0;
unsigned char const GZ_OS_AMIGA = 1;
unsigned char const GZ_OS_VMS = 2;
unsigned char const GZ_OS_UNIX = 3;
unsigned char const GZ_OS_VM_CMS = 4;
unsigned char const GZ_OS_TOS = 5;
unsigned char const GZ_OS_HPFS = 6;
unsigned char const GZ_OS_MAC = 7;
unsigned char const GZ_OS_ZSYSTEM = 8;
unsigned char const GZ_OS_CPM = 9;
unsigned char const GZ_OS_TOPS20 = 10;
unsigned char const GZ_OS_NTFS = 11;
unsigned char const GZ_OS_QDOS = 12;
unsigned char const GZ_OS_RISCOS = 13;
unsigned char const GZ_OS_UNKNOWN = 255;

size_t const GZ_TRAILER_SIZE = 8;

// Gzip trailer fields
size_t const GZ_TRAILER_CRC32 = 0;
size_t const GZ_TRAILER_ISIZE = 4;

}