magic(2)              MPE/iX Shell and Utilities              magic(2)
  ______________________________________________________________________

  NAME
       magic -- format of the /etc/magic file

  DESCRIPTION
       The file command uses /etc/magic in its attempt to identify the
       type of a binary file.  Essentially, /etc/magic contains tem-
       plates showing what different types of files look like.

       The magic file contains lines describing magic numbers which
       identify particular types of files.  Lines beginning with a >
       character represent continuation lines to the main entry.  If
       file finds a match on the main entry line, these additional pat-
       terns are checked and additional output may be generated for
       matching lines, separated by a single blank.  Each line consists
       of four fields, separated by one or more tabs.

       (a)  The first field is a byte offset in the file.

       (b)  The next field is a type:  byte, short, long, or string.
            byte, short, and long can be followed by an optional mask
            which is bitwise ANDed to the value prior to comparison, for
            example, byte &0x80 looks at the high bit.

       (c)  The next field is a value, preceded by an optional operator.
            Operators only apply to non-string types: byte, short, and
            long. The default operator is = (exact match). The other
            operators are:

               =          equal
               !          not equal
               >          greater than
               <          less than
               &          all bits in pattern must match
               ^          any bits in pattern may match
               x or ?     any value matches (must be the only
                          character in the field) (? is an extension
                          to traditional implementations of magic.)

            string values to be matched may contain any valid ANSI C
            backslash sequence. Thus, to match a single backslash, \\
            must be entered in the magic file.

            Note: Due to its format, the magic file must use a \t to
            match a tab character.

       (d)  The rest of the line is a string to be printed if the par-
            ticular file matches the template.  The fourth field may
            contain a printf()-type format indicator to output the magic
            number (See printf(1) for more details on format indica-
            tors).

                                                                       1

  magic(2)              MPE/iX Shell and Utilities              magic(2)
  ______________________________________________________________________

  EXAMPLES
       Here are some sample entries:

          0  short    0x5AD4  DOS executable
          0  short    0xFDF0  DOS library
          0  string   AH      Halo bitmapped font file
          0  short    0x601A  Atari ST contiguous executable
          >14         long    >0   - not stripped
          0  string   \037\036     packed file
          0  string   \037\235     compressed file
          >2 byte&0x1F        ?    - with %d bits

  SEE ALSO
       file(1), environ(3)

                                                                       2