Commit | Line | Data |
25f0751f |
1 | package IO::Compress::Gzip::Constants; |
2 | |
3 | use strict ; |
4 | use warnings; |
5 | use bytes; |
6 | |
7 | require Exporter; |
8 | |
9 | our ($VERSION, @ISA, @EXPORT, %GZIP_OS_Names); |
10 | our ($GZIP_FNAME_INVALID_CHAR_RE, $GZIP_FCOMMENT_INVALID_CHAR_RE); |
11 | |
b0cda13f |
12 | $VERSION = '2.003'; |
25f0751f |
13 | |
14 | @ISA = qw(Exporter); |
15 | |
16 | @EXPORT= qw( |
17 | |
18 | GZIP_ID_SIZE |
19 | GZIP_ID1 |
20 | GZIP_ID2 |
21 | |
22 | GZIP_FLG_DEFAULT |
23 | GZIP_FLG_FTEXT |
24 | GZIP_FLG_FHCRC |
25 | GZIP_FLG_FEXTRA |
26 | GZIP_FLG_FNAME |
27 | GZIP_FLG_FCOMMENT |
28 | GZIP_FLG_RESERVED |
29 | |
30 | GZIP_CM_DEFLATED |
31 | |
32 | GZIP_MIN_HEADER_SIZE |
33 | GZIP_TRAILER_SIZE |
34 | |
35 | GZIP_MTIME_DEFAULT |
36 | GZIP_XFL_DEFAULT |
37 | GZIP_FEXTRA_HEADER_SIZE |
38 | GZIP_FEXTRA_MAX_SIZE |
39 | GZIP_FEXTRA_SUBFIELD_HEADER_SIZE |
40 | GZIP_FEXTRA_SUBFIELD_ID_SIZE |
41 | GZIP_FEXTRA_SUBFIELD_LEN_SIZE |
42 | GZIP_FEXTRA_SUBFIELD_MAX_SIZE |
43 | |
44 | $GZIP_FNAME_INVALID_CHAR_RE |
45 | $GZIP_FCOMMENT_INVALID_CHAR_RE |
46 | |
47 | GZIP_FHCRC_SIZE |
48 | |
49 | GZIP_ISIZE_MAX |
50 | GZIP_ISIZE_MOD_VALUE |
51 | |
52 | |
53 | GZIP_NULL_BYTE |
54 | |
55 | GZIP_OS_DEFAULT |
56 | |
57 | %GZIP_OS_Names |
58 | |
59 | GZIP_MINIMUM_HEADER |
60 | |
61 | ); |
62 | |
63 | # Constant names derived from RFC 1952 |
64 | |
65 | use constant GZIP_ID_SIZE => 2 ; |
66 | use constant GZIP_ID1 => 0x1F; |
67 | use constant GZIP_ID2 => 0x8B; |
68 | |
69 | use constant GZIP_MIN_HEADER_SIZE => 10 ;# minimum gzip header size |
70 | use constant GZIP_TRAILER_SIZE => 8 ; |
71 | |
72 | |
73 | use constant GZIP_FLG_DEFAULT => 0x00 ; |
74 | use constant GZIP_FLG_FTEXT => 0x01 ; |
75 | use constant GZIP_FLG_FHCRC => 0x02 ; # called CONTINUATION in gzip |
76 | use constant GZIP_FLG_FEXTRA => 0x04 ; |
77 | use constant GZIP_FLG_FNAME => 0x08 ; |
78 | use constant GZIP_FLG_FCOMMENT => 0x10 ; |
79 | #use constant GZIP_FLG_ENCRYPTED => 0x20 ; # documented in gzip sources |
80 | use constant GZIP_FLG_RESERVED => (0x20 | 0x40 | 0x80) ; |
81 | |
82 | use constant GZIP_XFL_DEFAULT => 0x00 ; |
83 | |
84 | use constant GZIP_MTIME_DEFAULT => 0x00 ; |
85 | |
86 | use constant GZIP_FEXTRA_HEADER_SIZE => 2 ; |
87 | use constant GZIP_FEXTRA_MAX_SIZE => 0xFF ; |
88 | use constant GZIP_FEXTRA_SUBFIELD_ID_SIZE => 2 ; |
89 | use constant GZIP_FEXTRA_SUBFIELD_LEN_SIZE => 2 ; |
90 | use constant GZIP_FEXTRA_SUBFIELD_HEADER_SIZE => GZIP_FEXTRA_SUBFIELD_ID_SIZE + |
91 | GZIP_FEXTRA_SUBFIELD_LEN_SIZE; |
92 | use constant GZIP_FEXTRA_SUBFIELD_MAX_SIZE => GZIP_FEXTRA_MAX_SIZE - |
93 | GZIP_FEXTRA_SUBFIELD_HEADER_SIZE ; |
94 | |
95 | $GZIP_FNAME_INVALID_CHAR_RE = '[\x00-\x1F\x7F-\x9F]'; |
96 | $GZIP_FCOMMENT_INVALID_CHAR_RE = '[\x00-\x09\x11-\x1F\x7F-\x9F]'; |
97 | |
98 | use constant GZIP_FHCRC_SIZE => 2 ; # aka CONTINUATION in gzip |
99 | |
100 | use constant GZIP_CM_DEFLATED => 8 ; |
101 | |
102 | use constant GZIP_NULL_BYTE => "\x00"; |
103 | use constant GZIP_ISIZE_MAX => 0xFFFFFFFF ; |
104 | use constant GZIP_ISIZE_MOD_VALUE => GZIP_ISIZE_MAX + 1 ; |
105 | |
106 | # OS Names sourced from http://www.gzip.org/format.txt |
107 | |
108 | use constant GZIP_OS_DEFAULT=> 0xFF ; |
109 | %GZIP_OS_Names = ( |
110 | 0 => 'MS-DOS', |
111 | 1 => 'Amiga', |
112 | 2 => 'VMS', |
113 | 3 => 'Unix', |
114 | 4 => 'VM/CMS', |
115 | 5 => 'Atari TOS', |
116 | 6 => 'HPFS (OS/2, NT)', |
117 | 7 => 'Macintosh', |
118 | 8 => 'Z-System', |
119 | 9 => 'CP/M', |
120 | 10 => 'TOPS-20', |
121 | 11 => 'NTFS (NT)', |
122 | 12 => 'SMS QDOS', |
123 | 13 => 'Acorn RISCOS', |
124 | 14 => 'VFAT file system (Win95, NT)', |
125 | 15 => 'MVS', |
126 | 16 => 'BeOS', |
127 | 17 => 'Tandem/NSK', |
128 | 18 => 'THEOS', |
129 | GZIP_OS_DEFAULT() => 'Unknown', |
130 | ) ; |
131 | |
132 | use constant GZIP_MINIMUM_HEADER => pack("C4 V C C", |
133 | GZIP_ID1, GZIP_ID2, GZIP_CM_DEFLATED, GZIP_FLG_DEFAULT, |
134 | GZIP_MTIME_DEFAULT, GZIP_XFL_DEFAULT, GZIP_OS_DEFAULT) ; |
135 | |
136 | |
137 | 1; |