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