home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / FILE / FILTYP10.ZIP / FILETYPE.DOC next >
Encoding:
Text File  |  1991-07-31  |  6.6 KB  |  145 lines

  1.  
  2.                          F I L E T Y P E  1 . 0
  3.                          ======================
  4.  
  5.                Free Software by TapirSoft Gisbert W.Selke
  6.                                July 1991
  7.  
  8. This is a utility similar to the Un*x programme named file It takes
  9. the name of a file of unknown purpose and tries to guess what kind of a
  10. file it is -- a ZIP archive, an LZH archive, an executable, an MS Word
  11. document, a QuattroPro spreadsheet, a Bitstream font, or whatnot. Often,
  12. the purpose of a file can be gleaned from its extension; but sometimes
  13. (e.g., after transmission by E-mail), this extension is lost, and
  14. sometimes it just isn't meaningful. (After all, there are only finitely
  15. many permissible file extensions, but probably infinitely many purposes
  16. of files.)
  17.  
  18. FileType does its work by looking at sepcified bytes in the specified
  19. file; it tries to match these against a number of known file signatures.
  20. These signatures are stored in a plain ASCII text file; this signature
  21. file can be extended at will and as need dictates.
  22.  
  23. Naturally, these guesses are not always correct.
  24.  
  25. The simplest way to use FileType is
  26.  
  27.          filetype  <filename>
  28.  
  29. where <filename> is replaced by the name of the file to be examined.
  30. (No wildcards allowed.) Output consists of a header plus a single line.
  31.  
  32. E.g., if you type
  33.  
  34.          filetype filetype.exe
  35.  
  36. you'll get this answer:
  37.  
  38.          filetype.exe: executable (EXE)
  39.  
  40. In order to be able to work, FileType must have access to a file
  41. containing the magic signatures; ordinarily, this file is called
  42. MAGIC.FT and is located in the current directory or in the directory
  43. where FILETYPE.EXE itself is stored. (The latter method works only
  44. under MS-DOS 3.x or later.) You can specify a different magic file, or
  45. an explicit path, with the /f switch:
  46.  
  47.          filetype /fc:\stuff\mymagic.typ foo.bar
  48.  
  49. (Notice no blanks between /f and the file name!).
  50.  
  51. There's another command line switch, /q, which suppresses output of the
  52. header, by the way; and just typing 'filetype' without any arguments
  53. displays usage hints.
  54.  
  55. One thing remains to be told: how to extend the magic file? Just take an
  56. editor that stores plain ASCII files (no extraneous word processor
  57. information!) and add, modify, or delete lines at your leisure.
  58. These are the rules: (Advanced topics are marked with an asterisk.)
  59.  
  60.   - Each line consists of a file recognizer pattern, then at least one
  61.     blank, then a name for the file type thusly identified.
  62.   - The recognizer sequence consists of a file offset (optional), a bit
  63.     mask (optional), and a matching sequence (required). These items, if
  64.     present, must be separated by at least one blank each.
  65.   * The file offset starts with @, then an optional -, followed by
  66.     a seqence of hex (!) digits which represent an offset into the file
  67.     at which the matching should occur. (No blanks within the file
  68.     offset sequence!) Start of file is at 0(!). A negative offset
  69.     matches from the end of the file, with the last byte in the file
  70.     pointed to by -1. -- Default for offset is 0.
  71.   * The bit mask starts with & and is followed by a sequence as
  72.     specified for matching sequences (cf. below). This bit mask will be
  73.     ANDed bytewise to the bytes found in the file before matching takes
  74.     place. Thus, masking with DF would make matching of 7-bit ASCII
  75.     characters case-independent. (However, note the use of double quotes
  76.     below.) If the bit mask is shorter than the matching sequence, it is
  77.     extended with FF (functionally equivalent to no masking at all.) --
  78.     Default for the bit mask is all FFs.
  79.   - The matching sequence can be any mixture of pairs of hex digits and
  80.     ASCII strings enclosed in single (') or double (") quotes.
  81.   - Characters in single quotes require an exact match, characters in
  82.     double quotes are matched case-independently. Characters in
  83.     double quotes must be upper case themselves in order to work at
  84.     all. (Cf. the note on case-conversion below.)
  85.   - Both subtypes may contain a question mark to stand for any
  86.     character. (And I mean 'character', *not* hex digit!)
  87.   - ASCII strings may contain escaped sequences: \' and \" for
  88.     embedded quotes, \b (backspace), \t (tab), \n (newline), \v
  89.     (vertical tab), \f (form feed), \r (carriage return), \? (question
  90.     mark), \\ (backslash).
  91.   - If a starting sequence in this file is identical to the beginning of
  92.     another one, the longer sequence should come first.
  93.   - Comment lines may start with semicolon or hash mark.
  94.   * For case-independent matchings, FileType knows about the upper-case
  95.     equivalents of standard 7-bit ASCII characters. If you also use
  96.     additional (8-bit) national characters, you can include a pair of
  97.     lines starting with v and ^, respectively. These lines must not
  98.     contain any blanks after the line marker and must match character by
  99.     character. The 'v' line contains lower-case characters, the '^' line
  100.     the corresponding upper-case characters. You need specify only as
  101.     many characters as needed. These lines must occur in Magic.FT before
  102.     the first recognizer line in which they are needed. -- Note that
  103.     two or more pairs of translator lines may be specified, but only the
  104.     last one used will be in effect.
  105.   - The first line of the file is taboo.
  106.  
  107. Note that a file offset will rarely have to be used, since most files
  108. can be told from their first few bytes (if at all). You may consider
  109. offsets and masking as advanced topics which are necessary only in very
  110. special circumstances.
  111.  
  112. That's it. Enjoy. And if you feel I have omitted a really important sort
  113. of files from MAGIC.FT (as distributed) and you know its magic
  114. signature, why not send it to me? I can be reached at
  115.  
  116. TapirSoft
  117. Gisbert W.Selke
  118. Ermekeilstrasse 28
  119. D-5300 Bonn 1
  120. Germany
  121. E-Mail: <s00100@dbnrhrz1.bitnet>
  122.  
  123.  
  124.  
  125. Oh, the legal stuff:
  126.  
  127. FileType contains no material copyrighted by anyone else. I retain the
  128. copyright on FileType; however, there are no restrictions on using and
  129. copying the package, as long as no money is asked for and all files are
  130. distributed unaltered and together. (That is: FILETYPE.PAS,
  131. FILETYPE.EXE, MAGIC.FT, FILETYPE.DOC, suitably archived by your
  132. favourite archiver.) The usual standard disclaimers apply: I cannot be
  133. held responsible for this programme's doing anything at all, or nothing
  134. at all, or not doing what you'd like it to do. (Which, on the other
  135. hand, isn't meant to say that I'd ignore detailed bug reports.)
  136.  
  137.  
  138. Registered trademarks etc. used in this file:
  139.  
  140. Bitstream : Bitstream Inc.
  141. MS DOS, MicroSoft Word: Microsoft Corporation
  142. QuattroPro : Borland International
  143. ZIP : PKWare, Inc.
  144.  
  145.