xref: /netbsd-src/external/bsd/file/dist/doc/magic.5 (revision 1d4cb158d56645d9cc1f770f88d9b6be957f357c)
1.\"	$NetBSD: magic.5,v 1.24 2022/09/24 20:21:45 christos Exp $
2.\"
3.\" $File: magic.man,v 1.100 2022/09/10 13:19:26 christos Exp $
4.Dd September 10, 2022
5.Dt MAGIC 5
6.Os
7.\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
8.Sh NAME
9.Nm magic
10.Nd file command's magic pattern file
11.Sh DESCRIPTION
12This manual page documents the format of magic files as
13used by the
14.Xr file 1
15command, version 5.43.
16The
17.Xr file 1
18command identifies the type of a file using,
19among other tests,
20a test for whether the file contains certain
21.Dq "magic patterns" .
22The database of these
23.Dq "magic patterns"
24is usually located in a binary file in
25.Pa /usr/share/misc/magic.mgc
26or a directory of source text magic pattern fragment files in
27.Pa /usr/share/misc/magic .
28The database specifies what patterns are to be tested for, what message or
29MIME type to print if a particular pattern is found,
30and additional information to extract from the file.
31.Pp
32The format of the source fragment files that are used to build this database
33is as follows:
34Each line of a fragment file specifies a test to be performed.
35A test compares the data starting at a particular offset
36in the file with a byte value, a string or a numeric value.
37If the test succeeds, a message is printed.
38The line consists of the following fields:
39.Bl -tag -width ".Dv message"
40.It Dv offset
41A number specifying the offset (in bytes) into the file of the data
42which is to be tested.
43This offset can be a negative number if it is:
44.Bl -bullet  -compact
45.It
46The first direct offset of the magic entry (at continuation level 0),
47in which case it is interpreted an offset from end end of the file
48going backwards.
49This works only when a file descriptor to the file is available and it
50is a regular file.
51.It
52A continuation offset relative to the end of the last up-level field
53.Dv ( \*[Am] ) .
54.El
55.It Dv type
56The type of the data to be tested.
57The possible values are:
58.Bl -tag -width ".Dv lestring16"
59.It Dv byte
60A one-byte value.
61.It Dv short
62A two-byte value in this machine's native byte order.
63.It Dv long
64A four-byte value in this machine's native byte order.
65.It Dv quad
66An eight-byte value in this machine's native byte order.
67.It Dv float
68A 32-bit single precision IEEE floating point number in this machine's native byte order.
69.It Dv double
70A 64-bit double precision IEEE floating point number in this machine's native byte order.
71.It Dv string
72A string of bytes.
73The string type specification can be optionally followed
74by /[WwcCtbTf]*.
75The
76.Dq W
77flag compacts whitespace in the target, which must
78contain at least one whitespace character.
79If the magic has
80.Dv n
81consecutive blanks, the target needs at least
82.Dv n
83consecutive blanks to match.
84The
85.Dq w
86flag treats every blank in the magic as an optional blank.
87The
88.Dq f
89flags requires that the matched string is a full word, not a partial word match.
90The
91.Dq c
92flag specifies case insensitive matching: lower case
93characters in the magic match both lower and upper case characters in the
94target, whereas upper case characters in the magic only match upper case
95characters in the target.
96The
97.Dq C
98flag specifies case insensitive matching: upper case
99characters in the magic match both lower and upper case characters in the
100target, whereas lower case characters in the magic only match upper case
101characters in the target.
102To do a complete case insensitive match, specify both
103.Dq c
104and
105.Dq C .
106The
107.Dq t
108flag forces the test to be done for text files, while the
109.Dq b
110flag forces the test to be done for binary files.
111The
112.Dq T
113flag causes the string to be trimmed, i.e. leading and trailing whitespace
114is deleted before the string is printed.
115.It Dv pstring
116A Pascal-style string where the first byte/short/int is interpreted as the
117unsigned length.
118The length defaults to byte and can be specified as a modifier.
119The following modifiers are supported:
120.Bl -tag -compact -width B
121.It B
122A byte length (default).
123.It H
124A 2 byte big endian length.
125.It h
126A 2 byte little endian length.
127.It L
128A 4 byte big endian length.
129.It l
130A 4 byte little endian length.
131.It J
132The length includes itself in its count.
133.El
134The string is not NUL terminated.
135.Dq J
136is used rather than the more
137valuable
138.Dq I
139because this type of length is a feature of the JPEG
140format.
141.It Dv date
142A four-byte value interpreted as a UNIX date.
143.It Dv qdate
144An eight-byte value interpreted as a UNIX date.
145.It Dv ldate
146A four-byte value interpreted as a UNIX-style date, but interpreted as
147local time rather than UTC.
148.It Dv qldate
149An eight-byte value interpreted as a UNIX-style date, but interpreted as
150local time rather than UTC.
151.It Dv qwdate
152An eight-byte value interpreted as a Windows-style date.
153.It Dv beid3
154A 32-bit ID3 length in big-endian byte order.
155.It Dv beshort
156A two-byte value in big-endian byte order.
157.It Dv belong
158A four-byte value in big-endian byte order.
159.It Dv bequad
160An eight-byte value in big-endian byte order.
161.It Dv befloat
162A 32-bit single precision IEEE floating point number in big-endian byte order.
163.It Dv bedouble
164A 64-bit double precision IEEE floating point number in big-endian byte order.
165.It Dv bedate
166A four-byte value in big-endian byte order,
167interpreted as a Unix date.
168.It Dv beqdate
169An eight-byte value in big-endian byte order,
170interpreted as a Unix date.
171.It Dv beldate
172A four-byte value in big-endian byte order,
173interpreted as a UNIX-style date, but interpreted as local time rather
174than UTC.
175.It Dv beqldate
176An eight-byte value in big-endian byte order,
177interpreted as a UNIX-style date, but interpreted as local time rather
178than UTC.
179.It Dv beqwdate
180An eight-byte value in big-endian byte order,
181interpreted as a Windows-style date.
182.It Dv bestring16
183A two-byte unicode (UCS16) string in big-endian byte order.
184.It Dv leid3
185A 32-bit ID3 length in little-endian byte order.
186.It Dv leshort
187A two-byte value in little-endian byte order.
188.It Dv lelong
189A four-byte value in little-endian byte order.
190.It Dv lequad
191An eight-byte value in little-endian byte order.
192.It Dv lefloat
193A 32-bit single precision IEEE floating point number in little-endian byte order.
194.It Dv ledouble
195A 64-bit double precision IEEE floating point number in little-endian byte order.
196.It Dv ledate
197A four-byte value in little-endian byte order,
198interpreted as a UNIX date.
199.It Dv leqdate
200An eight-byte value in little-endian byte order,
201interpreted as a UNIX date.
202.It Dv leldate
203A four-byte value in little-endian byte order,
204interpreted as a UNIX-style date, but interpreted as local time rather
205than UTC.
206.It Dv leqldate
207An eight-byte value in little-endian byte order,
208interpreted as a UNIX-style date, but interpreted as local time rather
209than UTC.
210.It Dv leqwdate
211An eight-byte value in little-endian byte order,
212interpreted as a Windows-style date.
213.It Dv lestring16
214A two-byte unicode (UCS16) string in little-endian byte order.
215.It Dv melong
216A four-byte value in middle-endian (PDP-11) byte order.
217.It Dv medate
218A four-byte value in middle-endian (PDP-11) byte order,
219interpreted as a UNIX date.
220.It Dv meldate
221A four-byte value in middle-endian (PDP-11) byte order,
222interpreted as a UNIX-style date, but interpreted as local time rather
223than UTC.
224.It Dv indirect
225Starting at the given offset, consult the magic database again.
226The offset of the
227.Dv indirect
228magic is by default absolute in the file, but one can specify
229.Dv /r
230to indicate that the offset is relative from the beginning of the entry.
231.It Dv name
232Define a
233.Dq named
234magic instance that can be called from another
235.Dv use
236magic entry, like a subroutine call.
237Named instance direct magic offsets are relative to the offset of the
238previous matched entry, but indirect offsets are relative to the beginning
239of the file as usual.
240Named magic entries always match.
241.It Dv use
242Recursively call the named magic starting from the current offset.
243If the name of the referenced begins with a
244.Dv ^
245then the endianness of the magic is switched; if the magic mentioned
246.Dv leshort
247for example,
248it is treated as
249.Dv beshort
250and vice versa.
251This is useful to avoid duplicating the rules for different endianness.
252.It Dv regex
253A regular expression match in extended POSIX regular expression syntax
254(like egrep).
255Regular expressions can take exponential time to process, and their
256performance is hard to predict, so their use is discouraged.
257When used in production environments, their performance
258should be carefully checked.
259The size of the string to search should also be limited by specifying
260.Dv /<length> ,
261to avoid performance issues scanning long files.
262The type specification can also be optionally followed by
263.Dv /[c][s][l] .
264The
265.Dq c
266flag makes the match case insensitive, while the
267.Dq s
268flag update the offset to the start offset of the match, rather than the end.
269The
270.Dq l
271modifier, changes the limit of length to mean number of lines instead of a
272byte count.
273Lines are delimited by the platforms native line delimiter.
274When a line count is specified, an implicit byte count also computed assuming
275each line is 80 characters long.
276If neither a byte or line count is specified, the search is limited automatically
277to 8KiB.
278.Dv ^
279and
280.Dv $
281match the beginning and end of individual lines, respectively,
282not beginning and end of file.
283.It Dv search
284A literal string search starting at the given offset.
285The same modifier flags can be used as for string patterns.
286The search expression must contain the range in the form
287.Dv /number,
288that is the number of positions at which the match will be
289attempted, starting from the start offset.
290This is suitable for
291searching larger binary expressions with variable offsets, using
292.Dv \e
293escapes for special characters.
294The order of modifier and number is not relevant.
295.It Dv default
296This is intended to be used with the test
297.Em x
298(which is always true) and it has no type.
299It matches when no other test at that continuation level has matched before.
300Clearing that matched tests for a continuation level, can be done using the
301.Dv clear
302test.
303.It Dv clear
304This test is always true and clears the match flag for that continuation level.
305It is intended to be used with the
306.Dv default
307test.
308.It Dv der
309Parse the file as a DER Certificate file.
310The test field is used as a der type that needs to be matched.
311The DER types are:
312.Dv eoc ,
313.Dv bool ,
314.Dv int ,
315.Dv bit_str ,
316.Dv octet_str ,
317.Dv null ,
318.Dv obj_id ,
319.Dv obj_desc ,
320.Dv ext ,
321.Dv real ,
322.Dv enum ,
323.Dv embed ,
324.Dv utf8_str ,
325.Dv rel_oid ,
326.Dv time ,
327.Dv res2 ,
328.Dv seq ,
329.Dv set ,
330.Dv num_str ,
331.Dv prt_str ,
332.Dv t61_str ,
333.Dv vid_str ,
334.Dv ia5_str ,
335.Dv utc_time ,
336.Dv gen_time ,
337.Dv gr_str ,
338.Dv vis_str ,
339.Dv gen_str ,
340.Dv univ_str ,
341.Dv char_str ,
342.Dv bmp_str ,
343.Dv date ,
344.Dv tod ,
345.Dv datetime ,
346.Dv duration ,
347.Dv oid-iri ,
348.Dv rel-oid-iri .
349These types can be followed by an optional numeric size, which indicates
350the field width in bytes.
351.It Dv guid
352A Globally Unique Identifier, parsed and printed as
353XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
354It's format is a string.
355.It Dv offset
356This is a quad value indicating the current offset of the file.
357It can be used to determine the size of the file or the magic buffer.
358For example the magic entries:
359.Bd -literal -offset indent
360-0	offset	x	this file is %lld bytes
361-0	offset	<=100	must be more than 100 \e
362    bytes and is only %lld
363.Ed
364.It Dv octal
365A string representing an octal number.
366.El
367.El
368.Pp
369For compatibility with the Single
370.Ux
371Standard, the type specifiers
372.Dv dC
373and
374.Dv d1
375are equivalent to
376.Dv byte ,
377the type specifiers
378.Dv uC
379and
380.Dv u1
381are equivalent to
382.Dv ubyte ,
383the type specifiers
384.Dv dS
385and
386.Dv d2
387are equivalent to
388.Dv short ,
389the type specifiers
390.Dv uS
391and
392.Dv u2
393are equivalent to
394.Dv ushort ,
395the type specifiers
396.Dv dI ,
397.Dv dL ,
398and
399.Dv d4
400are equivalent to
401.Dv long ,
402the type specifiers
403.Dv uI ,
404.Dv uL ,
405and
406.Dv u4
407are equivalent to
408.Dv ulong ,
409the type specifier
410.Dv d8
411is equivalent to
412.Dv quad ,
413the type specifier
414.Dv u8
415is equivalent to
416.Dv uquad ,
417and the type specifier
418.Dv s
419is equivalent to
420.Dv string .
421In addition, the type specifier
422.Dv dQ
423is equivalent to
424.Dv quad
425and the type specifier
426.Dv uQ
427is equivalent to
428.Dv uquad .
429.Pp
430Each top-level magic pattern (see below for an explanation of levels)
431is classified as text or binary according to the types used.
432Types
433.Dq regex
434and
435.Dq search
436are classified as text tests, unless non-printable characters are used
437in the pattern.
438All other tests are classified as binary.
439A top-level
440pattern is considered to be a test text when all its patterns are text
441patterns; otherwise, it is considered to be a binary pattern.
442When
443matching a file, binary patterns are tried first; if no match is
444found, and the file looks like text, then its encoding is determined
445and the text patterns are tried.
446.Pp
447The numeric types may optionally be followed by
448.Dv \*[Am]
449and a numeric value,
450to specify that the value is to be AND'ed with the
451numeric value before any comparisons are done.
452Prepending a
453.Dv u
454to the type indicates that ordered comparisons should be unsigned.
455.It Dv test
456The value to be compared with the value from the file.
457If the type is
458numeric, this value
459is specified in C form; if it is a string, it is specified as a C string
460with the usual escapes permitted (e.g. \en for new-line).
461.Pp
462Numeric values
463may be preceded by a character indicating the operation to be performed.
464It may be
465.Dv = ,
466to specify that the value from the file must equal the specified value,
467.Dv \*[Lt] ,
468to specify that the value from the file must be less than the specified
469value,
470.Dv \*[Gt] ,
471to specify that the value from the file must be greater than the specified
472value,
473.Dv \*[Am] ,
474to specify that the value from the file must have set all of the bits
475that are set in the specified value,
476.Dv ^ ,
477to specify that the value from the file must have clear any of the bits
478that are set in the specified value, or
479.Dv ~ ,
480the value specified after is negated before tested.
481.Dv x ,
482to specify that any value will match.
483If the character is omitted, it is assumed to be
484.Dv = .
485Operators
486.Dv \*[Am] ,
487.Dv ^ ,
488and
489.Dv ~
490don't work with floats and doubles.
491The operator
492.Dv !\&
493specifies that the line matches if the test does
494.Em not
495succeed.
496.Pp
497Numeric values are specified in C form; e.g.
498.Dv 13
499is decimal,
500.Dv 013
501is octal, and
502.Dv 0x13
503is hexadecimal.
504.Pp
505Numeric operations are not performed on date types, instead the numeric
506value is interpreted as an offset.
507.Pp
508For string values, the string from the
509file must match the specified string.
510The operators
511.Dv = ,
512.Dv \*[Lt]
513and
514.Dv \*[Gt]
515(but not
516.Dv \*[Am] )
517can be applied to strings.
518The length used for matching is that of the string argument
519in the magic file.
520This means that a line can match any non-empty string (usually used to
521then print the string), with
522.Em \*[Gt]\e0
523(because all non-empty strings are greater than the empty string).
524.Pp
525Dates are treated as numerical values in the respective internal
526representation.
527.Pp
528The special test
529.Em x
530always evaluates to true.
531.It Dv message
532The message to be printed if the comparison succeeds.
533If the string contains a
534.Xr printf 3
535format specification, the value from the file (with any specified masking
536performed) is printed using the message as the format string.
537If the string begins with
538.Dq \eb ,
539the message printed is the remainder of the string with no whitespace
540added before it: multiple matches are normally separated by a single
541space.
542.El
543.Pp
544An APPLE 4+4 character APPLE creator and type can be specified as:
545.Bd -literal -offset indent
546!:apple	CREATYPE
547.Ed
548.Pp
549A MIME type is given on a separate line, which must be the next
550non-blank or comment line after the magic line that identifies the
551file type, and has the following format:
552.Bd -literal -offset indent
553!:mime	MIMETYPE
554.Ed
555.Pp
556i.e. the literal string
557.Dq !:mime
558followed by the MIME type.
559.Pp
560An optional strength can be supplied on a separate line which refers to
561the current magic description using the following format:
562.Bd -literal -offset indent
563!:strength OP VALUE
564.Ed
565.Pp
566The operand
567.Dv OP
568can be:
569.Dv + ,
570.Dv - ,
571.Dv * ,
572or
573.Dv /
574and
575.Dv VALUE
576is a constant between 0 and 255.
577This constant is applied using the specified operand
578to the currently computed default magic strength.
579.Pp
580Some file formats contain additional information which is to be printed
581along with the file type or need additional tests to determine the true
582file type.
583These additional tests are introduced by one or more
584.Em \*[Gt]
585characters preceding the offset.
586The number of
587.Em \*[Gt]
588on the line indicates the level of the test; a line with no
589.Em \*[Gt]
590at the beginning is considered to be at level 0.
591Tests are arranged in a tree-like hierarchy:
592if the test on a line at level
593.Em n
594succeeds, all following tests at level
595.Em n+1
596are performed, and the messages printed if the tests succeed, until a line
597with level
598.Em n
599(or less) appears.
600For more complex files, one can use empty messages to get just the
601"if/then" effect, in the following way:
602.Bd -literal -offset indent
6030      string   MZ
604\*[Gt]0x18  leshort  \*[Lt]0x40   MS-DOS executable
605\*[Gt]0x18  leshort  \*[Gt]0x3f   extended PC executable (e.g., MS Windows)
606.Ed
607.Pp
608Offsets do not need to be constant, but can also be read from the file
609being examined.
610If the first character following the last
611.Em \*[Gt]
612is a
613.Em \&(
614then the string after the parenthesis is interpreted as an indirect offset.
615That means that the number after the parenthesis is used as an offset in
616the file.
617The value at that offset is read, and is used again as an offset
618in the file.
619Indirect offsets are of the form:
620.Em (( x [[.,][bBcCeEfFgGhHiIlmsSqQ]][+\-][ y ]) .
621The value of
622.Em x
623is used as an offset in the file.
624A byte, id3 length, short or long is read at that offset depending on the
625.Em [bBcCeEfFgGhHiIlmsSqQ]
626type specifier.
627The value is treated as signed if
628.Dq ,
629is specified or unsigned if
630.Dq .
631is specified.
632The capitalized types interpret the number as a big endian
633value, whereas the small letter versions interpret the number as a little
634endian value;
635the
636.Em m
637type interprets the number as a middle endian (PDP-11) value.
638To that number the value of
639.Em y
640is added and the result is used as an offset in the file.
641The default type if one is not specified is long.
642The following types are recognized:
643.Bl -column -offset indent "Type" "Half/Short" "Little" "Size"
644.It Sy Type	Sy Mnemonic	Sy Endian	Sy Size
645.It bcBc	Byte/Char	N/A	1
646.It efg	Double	Little	8
647.It EFG	Double	Big	8
648.It hs	Half/Short	Little	2
649.It HS	Half/Short	Big	2
650.It i	ID3	Little	4
651.It I	ID3	Big	4
652.It m	Middle	Middle	4
653.It o	Octal	Textual	Variable
654.It q	Quad	Little	8
655.It Q	Quad	Big	8
656.El
657.Pp
658That way variable length structures can be examined:
659.Bd -literal -offset indent
660# MS Windows executables are also valid MS-DOS executables
6610           string  MZ
662\*[Gt]0x18       leshort \*[Lt]0x40   MZ executable (MS-DOS)
663# skip the whole block below if it is not an extended executable
664\*[Gt]0x18       leshort \*[Gt]0x3f
665\*[Gt]\*[Gt](0x3c.l)  string  PE\e0\e0  PE executable (MS-Windows)
666\*[Gt]\*[Gt](0x3c.l)  string  LX\e0\e0  LX executable (OS/2)
667.Ed
668.Pp
669This strategy of examining has a drawback: you must make sure that you
670eventually print something, or users may get empty output (such as when
671there is neither PE\e0\e0 nor LE\e0\e0 in the above example).
672.Pp
673If this indirect offset cannot be used directly, simple calculations are
674possible: appending
675.Em [+-*/%\*[Am]|^]number
676inside parentheses allows one to modify
677the value read from the file before it is used as an offset:
678.Bd -literal -offset indent
679# MS Windows executables are also valid MS-DOS executables
6800           string  MZ
681# sometimes, the value at 0x18 is less that 0x40 but there's still an
682# extended executable, simply appended to the file
683\*[Gt]0x18       leshort \*[Lt]0x40
684\*[Gt]\*[Gt](4.s*512) leshort 0x014c  COFF executable (MS-DOS, DJGPP)
685\*[Gt]\*[Gt](4.s*512) leshort !0x014c MZ executable (MS-DOS)
686.Ed
687.Pp
688Sometimes you do not know the exact offset as this depends on the length or
689position (when indirection was used before) of preceding fields.
690You can specify an offset relative to the end of the last up-level
691field using
692.Sq \*[Am]
693as a prefix to the offset:
694.Bd -literal -offset indent
6950           string  MZ
696\*[Gt]0x18       leshort \*[Gt]0x3f
697\*[Gt]\*[Gt](0x3c.l)  string  PE\e0\e0    PE executable (MS-Windows)
698# immediately following the PE signature is the CPU type
699\*[Gt]\*[Gt]\*[Gt]\*[Am]0       leshort 0x14c     for Intel 80386
700\*[Gt]\*[Gt]\*[Gt]\*[Am]0       leshort 0x184     for DEC Alpha
701.Ed
702.Pp
703Indirect and relative offsets can be combined:
704.Bd -literal -offset indent
7050             string  MZ
706\*[Gt]0x18         leshort \*[Lt]0x40
707\*[Gt]\*[Gt](4.s*512)   leshort !0x014c MZ executable (MS-DOS)
708# if it's not COFF, go back 512 bytes and add the offset taken
709# from byte 2/3, which is yet another way of finding the start
710# of the extended executable
711\*[Gt]\*[Gt]\*[Gt]\*[Am](2.s-514) string  LE      LE executable (MS Windows VxD driver)
712.Ed
713.Pp
714Or the other way around:
715.Bd -literal -offset indent
7160                 string  MZ
717\*[Gt]0x18             leshort \*[Gt]0x3f
718\*[Gt]\*[Gt](0x3c.l)        string  LE\e0\e0  LE executable (MS-Windows)
719# at offset 0x80 (-4, since relative offsets start at the end
720# of the up-level match) inside the LE header, we find the absolute
721# offset to the code area, where we look for a specific signature
722\*[Gt]\*[Gt]\*[Gt](\*[Am]0x7c.l+0x26) string  UPX     \eb, UPX compressed
723.Ed
724.Pp
725Or even both!
726.Bd -literal -offset indent
7270                string  MZ
728\*[Gt]0x18            leshort \*[Gt]0x3f
729\*[Gt]\*[Gt](0x3c.l)       string  LE\e0\e0 LE executable (MS-Windows)
730# at offset 0x58 inside the LE header, we find the relative offset
731# to a data area where we look for a specific signature
732\*[Gt]\*[Gt]\*[Gt]\*[Am](\*[Am]0x54.l-3)  string  UNACE  \eb, ACE self-extracting archive
733.Ed
734.Pp
735If you have to deal with offset/length pairs in your file, even the
736second value in a parenthesized expression can be taken from the file itself,
737using another set of parentheses.
738Note that this additional indirect offset is always relative to the
739start of the main indirect offset.
740.Bd -literal -offset indent
7410                 string       MZ
742\*[Gt]0x18             leshort      \*[Gt]0x3f
743\*[Gt]\*[Gt](0x3c.l)        string       PE\e0\e0 PE executable (MS-Windows)
744# search for the PE section called ".idata"...
745\*[Gt]\*[Gt]\*[Gt]\*[Am]0xf4          search/0x140 .idata
746# ...and go to the end of it, calculated from start+length;
747# these are located 14 and 10 bytes after the section name
748\*[Gt]\*[Gt]\*[Gt]\*[Gt](\*[Am]0xe.l+(-4)) string       PK\e3\e4 \eb, ZIP self-extracting archive
749.Ed
750.Pp
751If you have a list of known values at a particular continuation level,
752and you want to provide a switch-like default case:
753.Bd -literal -offset indent
754# clear that continuation level match
755\*[Gt]18	clear
756\*[Gt]18	lelong	1	one
757\*[Gt]18	lelong	2	two
758\*[Gt]18	default	x
759# print default match
760\*[Gt]\*[Gt]18	lelong	x	unmatched 0x%x
761.Ed
762.Sh SEE ALSO
763.Xr file 1
764\- the command that reads this file.
765.Sh BUGS
766The formats
767.Dv long ,
768.Dv belong ,
769.Dv lelong ,
770.Dv melong ,
771.Dv short ,
772.Dv beshort ,
773and
774.Dv leshort
775do not depend on the length of the C data types
776.Dv short
777and
778.Dv long
779on the platform, even though the Single
780.Ux
781Specification implies that they do.  However, as OS X Mountain Lion has
782passed the Single
783.Ux
784Specification validation suite, and supplies a version of
785.Xr file 1
786in which they do not depend on the sizes of the C data types and that is
787built for a 64-bit environment in which
788.Dv long
789is 8 bytes rather than 4 bytes, presumably the validation suite does not
790test whether, for example
791.Dv long
792refers to an item with the same size as the C data type
793.Dv long .
794There should probably be
795.Dv type
796names
797.Dv int8 ,
798.Dv uint8 ,
799.Dv int16 ,
800.Dv uint16 ,
801.Dv int32 ,
802.Dv uint32 ,
803.Dv int64 ,
804and
805.Dv uint64 ,
806and specified-byte-order variants of them,
807to make it clearer that those types have specified widths.
808.\"
809.\" From: guy@sun.uucp (Guy Harris)
810.\" Newsgroups: net.bugs.usg
811.\" Subject: /etc/magic's format isn't well documented
812.\" Message-ID: <2752@sun.uucp>
813.\" Date: 3 Sep 85 08:19:07 GMT
814.\" Organization: Sun Microsystems, Inc.
815.\" Lines: 136
816.\"
817.\" Here's a manual page for the format accepted by the "file" made by adding
818.\" the changes I posted to the S5R2 version.
819.\"
820.\" Modified for Ian Darwin's version of the file command.
821