1#!/usr/bin/python2 2""" 3Library used to determine a file MIME type by its magic number, it doesn't have 4any external dependencies. Based on work of Jason Petrone (jp_py@jsnp.net), 5adapted to autotest. 6 7Command Line Usage: Running as 'python magic.py file_path' will print a 8 mime string (or just a description) of the file present on file_path. 9 10API Usage: 11 magic.guess_type(file_path) - Returns a description of what the file on 12 path 'file' contains. This function name was chosen due to a similar 13 function on python standard library 'mimetypes'. 14 15@license: GPL v2 16@copyright: Jason Petrone (jp_py@jsnp.net) 2000 17@copyright: Lucas Meneghel Rodrigues (lmr@redhat.com) 2010 18@see: http://www.jsnp.net/code/magic.py 19""" 20 21from __future__ import absolute_import 22from __future__ import division 23from __future__ import print_function 24 25from six.moves import range 26import logging, optparse, os, re, sys, string, struct 27 28from autotest_lib.client.common_lib import logging_config 29from autotest_lib.client.common_lib import logging_manager 30 31 32def _str_to_num(n): 33 """ 34 Convert a hex or octal string to a decimal number. 35 36 @param n: Hex or octal string to be converted. 37 @return: Resulting decimal number. 38 """ 39 val = 0 40 col = int(1) 41 if n[:1] == 'x': n = '0' + n 42 if n[:2] == '0x': 43 # hex 44 n = str.lower(n[2:]) 45 while len(n) > 0: 46 l = n[len(n) - 1] 47 val = val + string.hexdigits.index(l) * col 48 col = col * 16 49 n = n[:len(n)-1] 50 elif n[0] == '\\': 51 # octal 52 n = n[1:] 53 while len(n) > 0: 54 l = n[len(n) - 1] 55 if ord(l) < 48 or ord(l) > 57: 56 break 57 val = val + int(l) * col 58 col = col * 8 59 n = n[:len(n)-1] 60 else: 61 val = int(n) 62 return val 63 64 65class MagicLoggingConfig(logging_config.LoggingConfig): 66 def configure_logging(self, results_dir=None, verbose=False): 67 super(MagicLoggingConfig, self).configure_logging(use_console=True, 68 verbose=verbose) 69 70 71class MagicTest(object): 72 """ 73 Compile a magic database entry so it can be compared with data read from 74 files. 75 """ 76 def __init__(self, offset, t, op, value, msg, mask=None): 77 """ 78 Reads magic database data. Maps the list fields into class attributes. 79 80 @param offset: Offset from start of the file. 81 @param t: Type of the magic data. 82 @param op: Operation to be performed when comparing the data. 83 @param value: Expected value of the magic data for a given data type. 84 @param msg: String representing the file mimetype. 85 """ 86 if t.count('&') > 0: 87 mask = _str_to_num(t[t.index('&')+1:]) 88 t = t[:t.index('&')] 89 if type(offset) == type('a'): 90 self.offset = _str_to_num(offset) 91 else: 92 self.offset = offset 93 self.type = t 94 self.msg = msg 95 self.subTests = [] 96 self.op = op 97 self.mask = mask 98 self.value = value 99 100 101 def test(self, data): 102 """ 103 Compare data read from file with self.value if operator is '='. 104 105 @param data: Data read from the file. 106 @return: None if no match between data and expected value string. Else, 107 print matching mime type information. 108 """ 109 if self.mask: 110 data = data & self.mask 111 if self.op == '=': 112 if self.value == data: 113 return self.msg 114 elif self.op == '<': 115 pass 116 elif self.op == '>': 117 pass 118 elif self.op == '&': 119 pass 120 elif self.op == '^': 121 pass 122 return None 123 124 125 def compare(self, data): 126 """ 127 Compare data read from the file with the expected data for this 128 particular mime type register. 129 130 @param data: Data read from the file. 131 """ 132 try: 133 if self.type == 'string': 134 c = ''; s = '' 135 for i in range(0, len(self.value)+1): 136 if i + self.offset > len(data) - 1: break 137 s = s + c 138 [c] = struct.unpack('c', data[self.offset + i]) 139 data = s 140 elif self.type == 'short': 141 [data] = struct.unpack('h', data[self.offset:self.offset + 2]) 142 elif self.type == 'leshort': 143 [data] = struct.unpack('<h', data[self.offset:self.offset + 2]) 144 elif self.type == 'beshort': 145 [data] = struct.unpack('>H', data[self.offset:self.offset + 2]) 146 elif self.type == 'long': 147 [data] = struct.unpack('l', data[self.offset:self.offset + 4]) 148 elif self.type == 'lelong': 149 [data] = struct.unpack('<l', data[self.offset:self.offset + 4]) 150 elif self.type == 'belong': 151 [data] = struct.unpack('>l', data[self.offset:self.offset + 4]) 152 else: 153 pass 154 except: 155 return None 156 157 return self.test(data) 158 159 160magic_database = [ 161 [0, 'leshort', '=', 1538, 'application/x-alan-adventure-game'], 162 [0, 'string', '=', 'TADS', 'application/x-tads-game'], 163 [0, 'short', '=', 420, 'application/x-executable-file'], 164 [0, 'short', '=', 421, 'application/x-executable-file'], 165 [0, 'leshort', '=', 603, 'application/x-executable-file'], 166 [0, 'string', '=', 'Core\001', 'application/x-executable-file'], 167 [0, 'string', '=', 'AMANDA: TAPESTART DATE', 'application/x-amanda-header'], 168 [0, 'belong', '=', 1011, 'application/x-executable-file'], 169 [0, 'belong', '=', 999, 'application/x-library-file'], 170 [0, 'belong', '=', 435, 'video/mpeg'], 171 [0, 'belong', '=', 442, 'video/mpeg'], 172 [0, 'beshort&0xfff0', '=', 65520, 'audio/mpeg'], 173 [4, 'leshort', '=', 44817, 'video/fli'], 174 [4, 'leshort', '=', 44818, 'video/flc'], 175 [0, 'string', '=', 'MOVI', 'video/x-sgi-movie'], 176 [4, 'string', '=', 'moov', 'video/quicktime'], 177 [4, 'string', '=', 'mdat', 'video/quicktime'], 178 [0, 'long', '=', 100554, 'application/x-apl-workspace'], 179 [0, 'string', '=', 'FiLeStArTfIlEsTaRt', 'text/x-apple-binscii'], 180 [0, 'string', '=', '\012GL', 'application/data'], 181 [0, 'string', '=', 'v\377', 'application/data'], 182 [0, 'string', '=', 'NuFile', 'application/data'], 183 [0, 'string', '=', 'N\365F\351l\345', 'application/data'], 184 [0, 'belong', '=', 333312, 'application/data'], 185 [0, 'belong', '=', 333319, 'application/data'], 186 [257, 'string', '=', 'ustar\000', 'application/x-tar'], 187 [257, 'string', '=', 'ustar \000', 'application/x-gtar'], 188 [0, 'short', '=', 70707, 'application/x-cpio'], 189 [0, 'short', '=', 143561, 'application/x-bcpio'], 190 [0, 'string', '=', '070707', 'application/x-cpio'], 191 [0, 'string', '=', '070701', 'application/x-cpio'], 192 [0, 'string', '=', '070702', 'application/x-cpio'], 193 [0, 'string', '=', '!<arch>\012debian', 'application/x-dpkg'], 194 [0, 'string', '=', '\xed\xab\xee\xdb', 'application/x-rpm'], 195 [0, 'long', '=', 177555, 'application/x-ar'], 196 [0, 'short', '=', 177555, 'application/data'], 197 [0, 'long', '=', 177545, 'application/data'], 198 [0, 'short', '=', 177545, 'application/data'], 199 [0, 'long', '=', 100554, 'application/x-apl-workspace'], 200 [0, 'string', '=', '<ar>', 'application/x-ar'], 201 [0, 'string', '=', '!<arch>\012__________E', 'application/x-ar'], 202 [0, 'string', '=', '-h-', 'application/data'], 203 [0, 'string', '=', '!<arch>', 'application/x-ar'], 204 [0, 'string', '=', '<ar>', 'application/x-ar'], 205 [0, 'string', '=', '<ar>', 'application/x-ar'], 206 [0, 'belong', '=', 1711210496, 'application/x-ar'], 207 [0, 'belong', '=', 1013019198, 'application/x-ar'], 208 [0, 'long', '=', 557605234, 'application/x-ar'], 209 [0, 'lelong', '=', 177555, 'application/data'], 210 [0, 'leshort', '=', 177555, 'application/data'], 211 [0, 'lelong', '=', 177545, 'application/data'], 212 [0, 'leshort', '=', 177545, 'application/data'], 213 [0, 'lelong', '=', 236525, 'application/data'], 214 [0, 'lelong', '=', 236526, 'application/data'], 215 [0, 'lelong&0x8080ffff', '=', 2074, 'application/x-arc'], 216 [0, 'lelong&0x8080ffff', '=', 2330, 'application/x-arc'], 217 [0, 'lelong&0x8080ffff', '=', 538, 'application/x-arc'], 218 [0, 'lelong&0x8080ffff', '=', 794, 'application/x-arc'], 219 [0, 'lelong&0x8080ffff', '=', 1050, 'application/x-arc'], 220 [0, 'lelong&0x8080ffff', '=', 1562, 'application/x-arc'], 221 [0, 'string', '=', '\032archive', 'application/data'], 222 [0, 'leshort', '=', 60000, 'application/x-arj'], 223 [0, 'string', '=', 'HPAK', 'application/data'], 224 [0, 'string', '=', '\351,\001JAM application/data', ''], 225 [2, 'string', '=', '-lh0-', 'application/x-lha'], 226 [2, 'string', '=', '-lh1-', 'application/x-lha'], 227 [2, 'string', '=', '-lz4-', 'application/x-lha'], 228 [2, 'string', '=', '-lz5-', 'application/x-lha'], 229 [2, 'string', '=', '-lzs-', 'application/x-lha'], 230 [2, 'string', '=', '-lh -', 'application/x-lha'], 231 [2, 'string', '=', '-lhd-', 'application/x-lha'], 232 [2, 'string', '=', '-lh2-', 'application/x-lha'], 233 [2, 'string', '=', '-lh3-', 'application/x-lha'], 234 [2, 'string', '=', '-lh4-', 'application/x-lha'], 235 [2, 'string', '=', '-lh5-', 'application/x-lha'], 236 [0, 'string', '=', 'Rar!', 'application/x-rar'], 237 [0, 'string', '=', 'SQSH', 'application/data'], 238 [0, 'string', '=', 'UC2\032', 'application/data'], 239 [0, 'string', '=', 'PK\003\004', 'application/zip'], 240 [20, 'lelong', '=', 4257523676, 'application/x-zoo'], 241 [10, 'string', '=', '# This is a shell archive', 'application/x-shar'], 242 [0, 'string', '=', '*STA', 'application/data'], 243 [0, 'string', '=', '2278', 'application/data'], 244 [0, 'beshort', '=', 560, 'application/x-executable-file'], 245 [0, 'beshort', '=', 561, 'application/x-executable-file'], 246 [0, 'string', '=', '\000\004\036\212\200', 'application/core'], 247 [0, 'string', '=', '.snd', 'audio/basic'], 248 [0, 'lelong', '=', 6583086, 'audio/basic'], 249 [0, 'string', '=', 'MThd', 'audio/midi'], 250 [0, 'string', '=', 'CTMF', 'audio/x-cmf'], 251 [0, 'string', '=', 'SBI', 'audio/x-sbi'], 252 [0, 'string', '=', 'Creative Voice File', 'audio/x-voc'], 253 [0, 'belong', '=', 1314148939, 'audio/x-multitrack'], 254 [0, 'string', '=', 'RIFF', 'audio/x-wav'], 255 [0, 'string', '=', 'EMOD', 'audio/x-emod'], 256 [0, 'belong', '=', 779248125, 'audio/x-pn-realaudio'], 257 [0, 'string', '=', 'MTM', 'audio/x-multitrack'], 258 [0, 'string', '=', 'if', 'audio/x-669-mod'], 259 [0, 'string', '=', 'FAR', 'audio/mod'], 260 [0, 'string', '=', 'MAS_U', 'audio/x-multimate-mod'], 261 [44, 'string', '=', 'SCRM', 'audio/x-st3-mod'], 262 [0, 'string', '=', 'GF1PATCH110\000ID#000002\000', 'audio/x-gus-patch'], 263 [0, 'string', '=', 'GF1PATCH100\000ID#000002\000', 'audio/x-gus-patch'], 264 [0, 'string', '=', 'JN', 'audio/x-669-mod'], 265 [0, 'string', '=', 'UN05', 'audio/x-mikmod-uni'], 266 [0, 'string', '=', 'Extended Module:', 'audio/x-ft2-mod'], 267 [21, 'string', '=', '!SCREAM!', 'audio/x-st2-mod'], 268 [1080, 'string', '=', 'M.K.', 'audio/x-protracker-mod'], 269 [1080, 'string', '=', 'M!K!', 'audio/x-protracker-mod'], 270 [1080, 'string', '=', 'FLT4', 'audio/x-startracker-mod'], 271 [1080, 'string', '=', '4CHN', 'audio/x-fasttracker-mod'], 272 [1080, 'string', '=', '6CHN', 'audio/x-fasttracker-mod'], 273 [1080, 'string', '=', '8CHN', 'audio/x-fasttracker-mod'], 274 [1080, 'string', '=', 'CD81', 'audio/x-oktalyzer-mod'], 275 [1080, 'string', '=', 'OKTA', 'audio/x-oktalyzer-mod'], 276 [1080, 'string', '=', '16CN', 'audio/x-taketracker-mod'], 277 [1080, 'string', '=', '32CN', 'audio/x-taketracker-mod'], 278 [0, 'string', '=', 'TOC', 'audio/x-toc'], 279 [0, 'short', '=', 3401, 'application/x-executable-file'], 280 [0, 'long', '=', 406, 'application/x-executable-file'], 281 [0, 'short', '=', 406, 'application/x-executable-file'], 282 [0, 'short', '=', 3001, 'application/x-executable-file'], 283 [0, 'lelong', '=', 314, 'application/x-executable-file'], 284 [0, 'string', '=', '//', 'text/cpp'], 285 [0, 'string', '=', '\\\\1cw\\', 'application/data'], 286 [0, 'string', '=', '\\\\1cw', 'application/data'], 287 [0, 'belong&0xffffff00', '=', 2231440384, 'application/data'], 288 [0, 'belong&0xffffff00', '=', 2231487232, 'application/data'], 289 [0, 'short', '=', 575, 'application/x-executable-file'], 290 [0, 'short', '=', 577, 'application/x-executable-file'], 291 [4, 'string', '=', 'pipe', 'application/data'], 292 [4, 'string', '=', 'prof', 'application/data'], 293 [0, 'string', '=', ': shell', 'application/data'], 294 [0, 'string', '=', '#!/bin/sh', 'application/x-sh'], 295 [0, 'string', '=', '#! /bin/sh', 'application/x-sh'], 296 [0, 'string', '=', '#! /bin/sh', 'application/x-sh'], 297 [0, 'string', '=', '#!/bin/csh', 'application/x-csh'], 298 [0, 'string', '=', '#! /bin/csh', 'application/x-csh'], 299 [0, 'string', '=', '#! /bin/csh', 'application/x-csh'], 300 [0, 'string', '=', '#!/bin/ksh', 'application/x-ksh'], 301 [0, 'string', '=', '#! /bin/ksh', 'application/x-ksh'], 302 [0, 'string', '=', '#! /bin/ksh', 'application/x-ksh'], 303 [0, 'string', '=', '#!/bin/tcsh', 'application/x-csh'], 304 [0, 'string', '=', '#! /bin/tcsh', 'application/x-csh'], 305 [0, 'string', '=', '#! /bin/tcsh', 'application/x-csh'], 306 [0, 'string', '=', '#!/usr/local/tcsh', 'application/x-csh'], 307 [0, 'string', '=', '#! /usr/local/tcsh', 'application/x-csh'], 308 [0, 'string', '=', '#!/usr/local/bin/tcsh', 'application/x-csh'], 309 [0, 'string', '=', '#! /usr/local/bin/tcsh', 'application/x-csh'], 310 [0, 'string', '=', '#! /usr/local/bin/tcsh', 'application/x-csh'], 311 [0, 'string', '=', '#!/usr/local/bin/zsh', 'application/x-zsh'], 312 [0, 'string', '=', '#! /usr/local/bin/zsh', 'application/x-zsh'], 313 [0, 'string', '=', '#! /usr/local/bin/zsh', 'application/x-zsh'], 314 [0, 'string', '=', '#!/usr/local/bin/ash', 'application/x-sh'], 315 [0, 'string', '=', '#! /usr/local/bin/ash', 'application/x-zsh'], 316 [0, 'string', '=', '#! /usr/local/bin/ash', 'application/x-zsh'], 317 [0, 'string', '=', '#!/usr/local/bin/ae', 'text/script'], 318 [0, 'string', '=', '#! /usr/local/bin/ae', 'text/script'], 319 [0, 'string', '=', '#! /usr/local/bin/ae', 'text/script'], 320 [0, 'string', '=', '#!/bin/nawk', 'application/x-awk'], 321 [0, 'string', '=', '#! /bin/nawk', 'application/x-awk'], 322 [0, 'string', '=', '#! /bin/nawk', 'application/x-awk'], 323 [0, 'string', '=', '#!/usr/bin/nawk', 'application/x-awk'], 324 [0, 'string', '=', '#! /usr/bin/nawk', 'application/x-awk'], 325 [0, 'string', '=', '#! /usr/bin/nawk', 'application/x-awk'], 326 [0, 'string', '=', '#!/usr/local/bin/nawk', 'application/x-awk'], 327 [0, 'string', '=', '#! /usr/local/bin/nawk', 'application/x-awk'], 328 [0, 'string', '=', '#! /usr/local/bin/nawk', 'application/x-awk'], 329 [0, 'string', '=', '#!/bin/gawk', 'application/x-awk'], 330 [0, 'string', '=', '#! /bin/gawk', 'application/x-awk'], 331 [0, 'string', '=', '#! /bin/gawk', 'application/x-awk'], 332 [0, 'string', '=', '#!/usr/bin/gawk', 'application/x-awk'], 333 [0, 'string', '=', '#! /usr/bin/gawk', 'application/x-awk'], 334 [0, 'string', '=', '#! /usr/bin/gawk', 'application/x-awk'], 335 [0, 'string', '=', '#!/usr/local/bin/gawk', 'application/x-awk'], 336 [0, 'string', '=', '#! /usr/local/bin/gawk', 'application/x-awk'], 337 [0, 'string', '=', '#! /usr/local/bin/gawk', 'application/x-awk'], 338 [0, 'string', '=', '#!/bin/awk', 'application/x-awk'], 339 [0, 'string', '=', '#! /bin/awk', 'application/x-awk'], 340 [0, 'string', '=', '#! /bin/awk', 'application/x-awk'], 341 [0, 'string', '=', '#!/usr/bin/awk', 'application/x-awk'], 342 [0, 'string', '=', '#! /usr/bin/awk', 'application/x-awk'], 343 [0, 'string', '=', '#! /usr/bin/awk', 'application/x-awk'], 344 [0, 'string', '=', 'BEGIN', 'application/x-awk'], 345 [0, 'string', '=', '#!/bin/perl', 'application/x-perl'], 346 [0, 'string', '=', '#! /bin/perl', 'application/x-perl'], 347 [0, 'string', '=', '#! /bin/perl', 'application/x-perl'], 348 [0, 'string', '=', 'eval "exec /bin/perl', 'application/x-perl'], 349 [0, 'string', '=', '#!/usr/bin/perl', 'application/x-perl'], 350 [0, 'string', '=', '#! /usr/bin/perl', 'application/x-perl'], 351 [0, 'string', '=', '#! /usr/bin/perl', 'application/x-perl'], 352 [0, 'string', '=', 'eval "exec /usr/bin/perl', 'application/x-perl'], 353 [0, 'string', '=', '#!/usr/local/bin/perl', 'application/x-perl'], 354 [0, 'string', '=', '#! /usr/local/bin/perl', 'application/x-perl'], 355 [0, 'string', '=', '#! /usr/local/bin/perl', 'application/x-perl'], 356 [0, 'string', '=', 'eval "exec /usr/local/bin/perl', 'application/x-perl'], 357 [0, 'string', '=', '#!/bin/python', 'application/x-python'], 358 [0, 'string', '=', '#! /bin/python', 'application/x-python'], 359 [0, 'string', '=', '#! /bin/python', 'application/x-python'], 360 [0, 'string', '=', 'eval "exec /bin/python', 'application/x-python'], 361 [0, 'string', '=', '#!/usr/bin/python', 'application/x-python'], 362 [0, 'string', '=', '#! /usr/bin/python', 'application/x-python'], 363 [0, 'string', '=', '#! /usr/bin/python', 'application/x-python'], 364 [0, 'string', '=', 'eval "exec /usr/bin/python', 'application/x-python'], 365 [0, 'string', '=', '#!/usr/local/bin/python', 'application/x-python'], 366 [0, 'string', '=', '#! /usr/local/bin/python', 'application/x-python'], 367 [0, 'string', '=', '#! /usr/local/bin/python', 'application/x-python'], 368 [0, 'string', '=', 'eval "exec /usr/local/bin/python', 'application/x-python'], 369 [0, 'string', '=', '#!/usr/bin/env python', 'application/x-python'], 370 [0, 'string', '=', '#! /usr/bin/env python', 'application/x-python'], 371 [0, 'string', '=', '#!/bin/rc', 'text/script'], 372 [0, 'string', '=', '#! /bin/rc', 'text/script'], 373 [0, 'string', '=', '#! /bin/rc', 'text/script'], 374 [0, 'string', '=', '#!/bin/bash', 'application/x-sh'], 375 [0, 'string', '=', '#! /bin/bash', 'application/x-sh'], 376 [0, 'string', '=', '#! /bin/bash', 'application/x-sh'], 377 [0, 'string', '=', '#!/usr/local/bin/bash', 'application/x-sh'], 378 [0, 'string', '=', '#! /usr/local/bin/bash', 'application/x-sh'], 379 [0, 'string', '=', '#! /usr/local/bin/bash', 'application/x-sh'], 380 [0, 'string', '=', '#! /', 'text/script'], 381 [0, 'string', '=', '#! /', 'text/script'], 382 [0, 'string', '=', '#!/', 'text/script'], 383 [0, 'string', '=', '#! text/script', ''], 384 [0, 'string', '=', '\037\235', 'application/compress'], 385 [0, 'string', '=', '\037\213', 'application/x-gzip'], 386 [0, 'string', '=', '\037\036', 'application/data'], 387 [0, 'short', '=', 17437, 'application/data'], 388 [0, 'short', '=', 8191, 'application/data'], 389 [0, 'string', '=', '\377\037', 'application/data'], 390 [0, 'short', '=', 145405, 'application/data'], 391 [0, 'string', '=', 'BZh', 'application/x-bzip2'], 392 [0, 'leshort', '=', 65398, 'application/data'], 393 [0, 'leshort', '=', 65142, 'application/data'], 394 [0, 'leshort', '=', 64886, 'application/x-lzh'], 395 [0, 'string', '=', '\037\237', 'application/data'], 396 [0, 'string', '=', '\037\236', 'application/data'], 397 [0, 'string', '=', '\037\240', 'application/data'], 398 [0, 'string', '=', 'BZ', 'application/x-bzip'], 399 [0, 'string', '=', '\211LZO\000\015\012\032\012', 'application/data'], 400 [0, 'belong', '=', 507, 'application/x-object-file'], 401 [0, 'belong', '=', 513, 'application/x-executable-file'], 402 [0, 'belong', '=', 515, 'application/x-executable-file'], 403 [0, 'belong', '=', 517, 'application/x-executable-file'], 404 [0, 'belong', '=', 70231, 'application/core'], 405 [24, 'belong', '=', 60011, 'application/data'], 406 [24, 'belong', '=', 60012, 'application/data'], 407 [24, 'belong', '=', 60013, 'application/data'], 408 [24, 'belong', '=', 60014, 'application/data'], 409 [0, 'belong', '=', 601, 'application/x-object-file'], 410 [0, 'belong', '=', 607, 'application/data'], 411 [0, 'belong', '=', 324508366, 'application/x-gdbm'], 412 [0, 'lelong', '=', 324508366, 'application/x-gdbm'], 413 [0, 'string', '=', 'GDBM', 'application/x-gdbm'], 414 [0, 'belong', '=', 398689, 'application/x-db'], 415 [0, 'belong', '=', 340322, 'application/x-db'], 416 [0, 'string', '=', '<list>\012<protocol bbn-m', 'application/data'], 417 [0, 'string', '=', 'diff text/x-patch', ''], 418 [0, 'string', '=', '*** text/x-patch', ''], 419 [0, 'string', '=', 'Only in text/x-patch', ''], 420 [0, 'string', '=', 'Common subdirectories: text/x-patch', ''], 421 [0, 'string', '=', '!<arch>\012________64E', 'application/data'], 422 [0, 'leshort', '=', 387, 'application/x-executable-file'], 423 [0, 'leshort', '=', 392, 'application/x-executable-file'], 424 [0, 'leshort', '=', 399, 'application/x-object-file'], 425 [0, 'string', '=', '\377\377\177', 'application/data'], 426 [0, 'string', '=', '\377\377|', 'application/data'], 427 [0, 'string', '=', '\377\377~', 'application/data'], 428 [0, 'string', '=', '\033c\033', 'application/data'], 429 [0, 'long', '=', 4553207, 'image/x11'], 430 [0, 'string', '=', '!<PDF>!\012', 'application/x-prof'], 431 [0, 'short', '=', 1281, 'application/x-locale'], 432 [24, 'belong', '=', 60012, 'application/x-dump'], 433 [24, 'belong', '=', 60011, 'application/x-dump'], 434 [24, 'lelong', '=', 60012, 'application/x-dump'], 435 [24, 'lelong', '=', 60011, 'application/x-dump'], 436 [0, 'string', '=', '\177ELF', 'application/x-executable-file'], 437 [0, 'short', '=', 340, 'application/data'], 438 [0, 'short', '=', 341, 'application/x-executable-file'], 439 [1080, 'leshort', '=', 61267, 'application/x-linux-ext2fs'], 440 [0, 'string', '=', '\366\366\366\366', 'application/x-pc-floppy'], 441 [774, 'beshort', '=', 55998, 'application/data'], 442 [510, 'leshort', '=', 43605, 'application/data'], 443 [1040, 'leshort', '=', 4991, 'application/x-filesystem'], 444 [1040, 'leshort', '=', 5007, 'application/x-filesystem'], 445 [1040, 'leshort', '=', 9320, 'application/x-filesystem'], 446 [1040, 'leshort', '=', 9336, 'application/x-filesystem'], 447 [0, 'string', '=', '-rom1fs-\000', 'application/x-filesystem'], 448 [395, 'string', '=', 'OS/2', 'application/x-bootable'], 449 [0, 'string', '=', 'FONT', 'font/x-vfont'], 450 [0, 'short', '=', 436, 'font/x-vfont'], 451 [0, 'short', '=', 17001, 'font/x-vfont'], 452 [0, 'string', '=', '%!PS-AdobeFont-1.0', 'font/type1'], 453 [6, 'string', '=', '%!PS-AdobeFont-1.0', 'font/type1'], 454 [0, 'belong', '=', 4, 'font/x-snf'], 455 [0, 'lelong', '=', 4, 'font/x-snf'], 456 [0, 'string', '=', 'STARTFONT font/x-bdf', ''], 457 [0, 'string', '=', '\001fcp', 'font/x-pcf'], 458 [0, 'string', '=', 'D1.0\015', 'font/x-speedo'], 459 [0, 'string', '=', 'flf', 'font/x-figlet'], 460 [0, 'string', '=', 'flc', 'application/x-font'], 461 [0, 'belong', '=', 335698201, 'font/x-libgrx'], 462 [0, 'belong', '=', 4282797902, 'font/x-dos'], 463 [7, 'belong', '=', 4540225, 'font/x-dos'], 464 [7, 'belong', '=', 5654852, 'font/x-dos'], 465 [4098, 'string', '=', 'DOSFONT', 'font/x-dos'], 466 [0, 'string', '=', '<MakerFile', 'application/x-framemaker'], 467 [0, 'string', '=', '<MIFFile', 'application/x-framemaker'], 468 [0, 'string', '=', '<MakerDictionary', 'application/x-framemaker'], 469 [0, 'string', '=', '<MakerScreenFont', 'font/x-framemaker'], 470 [0, 'string', '=', '<MML', 'application/x-framemaker'], 471 [0, 'string', '=', '<BookFile', 'application/x-framemaker'], 472 [0, 'string', '=', '<Maker', 'application/x-framemaker'], 473 [0, 'lelong&0377777777', '=', 41400407, 'application/x-executable-file'], 474 [0, 'lelong&0377777777', '=', 41400410, 'application/x-executable-file'], 475 [0, 'lelong&0377777777', '=', 41400413, 'application/x-executable-file'], 476 [0, 'lelong&0377777777', '=', 41400314, 'application/x-executable-file'], 477 [7, 'string', '=', '\357\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000', 'application/core'], 478 [0, 'lelong', '=', 11421044151, 'application/data'], 479 [0, 'string', '=', 'GIMP Gradient', 'application/x-gimp-gradient'], 480 [0, 'string', '=', 'gimp xcf', 'application/x-gimp-image'], 481 [20, 'string', '=', 'GPAT', 'application/x-gimp-pattern'], 482 [20, 'string', '=', 'GIMP', 'application/x-gimp-brush'], 483 [0, 'string', '=', '\336\022\004\225', 'application/x-locale'], 484 [0, 'string', '=', '\225\004\022\336', 'application/x-locale'], 485 [0, 'beshort', '=', 627, 'application/x-executable-file'], 486 [0, 'beshort', '=', 624, 'application/x-executable-file'], 487 [0, 'string', '=', '\000\001\000\000\000', 'font/ttf'], 488 [0, 'long', '=', 1203604016, 'application/data'], 489 [0, 'long', '=', 1702407010, 'application/data'], 490 [0, 'long', '=', 1003405017, 'application/data'], 491 [0, 'long', '=', 1602007412, 'application/data'], 492 [0, 'belong', '=', 34603270, 'application/x-object-file'], 493 [0, 'belong', '=', 34603271, 'application/x-executable-file'], 494 [0, 'belong', '=', 34603272, 'application/x-executable-file'], 495 [0, 'belong', '=', 34603275, 'application/x-executable-file'], 496 [0, 'belong', '=', 34603278, 'application/x-library-file'], 497 [0, 'belong', '=', 34603277, 'application/x-library-file'], 498 [0, 'belong', '=', 34865414, 'application/x-object-file'], 499 [0, 'belong', '=', 34865415, 'application/x-executable-file'], 500 [0, 'belong', '=', 34865416, 'application/x-executable-file'], 501 [0, 'belong', '=', 34865419, 'application/x-executable-file'], 502 [0, 'belong', '=', 34865422, 'application/x-library-file'], 503 [0, 'belong', '=', 34865421, 'application/x-object-file'], 504 [0, 'belong', '=', 34275590, 'application/x-object-file'], 505 [0, 'belong', '=', 34275591, 'application/x-executable-file'], 506 [0, 'belong', '=', 34275592, 'application/x-executable-file'], 507 [0, 'belong', '=', 34275595, 'application/x-executable-file'], 508 [0, 'belong', '=', 34275598, 'application/x-library-file'], 509 [0, 'belong', '=', 34275597, 'application/x-library-file'], 510 [0, 'belong', '=', 557605234, 'application/x-ar'], 511 [0, 'long', '=', 34078982, 'application/x-executable-file'], 512 [0, 'long', '=', 34078983, 'application/x-executable-file'], 513 [0, 'long', '=', 34078984, 'application/x-executable-file'], 514 [0, 'belong', '=', 34341128, 'application/x-executable-file'], 515 [0, 'belong', '=', 34341127, 'application/x-executable-file'], 516 [0, 'belong', '=', 34341131, 'application/x-executable-file'], 517 [0, 'belong', '=', 34341126, 'application/x-executable-file'], 518 [0, 'belong', '=', 34210056, 'application/x-executable-file'], 519 [0, 'belong', '=', 34210055, 'application/x-executable-file'], 520 [0, 'belong', '=', 34341134, 'application/x-library-file'], 521 [0, 'belong', '=', 34341133, 'application/x-library-file'], 522 [0, 'long', '=', 65381, 'application/x-library-file'], 523 [0, 'long', '=', 34275173, 'application/x-library-file'], 524 [0, 'long', '=', 34406245, 'application/x-library-file'], 525 [0, 'long', '=', 34144101, 'application/x-library-file'], 526 [0, 'long', '=', 22552998, 'application/core'], 527 [0, 'long', '=', 1302851304, 'font/x-hp-windows'], 528 [0, 'string', '=', 'Bitmapfile', 'image/unknown'], 529 [0, 'string', '=', 'IMGfile', 'CIS image/unknown'], 530 [0, 'long', '=', 34341132, 'application/x-lisp'], 531 [0, 'string', '=', 'msgcat01', 'application/x-locale'], 532 [0, 'string', '=', 'HPHP48-', 'HP48 binary'], 533 [0, 'string', '=', '%%HP:', 'HP48 text'], 534 [0, 'beshort', '=', 200, 'hp200 (68010) BSD'], 535 [0, 'beshort', '=', 300, 'hp300 (68020+68881) BSD'], 536 [0, 'beshort', '=', 537, '370 XA sysV executable'], 537 [0, 'beshort', '=', 532, '370 XA sysV pure executable'], 538 [0, 'beshort', '=', 54001, '370 sysV pure executable'], 539 [0, 'beshort', '=', 55001, '370 XA sysV pure executable'], 540 [0, 'beshort', '=', 56401, '370 sysV executable'], 541 [0, 'beshort', '=', 57401, '370 XA sysV executable'], 542 [0, 'beshort', '=', 531, 'SVR2 executable (Amdahl-UTS)'], 543 [0, 'beshort', '=', 534, 'SVR2 pure executable (Amdahl-UTS)'], 544 [0, 'beshort', '=', 530, 'SVR2 pure executable (USS/370)'], 545 [0, 'beshort', '=', 535, 'SVR2 executable (USS/370)'], 546 [0, 'beshort', '=', 479, 'executable (RISC System/6000 V3.1) or obj module'], 547 [0, 'beshort', '=', 260, 'shared library'], 548 [0, 'beshort', '=', 261, 'ctab data'], 549 [0, 'beshort', '=', 65028, 'structured file'], 550 [0, 'string', '=', '0xabcdef', 'AIX message catalog'], 551 [0, 'belong', '=', 505, 'AIX compiled message catalog'], 552 [0, 'string', '=', '<aiaff>', 'archive'], 553 [0, 'string', '=', 'FORM', 'IFF data'], 554 [0, 'string', '=', 'P1', 'image/x-portable-bitmap'], 555 [0, 'string', '=', 'P2', 'image/x-portable-graymap'], 556 [0, 'string', '=', 'P3', 'image/x-portable-pixmap'], 557 [0, 'string', '=', 'P4', 'image/x-portable-bitmap'], 558 [0, 'string', '=', 'P5', 'image/x-portable-graymap'], 559 [0, 'string', '=', 'P6', 'image/x-portable-pixmap'], 560 [0, 'string', '=', 'IIN1', 'image/tiff'], 561 [0, 'string', '=', 'MM\000*', 'image/tiff'], 562 [0, 'string', '=', 'II*\000', 'image/tiff'], 563 [0, 'string', '=', '\211PNG', 'image/x-png'], 564 [1, 'string', '=', 'PNG', 'image/x-png'], 565 [0, 'string', '=', 'GIF8', 'image/gif'], 566 [0, 'string', '=', '\361\000@\273', 'image/x-cmu-raster'], 567 [0, 'string', '=', 'id=ImageMagick', 'MIFF image data'], 568 [0, 'long', '=', 1123028772, 'Artisan image data'], 569 [0, 'string', '=', '#FIG', 'FIG image text'], 570 [0, 'string', '=', 'ARF_BEGARF', 'PHIGS clear text archive'], 571 [0, 'string', '=', '@(#)SunPHIGS', 'SunPHIGS'], 572 [0, 'string', '=', 'GKSM', 'GKS Metafile'], 573 [0, 'string', '=', 'BEGMF', 'clear text Computer Graphics Metafile'], 574 [0, 'beshort&0xffe0', '=', 32, 'binary Computer Graphics Metafile'], 575 [0, 'beshort', '=', 12320, 'character Computer Graphics Metafile'], 576 [0, 'string', '=', 'yz', 'MGR bitmap, modern format, 8-bit aligned'], 577 [0, 'string', '=', 'zz', 'MGR bitmap, old format, 1-bit deep, 16-bit aligned'], 578 [0, 'string', '=', 'xz', 'MGR bitmap, old format, 1-bit deep, 32-bit aligned'], 579 [0, 'string', '=', 'yx', 'MGR bitmap, modern format, squeezed'], 580 [0, 'string', '=', '%bitmap\000', 'FBM image data'], 581 [1, 'string', '=', 'PC Research, Inc', 'group 3 fax data'], 582 [0, 'beshort', '=', 65496, 'image/jpeg'], 583 [0, 'string', '=', 'hsi1', 'image/x-jpeg-proprietary'], 584 [0, 'string', '=', 'BM', 'image/x-bmp'], 585 [0, 'string', '=', 'IC', 'image/x-ico'], 586 [0, 'string', '=', 'PI', 'PC pointer image data'], 587 [0, 'string', '=', 'CI', 'PC color icon data'], 588 [0, 'string', '=', 'CP', 'PC color pointer image data'], 589 [0, 'string', '=', '/* XPM */', 'X pixmap image text'], 590 [0, 'leshort', '=', 52306, 'RLE image data,'], 591 [0, 'string', '=', 'Imagefile version-', 'iff image data'], 592 [0, 'belong', '=', 1504078485, 'x/x-image-sun-raster'], 593 [0, 'beshort', '=', 474, 'x/x-image-sgi'], 594 [0, 'string', '=', 'IT01', 'FIT image data'], 595 [0, 'string', '=', 'IT02', 'FIT image data'], 596 [2048, 'string', '=', 'PCD_IPI', 'x/x-photo-cd-pack-file'], 597 [0, 'string', '=', 'PCD_OPA', 'x/x-photo-cd-overfiew-file'], 598 [0, 'string', '=', 'SIMPLE =', 'FITS image data'], 599 [0, 'string', '=', 'This is a BitMap file', 'Lisp Machine bit-array-file'], 600 [0, 'string', '=', '!!', 'Bennet Yee\'s "face" format'], 601 [0, 'beshort', '=', 4112, 'PEX Binary Archive'], 602 [3000, 'string', '=', 'Visio (TM) Drawing', '%s'], 603 [0, 'leshort', '=', 502, 'basic-16 executable'], 604 [0, 'leshort', '=', 503, 'basic-16 executable (TV)'], 605 [0, 'leshort', '=', 510, 'application/x-executable-file'], 606 [0, 'leshort', '=', 511, 'application/x-executable-file'], 607 [0, 'leshort', '=', 512, 'application/x-executable-file'], 608 [0, 'leshort', '=', 522, 'application/x-executable-file'], 609 [0, 'leshort', '=', 514, 'application/x-executable-file'], 610 [0, 'string', '=', '\210OPS', 'Interleaf saved data'], 611 [0, 'string', '=', '<!OPS', 'Interleaf document text'], 612 [4, 'string', '=', 'pgscriptver', 'IslandWrite document'], 613 [13, 'string', '=', 'DrawFile', 'IslandDraw document'], 614 [0, 'leshort&0xFFFC', '=', 38400, 'little endian ispell'], 615 [0, 'beshort&0xFFFC', '=', 38400, 'big endian ispell'], 616 [0, 'belong', '=', 3405691582, 'compiled Java class data,'], 617 [0, 'beshort', '=', 44269, 'Java serialization data'], 618 [0, 'string', '=', 'KarmaRHD', 'Version Karma Data Structure Version'], 619 [0, 'string', '=', 'lect', 'DEC SRC Virtual Paper Lectern file'], 620 [53, 'string', '=', 'yyprevious', 'C program text (from lex)'], 621 [21, 'string', '=', 'generated by flex', 'C program text (from flex)'], 622 [0, 'string', '=', '%{', 'lex description text'], 623 [0, 'short', '=', 32768, 'lif file'], 624 [0, 'lelong', '=', 6553863, 'Linux/i386 impure executable (OMAGIC)'], 625 [0, 'lelong', '=', 6553864, 'Linux/i386 pure executable (NMAGIC)'], 626 [0, 'lelong', '=', 6553867, 'Linux/i386 demand-paged executable (ZMAGIC)'], 627 [0, 'lelong', '=', 6553804, 'Linux/i386 demand-paged executable (QMAGIC)'], 628 [0, 'string', '=', '\007\001\000', 'Linux/i386 object file'], 629 [0, 'string', '=', '\001\003\020\004', 'Linux-8086 impure executable'], 630 [0, 'string', '=', '\001\003 \004', 'Linux-8086 executable'], 631 [0, 'string', '=', '\243\206\001\000', 'Linux-8086 object file'], 632 [0, 'string', '=', '\001\003\020\020', 'Minix-386 impure executable'], 633 [0, 'string', '=', '\001\003 \020', 'Minix-386 executable'], 634 [0, 'string', '=', '*nazgul*', 'Linux compiled message catalog'], 635 [216, 'lelong', '=', 421, 'Linux/i386 core file'], 636 [2, 'string', '=', 'LILO', 'Linux/i386 LILO boot/chain loader'], 637 [0, 'string', '=', '0.9', ''], 638 [0, 'leshort', '=', 1078, 'font/linux-psf'], 639 [4086, 'string', '=', 'SWAP-SPACE', 'Linux/i386 swap file'], 640 [0, 'leshort', '=', 387, 'ECOFF alpha'], 641 [514, 'string', '=', 'HdrS', 'Linux kernel'], 642 [0, 'belong', '=', 3099592590, 'Linux kernel'], 643 [0, 'string', '=', 'Begin3', 'Linux Software Map entry text'], 644 [0, 'string', '=', ';;', 'Lisp/Scheme program text'], 645 [0, 'string', '=', '\012(', 'byte-compiled Emacs-Lisp program data'], 646 [0, 'string', '=', ';ELC\023\000\000\000', 'byte-compiled Emacs-Lisp program data'], 647 [0, 'string', '=', "(SYSTEM::VERSION '", 'CLISP byte-compiled Lisp program text'], 648 [0, 'long', '=', 1886817234, 'CLISP memory image data'], 649 [0, 'long', '=', 3532355184, 'CLISP memory image data, other endian'], 650 [0, 'long', '=', 3725722773, 'GNU-format message catalog data'], 651 [0, 'long', '=', 2500072158, 'GNU-format message catalog data'], 652 [0, 'belong', '=', 3405691582, 'mach-o fat file'], 653 [0, 'belong', '=', 4277009102, 'mach-o'], 654 [11, 'string', '=', 'must be converted with BinHex', 'BinHex binary text'], 655 [0, 'string', '=', 'SIT!', 'StuffIt Archive (data)'], 656 [65, 'string', '=', 'SIT!', 'StuffIt Archive (rsrc + data)'], 657 [0, 'string', '=', 'SITD', 'StuffIt Deluxe (data)'], 658 [65, 'string', '=', 'SITD', 'StuffIt Deluxe (rsrc + data)'], 659 [0, 'string', '=', 'Seg', 'StuffIt Deluxe Segment (data)'], 660 [65, 'string', '=', 'Seg', 'StuffIt Deluxe Segment (rsrc + data)'], 661 [0, 'string', '=', 'APPL', 'Macintosh Application (data)'], 662 [65, 'string', '=', 'APPL', 'Macintosh Application (rsrc + data)'], 663 [0, 'string', '=', 'zsys', 'Macintosh System File (data)'], 664 [65, 'string', '=', 'zsys', 'Macintosh System File(rsrc + data)'], 665 [0, 'string', '=', 'FNDR', 'Macintosh Finder (data)'], 666 [65, 'string', '=', 'FNDR', 'Macintosh Finder(rsrc + data)'], 667 [0, 'string', '=', 'libr', 'Macintosh Library (data)'], 668 [65, 'string', '=', 'libr', 'Macintosh Library(rsrc + data)'], 669 [0, 'string', '=', 'shlb', 'Macintosh Shared Library (data)'], 670 [65, 'string', '=', 'shlb', 'Macintosh Shared Library(rsrc + data)'], 671 [0, 'string', '=', 'cdev', 'Macintosh Control Panel (data)'], 672 [65, 'string', '=', 'cdev', 'Macintosh Control Panel(rsrc + data)'], 673 [0, 'string', '=', 'INIT', 'Macintosh Extension (data)'], 674 [65, 'string', '=', 'INIT', 'Macintosh Extension(rsrc + data)'], 675 [0, 'string', '=', 'FFIL', 'font/ttf'], 676 [65, 'string', '=', 'FFIL', 'font/ttf'], 677 [0, 'string', '=', 'LWFN', 'font/type1'], 678 [65, 'string', '=', 'LWFN', 'font/type1'], 679 [0, 'string', '=', 'PACT', 'Macintosh Compact Pro Archive (data)'], 680 [65, 'string', '=', 'PACT', 'Macintosh Compact Pro Archive(rsrc + data)'], 681 [0, 'string', '=', 'ttro', 'Macintosh TeachText File (data)'], 682 [65, 'string', '=', 'ttro', 'Macintosh TeachText File(rsrc + data)'], 683 [0, 'string', '=', 'TEXT', 'Macintosh TeachText File (data)'], 684 [65, 'string', '=', 'TEXT', 'Macintosh TeachText File(rsrc + data)'], 685 [0, 'string', '=', 'PDF', 'Macintosh PDF File (data)'], 686 [65, 'string', '=', 'PDF', 'Macintosh PDF File(rsrc + data)'], 687 [0, 'string', '=', '# Magic', 'magic text file for file(1) cmd'], 688 [0, 'string', '=', 'Relay-Version:', 'old news text'], 689 [0, 'string', '=', '#! rnews', 'batched news text'], 690 [0, 'string', '=', 'N#! rnews', 'mailed, batched news text'], 691 [0, 'string', '=', 'Forward to', 'mail forwarding text'], 692 [0, 'string', '=', 'Pipe to', 'mail piping text'], 693 [0, 'string', '=', 'Return-Path:', 'message/rfc822'], 694 [0, 'string', '=', 'Path:', 'message/news'], 695 [0, 'string', '=', 'Xref:', 'message/news'], 696 [0, 'string', '=', 'From:', 'message/rfc822'], 697 [0, 'string', '=', 'Article', 'message/news'], 698 [0, 'string', '=', 'BABYL', 'message/x-gnu-rmail'], 699 [0, 'string', '=', 'Received:', 'message/rfc822'], 700 [0, 'string', '=', 'MIME-Version:', 'MIME entity text'], 701 [0, 'string', '=', 'Content-Type: ', ''], 702 [0, 'string', '=', 'Content-Type:', ''], 703 [0, 'long', '=', 31415, 'Mirage Assembler m.out executable'], 704 [0, 'string', '=', '\311\304', 'ID tags data'], 705 [0, 'string', '=', '\001\001\001\001', 'MMDF mailbox'], 706 [4, 'string', '=', 'Research,', 'Digifax-G3-File'], 707 [0, 'short', '=', 256, 'raw G3 data, byte-padded'], 708 [0, 'short', '=', 5120, 'raw G3 data'], 709 [0, 'string', '=', 'RMD1', 'raw modem data'], 710 [0, 'string', '=', 'PVF1\012', 'portable voice format'], 711 [0, 'string', '=', 'PVF2\012', 'portable voice format'], 712 [0, 'beshort', '=', 520, 'mc68k COFF'], 713 [0, 'beshort', '=', 521, 'mc68k executable (shared)'], 714 [0, 'beshort', '=', 522, 'mc68k executable (shared demand paged)'], 715 [0, 'beshort', '=', 554, '68K BCS executable'], 716 [0, 'beshort', '=', 555, '88K BCS executable'], 717 [0, 'string', '=', 'S0', 'Motorola S-Record; binary data in text format'], 718 [0, 'string', '=', '@echo off', 'MS-DOS batch file text'], 719 [128, 'string', '=', 'PE\000\000', 'MS Windows PE'], 720 [0, 'leshort', '=', 332, 'MS Windows COFF Intel 80386 object file'], 721 [0, 'leshort', '=', 358, 'MS Windows COFF MIPS R4000 object file'], 722 [0, 'leshort', '=', 388, 'MS Windows COFF Alpha object file'], 723 [0, 'leshort', '=', 616, 'MS Windows COFF Motorola 68000 object file'], 724 [0, 'leshort', '=', 496, 'MS Windows COFF PowerPC object file'], 725 [0, 'leshort', '=', 656, 'MS Windows COFF PA-RISC object file'], 726 [0, 'string', '=', 'MZ', 'application/x-ms-dos-executable'], 727 [0, 'string', '=', 'LZ', 'MS-DOS executable (built-in)'], 728 [0, 'string', '=', 'regf', 'Windows NT Registry file'], 729 [2080, 'string', '=', 'Microsoft Word 6.0 Document', 'text/vnd.ms-word'], 730 [2080, 'string', '=', 'Documento Microsoft Word 6', 'text/vnd.ms-word'], 731 [2112, 'string', '=', 'MSWordDoc', 'text/vnd.ms-word'], 732 [0, 'belong', '=', 834535424, 'text/vnd.ms-word'], 733 [0, 'string', '=', 'PO^Q`', 'text/vnd.ms-word'], 734 [2080, 'string', '=', 'Microsoft Excel 5.0 Worksheet', 'application/vnd.ms-excel'], 735 [2114, 'string', '=', 'Biff5', 'application/vnd.ms-excel'], 736 [0, 'belong', '=', 6656, 'Lotus 1-2-3'], 737 [0, 'belong', '=', 512, 'Lotus 1-2-3'], 738 [1, 'string', '=', 'WPC', 'text/vnd.wordperfect'], 739 [0, 'beshort', '=', 610, 'Tower/XP rel 2 object'], 740 [0, 'beshort', '=', 615, 'Tower/XP rel 2 object'], 741 [0, 'beshort', '=', 620, 'Tower/XP rel 3 object'], 742 [0, 'beshort', '=', 625, 'Tower/XP rel 3 object'], 743 [0, 'beshort', '=', 630, 'Tower32/600/400 68020 object'], 744 [0, 'beshort', '=', 640, 'Tower32/800 68020'], 745 [0, 'beshort', '=', 645, 'Tower32/800 68010'], 746 [0, 'lelong', '=', 407, 'NetBSD little-endian object file'], 747 [0, 'belong', '=', 407, 'NetBSD big-endian object file'], 748 [0, 'belong&0377777777', '=', 41400413, 'NetBSD/i386 demand paged'], 749 [0, 'belong&0377777777', '=', 41400410, 'NetBSD/i386 pure'], 750 [0, 'belong&0377777777', '=', 41400407, 'NetBSD/i386'], 751 [0, 'belong&0377777777', '=', 41400507, 'NetBSD/i386 core'], 752 [0, 'belong&0377777777', '=', 41600413, 'NetBSD/m68k demand paged'], 753 [0, 'belong&0377777777', '=', 41600410, 'NetBSD/m68k pure'], 754 [0, 'belong&0377777777', '=', 41600407, 'NetBSD/m68k'], 755 [0, 'belong&0377777777', '=', 41600507, 'NetBSD/m68k core'], 756 [0, 'belong&0377777777', '=', 42000413, 'NetBSD/m68k4k demand paged'], 757 [0, 'belong&0377777777', '=', 42000410, 'NetBSD/m68k4k pure'], 758 [0, 'belong&0377777777', '=', 42000407, 'NetBSD/m68k4k'], 759 [0, 'belong&0377777777', '=', 42000507, 'NetBSD/m68k4k core'], 760 [0, 'belong&0377777777', '=', 42200413, 'NetBSD/ns32532 demand paged'], 761 [0, 'belong&0377777777', '=', 42200410, 'NetBSD/ns32532 pure'], 762 [0, 'belong&0377777777', '=', 42200407, 'NetBSD/ns32532'], 763 [0, 'belong&0377777777', '=', 42200507, 'NetBSD/ns32532 core'], 764 [0, 'belong&0377777777', '=', 42400413, 'NetBSD/sparc demand paged'], 765 [0, 'belong&0377777777', '=', 42400410, 'NetBSD/sparc pure'], 766 [0, 'belong&0377777777', '=', 42400407, 'NetBSD/sparc'], 767 [0, 'belong&0377777777', '=', 42400507, 'NetBSD/sparc core'], 768 [0, 'belong&0377777777', '=', 42600413, 'NetBSD/pmax demand paged'], 769 [0, 'belong&0377777777', '=', 42600410, 'NetBSD/pmax pure'], 770 [0, 'belong&0377777777', '=', 42600407, 'NetBSD/pmax'], 771 [0, 'belong&0377777777', '=', 42600507, 'NetBSD/pmax core'], 772 [0, 'belong&0377777777', '=', 43000413, 'NetBSD/vax demand paged'], 773 [0, 'belong&0377777777', '=', 43000410, 'NetBSD/vax pure'], 774 [0, 'belong&0377777777', '=', 43000407, 'NetBSD/vax'], 775 [0, 'belong&0377777777', '=', 43000507, 'NetBSD/vax core'], 776 [0, 'lelong', '=', 459141, 'ECOFF NetBSD/alpha binary'], 777 [0, 'belong&0377777777', '=', 43200507, 'NetBSD/alpha core'], 778 [0, 'belong&0377777777', '=', 43400413, 'NetBSD/mips demand paged'], 779 [0, 'belong&0377777777', '=', 43400410, 'NetBSD/mips pure'], 780 [0, 'belong&0377777777', '=', 43400407, 'NetBSD/mips'], 781 [0, 'belong&0377777777', '=', 43400507, 'NetBSD/mips core'], 782 [0, 'belong&0377777777', '=', 43600413, 'NetBSD/arm32 demand paged'], 783 [0, 'belong&0377777777', '=', 43600410, 'NetBSD/arm32 pure'], 784 [0, 'belong&0377777777', '=', 43600407, 'NetBSD/arm32'], 785 [0, 'belong&0377777777', '=', 43600507, 'NetBSD/arm32 core'], 786 [0, 'string', '=', 'StartFontMetrics', 'font/x-sunos-news'], 787 [0, 'string', '=', 'StartFont', 'font/x-sunos-news'], 788 [0, 'belong', '=', 326773060, 'font/x-sunos-news'], 789 [0, 'belong', '=', 326773063, 'font/x-sunos-news'], 790 [0, 'belong', '=', 326773072, 'font/x-sunos-news'], 791 [0, 'belong', '=', 326773073, 'font/x-sunos-news'], 792 [8, 'belong', '=', 326773573, 'font/x-sunos-news'], 793 [8, 'belong', '=', 326773576, 'font/x-sunos-news'], 794 [0, 'string', '=', 'Octave-1-L', 'Octave binary data (little endian)'], 795 [0, 'string', '=', 'Octave-1-B', 'Octave binary data (big endian)'], 796 [0, 'string', '=', '\177OLF', 'OLF'], 797 [0, 'beshort', '=', 34765, 'OS9/6809 module:'], 798 [0, 'beshort', '=', 19196, 'OS9/68K module:'], 799 [0, 'long', '=', 61374, 'OSF/Rose object'], 800 [0, 'short', '=', 565, 'i386 COFF object'], 801 [0, 'short', '=', 10775, '"compact bitmap" format (Poskanzer)'], 802 [0, 'string', '=', '%PDF-', 'PDF document'], 803 [0, 'lelong', '=', 101555, 'PDP-11 single precision APL workspace'], 804 [0, 'lelong', '=', 101554, 'PDP-11 double precision APL workspace'], 805 [0, 'leshort', '=', 407, 'PDP-11 executable'], 806 [0, 'leshort', '=', 401, 'PDP-11 UNIX/RT ldp'], 807 [0, 'leshort', '=', 405, 'PDP-11 old overlay'], 808 [0, 'leshort', '=', 410, 'PDP-11 pure executable'], 809 [0, 'leshort', '=', 411, 'PDP-11 separate I&D executable'], 810 [0, 'leshort', '=', 437, 'PDP-11 kernel overlay'], 811 [0, 'beshort', '=', 39168, 'PGP key public ring'], 812 [0, 'beshort', '=', 38145, 'PGP key security ring'], 813 [0, 'beshort', '=', 38144, 'PGP key security ring'], 814 [0, 'beshort', '=', 42496, 'PGP encrypted data'], 815 [0, 'string', '=', '-----BEGIN PGP', 'PGP armored data'], 816 [0, 'string', '=', '# PaCkAgE DaTaStReAm', 'pkg Datastream (SVR4)'], 817 [0, 'short', '=', 601, 'mumps avl global'], 818 [0, 'short', '=', 602, 'mumps blt global'], 819 [0, 'string', '=', '%!', 'application/postscript'], 820 [0, 'string', '=', '\004%!', 'application/postscript'], 821 [0, 'belong', '=', 3318797254, 'DOS EPS Binary File'], 822 [0, 'string', '=', '*PPD-Adobe:', 'PPD file'], 823 [0, 'string', '=', '\033%-12345X@PJL', 'HP Printer Job Language data'], 824 [0, 'string', '=', '\033%-12345X@PJL', 'HP Printer Job Language data'], 825 [0, 'string', '=', '\033E\033', 'image/x-pcl-hp'], 826 [0, 'string', '=', '@document(', 'Imagen printer'], 827 [0, 'string', '=', 'Rast', 'RST-format raster font data'], 828 [0, 'belong&0xff00ffff', '=', 1442840576, 'ps database'], 829 [0, 'long', '=', 1351614727, 'Pyramid 90x family executable'], 830 [0, 'long', '=', 1351614728, 'Pyramid 90x family pure executable'], 831 [0, 'long', '=', 1351614731, 'Pyramid 90x family demand paged pure executable'], 832 [0, 'beshort', '=', 60843, ''], 833 [0, 'string', '=', '{\\\\rtf', 'Rich Text Format data,'], 834 [38, 'string', '=', 'Spreadsheet', 'sc spreadsheet file'], 835 [8, 'string', '=', '\001s SCCS', 'archive data'], 836 [0, 'byte', '=', 46, 'Sendmail frozen configuration'], 837 [0, 'short', '=', 10012, 'Sendmail frozen configuration'], 838 [0, 'lelong', '=', 234, 'BALANCE NS32000 .o'], 839 [0, 'lelong', '=', 4330, 'BALANCE NS32000 executable (0 @ 0)'], 840 [0, 'lelong', '=', 8426, 'BALANCE NS32000 executable (invalid @ 0)'], 841 [0, 'lelong', '=', 12522, 'BALANCE NS32000 standalone executable'], 842 [0, 'leshort', '=', 4843, 'SYMMETRY i386 .o'], 843 [0, 'leshort', '=', 8939, 'SYMMETRY i386 executable (0 @ 0)'], 844 [0, 'leshort', '=', 13035, 'SYMMETRY i386 executable (invalid @ 0)'], 845 [0, 'leshort', '=', 17131, 'SYMMETRY i386 standalone executable'], 846 [0, 'string', '=', 'kbd!map', 'kbd map file'], 847 [0, 'belong', '=', 407, 'old SGI 68020 executable'], 848 [0, 'belong', '=', 410, 'old SGI 68020 pure executable'], 849 [0, 'beshort', '=', 34661, 'disk quotas file'], 850 [0, 'beshort', '=', 1286, 'IRIS Showcase file'], 851 [0, 'beshort', '=', 550, 'IRIS Showcase template'], 852 [0, 'belong', '=', 1396917837, 'IRIS Showcase file'], 853 [0, 'belong', '=', 1413695053, 'IRIS Showcase template'], 854 [0, 'belong', '=', 3735927486, 'IRIX Parallel Arena'], 855 [0, 'beshort', '=', 352, 'MIPSEB COFF executable'], 856 [0, 'beshort', '=', 354, 'MIPSEL COFF executable'], 857 [0, 'beshort', '=', 24577, 'MIPSEB-LE COFF executable'], 858 [0, 'beshort', '=', 25089, 'MIPSEL-LE COFF executable'], 859 [0, 'beshort', '=', 355, 'MIPSEB MIPS-II COFF executable'], 860 [0, 'beshort', '=', 358, 'MIPSEL MIPS-II COFF executable'], 861 [0, 'beshort', '=', 25345, 'MIPSEB-LE MIPS-II COFF executable'], 862 [0, 'beshort', '=', 26113, 'MIPSEL-LE MIPS-II COFF executable'], 863 [0, 'beshort', '=', 320, 'MIPSEB MIPS-III COFF executable'], 864 [0, 'beshort', '=', 322, 'MIPSEL MIPS-III COFF executable'], 865 [0, 'beshort', '=', 16385, 'MIPSEB-LE MIPS-III COFF executable'], 866 [0, 'beshort', '=', 16897, 'MIPSEL-LE MIPS-III COFF executable'], 867 [0, 'beshort', '=', 384, 'MIPSEB Ucode'], 868 [0, 'beshort', '=', 386, 'MIPSEL Ucode'], 869 [0, 'belong', '=', 3735924144, 'IRIX core dump'], 870 [0, 'belong', '=', 3735924032, 'IRIX 64-bit core dump'], 871 [0, 'belong', '=', 3133063355, 'IRIX N32 core dump'], 872 [0, 'string', '=', 'CrshDump', 'IRIX vmcore dump of'], 873 [0, 'string', '=', 'SGIAUDIT', 'SGI Audit file'], 874 [0, 'string', '=', 'WNGZWZSC', 'Wingz compiled script'], 875 [0, 'string', '=', 'WNGZWZSS', 'Wingz spreadsheet'], 876 [0, 'string', '=', 'WNGZWZHP', 'Wingz help file'], 877 [0, 'string', '=', '\\#Inventor', 'V IRIS Inventor 1.0 file'], 878 [0, 'string', '=', '\\#Inventor', 'V2 Open Inventor 2.0 file'], 879 [0, 'string', '=', 'glfHeadMagic();', 'GLF_TEXT'], 880 [4, 'belong', '=', 1090584576, 'GLF_BINARY_LSB_FIRST'], 881 [4, 'belong', '=', 321, 'GLF_BINARY_MSB_FIRST'], 882 [0, 'string', '=', '<!DOCTYPE HTML', 'text/html'], 883 [0, 'string', '=', '<!doctype html', 'text/html'], 884 [0, 'string', '=', '<HEAD', 'text/html'], 885 [0, 'string', '=', '<head', 'text/html'], 886 [0, 'string', '=', '<TITLE', 'text/html'], 887 [0, 'string', '=', '<title', 'text/html'], 888 [0, 'string', '=', '<html', 'text/html'], 889 [0, 'string', '=', '<HTML', 'text/html'], 890 [0, 'string', '=', '<?xml', 'application/xml'], 891 [0, 'string', '=', '<!DOCTYPE', 'exported SGML document text'], 892 [0, 'string', '=', '<!doctype', 'exported SGML document text'], 893 [0, 'string', '=', '<!SUBDOC', 'exported SGML subdocument text'], 894 [0, 'string', '=', '<!subdoc', 'exported SGML subdocument text'], 895 [0, 'string', '=', '<!--', 'exported SGML document text'], 896 [0, 'string', '=', 'RTSS', 'NetMon capture file'], 897 [0, 'string', '=', 'TRSNIFF data \032', 'Sniffer capture file'], 898 [0, 'string', '=', 'XCP\000', 'NetXRay capture file'], 899 [0, 'ubelong', '=', 2712847316, 'tcpdump capture file (big-endian)'], 900 [0, 'ulelong', '=', 2712847316, 'tcpdump capture file (little-endian)'], 901 [0, 'string', '=', '<!SQ DTD>', 'Compiled SGML rules file'], 902 [0, 'string', '=', '<!SQ A/E>', 'A/E SGML Document binary'], 903 [0, 'string', '=', '<!SQ STS>', 'A/E SGML binary styles file'], 904 [0, 'short', '=', 49374, 'Compiled PSI (v1) data'], 905 [0, 'short', '=', 49370, 'Compiled PSI (v2) data'], 906 [0, 'short', '=', 125252, 'SoftQuad DESC or font file binary'], 907 [0, 'string', '=', 'SQ BITMAP1', 'SoftQuad Raster Format text'], 908 [0, 'string', '=', 'X SoftQuad', 'troff Context intermediate'], 909 [0, 'belong&077777777', '=', 600413, 'sparc demand paged'], 910 [0, 'belong&077777777', '=', 600410, 'sparc pure'], 911 [0, 'belong&077777777', '=', 600407, 'sparc'], 912 [0, 'belong&077777777', '=', 400413, 'mc68020 demand paged'], 913 [0, 'belong&077777777', '=', 400410, 'mc68020 pure'], 914 [0, 'belong&077777777', '=', 400407, 'mc68020'], 915 [0, 'belong&077777777', '=', 200413, 'mc68010 demand paged'], 916 [0, 'belong&077777777', '=', 200410, 'mc68010 pure'], 917 [0, 'belong&077777777', '=', 200407, 'mc68010'], 918 [0, 'belong', '=', 407, 'old sun-2 executable'], 919 [0, 'belong', '=', 410, 'old sun-2 pure executable'], 920 [0, 'belong', '=', 413, 'old sun-2 demand paged executable'], 921 [0, 'belong', '=', 525398, 'SunOS core file'], 922 [0, 'long', '=', 4197695630, 'SunPC 4.0 Hard Disk'], 923 [0, 'string', '=', '#SUNPC_CONFIG', 'SunPC 4.0 Properties Values'], 924 [0, 'string', '=', 'snoop', 'Snoop capture file'], 925 [36, 'string', '=', 'acsp', 'Kodak Color Management System, ICC Profile'], 926 [0, 'string', '=', '#!teapot\012xdr', 'teapot work sheet (XDR format)'], 927 [0, 'string', '=', '\032\001', 'Compiled terminfo entry'], 928 [0, 'short', '=', 433, 'Curses screen image'], 929 [0, 'short', '=', 434, 'Curses screen image'], 930 [0, 'string', '=', '\367\002', 'TeX DVI file'], 931 [0, 'string', '=', '\367\203', 'font/x-tex'], 932 [0, 'string', '=', '\367Y', 'font/x-tex'], 933 [0, 'string', '=', '\367\312', 'font/x-tex'], 934 [0, 'string', '=', 'This is TeX,', 'TeX transcript text'], 935 [0, 'string', '=', 'This is METAFONT,', 'METAFONT transcript text'], 936 [2, 'string', '=', '\000\021', 'font/x-tex-tfm'], 937 [2, 'string', '=', '\000\022', 'font/x-tex-tfm'], 938 [0, 'string', '=', '\\\\input\\', 'texinfo Texinfo source text'], 939 [0, 'string', '=', 'This is Info file', 'GNU Info text'], 940 [0, 'string', '=', '\\\\input', 'TeX document text'], 941 [0, 'string', '=', '\\\\section', 'LaTeX document text'], 942 [0, 'string', '=', '\\\\setlength', 'LaTeX document text'], 943 [0, 'string', '=', '\\\\documentstyle', 'LaTeX document text'], 944 [0, 'string', '=', '\\\\chapter', 'LaTeX document text'], 945 [0, 'string', '=', '\\\\documentclass', 'LaTeX 2e document text'], 946 [0, 'string', '=', '\\\\relax', 'LaTeX auxiliary file'], 947 [0, 'string', '=', '\\\\contentsline', 'LaTeX table of contents'], 948 [0, 'string', '=', '\\\\indexentry', 'LaTeX raw index file'], 949 [0, 'string', '=', '\\\\begin{theindex}', 'LaTeX sorted index'], 950 [0, 'string', '=', '\\\\glossaryentry', 'LaTeX raw glossary'], 951 [0, 'string', '=', '\\\\begin{theglossary}', 'LaTeX sorted glossary'], 952 [0, 'string', '=', 'This is makeindex', 'Makeindex log file'], 953 [0, 'string', '=', '**TI82**', 'TI-82 Graphing Calculator'], 954 [0, 'string', '=', '**TI83**', 'TI-83 Graphing Calculator'], 955 [0, 'string', '=', '**TI85**', 'TI-85 Graphing Calculator'], 956 [0, 'string', '=', '**TI92**', 'TI-92 Graphing Calculator'], 957 [0, 'string', '=', '**TI80**', 'TI-80 Graphing Calculator File.'], 958 [0, 'string', '=', '**TI81**', 'TI-81 Graphing Calculator File.'], 959 [0, 'string', '=', 'TZif', 'timezone data'], 960 [0, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000', 'old timezone data'], 961 [0, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000', 'old timezone data'], 962 [0, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\000', 'old timezone data'], 963 [0, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000', 'old timezone data'], 964 [0, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\005\000', 'old timezone data'], 965 [0, 'string', '=', '\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\006\000', 'old timezone data'], 966 [0, 'string', '=', '.\\\\"', 'troff or preprocessor input text'], 967 [0, 'string', '=', '\'\\\\"', 'troff or preprocessor input text'], 968 [0, 'string', '=', '\'.\\\\"', 'troff or preprocessor input text'], 969 [0, 'string', '=', '\\\\"', 'troff or preprocessor input text'], 970 [0, 'string', '=', 'x T', 'ditroff text'], 971 [0, 'string', '=', '@\357', 'very old (C/A/T) troff output data'], 972 [0, 'string', '=', 'Interpress/Xerox', 'Xerox InterPress data'], 973 [0, 'short', '=', 263, 'unknown machine executable'], 974 [0, 'short', '=', 264, 'unknown pure executable'], 975 [0, 'short', '=', 265, 'PDP-11 separate I&D'], 976 [0, 'short', '=', 267, 'unknown pure executable'], 977 [0, 'long', '=', 268, 'unknown demand paged pure executable'], 978 [0, 'long', '=', 269, 'unknown demand paged pure executable'], 979 [0, 'long', '=', 270, 'unknown readable demand paged pure executable'], 980 [0, 'string', '=', 'begin uuencoded', 'or xxencoded text'], 981 [0, 'string', '=', 'xbtoa Begin', "btoa'd text"], 982 [0, 'string', '=', '$\012ship', "ship'd binary text"], 983 [0, 'string', '=', 'Decode the following with bdeco', 'bencoded News text'], 984 [11, 'string', '=', 'must be converted with BinHex', 'BinHex binary text'], 985 [0, 'short', '=', 610, 'Perkin-Elmer executable'], 986 [0, 'beshort', '=', 572, 'amd 29k coff noprebar executable'], 987 [0, 'beshort', '=', 1572, 'amd 29k coff prebar executable'], 988 [0, 'beshort', '=', 160007, 'amd 29k coff archive'], 989 [6, 'beshort', '=', 407, 'unicos (cray) executable'], 990 [596, 'string', '=', 'X\337\377\377', 'Ultrix core file'], 991 [0, 'string', '=', 'Joy!peffpwpc', 'header for PowerPC PEF executable'], 992 [0, 'lelong', '=', 101557, 'VAX single precision APL workspace'], 993 [0, 'lelong', '=', 101556, 'VAX double precision APL workspace'], 994 [0, 'lelong', '=', 407, 'VAX executable'], 995 [0, 'lelong', '=', 410, 'VAX pure executable'], 996 [0, 'lelong', '=', 413, 'VAX demand paged pure executable'], 997 [0, 'leshort', '=', 570, 'VAX COFF executable'], 998 [0, 'leshort', '=', 575, 'VAX COFF pure executable'], 999 [0, 'string', '=', 'LBLSIZE=', 'VICAR image data'], 1000 [43, 'string', '=', 'SFDU_LABEL', 'VICAR label file'], 1001 [0, 'short', '=', 21845, 'VISX image file'], 1002 [0, 'string', '=', '\260\0000\000', 'VMS VAX executable'], 1003 [0, 'belong', '=', 50331648, 'VMS Alpha executable'], 1004 [1, 'string', '=', 'WPC', '(Corel/WP)'], 1005 [0, 'string', '=', 'core', 'core file (Xenix)'], 1006 [0, 'byte', '=', 128, '8086 relocatable (Microsoft)'], 1007 [0, 'leshort', '=', 65381, 'x.out'], 1008 [0, 'leshort', '=', 518, 'Microsoft a.out'], 1009 [0, 'leshort', '=', 320, 'old Microsoft 8086 x.out'], 1010 [0, 'lelong', '=', 518, 'b.out'], 1011 [0, 'leshort', '=', 1408, 'XENIX 8086 relocatable or 80286 small model'], 1012 [0, 'long', '=', 59399, 'object file (z8000 a.out)'], 1013 [0, 'long', '=', 59400, 'pure object file (z8000 a.out)'], 1014 [0, 'long', '=', 59401, 'separate object file (z8000 a.out)'], 1015 [0, 'long', '=', 59397, 'overlay object file (z8000 a.out)'], 1016 [0, 'string', '=', 'ZyXEL\002', 'ZyXEL voice data'], 1017] 1018 1019magic_tests = [] 1020 1021for record in magic_database: 1022 magic_tests.append(MagicTest(record[0], record[1], record[2], record[3], 1023 record[4])) 1024 1025 1026def guess_type(filename): 1027 """ 1028 Guess the mimetype of a file based on its filename. 1029 1030 @param filename: File name. 1031 @return: Mimetype string or description, when appropriate mime not 1032 available. 1033 """ 1034 if not os.path.isfile(filename): 1035 logging.debug('%s is not a file', filename) 1036 return None 1037 1038 try: 1039 data = open(filename, 'r').read(8192) 1040 except Exception as e: 1041 logging.error(str(e)) 1042 return None 1043 1044 for test in magic_tests: 1045 type = test.compare(data) 1046 if type: 1047 return type 1048 1049 # No matching magic number in the database. is it binary or text? 1050 for c in data: 1051 if ord(c) > 128: 1052 # Non ASCII (binary) data 1053 return 'Data' 1054 1055 # ASCII, do some text tests 1056 if string.find('The', data, 0, 8192) > -1: 1057 return 'English text' 1058 if string.find('def', data, 0, 8192) > -1: 1059 return 'Python Source' 1060 return 'ASCII text' 1061 1062 1063if __name__ == '__main__': 1064 parser = optparse.OptionParser("usage: %prog [options] [filenames]") 1065 options, args = parser.parse_args() 1066 logging_manager.configure_logging(MagicLoggingConfig(), verbose=True) 1067 1068 if not args: 1069 parser.print_help() 1070 sys.exit(1) 1071 1072 for arg in args: 1073 msg = None 1074 if os.path.isfile(arg): 1075 msg = guess_type(arg) 1076 if msg: 1077 logging.info('%s: %s', arg, msg) 1078 else: 1079 logging.info('%s: unknown', arg) 1080