xref: /freebsd/contrib/file/magic/Magdir/compress (revision f39bffc62c1395bde25d152c7f68fdf7cbaab414)
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)
4#
5# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
6#
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.
10
11# standard unix compress
120	string		\037\235	compress'd data
13!:mime	application/x-compress
14!:apple	LZIVZIVU
15>2	byte&0x80	>0		block compressed
16>2	byte&0x1f	x		%d bits
17
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).
230       string          \037\213        gzip compressed data
24!:mime	application/x-gzip
25!:strength * 2
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
31>3	byte&0xC	=0x08
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
53
54# packed data, Huffman (minimum redundancy) codes on a byte-by-byte basis
550	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
59#
60# This magic number is byte-order-independent.
610	short		0x1f1f		old packed data
62!:mime	application/octet-stream
63
64# XXX - why *two* entries for "compacted data", one of which is
65# byte-order independent, and one of which is byte-order dependent?
66#
670	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.
710	string		\377\037	compacted data
72!:mime	application/octet-stream
730	short		0145405		huf output
74!:mime	application/octet-stream
75
76# bzip2
770	string		BZh		bzip2 compressed data
78!:mime	application/x-bzip2
79>3	byte		>47		\b, block size = %c00k
80
81# bzip	a block-sorting file compressor
82#	by Julian Seward <sewardj@cs.man.ac.uk> and others
830	string		BZ0		bzip compressed data
84!:mime	application/x-bzip
85>3	byte		>47		\b, block size = %c00k
86
87# lzip
880	string		LZIP		lzip compressed data
89!:mime application/x-lzip
90>4	byte		x		\b, version: %d
91
92# squeeze and crunch
93# Michael Haardt <michael@cantor.informatik.rwth-aachen.de>
940	beshort		0x76FF		squeezed data,
95>4	string		x		original name %s
960	beshort		0x76FE		crunched data,
97>2	string		x		original name %s
980	beshort		0x76FD		LZH compressed data,
99>2	string		x		original name %s
100
101# Freeze
1020	string		\037\237	frozen file 2.1
1030	string		\037\236	frozen file 1.0 (or gzip 0.5)
104
105# SCO compress -H (LZH)
1060	string		\037\240	SCO compress -H (LZH) data
107
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.
111#
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.
114#
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
118#>33	byte&0xF0	0xd0
119#>66	byte&0xF0	0xd0
120#>99	byte&0xF0	0xd0
121#>132	byte&0xF0	0xd0		GSM 06.10 compressed audio
122
123# lzop from <markus.oberhumer@jk.uni-linz.ac.at>
1240	string		\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a	lzop compressed data
125>9	beshort		<0x0940
126>>9	byte&0xf0	=0x00		- version 0.
127>>9	beshort&0x0fff	x		\b%03x,
128>>13	byte		1		LZO1X-1,
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
142>9	beshort		>0x0939
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,
147>>15	byte		1		LZO1X-1,
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
161
162# 4.3BSD-Quasijarus Strong Compression
163# http://minnie.tuhs.org/Quasijarus/compress.html
1640	string		\037\241	Quasijarus strong compressed data
165
166# From: Cory Dikkers <cdikkers@swbell.net>
1670	string		XPKF		Amiga xpkf.library compressed data
1680	string		PP11		Power Packer 1.1 compressed data
1690	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
175
176# 7-zip archiver, from Thomas Klausner (wiz@danbala.tuwien.ac.at)
177# http://www.7-zip.org or DOC/7zFormat.txt
178#
1790	string		7z\274\257\047\034	7-zip archive data,
180>6	byte		x			version %d
181>7	byte		x			\b.%d
182!:mime	application/x-7z-compressed
183!:ext 7z/cb7
184
185# Type: LZMA
1860	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
194
195# http://tukaani.org/xz/xz-file-format.txt
1960	ustring		\xFD7zXZ\x00		XZ compressed data
197!:strength * 2
198!:mime	application/x-xz
199
200# https://github.com/ckolivas/lrzip/blob/master/doc/magic.header.txt
2010	string		LRZI			LRZIP compressed data
202>4	byte		x			- version %d
203>5	byte		x			\b.%d
204!:mime	application/x-lrzip
205
206# http://fastcompression.blogspot.fi/2013/04/lz4-streaming-format-final.html
2070	lelong		0x184d2204	LZ4 compressed data (v1.4+)
208!:mime	application/x-lz4
209# Added by osm0sis@xda-developers.com
2100 	lelong		0x184c2103	LZ4 compressed data (v1.0-v1.3)
211!:mime	application/x-lz4
2120	lelong		0x184c2102	LZ4 compressed data (v0.1-v0.9)
213!:mime	application/x-lz4
214
215# Zstandard/LZ4 skippable frames
216# https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md
2170         lelong&0xFFFFFFF0  0x184D2A50
218>(4.l+8)  indirect	x
219
220# Zstandard Dictionary ID subroutine
2210     name        zstd-dictionary-id
222# Single Segment = True
223>0    byte        &0x20   \b, Dictionary ID:
224>>0   byte&0x03   0       None
225>>0   byte&0x03   1
226>>>1  byte        x       %u
227>>0   byte&0x03   2
228>>>1  leshort     x       %u
229>>0   byte&0x03   3
230>>>1  lelong      x       %u
231# Single Segment = False
232>0    byte        ^0x20   \b, Dictionary ID:
233>>0   byte&0x03   0       None
234>>0   byte&0x03   1
235>>>2  byte        x       %u
236>>0   byte&0x03   2
237>>>2  leshort     x       %u
238>>0   byte&0x03   3
239>>>2  lelong      x       %u
240
241# Zstandard compressed data
242# https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md
2430     lelong       0xFD2FB522  Zstandard compressed data (v0.2)
244!:mime  application/x-zstd
2450     lelong       0xFD2FB523  Zstandard compressed data (v0.3)
246!:mime  application/x-zstd
2470     lelong       0xFD2FB524  Zstandard compressed data (v0.4)
248!:mime  application/x-zstd
2490     lelong       0xFD2FB525  Zstandard compressed data (v0.5)
250!:mime  application/x-zstd
2510     lelong       0xFD2FB526  Zstandard compressed data (v0.6)
252!:mime  application/x-zstd
2530     lelong       0xFD2FB527  Zstandard compressed data (v0.7)
254!:mime  application/x-zstd
255>4    use          zstd-dictionary-id
2560     lelong       0xFD2FB528  Zstandard compressed data (v0.8+)
257!:mime  application/x-zstd
258>4    use          zstd-dictionary-id
259
260# https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md
2610  lelong    0xEC30A437  Zstandard dictionary
262!:mime  application/x-zstd-dictionary
263>4 lelong    x           (ID %u)
264
265# AFX compressed files (Wolfram Kleff)
2662	string		-afx-		AFX compressed file data
267
268# Supplementary magic data for the file(1) command to support
269# rzip(1).  The format is described in magic(5).
270#
271# Copyright (C) 2003 by Andrew Tridgell.  You may do whatever you want with
272# this file.
273#
2740	string		RZIP		rzip compressed data
275>4	byte		x		- version %d
276>5	byte		x		\b.%d
277>6	belong		x		(%d bytes)
278
2790	string		ArC\x01		FreeArc archive <http://freearc.org>
280
281# Type:	DACT compressed files
2820	long	0x444354C3	DACT compressed data
283>4	byte	>-1		(version %i.
284>5	byte	>-1		%i.
285>6	byte	>-1		%i)
286>7	long	>0		, original size: %i bytes
287>15	long	>30		, block size: %i bytes
288
289# Valve Pack (VPK) files
2900	lelong	0x55aa1234	Valve Pak file
291>0x4	lelong	x		\b, version %u
292>0x8	lelong	x		\b, %u entries
293
294# Snappy framing format
295# http://code.google.com/p/snappy/source/browse/trunk/framing_format.txt
2960	string	\377\006\0\0sNaPpY	snappy framed data
297!:mime	application/x-snappy-framed
298
299# qpress, http://www.quicklz.com/
3000	string	qpress10	qpress compressed data
301!:mime	application/x-qpress
302
303# Zlib https://www.ietf.org/rfc/rfc6713.txt
3040	string/b	x
305>0	beshort%31	=0
306>>0	byte&0xf	=8
307>>>0	byte&0x80 	=0	zlib compressed data
308!:mime	application/zlib
309
310# BWC compression
3110	string		BWC
312>3	byte		0	BWC compressed data
313
314# UCL compression
3150	bequad		0x00e955434cff011a	UCL compressed data
316
317# Softlib archive
3180	string		SLIB	Softlib archive
319>4	leshort		x	\b, version %d
320>6	leshort		x	(contains %d files)
321
322# URL:  https://github.com/lzfse/lzfse/blob/master/src/lzfse_internal.h#L276
323# From: Eric Hall <eric.hall@darkart.com>
3240	string	bvx-	lzfse encoded, no compression
3250	string	bvx1	lzfse compressed, uncompressed tables
3260	string	bvx2	lzfse compressed, compressed tables
3270	string	bvxn	lzfse encoded, lzvn compressed
328