1 #------------------------------------------------------------------------------
2 # $File: compress,v 1.72 2018/03/27 23:26:41 christos Exp $
3 # compress: file(1) magic for pure-compression formats (no archives)
5 # compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
7 # Formats for various forms of compressed data
8 # Formats for "compress" proper have been moved into "compress.c",
9 # because it tries to uncompress it to figure out what's inside.
11 # standard unix compress
12 0 string \037\235 compress'd data
13 !:mime application/x-compress
15 >2 byte&0x80 >0 block compressed
16 >2 byte&0x1f x %d bits
18 # gzip (GNU zip, not to be confused with Info-ZIP or PKWARE zip archiver)
19 # Edited by Chris Chittleborough <cchittleborough@yahoo.com.au>, March 2002
20 # * Original filename is only at offset 10 if "extra field" absent
21 # * Produce shorter output - notably, only report compression methods
22 # other than 8 ("deflate", the only method defined in RFC 1952).
23 0 string \037\213 gzip compressed data
24 !:mime application/x-gzip
26 >2 byte <8 \b, reserved method
27 >2 byte >8 \b, unknown method
28 >3 byte &0x01 \b, ASCII
29 >3 byte &0x02 \b, has CRC
30 >3 byte &0x04 \b, extra field
32 >>10 string x \b, was "%s"
33 >3 byte &0x10 \b, has comment
34 >3 byte &0x20 \b, encrypted
35 >4 ledate >0 \b, last modified: %s
36 >8 byte 2 \b, max compression
37 >8 byte 4 \b, max speed
38 >9 byte =0x00 \b, from FAT filesystem (MS-DOS, OS/2, NT)
39 >9 byte =0x01 \b, from Amiga
40 >9 byte =0x02 \b, from VMS
41 >9 byte =0x03 \b, from Unix
42 >9 byte =0x04 \b, from VM/CMS
43 >9 byte =0x05 \b, from Atari
44 >9 byte =0x06 \b, from HPFS filesystem (OS/2, NT)
45 >9 byte =0x07 \b, from MacOS
46 >9 byte =0x08 \b, from Z-System
47 >9 byte =0x09 \b, from CP/M
48 >9 byte =0x0A \b, from TOPS/20
49 >9 byte =0x0B \b, from NTFS filesystem (NT)
50 >9 byte =0x0C \b, from QDOS
51 >9 byte =0x0D \b, from Acorn RISCOS
52 >-4 lelong x \b, original size %d
54 # packed data, Huffman (minimum redundancy) codes on a byte-by-byte basis
55 0 string \037\036 packed data
56 !:mime application/octet-stream
57 >2 belong >1 \b, %d characters originally
58 >2 belong =1 \b, %d character originally
60 # This magic number is byte-order-independent.
61 0 short 0x1f1f old packed data
62 !:mime application/octet-stream
64 # XXX - why *two* entries for "compacted data", one of which is
65 # byte-order independent, and one of which is byte-order dependent?
67 0 short 0x1fff compacted data
68 !:mime application/octet-stream
69 # This string is valid for SunOS (BE) and a matching "short" is listed
70 # in the Ultrix (LE) magic file.
71 0 string \377\037 compacted data
72 !:mime application/octet-stream
73 0 short 0145405 huf output
74 !:mime application/octet-stream
77 0 string BZh bzip2 compressed data
78 !:mime application/x-bzip2
79 >3 byte >47 \b, block size = %c00k
81 # bzip a block-sorting file compressor
82 # by Julian Seward <sewardj@cs.man.ac.uk> and others
83 0 string BZ0 bzip compressed data
84 !:mime application/x-bzip
85 >3 byte >47 \b, block size = %c00k
88 0 string LZIP lzip compressed data
89 !:mime application/x-lzip
90 >4 byte x \b, version: %d
93 # Michael Haardt <michael@cantor.informatik.rwth-aachen.de>
94 0 beshort 0x76FF squeezed data,
95 >4 string x original name %s
96 0 beshort 0x76FE crunched data,
97 >2 string x original name %s
98 0 beshort 0x76FD LZH compressed data,
99 >2 string x original name %s
102 0 string \037\237 frozen file 2.1
103 0 string \037\236 frozen file 1.0 (or gzip 0.5)
105 # SCO compress -H (LZH)
106 0 string \037\240 SCO compress -H (LZH) data
108 # European GSM 06.10 is a provisional standard for full-rate speech
109 # transcoding, prI-ETS 300 036, which uses RPE/LTP (residual pulse
110 # excitation/long term prediction) coding at 13 kbit/s.
112 # There's only a magic nibble (4 bits); that nibble repeats every 33
113 # bytes. This isn't suited for use, but maybe we can use it someday.
115 # This will cause very short GSM files to be declared as data and
116 # mismatches to be declared as data too!
117 #0 byte&0xF0 0xd0 data
121 #>132 byte&0xF0 0xd0 GSM 06.10 compressed audio
123 # lzop from <markus.oberhumer@jk.uni-linz.ac.at>
124 0 string \x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a lzop compressed data
126 >>9 byte&0xf0 =0x00 - version 0.
127 >>9 beshort&0x0fff x \b%03x,
129 >>13 byte 2 LZO1X-1(15),
130 >>13 byte 3 LZO1X-999,
131 ## >>22 bedate >0 last modified: %s,
132 >>14 byte =0x00 os: MS-DOS
133 >>14 byte =0x01 os: Amiga
134 >>14 byte =0x02 os: VMS
135 >>14 byte =0x03 os: Unix
136 >>14 byte =0x05 os: Atari
137 >>14 byte =0x06 os: OS/2
138 >>14 byte =0x07 os: MacOS
139 >>14 byte =0x0A os: Tops/20
140 >>14 byte =0x0B os: WinNT
141 >>14 byte =0x0E os: Win32
143 >>9 byte&0xf0 =0x00 - version 0.
144 >>9 byte&0xf0 =0x10 - version 1.
145 >>9 byte&0xf0 =0x20 - version 2.
146 >>9 beshort&0x0fff x \b%03x,
148 >>15 byte 2 LZO1X-1(15),
149 >>15 byte 3 LZO1X-999,
150 ## >>25 bedate >0 last modified: %s,
151 >>17 byte =0x00 os: MS-DOS
152 >>17 byte =0x01 os: Amiga
153 >>17 byte =0x02 os: VMS
154 >>17 byte =0x03 os: Unix
155 >>17 byte =0x05 os: Atari
156 >>17 byte =0x06 os: OS/2
157 >>17 byte =0x07 os: MacOS
158 >>17 byte =0x0A os: Tops/20
159 >>17 byte =0x0B os: WinNT
160 >>17 byte =0x0E os: Win32
162 # 4.3BSD-Quasijarus Strong Compression
163 # http://minnie.tuhs.org/Quasijarus/compress.html
164 0 string \037\241 Quasijarus strong compressed data
166 # From: Cory Dikkers <cdikkers@swbell.net>
167 0 string XPKF Amiga xpkf.library compressed data
168 0 string PP11 Power Packer 1.1 compressed data
169 0 string PP20 Power Packer 2.0 compressed data,
170 >4 belong 0x09090909 fast compression
171 >4 belong 0x090A0A0A mediocre compression
172 >4 belong 0x090A0B0B good compression
173 >4 belong 0x090A0C0C very good compression
174 >4 belong 0x090A0C0D best compression
176 # 7-zip archiver, from Thomas Klausner (wiz@danbala.tuwien.ac.at)
177 # http://www.7-zip.org or DOC/7zFormat.txt
179 0 string 7z\274\257\047\034 7-zip archive data,
182 !:mime application/x-7z-compressed
186 0 lelong&0xffffff =0x5d
187 >12 leshort 0xff LZMA compressed data,
188 !:mime application/x-lzma
189 >>5 lequad =0xffffffffffffffff streamed
190 >>5 lequad !0xffffffffffffffff non-streamed, size %lld
191 >12 leshort 0 LZMA compressed data,
192 >>5 lequad =0xffffffffffffffff streamed
193 >>5 lequad !0xffffffffffffffff non-streamed, size %lld
195 # http://tukaani.org/xz/xz-file-format.txt
196 0 ustring \xFD7zXZ\x00 XZ compressed data
198 !:mime application/x-xz
200 # https://github.com/ckolivas/lrzip/blob/master/doc/magic.header.txt
201 0 string LRZI LRZIP compressed data
202 >4 byte x - version %d
204 !:mime application/x-lrzip
206 # http://fastcompression.blogspot.fi/2013/04/lz4-streaming-format-final.html
207 0 lelong 0x184d2204 LZ4 compressed data (v1.4+)
208 !:mime application/x-lz4
209 # Added by osm0sis@xda-developers.com
210 0 lelong 0x184c2103 LZ4 compressed data (v1.0-v1.3)
211 !:mime application/x-lz4
212 0 lelong 0x184c2102 LZ4 compressed data (v0.1-v0.9)
213 !:mime application/x-lz4
215 # Zstandard/LZ4 skippable frames
216 # https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md
217 0 lelong&0xFFFFFFF0 0x184D2A50
220 # Zstandard Dictionary ID subroutine
221 0 name zstd-dictionary-id
222 # Single Segment = True
223 >0 byte &0x20 \b, Dictionary ID:
231 # Single Segment = False
232 >0 byte ^0x20 \b, Dictionary ID:
241 # Zstandard compressed data
242 # https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md
243 0 lelong 0xFD2FB522 Zstandard compressed data (v0.2)
244 !:mime application/x-zstd
245 0 lelong 0xFD2FB523 Zstandard compressed data (v0.3)
246 !:mime application/x-zstd
247 0 lelong 0xFD2FB524 Zstandard compressed data (v0.4)
248 !:mime application/x-zstd
249 0 lelong 0xFD2FB525 Zstandard compressed data (v0.5)
250 !:mime application/x-zstd
251 0 lelong 0xFD2FB526 Zstandard compressed data (v0.6)
252 !:mime application/x-zstd
253 0 lelong 0xFD2FB527 Zstandard compressed data (v0.7)
254 !:mime application/x-zstd
255 >4 use zstd-dictionary-id
256 0 lelong 0xFD2FB528 Zstandard compressed data (v0.8+)
257 !:mime application/x-zstd
258 >4 use zstd-dictionary-id
260 # https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md
261 0 lelong 0xEC30A437 Zstandard dictionary
262 !:mime application/x-zstd-dictionary
265 # AFX compressed files (Wolfram Kleff)
266 2 string -afx- AFX compressed file data
268 # Supplementary magic data for the file(1) command to support
269 # rzip(1). The format is described in magic(5).
271 # Copyright (C) 2003 by Andrew Tridgell. You may do whatever you want with
274 0 string RZIP rzip compressed data
275 >4 byte x - version %d
277 >6 belong x (%d bytes)
279 0 string ArC\x01 FreeArc archive <http://freearc.org>
281 # Type: DACT compressed files
282 0 long 0x444354C3 DACT compressed data
283 >4 byte >-1 (version %i.
286 >7 long >0 , original size: %i bytes
287 >15 long >30 , block size: %i bytes
289 # Valve Pack (VPK) files
290 0 lelong 0x55aa1234 Valve Pak file
291 >0x4 lelong x \b, version %u
292 >0x8 lelong x \b, %u entries
294 # Snappy framing format
295 # http://code.google.com/p/snappy/source/browse/trunk/framing_format.txt
296 0 string \377\006\0\0sNaPpY snappy framed data
297 !:mime application/x-snappy-framed
299 # qpress, http://www.quicklz.com/
300 0 string qpress10 qpress compressed data
301 !:mime application/x-qpress
303 # Zlib https://www.ietf.org/rfc/rfc6713.txt
307 >>>0 byte&0x80 =0 zlib compressed data
308 !:mime application/zlib
312 >3 byte 0 BWC compressed data
315 0 bequad 0x00e955434cff011a UCL compressed data
318 0 string SLIB Softlib archive
319 >4 leshort x \b, version %d
320 >6 leshort x (contains %d files)
322 # URL: https://github.com/lzfse/lzfse/blob/master/src/lzfse_internal.h#L276
323 # From: Eric Hall <eric.hall@darkart.com>
324 0 string bvx- lzfse encoded, no compression
325 0 string bvx1 lzfse compressed, uncompressed tables
326 0 string bvx2 lzfse compressed, compressed tables
327 0 string bvxn lzfse encoded, lzvn compressed