1#	$OpenBSD: macintosh,v 1.4 2009/04/24 18:54:34 chl Exp $
2
3#------------------------------------------------------------------------------
4# macintosh description
5#
6# BinHex is the Macintosh ASCII-encoded file format (see also "apple")
7# Daniel Quinlan, quinlan@yggdrasil.com
811	string	must\ be\ converted\ with\ BinHex	BinHex binary text
9!:mime	application/mac-binhex40
10>41	string	x					\b, version %.3s
11
12# Stuffit archives are the de facto standard of compression for Macintosh
13# files obtained from most archives. (franklsm@tuns.ca)
140	string		SIT!			StuffIt Archive (data)
15>2	string		x			: %s
160	string		SITD			StuffIt Deluxe (data)
17>2	string		x			: %s
180	string		Seg			StuffIt Deluxe Segment (data)
19>2	string		x			: %s
20
21# Newer StuffIt archives (grant@netbsd.org)
220	string		StuffIt			StuffIt Archive
23!:mime	application/x-stuffit
24#>162	string		>0			: %s
25
26# Macintosh Applications and Installation binaries (franklsm@tuns.ca)
27# GRR: Too weak
28#0	string		APPL			Macintosh Application (data)
29#>2	string		x			\b: %s
30
31# Macintosh System files (franklsm@tuns.ca)
32# GRR: Too weak
33#0	string		zsys			Macintosh System File (data)
34#0	string		FNDR			Macintosh Finder (data)
35#0	string		libr			Macintosh Library (data)
36#>2	string		x			: %s
37#0	string		shlb			Macintosh Shared Library (data)
38#>2	string		x			: %s
39#0	string		cdev			Macintosh Control Panel (data)
40#>2	string		x			: %s
41#0	string		INIT			Macintosh Extension (data)
42#>2	string		x			: %s
43#0	string		FFIL			Macintosh Truetype Font (data)
44#>2	string		x			: %s
45#0	string		LWFN			Macintosh Postscript Font (data)
46#>2	string		x			: %s
47
48# Additional Macintosh Files (franklsm@tuns.ca)
49# GRR: Too weak
50#0	string		PACT			Macintosh Compact Pro Archive (data)
51#>2	string		x			: %s
52#0	string		ttro			Macintosh TeachText File (data)
53#>2	string		x			: %s
54#0	string		TEXT			Macintosh TeachText File (data)
55#>2	string		x			: %s
56#0	string		PDF			Macintosh PDF File (data)
57#>2	string		x			: %s
58
59# MacBinary format (Eric Fischer, enf@pobox.com)
60#
61# Unfortunately MacBinary doesn't really have a magic number prior
62# to the MacBinary III format.  The checksum is really the way to
63# do it, but the magic file format isn't up to the challenge.
64#
65# 0	byte		0
66# 1	byte				# filename length
67# 2	string				# filename
68# 65    string				# file type
69# 69	string				# file creator
70# 73	byte				# Finder flags
71# 74	byte		0
72# 75	beshort				# vertical posn in window
73# 77	beshort				# horiz posn in window
74# 79	beshort				# window or folder ID
75# 81    byte				# protected?
76# 82	byte		0
77# 83	belong				# length of data segment
78# 87	belong				# length of resource segment
79# 91	belong				# file creation date
80# 95	belong				# file modification date
81# 99	beshort				# length of comment after resource
82# 101	byte				# new Finder flags
83# 102	string		mBIN		# (only in MacBinary III)
84# 106	byte				# char. code of file name
85# 107	byte				# still more Finder flags
86# 116	belong				# total file length
87# 120	beshort				# length of add'l header
88# 122	byte		129		# for MacBinary II
89# 122	byte		130		# for MacBinary III
90# 123	byte		129		# minimum version that can read fmt
91# 124	beshort				# checksum
92#
93# This attempts to use the version numbers as a magic number, requiring
94# that the first one be 0x80, 0x81, 0x82, or 0x83, and that the second
95# be 0x81.  This works for the files I have, but maybe not for everyone's.
96
97# Unfortunately, this magic is quite weak - MPi
98#122	beshort&0xFCFF	0x8081		Macintosh MacBinary data
99
100# MacBinary I doesn't have the version number field at all, but MacBinary II
101# has been in use since 1987 so I hope there aren't many really old files
102# floating around that this will miss.  The original spec calls for using
103# the nulls in 0, 74, and 82 as the magic number.
104#
105# Another possibility, that would also work for MacBinary I, is to use
106# the assumption that 65-72 will all be ASCII (0x20-0x7F), that 73 will
107# have bits 1 (changed), 2 (busy), 3 (bozo), and 6 (invisible) unset,
108# and that 74 will be 0.  So something like
109# 
110# 71 	belong&0x80804EFF 0x00000000 	Macintosh MacBinary data
111# 
112# >73	byte&0x01	0x01		\b, inited
113# >73	byte&0x02	0x02		\b, changed
114# >73	byte&0x04	0x04		\b, busy
115# >73	byte&0x08	0x08		\b, bozo
116# >73	byte&0x10	0x10		\b, system
117# >73	byte&0x10	0x20		\b, bundle
118# >73	byte&0x10	0x40		\b, invisible
119# >73	byte&0x10	0x80		\b, locked
120
121#>65	string		x		\b, type "%4.4s"
122
123#>65	string		8BIM		(PhotoShop)
124#>65	string		ALB3		(PageMaker 3)
125#>65	string		ALB4		(PageMaker 4)
126#>65	string		ALT3		(PageMaker 3)
127#>65	string		APPL		(application)
128#>65	string		AWWP		(AppleWorks word processor)
129#>65	string		CIRC		(simulated circuit)
130#>65	string		DRWG		(MacDraw)
131#>65	string		EPSF		(Encapsulated PostScript)
132#>65	string		FFIL		(font suitcase)
133#>65	string		FKEY		(function key)
134#>65	string		FNDR		(Macintosh Finder)
135#>65	string		GIFf		(GIF image)
136#>65	string		Gzip		(GNU gzip)
137#>65	string		INIT		(system extension)
138#>65	string		LIB\ 		(library)
139#>65	string		LWFN		(PostScript font)
140#>65	string		MSBC		(Microsoft BASIC)
141#>65	string		PACT		(Compact Pro archive)
142#>65	string		PDF\ 		(Portable Document Format)
143#>65	string		PICT		(picture)
144#>65	string		PNTG		(MacPaint picture)
145#>65	string		PREF		(preferences)
146#>65	string		PROJ		(Think C project)
147#>65	string		QPRJ		(Think Pascal project)
148#>65	string		SCFL		(Defender scores)
149#>65	string		SCRN		(startup screen)
150#>65	string		SITD		(StuffIt Deluxe)
151#>65	string		SPn3		(SuperPaint)
152#>65	string		STAK		(HyperCard stack)
153#>65	string		Seg\ 		(StuffIt segment)
154#>65	string		TARF		(Unix tar archive)
155#>65	string		TEXT		(ASCII)
156#>65	string		TIFF		(TIFF image)
157#>65	string		TOVF		(Eudora table of contents)
158#>65	string		WDBN		(Microsoft Word word processor)
159#>65	string		WORD		(MacWrite word processor)
160#>65	string		XLS\ 		(Microsoft Excel)
161#>65	string		ZIVM		(compress (.Z))
162#>65	string		ZSYS		(Pre-System 7 system file)
163#>65	string		acf3		(Aldus FreeHand)
164#>65	string		cdev		(control panel)
165#>65	string		dfil		(Desk Acessory suitcase)
166#>65	string		libr		(library)
167#>65	string		nX^d		(WriteNow word processor)
168#>65	string		nX^w		(WriteNow dictionary)
169#>65	string		rsrc		(resource)
170#>65	string		scbk		(Scrapbook)
171#>65	string		shlb		(shared library)
172#>65	string		ttro		(SimpleText read-only)
173#>65	string		zsys		(system file)
174
175#>69	string		x		\b, creator "%4.4s"
176
177# Somewhere, Apple has a repository of registered Creator IDs.  These are
178# just the ones that I happened to have files from and was able to identify.
179
180#>69	string		8BIM		(Adobe Photoshop)
181#>69	string		ALD3		(PageMaker 3)
182#>69	string		ALD4		(PageMaker 4)
183#>69	string		ALFA		(Alpha editor)
184#>69	string		APLS		(Apple Scanner)
185#>69	string		APSC		(Apple Scanner)
186#>69	string		BRKL		(Brickles)
187#>69	string		BTFT		(BitFont)
188#>69	string		CCL2 		(Common Lisp 2)
189#>69	string		CCL\ 		(Common Lisp)
190#>69	string		CDmo		(The Talking Moose)
191#>69	string		CPCT		(Compact Pro)
192#>69	string		CSOm		(Eudora)
193#>69	string		DMOV		(Font/DA Mover)
194#>69	string		DSIM		(DigSim)
195#>69	string		EDIT		(Macintosh Edit)
196#>69	string		ERIK		(Macintosh Finder)
197#>69	string		EXTR		(self-extracting archive)
198#>69	string		Gzip		(GNU gzip)
199#>69	string		KAHL		(Think C)
200#>69	string		LWFU		(LaserWriter Utility)
201#>69	string		LZIV		(compress)
202#>69	string		MACA		(MacWrite)
203#>69	string		MACS		(Macintosh operating system)
204#>69	string		MAcK		(MacKnowledge terminal emulator)
205#>69	string		MLND		(Defender)
206#>69	string		MPNT		(MacPaint)
207#>69	string		MSBB		(Microsoft BASIC (binary))
208#>69	string		MSWD		(Microsoft Word)
209#>69	string		NCSA		(NCSA Telnet)
210#>69	string		PJMM		(Think Pascal)
211#>69	string		PSAL		(Hunt the Wumpus)
212#>69	string		PSI2		(Apple File Exchange)
213#>69	string		R*ch		(BBEdit)
214#>69	string		RMKR		(Resource Maker)
215#>69	string		RSED		(Resource Editor)
216#>69	string		Rich		(BBEdit)
217#>69	string		SIT!		(StuffIt)
218#>69	string		SPNT		(SuperPaint)
219#>69	string		Unix		(NeXT Mac filesystem)
220#>69	string		VIM!		(Vim editor)
221#>69	string		WILD		(HyperCard)
222#>69	string		XCEL		(Microsoft Excel)
223#>69	string		aCa2		(Fontographer)
224#>69	string		aca3		(Aldus FreeHand)
225#>69	string		dosa		(Macintosh MS-DOS file system)
226#>69	string		movr		(Font/DA Mover)
227#>69	string		nX^n		(WriteNow)
228#>69	string		pdos		(Apple ProDOS file system)
229#>69	string		scbk		(Scrapbook)
230#>69	string		ttxt		(SimpleText)
231#>69	string		ufox		(Foreign File Access)
232
233# Just in case...
234
235102	string		mBIN		MacBinary III data with surprising version number
236
237# sas magic from Bruce Foster (bef@nwu.edu)
238#
239#0	string		SAS		SAS
240#>8	string		x		%s
2410	string		SAS		SAS
242>24	string		DATA		data file
243>24	string		CATALOG		catalog
244>24	string		INDEX		data file index
245>24	string		VIEW		data view
246# sas 7+ magic from Reinhold Koch (reinhold.koch@roche.com)
247#
2480x54    string          SAS             SAS 7+
249>0x9C   string          DATA            data file
250>0x9C   string          CATALOG         catalog
251>0x9C   string          INDEX           data file index
252>0x9C   string          VIEW            data view
253
254# spss magic for SPSS system and portable files, 
255#	 from Bruce Foster (bef@nwu.edu).
256
2570	long		0xc1e2c3c9	SPSS Portable File
258>40	string 		x		%s
259
2600	string		$FL2		SPSS System File
261>24	string		x		%s
262
263# Macintosh filesystem data
264# From "Tom N Harris" <telliamed@mac.com>
265# Fixed HFS+ and Partition map magic: Ethan Benson <erbenson@alaska.net>
266# The MacOS epoch begins on 1 Jan 1904 instead of 1 Jan 1970, so these
267# entries depend on the data arithmetic added after v.35
268# There's also some Pascal strings in here, ditto...
269
270# The boot block signature, according to IM:Files, is 
271# "for HFS volumes, this field always contains the value 0x4C4B."
272# But if this is true for MFS or HFS+ volumes, I don't know.
273# Alternatively, the boot block is supposed to be zeroed if it's
274# unused, so a simply >0 should suffice.
275
2760x400	beshort			0xD2D7		Macintosh MFS data
277>0	beshort			0x4C4B		(bootable)
278>0x40a	beshort			&0x8000		(locked)
279>0x402	beldate-0x7C25B080	x		created: %s,
280>0x406	beldate-0x7C25B080	>0		last backup: %s,
281>0x414	belong			x		block size: %d,
282>0x412	beshort			x		number of blocks: %d,
283>0x424	pstring			x		volume name: %s
284
285# "BD" is has many false positives
286#0x400	beshort			0x4244		Macintosh HFS data
287#>0	beshort			0x4C4B		(bootable)
288#>0x40a	beshort			&0x8000		(locked)
289#>0x40a	beshort			^0x0100		(mounted)
290#>0x40a	beshort			&0x0200		(spared blocks)
291#>0x40a	beshort			&0x0800		(unclean)
292#>0x47C	beshort			0x482B		(Embedded HFS+ Volume)
293#>0x402	beldate-0x7C25B080	x		created: %s,
294#>0x406	beldate-0x7C25B080	x		last modified: %s,
295#>0x440	beldate-0x7C25B080	>0		last backup: %s,
296#>0x414	belong			x		block size: %d,
297#>0x412	beshort			x		number of blocks: %d,
298#>0x424	pstring			x		volume name: %s
299
3000x400	beshort			0x482B		Macintosh HFS Extended
301>&0	beshort			x		version %d data
302>0	beshort			0x4C4B		(bootable)
303>0x404	belong			^0x00000100	(mounted)
304>&2	belong			&0x00000200	(spared blocks)
305>&2	belong			&0x00000800	(unclean)
306>&2	belong			&0x00008000	(locked)
307>&6	string			x		last mounted by: '%.4s',
308# really, that should be treated as a belong and we print a string
309# based on the value. TN1150 only mentions '8.10' for "MacOS 8.1"
310>&14	beldate-0x7C25B080	x		created: %s,
311# only the creation date is local time, all other timestamps in HFS+ are UTC.
312>&18	bedate-0x7C25B080	x		last modified: %s,
313>&22	bedate-0x7C25B080	>0		last backup: %s,
314>&26	bedate-0x7C25B080	>0		last checked: %s,
315>&38	belong			x		block size: %d,
316>&42	belong			x		number of blocks: %d,
317>&46	belong			x		free blocks: %d
318
319# I don't think this is really necessary since it doesn't do much and 
320# anything with a valid driver descriptor will also have a valid
321# partition map
322#0		beshort		0x4552		Apple Device Driver data
323#>&24		beshort		=1		\b, MacOS
324
325# Is that the partition type a cstring or a pstring? Well, IM says "strings 
326# shorter than 32 bytes must be terminated with NULL" so I'll treat it as a 
327# cstring. Of course, partitions can contain more than four entries, but 
328# what're you gonna do?
329# GRR: This magic is too weak, it is just "PM"
330#0x200		beshort		0x504D		Apple Partition data
331#>0x2		beshort		x		(block size: %d):
332#>0x230		string		x		first type: %s,
333#>0x210		string		x		name: %s,
334#>0x254		belong		x		number of blocks: %d,
335#>0x400		beshort		0x504D		
336#>>0x430		string		x		second type: %s,
337#>>0x410		string		x		name: %s,
338#>>0x454		belong		x		number of blocks: %d,
339#>>0x600		beshort		0x504D
340#>>>0x630	string		x		third type: %s,
341#>>>0x610	string		x		name: %s,
342#>>>0x654	belong		x		number of blocks: %d,
343#>>0x800		beshort		0x504D		
344#>>>0x830	string		x		fourth type: %s,
345#>>>0x810	string		x		name: %s,
346#>>>0x854	belong		x		number of blocks: %d,
347#>>>0xa00	beshort		0x504D		
348#>>>>0xa30	string		x		fifth type: %s,
349#>>>>0xa10	string		x		name: %s,
350#>>>>0xa54	belong		x		number of blocks: %d
351#>>>0xc00	beshort		0x504D
352#>>>>0xc30	string		x		sixth type: %s,
353#>>>>0xc10	string		x		name: %s,
354#>>>>0xc54	belong		x		number of blocks: %d
355## AFAIK, only the signature is different
356#0x200		beshort		0x5453		Apple Old Partition data
357#>0x2		beshort		x		block size: %d,
358#>0x230		string		x		first type: %s,
359#>0x210		string		x		name: %s,
360#>0x254		belong		x		number of blocks: %d,
361#>0x400		beshort		0x504D		
362#>>0x430		string		x		second type: %s,
363#>>0x410		string		x		name: %s,
364#>>0x454		belong		x		number of blocks: %d,
365#>>0x800		beshort		0x504D		
366#>>>0x830	string		x		third type: %s,
367#>>>0x810	string		x		name: %s,
368#>>>0x854	belong		x		number of blocks: %d,
369#>>>0xa00	beshort		0x504D		
370#>>>>0xa30	string		x		fourth type: %s,
371#>>>>0xa10	string		x		name: %s,
372#>>>>0xa54	belong		x		number of blocks: %d
373
374# From: Remi Mommsen <mommsen@slac.stanford.edu>
3750		string		BOMStore	Mac OS X bill of materials (BOM) file
376