1*b6cee71dSXin LI#------------------------------------------------------------------------------ 2*b6cee71dSXin LI# $File: compress,v 1.58 2014/05/07 19:36:59 christos Exp $ 3*b6cee71dSXin LI# compress: file(1) magic for pure-compression formats (no archives) 4*b6cee71dSXin LI# 5*b6cee71dSXin LI# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc. 6*b6cee71dSXin LI# 7*b6cee71dSXin LI# Formats for various forms of compressed data 8*b6cee71dSXin LI# Formats for "compress" proper have been moved into "compress.c", 9*b6cee71dSXin LI# because it tries to uncompress it to figure out what's inside. 10*b6cee71dSXin LI 11*b6cee71dSXin LI# standard unix compress 12*b6cee71dSXin LI0 string \037\235 compress'd data 13*b6cee71dSXin LI!:mime application/x-compress 14*b6cee71dSXin LI!:apple LZIVZIVU 15*b6cee71dSXin LI>2 byte&0x80 >0 block compressed 16*b6cee71dSXin LI>2 byte&0x1f x %d bits 17*b6cee71dSXin LI 18*b6cee71dSXin LI# gzip (GNU zip, not to be confused with Info-ZIP or PKWARE zip archiver) 19*b6cee71dSXin LI# Edited by Chris Chittleborough <cchittleborough@yahoo.com.au>, March 2002 20*b6cee71dSXin LI# * Original filename is only at offset 10 if "extra field" absent 21*b6cee71dSXin LI# * Produce shorter output - notably, only report compression methods 22*b6cee71dSXin LI# other than 8 ("deflate", the only method defined in RFC 1952). 23*b6cee71dSXin LI0 string \037\213 gzip compressed data 24*b6cee71dSXin LI!:mime application/x-gzip 25*b6cee71dSXin LI!:strength * 2 26*b6cee71dSXin LI>2 byte <8 \b, reserved method 27*b6cee71dSXin LI>2 byte >8 \b, unknown method 28*b6cee71dSXin LI>3 byte &0x01 \b, ASCII 29*b6cee71dSXin LI>3 byte &0x02 \b, has CRC 30*b6cee71dSXin LI>3 byte &0x04 \b, extra field 31*b6cee71dSXin LI>3 byte&0xC =0x08 32*b6cee71dSXin LI>>10 string x \b, was "%s" 33*b6cee71dSXin LI>3 byte &0x10 \b, has comment 34*b6cee71dSXin LI>3 byte &0x20 \b, encrypted 35*b6cee71dSXin LI>4 ledate >0 \b, last modified: %s 36*b6cee71dSXin LI>8 byte 2 \b, max compression 37*b6cee71dSXin LI>8 byte 4 \b, max speed 38*b6cee71dSXin LI>9 byte =0x00 \b, from FAT filesystem (MS-DOS, OS/2, NT) 39*b6cee71dSXin LI>9 byte =0x01 \b, from Amiga 40*b6cee71dSXin LI>9 byte =0x02 \b, from VMS 41*b6cee71dSXin LI>9 byte =0x03 \b, from Unix 42*b6cee71dSXin LI>9 byte =0x04 \b, from VM/CMS 43*b6cee71dSXin LI>9 byte =0x05 \b, from Atari 44*b6cee71dSXin LI>9 byte =0x06 \b, from HPFS filesystem (OS/2, NT) 45*b6cee71dSXin LI>9 byte =0x07 \b, from MacOS 46*b6cee71dSXin LI>9 byte =0x08 \b, from Z-System 47*b6cee71dSXin LI>9 byte =0x09 \b, from CP/M 48*b6cee71dSXin LI>9 byte =0x0A \b, from TOPS/20 49*b6cee71dSXin LI>9 byte =0x0B \b, from NTFS filesystem (NT) 50*b6cee71dSXin LI>9 byte =0x0C \b, from QDOS 51*b6cee71dSXin LI>9 byte =0x0D \b, from Acorn RISCOS 52*b6cee71dSXin LI 53*b6cee71dSXin LI# packed data, Huffman (minimum redundancy) codes on a byte-by-byte basis 54*b6cee71dSXin LI0 string \037\036 packed data 55*b6cee71dSXin LI!:mime application/octet-stream 56*b6cee71dSXin LI>2 belong >1 \b, %d characters originally 57*b6cee71dSXin LI>2 belong =1 \b, %d character originally 58*b6cee71dSXin LI# 59*b6cee71dSXin LI# This magic number is byte-order-independent. 60*b6cee71dSXin LI0 short 0x1f1f old packed data 61*b6cee71dSXin LI!:mime application/octet-stream 62*b6cee71dSXin LI 63*b6cee71dSXin LI# XXX - why *two* entries for "compacted data", one of which is 64*b6cee71dSXin LI# byte-order independent, and one of which is byte-order dependent? 65*b6cee71dSXin LI# 66*b6cee71dSXin LI0 short 0x1fff compacted data 67*b6cee71dSXin LI!:mime application/octet-stream 68*b6cee71dSXin LI# This string is valid for SunOS (BE) and a matching "short" is listed 69*b6cee71dSXin LI# in the Ultrix (LE) magic file. 70*b6cee71dSXin LI0 string \377\037 compacted data 71*b6cee71dSXin LI!:mime application/octet-stream 72*b6cee71dSXin LI0 short 0145405 huf output 73*b6cee71dSXin LI!:mime application/octet-stream 74*b6cee71dSXin LI 75*b6cee71dSXin LI# bzip2 76*b6cee71dSXin LI0 string BZh bzip2 compressed data 77*b6cee71dSXin LI!:mime application/x-bzip2 78*b6cee71dSXin LI>3 byte >47 \b, block size = %c00k 79*b6cee71dSXin LI 80*b6cee71dSXin LI# lzip 81*b6cee71dSXin LI0 string LZIP lzip compressed data 82*b6cee71dSXin LI!:mime application/x-lzip 83*b6cee71dSXin LI>4 byte x \b, version: %d 84*b6cee71dSXin LI 85*b6cee71dSXin LI# squeeze and crunch 86*b6cee71dSXin LI# Michael Haardt <michael@cantor.informatik.rwth-aachen.de> 87*b6cee71dSXin LI0 beshort 0x76FF squeezed data, 88*b6cee71dSXin LI>4 string x original name %s 89*b6cee71dSXin LI0 beshort 0x76FE crunched data, 90*b6cee71dSXin LI>2 string x original name %s 91*b6cee71dSXin LI0 beshort 0x76FD LZH compressed data, 92*b6cee71dSXin LI>2 string x original name %s 93*b6cee71dSXin LI 94*b6cee71dSXin LI# Freeze 95*b6cee71dSXin LI0 string \037\237 frozen file 2.1 96*b6cee71dSXin LI0 string \037\236 frozen file 1.0 (or gzip 0.5) 97*b6cee71dSXin LI 98*b6cee71dSXin LI# SCO compress -H (LZH) 99*b6cee71dSXin LI0 string \037\240 SCO compress -H (LZH) data 100*b6cee71dSXin LI 101*b6cee71dSXin LI# European GSM 06.10 is a provisional standard for full-rate speech 102*b6cee71dSXin LI# transcoding, prI-ETS 300 036, which uses RPE/LTP (residual pulse 103*b6cee71dSXin LI# excitation/long term prediction) coding at 13 kbit/s. 104*b6cee71dSXin LI# 105*b6cee71dSXin LI# There's only a magic nibble (4 bits); that nibble repeats every 33 106*b6cee71dSXin LI# bytes. This isn't suited for use, but maybe we can use it someday. 107*b6cee71dSXin LI# 108*b6cee71dSXin LI# This will cause very short GSM files to be declared as data and 109*b6cee71dSXin LI# mismatches to be declared as data too! 110*b6cee71dSXin LI#0 byte&0xF0 0xd0 data 111*b6cee71dSXin LI#>33 byte&0xF0 0xd0 112*b6cee71dSXin LI#>66 byte&0xF0 0xd0 113*b6cee71dSXin LI#>99 byte&0xF0 0xd0 114*b6cee71dSXin LI#>132 byte&0xF0 0xd0 GSM 06.10 compressed audio 115*b6cee71dSXin LI 116*b6cee71dSXin LI# bzip a block-sorting file compressor 117*b6cee71dSXin LI# by Julian Seward <sewardj@cs.man.ac.uk> and others 118*b6cee71dSXin LI# 119*b6cee71dSXin LI#0 string BZ bzip compressed data 120*b6cee71dSXin LI#>2 byte x \b, version: %c 121*b6cee71dSXin LI#>3 string =1 \b, compression block size 100k 122*b6cee71dSXin LI#>3 string =2 \b, compression block size 200k 123*b6cee71dSXin LI#>3 string =3 \b, compression block size 300k 124*b6cee71dSXin LI#>3 string =4 \b, compression block size 400k 125*b6cee71dSXin LI#>3 string =5 \b, compression block size 500k 126*b6cee71dSXin LI#>3 string =6 \b, compression block size 600k 127*b6cee71dSXin LI#>3 string =7 \b, compression block size 700k 128*b6cee71dSXin LI#>3 string =8 \b, compression block size 800k 129*b6cee71dSXin LI#>3 string =9 \b, compression block size 900k 130*b6cee71dSXin LI 131*b6cee71dSXin LI# lzop from <markus.oberhumer@jk.uni-linz.ac.at> 132*b6cee71dSXin LI0 string \x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a lzop compressed data 133*b6cee71dSXin LI>9 beshort <0x0940 134*b6cee71dSXin LI>>9 byte&0xf0 =0x00 - version 0. 135*b6cee71dSXin LI>>9 beshort&0x0fff x \b%03x, 136*b6cee71dSXin LI>>13 byte 1 LZO1X-1, 137*b6cee71dSXin LI>>13 byte 2 LZO1X-1(15), 138*b6cee71dSXin LI>>13 byte 3 LZO1X-999, 139*b6cee71dSXin LI## >>22 bedate >0 last modified: %s, 140*b6cee71dSXin LI>>14 byte =0x00 os: MS-DOS 141*b6cee71dSXin LI>>14 byte =0x01 os: Amiga 142*b6cee71dSXin LI>>14 byte =0x02 os: VMS 143*b6cee71dSXin LI>>14 byte =0x03 os: Unix 144*b6cee71dSXin LI>>14 byte =0x05 os: Atari 145*b6cee71dSXin LI>>14 byte =0x06 os: OS/2 146*b6cee71dSXin LI>>14 byte =0x07 os: MacOS 147*b6cee71dSXin LI>>14 byte =0x0A os: Tops/20 148*b6cee71dSXin LI>>14 byte =0x0B os: WinNT 149*b6cee71dSXin LI>>14 byte =0x0E os: Win32 150*b6cee71dSXin LI>9 beshort >0x0939 151*b6cee71dSXin LI>>9 byte&0xf0 =0x00 - version 0. 152*b6cee71dSXin LI>>9 byte&0xf0 =0x10 - version 1. 153*b6cee71dSXin LI>>9 byte&0xf0 =0x20 - version 2. 154*b6cee71dSXin LI>>9 beshort&0x0fff x \b%03x, 155*b6cee71dSXin LI>>15 byte 1 LZO1X-1, 156*b6cee71dSXin LI>>15 byte 2 LZO1X-1(15), 157*b6cee71dSXin LI>>15 byte 3 LZO1X-999, 158*b6cee71dSXin LI## >>25 bedate >0 last modified: %s, 159*b6cee71dSXin LI>>17 byte =0x00 os: MS-DOS 160*b6cee71dSXin LI>>17 byte =0x01 os: Amiga 161*b6cee71dSXin LI>>17 byte =0x02 os: VMS 162*b6cee71dSXin LI>>17 byte =0x03 os: Unix 163*b6cee71dSXin LI>>17 byte =0x05 os: Atari 164*b6cee71dSXin LI>>17 byte =0x06 os: OS/2 165*b6cee71dSXin LI>>17 byte =0x07 os: MacOS 166*b6cee71dSXin LI>>17 byte =0x0A os: Tops/20 167*b6cee71dSXin LI>>17 byte =0x0B os: WinNT 168*b6cee71dSXin LI>>17 byte =0x0E os: Win32 169*b6cee71dSXin LI 170*b6cee71dSXin LI# 4.3BSD-Quasijarus Strong Compression 171*b6cee71dSXin LI# http://minnie.tuhs.org/Quasijarus/compress.html 172*b6cee71dSXin LI0 string \037\241 Quasijarus strong compressed data 173*b6cee71dSXin LI 174*b6cee71dSXin LI# From: Cory Dikkers <cdikkers@swbell.net> 175*b6cee71dSXin LI0 string XPKF Amiga xpkf.library compressed data 176*b6cee71dSXin LI0 string PP11 Power Packer 1.1 compressed data 177*b6cee71dSXin LI0 string PP20 Power Packer 2.0 compressed data, 178*b6cee71dSXin LI>4 belong 0x09090909 fast compression 179*b6cee71dSXin LI>4 belong 0x090A0A0A mediocre compression 180*b6cee71dSXin LI>4 belong 0x090A0B0B good compression 181*b6cee71dSXin LI>4 belong 0x090A0C0C very good compression 182*b6cee71dSXin LI>4 belong 0x090A0C0D best compression 183*b6cee71dSXin LI 184*b6cee71dSXin LI# 7-zip archiver, from Thomas Klausner (wiz@danbala.tuwien.ac.at) 185*b6cee71dSXin LI# http://www.7-zip.org or DOC/7zFormat.txt 186*b6cee71dSXin LI# 187*b6cee71dSXin LI0 string 7z\274\257\047\034 7-zip archive data, 188*b6cee71dSXin LI>6 byte x version %d 189*b6cee71dSXin LI>7 byte x \b.%d 190*b6cee71dSXin LI!:mime application/x-7z-compressed 191*b6cee71dSXin LI 192*b6cee71dSXin LI# Type: LZMA 193*b6cee71dSXin LI0 lelong&0xffffff =0x5d 194*b6cee71dSXin LI>12 leshort 0xff LZMA compressed data, 195*b6cee71dSXin LI!:mime application/x-lzma 196*b6cee71dSXin LI>>5 lequad =0xffffffffffffffff streamed 197*b6cee71dSXin LI>>5 lequad !0xffffffffffffffff non-streamed, size %lld 198*b6cee71dSXin LI>12 leshort 0 LZMA compressed data, 199*b6cee71dSXin LI>>5 lequad =0xffffffffffffffff streamed 200*b6cee71dSXin LI>>5 lequad !0xffffffffffffffff non-streamed, size %lld 201*b6cee71dSXin LI 202*b6cee71dSXin LI# http://tukaani.org/xz/xz-file-format.txt 203*b6cee71dSXin LI0 ustring \xFD7zXZ\x00 XZ compressed data 204*b6cee71dSXin LI!:mime application/x-xz 205*b6cee71dSXin LI 206*b6cee71dSXin LI# https://github.com/ckolivas/lrzip/blob/master/doc/magic.header.txt 207*b6cee71dSXin LI0 string LRZI LRZIP compressed data 208*b6cee71dSXin LI>4 byte x - version %d 209*b6cee71dSXin LI>5 byte x \b.%d 210*b6cee71dSXin LI!:mime application/x-lrzip 211*b6cee71dSXin LI 212*b6cee71dSXin LI# http://fastcompression.blogspot.fi/2013/04/lz4-streaming-format-final.html 213*b6cee71dSXin LI0 lelong 0x184d2204 LZ4 compressed data (v1.4+) 214*b6cee71dSXin LI!:mime application/x-lz4 215*b6cee71dSXin LI# Added by osm0sis@xda-developers.com 216*b6cee71dSXin LI0 lelong 0x184c2103 LZ4 compressed data (v1.0-v1.3) 217*b6cee71dSXin LI!:mime application/x-lz4 218*b6cee71dSXin LI0 lelong 0x184c2102 LZ4 compressed data (v0.1-v0.9) 219*b6cee71dSXin LI!:mime application/x-lz4 220*b6cee71dSXin LI 221*b6cee71dSXin LI# AFX compressed files (Wolfram Kleff) 222*b6cee71dSXin LI2 string -afx- AFX compressed file data 223*b6cee71dSXin LI 224*b6cee71dSXin LI# Supplementary magic data for the file(1) command to support 225*b6cee71dSXin LI# rzip(1). The format is described in magic(5). 226*b6cee71dSXin LI# 227*b6cee71dSXin LI# Copyright (C) 2003 by Andrew Tridgell. You may do whatever you want with 228*b6cee71dSXin LI# this file. 229*b6cee71dSXin LI# 230*b6cee71dSXin LI0 string RZIP rzip compressed data 231*b6cee71dSXin LI>4 byte x - version %d 232*b6cee71dSXin LI>5 byte x \b.%d 233*b6cee71dSXin LI>6 belong x (%d bytes) 234*b6cee71dSXin LI 235*b6cee71dSXin LI0 string ArC\x01 FreeArc archive <http://freearc.org> 236*b6cee71dSXin LI 237*b6cee71dSXin LI# Type: DACT compressed files 238*b6cee71dSXin LI0 long 0x444354C3 DACT compressed data 239*b6cee71dSXin LI>4 byte >-1 (version %i. 240*b6cee71dSXin LI>5 byte >-1 %i. 241*b6cee71dSXin LI>6 byte >-1 %i) 242*b6cee71dSXin LI>7 long >0 , original size: %i bytes 243*b6cee71dSXin LI>15 long >30 , block size: %i bytes 244*b6cee71dSXin LI 245*b6cee71dSXin LI# Valve Pack (VPK) files 246*b6cee71dSXin LI0 lelong 0x55aa1234 Valve Pak file 247*b6cee71dSXin LI>0x4 lelong x \b, version %u 248*b6cee71dSXin LI>0x8 lelong x \b, %u entries 249*b6cee71dSXin LI 250*b6cee71dSXin LI# Snappy framing format 251*b6cee71dSXin LI# http://code.google.com/p/snappy/source/browse/trunk/framing_format.txt 252*b6cee71dSXin LI0 string \377\006\0\0sNaPpY snappy framed data 253*b6cee71dSXin LI!:mime application/x-snappy-framed 254