1b6cee71dSXin LI 2b6cee71dSXin LI#------------------------------------------------------------------------------ 3*a4d6d3b8SXin LI# $File: palm,v 1.15 2021/12/16 21:50:06 christos Exp $ 4b6cee71dSXin LI# palm: file(1) magic for PalmOS {.prc,.pdb}: applications, docfiles, and hacks 5b6cee71dSXin LI# 6b6cee71dSXin LI# Brian Lalor <blalor@hcirisc.cs.binghamton.edu> 7b6cee71dSXin LI 8b6cee71dSXin LI# These are weak, byte 59 is not guaranteed to be 0 and there are 9b6cee71dSXin LI# 8 character identifiers at byte 60, one I found for appl is BIGb. 10b6cee71dSXin LI# What are the possibilities and where is this documented? 11b6cee71dSXin LI 12b6cee71dSXin LI# The common header format for PalmOS .pdb/.prc files is 13b6cee71dSXin LI# { 14b6cee71dSXin LI# char name[ 32 ]; 15b6cee71dSXin LI# Word attributes; 16b6cee71dSXin LI# Word version; 17b6cee71dSXin LI# DWord creationDate; 18b6cee71dSXin LI# DWord modificationDate; 19b6cee71dSXin LI# DWord lastBackupDate; 20b6cee71dSXin LI# DWord modificationNumber; 21b6cee71dSXin LI# DWord appInfoID; 22b6cee71dSXin LI# DWord sortInfoID; 23b6cee71dSXin LI# char type[4]; 24b6cee71dSXin LI# char creator[4]; 25b6cee71dSXin LI# DWord uniqueIDSeed; 26b6cee71dSXin LI# RecordListType recordList; 27b6cee71dSXin LI# }; 28b6cee71dSXin LI# 29b6cee71dSXin LI# Datestamps are unsigned seconds since the MacOS epoch (Jan 1, 1904), 30b6cee71dSXin LI# or Unix/POSIX time + 2082844800. 31b6cee71dSXin LI 32b6cee71dSXin LI0 name aportisdoc 33b6cee71dSXin LI# date is supposed to be big-endian seconds since 1 Jan 1904, but many 34b6cee71dSXin LI# files contain the timestamp in little-endian or a completely 35b6cee71dSXin LI# nonsensical value... 36b6cee71dSXin LI#>36 bedate-2082844800 >0 \b, created %s 37b6cee71dSXin LI# compression: 1=uncomp, 2=orig, 0x4448=HuffDic 38b6cee71dSXin LI>(78.L) beshort =1 \b, uncompressed 39b6cee71dSXin LI# compressed 40b6cee71dSXin LI>(78.L) beshort >1 41b6cee71dSXin LI>>(78.L+4) belong x \b, %d bytes uncompressed 42b6cee71dSXin LI 43b6cee71dSXin LI# appl 44b6cee71dSXin LI#60 string appl PalmOS application 45b6cee71dSXin LI#>0 string >\0 "%s" 46b6cee71dSXin LI 47b6cee71dSXin LI# HACK 48b6cee71dSXin LI#60 string HACK HackMaster hack 49b6cee71dSXin LI#>0 string >\0 "%s" 50b6cee71dSXin LI 51b6cee71dSXin LI# iSiloX e-book 52b6cee71dSXin LI60 string SDocSilX iSiloX E-book 53b6cee71dSXin LI>0 string >\0 "%s" 54b6cee71dSXin LI 55b6cee71dSXin LI# Mobipocket (www.mobipocket.com), donated by Carl Witty 56b6cee71dSXin LI# expanded by Ralf Brown 57b6cee71dSXin LI60 string BOOKMOBI Mobipocket E-book 58*a4d6d3b8SXin LI!:mime application/x-mobipocket-ebook 59b6cee71dSXin LI# MobiPocket stores a full title, pointed at by the belong at offset 60b6cee71dSXin LI# 0x54 in its header at (78.L), with length given by the belong at 61b6cee71dSXin LI# offset 0x58. 62b6cee71dSXin LI# there's no guarantee that the title string is null-terminated, but 63b6cee71dSXin LI# we currently can't specify a variable-length string where the length 64b6cee71dSXin LI# field is not at the start of the string; in practice, the data 65b6cee71dSXin LI# following the string always seems to start with a zero byte 66b6cee71dSXin LI>(78.L) belong x 67b6cee71dSXin LI>>&(&0x50.L-4) string >\0 "%s" 68b6cee71dSXin LI>0 use aportisdoc 69b6cee71dSXin LI>>(78.L+0x68) belong >0 \b, version %d 70b6cee71dSXin LI>>(78.L+0x1C) belong !0 \b, codepage %d 71b6cee71dSXin LI>>(78.L+0x0C) beshort >0 \b, encrypted (type %d) 72b6cee71dSXin LI 73b6cee71dSXin LI# AportisDoc/PalmDOC 74b6cee71dSXin LI60 string TEXtREAd AportisDoc/PalmDOC E-book 75b6cee71dSXin LI>0 string >\0 "%s" 76b6cee71dSXin LI>0 use aportisdoc 77b6cee71dSXin LI 78b6cee71dSXin LI# Variety of PalmOS document types 79b6cee71dSXin LI# Michael-John Turner <mj@debian.org> 80b6cee71dSXin LI# Thanks to Hasan Umit Ezerce <humit@tr-net.net.tr> for his DocType 81b6cee71dSXin LI60 string BVokBDIC BDicty PalmOS document 82b6cee71dSXin LI>0 string >\0 "%s" 83b6cee71dSXin LI60 string DB99DBOS DB PalmOS document 84b6cee71dSXin LI>0 string >\0 "%s" 85b6cee71dSXin LI60 string vIMGView FireViewer/ImageViewer PalmOS document 86b6cee71dSXin LI>0 string >\0 "%s" 87b6cee71dSXin LI60 string PmDBPmDB HanDBase PalmOS document 88b6cee71dSXin LI>0 string >\0 "%s" 89b6cee71dSXin LI60 string InfoINDB InfoView PalmOS document 90b6cee71dSXin LI>0 string >\0 "%s" 91b6cee71dSXin LI60 string ToGoToGo iSilo PalmOS document 92b6cee71dSXin LI>0 string >\0 "%s" 93b6cee71dSXin LI60 string JfDbJBas JFile PalmOS document 94b6cee71dSXin LI>0 string >\0 "%s" 95b6cee71dSXin LI60 string JfDbJFil JFile Pro PalmOS document 96b6cee71dSXin LI>0 string >\0 "%s" 97b6cee71dSXin LI60 string DATALSdb List PalmOS document 98b6cee71dSXin LI>0 string >\0 "%s" 99b6cee71dSXin LI60 string Mdb1Mdb1 MobileDB PalmOS document 100b6cee71dSXin LI>0 string >\0 "%s" 101b6cee71dSXin LI60 string PNRdPPrs PeanutPress PalmOS document 102b6cee71dSXin LI>0 string >\0 "%s" 103b6cee71dSXin LI60 string DataPlkr Plucker PalmOS document 104b6cee71dSXin LI>0 string >\0 "%s" 105b6cee71dSXin LI60 string DataSprd QuickSheet PalmOS document 106b6cee71dSXin LI>0 string >\0 "%s" 107b6cee71dSXin LI60 string SM01SMem SuperMemo PalmOS document 108b6cee71dSXin LI>0 string >\0 "%s" 109b6cee71dSXin LI60 string TEXtTlDc TealDoc PalmOS document 110b6cee71dSXin LI>0 string >\0 "%s" 111b6cee71dSXin LI60 string InfoTlIf TealInfo PalmOS document 112b6cee71dSXin LI>0 string >\0 "%s" 113b6cee71dSXin LI60 string DataTlMl TealMeal PalmOS document 114b6cee71dSXin LI>0 string >\0 "%s" 115b6cee71dSXin LI60 string DataTlPt TealPaint PalmOS document 116b6cee71dSXin LI>0 string >\0 "%s" 117b6cee71dSXin LI60 string dataTDBP ThinkDB PalmOS document 118b6cee71dSXin LI>0 string >\0 "%s" 119b6cee71dSXin LI60 string TdatTide Tides PalmOS document 120b6cee71dSXin LI>0 string >\0 "%s" 121b6cee71dSXin LI60 string ToRaTRPW TomeRaider PalmOS document 122b6cee71dSXin LI>0 string >\0 "%s" 123b6cee71dSXin LI 124b6cee71dSXin LI# A GutenPalm zTXT etext for use on Palm Pilots (http://gutenpalm.sf.net) 125b6cee71dSXin LI# For version 1.xx zTXTs, outputs version and numbers of bookmarks and 126b6cee71dSXin LI# annotations. 127b6cee71dSXin LI# For other versions, just outputs version. 128b6cee71dSXin LI# 129b6cee71dSXin LI60 string zTXT A GutenPalm zTXT e-book 130b6cee71dSXin LI>0 string >\0 "%s" 131b6cee71dSXin LI>(0x4E.L) byte 0 132b6cee71dSXin LI>>(0x4E.L+1) byte x (v0.%02d) 133b6cee71dSXin LI>(0x4E.L) byte 1 134b6cee71dSXin LI>>(0x4E.L+1) byte x (v1.%02d) 135b6cee71dSXin LI>>>(0x4E.L+10) beshort >0 136b6cee71dSXin LI>>>>(0x4E.L+10) beshort <2 - 1 bookmark 137b6cee71dSXin LI>>>>(0x4E.L+10) beshort >1 - %d bookmarks 138b6cee71dSXin LI>>>(0x4E.L+14) beshort >0 139b6cee71dSXin LI>>>>(0x4E.L+14) beshort <2 - 1 annotation 140b6cee71dSXin LI>>>>(0x4E.L+14) beshort >1 - %d annotations 141b6cee71dSXin LI>(0x4E.L) byte >1 (v%d. 142b6cee71dSXin LI>>(0x4E.L+1) byte x %02d) 143b6cee71dSXin LI 144b6cee71dSXin LI# Palm OS .prc file types 145b6cee71dSXin LI60 string libr 146b6cee71dSXin LI# flags, only bit 0 or bit 6 14748c779cdSXin LI# https://en.wikipedia.org/wiki/PRC_%28Palm_OS%29 14848c779cdSXin LI# https://web.mit.edu/tytso/www/pilot/prc-format.html 149b6cee71dSXin LI>0x20 beshort&0xffbe 0 150b6cee71dSXin LI>>0 string >\0 Palm OS dynamic library data "%s" 151b6cee71dSXin LI60 string ptch Palm OS operating system patch data 152b6cee71dSXin LI>0 string >\0 "%s" 153b6cee71dSXin LI 154b6cee71dSXin LI# Mobipocket (www.mobipocket.com), donated by Carl Witty 155b6cee71dSXin LI60 string BOOKMOBI Mobipocket E-book 156b6cee71dSXin LI>0 string >\0 "%s" 157