macintosh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. #------------------------------------------------------------------------------
  2. # $File: macintosh,v 1.36 2022/12/06 18:45:20 christos Exp $
  3. # macintosh description
  4. #
  5. # BinHex is the Macintosh ASCII-encoded file format (see also "apple")
  6. # Daniel Quinlan, quinlan@yggdrasil.com
  7. # Update: Joerg Jenderek
  8. # URL: https://en.wikipedia.org/wiki/BinHex
  9. # Reference: http://fileformats.archiveteam.org/wiki/BinHex
  10. # Note: only tested with version 4.0 and hqx extension
  11. # Any text/binary before the characteristic comment sentence is to be ignored like in
  12. # http://ftp.vim.org/pub/ftp/ftp/infomac/disk/mac-update-40b7.hqx
  13. 0 search/1602 (This\ file\
  14. >&0 use binhex
  15. # http://ftp.vim.org/pub/ftp/ftp/infomac/_Disk_&_File/zap-res-forks-101.hqx
  16. 0 search/2652/b (This\ file\
  17. >&0 use binhex
  18. 0 name binhex
  19. # keep split search string format similar like in version 5.37
  20. >0 string must\ be\ converted\ with\ BinHex\ BinHex binary text, version
  21. # http://www.macdisk.com/binhexen.php3
  22. !:apple BNHQTEXT
  23. # http://www.faqs.org/faqs/macintosh/comm-faq/part1/
  24. >>&0 string 1.0 1.0
  25. !:mime application/mac-binhex
  26. !:ext hex
  27. >>&0 string 2.0 2.0
  28. !:mime application/mac-binhex
  29. !:ext hcx
  30. # BinHex 3.0 never existed
  31. >>&0 string 4.0 4.0
  32. !:mime application/mac-binhex40
  33. !:ext hqx
  34. # BinHex 5.0 also MacBinary I
  35. >>&0 string 5.0 5.0
  36. !:mime application/mac-binhex40
  37. !:ext hqx
  38. # this should never happen
  39. >>&0 default x
  40. >>>&0 string x %.3s
  41. !:mime application/mac-binhex
  42. !:ext hqx
  43. # Stuffit archives are the de facto standard of compression for Macintosh
  44. # files obtained from most archives. (franklsm@tuns.ca)
  45. 0 string SIT! StuffIt Archive (data)
  46. !:mime application/x-stuffit
  47. !:apple SIT!SIT!
  48. >2 string x : %s
  49. 0 string SITD StuffIt Deluxe (data)
  50. >2 string x : %s
  51. 0 string Seg StuffIt Deluxe Segment (data)
  52. >2 string x : %s
  53. # Newer StuffIt archives (grant@netbsd.org)
  54. 0 string StuffIt StuffIt Archive
  55. !:mime application/x-stuffit
  56. !:apple SIT!SIT!
  57. #>162 string >0 : %s
  58. # Macintosh Applications and Installation binaries (franklsm@tuns.ca)
  59. # GRR: Too weak
  60. #0 string APPL Macintosh Application (data)
  61. #>2 string x \b: %s
  62. # Macintosh System files (franklsm@tuns.ca)
  63. # GRR: Too weak
  64. #0 string zsys Macintosh System File (data)
  65. #0 string FNDR Macintosh Finder (data)
  66. #0 string libr Macintosh Library (data)
  67. #>2 string x : %s
  68. #0 string shlb Macintosh Shared Library (data)
  69. #>2 string x : %s
  70. #0 string cdev Macintosh Control Panel (data)
  71. #>2 string x : %s
  72. #0 string INIT Macintosh Extension (data)
  73. #>2 string x : %s
  74. #0 string FFIL Macintosh Truetype Font (data)
  75. #>2 string x : %s
  76. #0 string LWFN Macintosh Postscript Font (data)
  77. #>2 string x : %s
  78. # Additional Macintosh Files (franklsm@tuns.ca)
  79. # GRR: Too weak
  80. #0 string PACT Macintosh Compact Pro Archive (data)
  81. #>2 string x : %s
  82. #0 string ttro Macintosh TeachText File (data)
  83. #>2 string x : %s
  84. #0 string TEXT Macintosh TeachText File (data)
  85. #>2 string x : %s
  86. #0 string PDF Macintosh PDF File (data)
  87. #>2 string x : %s
  88. # MacBinary format (Eric Fischer, enf@pobox.com)
  89. # Update: Joerg Jenderek
  90. # URL: https://en.wikipedia.org/wiki/MacBinary
  91. # http://fileformats.archiveteam.org/wiki/MacBinary
  92. # Reference: https://files.stairways.com/other/macbinaryii-standard-info.txt
  93. # Note: verified by macutils `macunpack -i -v BBEdit4.0.sit.bin` and
  94. # `deark -l -d -m macbinary G3FirmwareUpdate1.1.smi.bin`
  95. #
  96. # Unfortunately MacBinary doesn't really have a magic number prior
  97. # to the MacBinary III format.
  98. #
  99. # old version number, must be kept at zero for compatibility
  100. 0 byte 0
  101. # length of filename (must be in the range 1-63)
  102. >1 ubyte >0
  103. # skip T.PIC.LZ INSTRUMENT.7T INVENTORY
  104. >>1 ubyte <64
  105. # skip Docs.MWII ReadMe.MacWrite "Notes (MacWrite II)"
  106. # by looking for printable characters at beginning of file name
  107. >>>2 ubelong >0x1F000000
  108. # zero fill, must be zero for compatibility
  109. >>>>74 byte 0
  110. # zero fill, must be zero for compatibility
  111. >>>>>82 byte 0
  112. # skip few DEGAS mid-res uncompressed bitmap (GEMINI03.PI2 CODE_RAM.PI2) with "too high" file names ffffff88 ffff4f00
  113. >>>>>>2 ubelong <0xffff0000
  114. # MacBinary I test for valid version numbers
  115. >>>>>>>122 ubeshort 0
  116. # additional check for undefined header fields in MacBinary I
  117. #>>>>>>>>101 ulong 0
  118. >>>>>>>>0 use mac-bin
  119. # MacBinary II the newer versions begins at 129
  120. >>>>>>>122 ubeshort 0x8181
  121. >>>>>>>>0 use mac-bin
  122. # MacBinary III with MacBinary II to read
  123. >>>>>>122 ubeshort 0x8281
  124. >>>>>>>0 use mac-bin
  125. # display information of MacBinary file
  126. 0 name mac-bin
  127. >122 ubyte x MacBinary
  128. # versions for MacBinary II/III
  129. >122 ubyte 129 II
  130. >122 ubyte 130 III
  131. # only in MacBinary III
  132. >>102 string !mBIN with surprising version
  133. !:mime application/x-macbinary
  134. !:apple PSPTBINA
  135. !:ext bin/macbin
  136. # THIS SHOULD NEVER HAPPEN! Maybe another file type is misidentified as MacBinary
  137. #>1 ubyte >63 \b, name length %u too BIG!
  138. #>122 ubeshort x \b, version %#x
  139. # Finder flags if not 0
  140. # >73 byte !0 \b, flags 0x
  141. # >73 byte =0
  142. # >>101 byte !0 \b, flags 0x
  143. # # original Finder flags (Bits 8-15)
  144. # >73 byte !0 \b%x
  145. # # finder flags, bits 0-7
  146. # >101 byte !0 \b%x
  147. >73 byte &0x01 \b, inited
  148. >73 byte &0x02 \b, changed
  149. >73 byte &0x04 \b, busy
  150. >73 byte &0x08 \b, bozo
  151. >73 byte &0x10 \b, system
  152. >73 byte &0x20 \b, bundle
  153. >73 byte &0x40 \b, invisible
  154. >73 byte &0x80 \b, locked
  155. # 75 beshort # vertical posn in window
  156. #>75 beshort !0 \b, v.pos %u
  157. # 77 beshort # horiz posn in window
  158. #>77 beshort !0 \b, h.pos %u
  159. # 79 beshort # window or folder ID
  160. >79 ubeshort !0 \b, ID %#x
  161. # protected flag
  162. >81 byte !0 \b, protected %#x
  163. # length of comment after resource
  164. >99 ubeshort !0 \b, comment length %u
  165. # char. code of file name
  166. >106 ubyte !0 \b, char. code %#x
  167. # still more Finder flags
  168. >107 ubyte !0 \b, more flags %#x
  169. # length of total files when unpacked only used when pack and unpack on the fly
  170. >116 ubelong !0 \b, total length %u
  171. # 120 beshort # length of add'l header
  172. >120 ubeshort !0 \b, 2nd header length %u
  173. # 124 beshort # checksum
  174. #>124 ubeshort !0 \b, CRC %#x
  175. # creation date in seconds since MacOS epoch start. So 1 Jan 1970 ~ 7C25B080
  176. # few (31/1247) examples (hinkC4.0.sitx.bin InternetExplorer5.1.smi.bin G3FirmwareUpdate1.1.smi.bin Firewire2.3.3.smi.bin LR2image.bin) contain zeroed date fields
  177. >91 long !0
  178. >>91 beldate-0x7C25B080 x \b, %s
  179. # THIS SHOULD NEVER HAPPEN! Maybe another file type is misidentified or time overflow
  180. >91 ubelong <0x7c25b080 INVALID date
  181. # reported date seconds by deark
  182. #>91 ubelong x deark-DATE=%u
  183. # last modified date
  184. >95 long !0
  185. >>95 beldate-0x7C25B080 x \b, modified %s
  186. # Apple creator+typ if not null
  187. # file creator (normally expressed as four characters)
  188. >69 ulong !0 \b, creator
  189. # instead 4 character code display full creator name
  190. >>69 use apple-creator
  191. # file type (normally expressed as four characters)
  192. >65 ulong !0 \b, type
  193. >>65 use apple-type
  194. # length of data segment
  195. >83 ubelong !0 \b, %u bytes
  196. # filename (in the range 1-63)
  197. # like "BBEdit4.0.sit" "Archive.sitx" "MacPGP 2.2 (.sea)"
  198. >1 pstring x "%s"
  199. # print 1 space and then at offset 128 inspect data fork content if it has one
  200. >83 ubelong !0 \b
  201. >>128 indirect x
  202. # Afterwards resource fork if length of resource segment not zero
  203. >87 ubelong !0
  204. # calculate resource fork offset
  205. >>83 ubelong+128 x \b, at %#x
  206. # length of resource segment
  207. >>87 ubelong !0 %u bytes
  208. >>(83.S+128) ubequad x resource
  209. # further resource fork content inspection
  210. >>>&-8 indirect x
  211. # Apple Type/Creator Database
  212. # URL: https://en.wikipedia.org/wiki/Type_code
  213. # Reference: https://www.lacikam.co.il/tcdb/
  214. # https://www.macdisk.com/macsigen.php
  215. # Note: classic Mac OS files have two 4 character codes for type and creator.
  216. # Thereby the Finder attach documents types to applications.
  217. #>65 string x \b, type "%4.4s"
  218. # display information about apple type
  219. 0 name apple-type
  220. >0 string 8BIM PhotoShop
  221. >0 string ALB3 PageMaker 3
  222. >0 string ALB4 PageMaker 4
  223. >0 string ALT3 PageMaker 3
  224. >0 string APPL application
  225. >0 string AWWP AppleWorks word processor
  226. >0 string CIRC simulated circuit
  227. >0 string DRWG MacDraw
  228. >0 string EPSF Encapsulated PostScript
  229. >0 string FFIL font suitcase
  230. >0 string FKEY function key
  231. >0 string FNDR Macintosh Finder
  232. >0 string GIFf GIF image
  233. >0 string Gzip GNU gzip
  234. >0 string INIT system extension
  235. >0 string LIB\ library
  236. >0 string LWFN PostScript font
  237. >0 string MSBC Microsoft BASIC
  238. >0 string PACT Compact Pro archive
  239. >0 string PDF\ Portable Document Format
  240. >0 string PICT picture
  241. >0 string PNTG MacPaint picture
  242. >0 string PREF preferences
  243. >0 string PROJ Think C project
  244. >0 string QPRJ Think Pascal project
  245. >0 string SCFL Defender scores
  246. >0 string SCRN startup screen
  247. >0 string SITD StuffIt Deluxe
  248. >0 string SPn3 SuperPaint
  249. >0 string STAK HyperCard stack
  250. >0 string Seg\ StuffIt segment
  251. >0 string TARF Unix tar archive
  252. >0 string TEXT ASCII
  253. >0 string TIFF TIFF image
  254. >0 string TOVF Eudora table of contents
  255. >0 string WDBN Microsoft Word word processor
  256. >0 string WORD MacWrite word processor
  257. >0 string XLS\ Microsoft Excel
  258. >0 string ZIVM compress (.Z)
  259. >0 string ZSYS Pre-System 7 system file
  260. >0 string acf3 Aldus FreeHand
  261. >0 string cdev control panel
  262. >0 string dfil Desk Accessory suitcase
  263. >0 string libr library
  264. >0 string nX^d WriteNow word processor
  265. >0 string nX^w WriteNow dictionary
  266. >0 string rsrc resource
  267. >0 string scbk Scrapbook
  268. >0 string shlb shared library
  269. >0 string ttro SimpleText read-only
  270. >0 string zsys system file
  271. # additional types added in Dec 2017
  272. >0 string BINA binary file
  273. >0 string BMPp BMP image
  274. >0 string JPEG JPEG image
  275. #>0 string W4BN Microsoft Word x.y word processor?
  276. # if type name is not known display 4 character identifier
  277. >0 default x
  278. >>0 string x '%4.4s'
  279. #>69 string x \b, creator "%4.4s"
  280. # Now Apple has no repository of registered Creator IDs any more. These are
  281. # just the ones that I happened to have files from and was able to identify.
  282. # display information about apple creator
  283. 0 name apple-creator
  284. >0 string 8BIM Adobe Photoshop
  285. >0 string ALD3 PageMaker 3
  286. >0 string ALD4 PageMaker 4
  287. >0 string ALFA Alpha editor
  288. >0 string APLS Apple Scanner
  289. >0 string APSC Apple Scanner
  290. >0 string BRKL Brickles
  291. >0 string BTFT BitFont
  292. >0 string CCL2 Common Lisp 2
  293. >0 string CCL\ Common Lisp
  294. >0 string CDmo The Talking Moose
  295. >0 string CPCT Compact Pro
  296. >0 string CSOm Eudora
  297. >0 string DMOV Font/DA Mover
  298. >0 string DSIM DigSim
  299. >0 string EDIT Macintosh Edit
  300. >0 string ERIK Macintosh Finder
  301. >0 string EXTR self-extracting archive
  302. >0 string Gzip GNU gzip
  303. >0 string KAHL Think C
  304. >0 string LWFU LaserWriter Utility
  305. >0 string LZIV compress
  306. >0 string MACA MacWrite
  307. >0 string MACS Macintosh operating system
  308. >0 string MAcK MacKnowledge terminal emulator
  309. >0 string MLND Defender
  310. >0 string MPNT MacPaint
  311. >0 string MSBB Microsoft BASIC (binary)
  312. >0 string MSWD Microsoft Word
  313. >0 string NCSA NCSA Telnet
  314. >0 string PJMM Think Pascal
  315. >0 string PSAL Hunt the Wumpus
  316. #>0 string PSI2 Apple File Exchange
  317. >0 string R*ch BBEdit
  318. >0 string RMKR Resource Maker
  319. >0 string RSED Resource Editor
  320. >0 string Rich BBEdit
  321. >0 string SIT! StuffIt
  322. >0 string SPNT SuperPaint
  323. >0 string Unix NeXT Mac filesystem
  324. >0 string VIM! Vim editor
  325. >0 string WILD HyperCard
  326. >0 string XCEL Microsoft Excel
  327. >0 string aCa2 Fontographer
  328. >0 string aca3 Aldus FreeHand
  329. >0 string dosa Macintosh MS-DOS file system
  330. >0 string movr Font/DA Mover
  331. >0 string nX^n WriteNow
  332. >0 string pdos Apple ProDOS file system
  333. >0 string scbk Scrapbook
  334. >0 string ttxt SimpleText
  335. >0 string ufox Foreign File Access
  336. # additional creators added in Dec 2017
  337. # Claris/Apple Works
  338. >0 string BOBO Apple Works
  339. # CU-SeeMe_0.87b3_(68K).bin
  340. #>0 string CUce bar
  341. >0 string PSPT Apple File Exchange
  342. # Disk_Copy_4.2.sea.bin
  343. #>0 string NCse foo
  344. # probably StuffIt/Aladdin by Smith Micro Software, Inc.
  345. >0 string STi0 stuffit
  346. # MacGzip-1.1.3.sea.bin
  347. #>0 string aust bar
  348. # D-Disk_Copy_6.3.3.smi.bin
  349. >0 string oneb Disk Copy Self Mounting
  350. # if creator name is not known display 4 character identifier
  351. >0 default x
  352. >>0 string x '%4.4s'
  353. # sas magic from Bruce Foster (bef@nwu.edu)
  354. #
  355. #0 string SAS SAS
  356. #>8 string x %s
  357. 0 string SAS SAS
  358. >24 string DATA data file
  359. >24 string CATALOG catalog
  360. >24 string INDEX data file index
  361. >24 string VIEW data view
  362. # sas 7+ magic from Reinhold Koch (reinhold.koch@roche.com)
  363. #
  364. 0x54 string SAS SAS 7+
  365. >0x9C string DATA data file
  366. >0x9C string CATALOG catalog
  367. >0x9C string INDEX data file index
  368. >0x9C string VIEW data view
  369. # spss magic for SPSS system and portable files,
  370. # from Bruce Foster (bef@nwu.edu).
  371. 0 long 0xc1e2c3c9 SPSS Portable File
  372. >40 string x %s
  373. 0 string $FL2 SPSS System File
  374. >24 string x %s
  375. 0 string $FL3 SPSS System File
  376. >24 string x %s
  377. # Macintosh filesystem data
  378. # From "Tom N Harris" <telliamed@mac.com>
  379. # Fixed HFS+ and Partition map magic: Ethan Benson <erbenson@alaska.net>
  380. # The MacOS epoch begins on 1 Jan 1904 instead of 1 Jan 1970, so these
  381. # entries depend on the data arithmetic added after v.35
  382. # There's also some Pascal strings in here, ditto...
  383. # The boot block signature, according to IM:Files, is
  384. # "for HFS volumes, this field always contains the value 0x4C4B."
  385. # But if this is true for MFS or HFS+ volumes, I don't know.
  386. # Alternatively, the boot block is supposed to be zeroed if it's
  387. # unused, so a simply >0 should suffice.
  388. 0x400 beshort 0xD2D7 Macintosh MFS data
  389. >0 beshort 0x4C4B (bootable)
  390. >0x40a beshort &0x8000 (locked)
  391. >0x402 beldate-0x7C25B080 x created: %s,
  392. >0x406 beldate-0x7C25B080 >0 last backup: %s,
  393. >0x414 belong x block size: %d,
  394. >0x412 beshort x number of blocks: %d,
  395. >0x424 pstring x volume name: %s
  396. # *.hfs updated by Joerg Jenderek
  397. # https://en.wikipedia.org/wiki/Hierarchical_File_System
  398. # "BD" gives many false positives
  399. 0x400 beshort 0x4244
  400. # ftp://ftp.mars.org/pub/hfs/hfsutils-3.2.6.tar.gz/hfsutils-3.2.6/libhfs/apple.h
  401. # first block of volume bit map (always 3)
  402. >0x40e ubeshort 0x0003
  403. # maximal length of volume name is 27
  404. >>0x424 ubyte <28 Macintosh HFS data
  405. !:mime application/x-apple-diskimage
  406. #!:apple hfsdINIT
  407. #!:apple MACSdisk
  408. # https://www.macdisk.com/macsigen.php
  409. #!:apple ddskdevi
  410. !:apple ????devi
  411. # https://en.wikipedia.org/wiki/Apple_Disk_Image
  412. !:ext hfs/dmg
  413. >>>0 beshort 0x4C4B (bootable)
  414. #>>>0 beshort 0x0000 (not bootable)
  415. >>>0x40a beshort &0x8000 (locked)
  416. >>>0x40a beshort ^0x0100 (mounted)
  417. >>>0x40a beshort &0x0200 (spared blocks)
  418. >>>0x40a beshort &0x0800 (unclean)
  419. >>>0x47C beshort 0x482B (Embedded HFS+ Volume)
  420. # https://www.epochconverter.com/
  421. # 0x7C245F00 seconds ~ 2082758400 ~ 01 Jan 2036 00:00:00 ~ 66 years to 1970
  422. # 0x7C25B080 seconds ~ 2082844800 ~ 02 Jan 2036 00:00:00
  423. # construct not working
  424. #>>>0x402 beldate-0x7C25B080 x created: %s,
  425. #>>>0x406 beldate-0x7C25B080 x last modified: %s,
  426. #>>>0x440 beldate-0x7C25B080 >0 last backup: %s,
  427. # found block sizes 200h,1200h,2800h
  428. >>>0x414 belong x block size: %d,
  429. >>>0x412 beshort x number of blocks: %d,
  430. >>>0x424 pstring x volume name: %s
  431. 0 name hfsplus
  432. >&0 beshort x version %d data
  433. >0 beshort 0x4C4B (bootable)
  434. >0x404 belong ^0x00000100 (mounted)
  435. >&2 belong &0x00000200 (spared blocks)
  436. >&2 belong &0x00000800 (unclean)
  437. >&2 belong &0x00008000 (locked)
  438. >&6 string x last mounted by: '%.4s',
  439. # really, that should be treated as a belong and we print a string
  440. # based on the value. TN1150 only mentions '8.10' for "MacOS 8.1"
  441. >&14 beldate-0x7C25B080 x created: %s,
  442. # only the creation date is local time, all other timestamps in HFS+ are UTC.
  443. >&18 bedate-0x7C25B080 x last modified: %s,
  444. >&22 bedate-0x7C25B080 >0 last backup: %s,
  445. >&26 bedate-0x7C25B080 >0 last checked: %s,
  446. >&38 belong x block size: %d,
  447. >&42 belong x number of blocks: %d,
  448. >&46 belong x free blocks: %d
  449. 0x400 beshort 0x482B Apple HFS Plus
  450. >&0 use hfsplus
  451. 0x400 beshort 0x4858 Apple HFS Plus Extended
  452. >&0 use hfsplus
  453. ## AFAIK, only the signature is different
  454. # same as Apple Partition Map
  455. # GRR: This magic is too weak, it is just "TS"
  456. #0x200 beshort 0x5453 Apple Old Partition data
  457. #>0x2 beshort x block size: %d,
  458. #>0x230 string x first type: %s,
  459. #>0x210 string x name: %s,
  460. #>0x254 belong x number of blocks: %d,
  461. #>0x400 beshort 0x504D
  462. #>>0x430 string x second type: %s,
  463. #>>0x410 string x name: %s,
  464. #>>0x454 belong x number of blocks: %d,
  465. #>>0x800 beshort 0x504D
  466. #>>>0x830 string x third type: %s,
  467. #>>>0x810 string x name: %s,
  468. #>>>0x854 belong x number of blocks: %d,
  469. #>>>0xa00 beshort 0x504D
  470. #>>>>0xa30 string x fourth type: %s,
  471. #>>>>0xa10 string x name: %s,
  472. #>>>>0xa54 belong x number of blocks: %d
  473. # From: Remi Mommsen <mommsen@slac.stanford.edu>
  474. 0 string BOMStore Mac OS X bill of materials (BOM) file