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