PDB

From MobileRead

Jump to: navigation, search

PalmOS keeps all RAM storage in a database format. There is no file system in the RAM. When sync'd to a PC these databases will be saved in separate files and this is where the extension is added. All files in device RAM must be in Palm Database format, whether programs or data. The PDB files created for external storage are data files, which can contain arbitrary content.

Contents

[edit] Intro to the Database format

The first record of the database contains attribute information about the database, including the Creator ID, Type, Date Created, Date Modified, Launchable, database (book) name, and other data. Palm database files will generally have a .pdb extension but in some cases they may have a .prc extension (see PRC). The extension doesn't really matter on the Palm device so long as it is one of these two. The launcher will look inside the file to determine its type.

PalmOS programs are expected to have a unique four character "Creator" ID. All data files used by a program will have the same Creator ID as the program that uses them. PalmOS uses the Creator ID to know what data files are used by a program, and what program is used to open any particular data file.

[edit] Intro to PalmDOC

The default text file format on Palm devices is the PalmDOC file. This format was originally used by Aportis for their Aportis Reader product. It starts as a plain ASCII text file and is converted using a form of RLE compression to save space in RAM. Available doc readers decompress the file on the fly as they display it. The compression method is "asynchronous" -- it can be decompressed much faster than it can be compressed. Most doc files are created on desktops and synced to the target device, as compressing on the Palm is slow. RLE compression results in an approximate 40% reduction in file size.

Aportis went out of business years ago, and the Aportis Reader is no longer available, but the DOC format was reverse engineered and many reader products can view it. PalmDOC files have a Creator ID of REAd and a Type of TEXt. TealDOC also has a Type of TEXt and it is identical with PalmDOC.

[edit] Intro to zTXT

A newer plain text format for PalmOS is the zTXT file. zTXT files also start as plain ASCII text files, but are then compressed with gzip compatible compression, for an average reduction of 70%. Decompressing the files requires sysZlib.prc, a port of the Zlib library, implemented as a PalmOS shared library. sysZlib is currently used by the LionDoc, PalmFiction, Plucker, and WeaselReader document viewers.

If the PDB file has the Launchable attribute set, an icon for the file will appear in the launcher. The icon will be that of the program with the Creator ID of the PDB file. If the Creator app supports the PalmOS sysAppLaunchCmdOpenDB function, the user can tap on the document icon and invoke the owning program to view/edit the file, similar to the Way windows shortcuts work. Not all programs support this usage, so experimentation is needed to see if it will work.

[edit] Palm Database File Code

A table showing the decode of the various Palm database formats. Note that are are more database formats but the table is the ones likely to be encountered by users dealing with eBooks.

Reader
Type Code
Adobe Reader.pdfADBE
PalmDOC TEXtREAd
BDictyBVokBDIC
DB (Database program)DB99DBOS
eReaderPNRdPPrs
eReaderDataPPrs
FireViewer (ImageViewer) vIMGView
HanDBase PmDBPmDB
InfoView InfoINDB
iSilo ToGoToGo
iSilo 3 SDocSilX
JFile JbDbJBas
JFile Pro JfDbJFil
LIST DATALSdb
MobileDB Mdb1Mdb1
MobiPocket BOOKMOBI
Plucker DataPlkr
QuickSheet DataSprd
SuperMemoSM01SMem
TealDoc TEXtTlDc
TealInfo InfoTlIf
TealMeal DataTlMl
TealPaint DataTlPt
ThinkDB dataTDBP
Tides TdatTide
TomeRaider ToRaTRPW
WeaselzTXTGPlm
WordSmith BDOCWrdS

You can usually use a standard text editor to view the file even though it is a binary image. The file type will show up as clear text on the first line. The internal title for the book is also visible on the first line. Be careful not to modify the file when viewing it in this fashion.

[edit] Palm Database Format

A Palm Database is not a file when stored on the Palm in RAM. However it will be stored as a file if it is synced to a computer. The name of that file will always be the database name. The file will have the following content:

bytescontentcomments
32namedatabase name. This name is 0 terminated in the field and will be used as the file name on a computer. For eBooks this usually contains the title and may have the author depending on the length available.
2attributesbit field.

0x0002 Read-Only

0x0004 Dirty AppInfoArea

0x0008 Backup this database (i.e. no conduit exists)

0x0010 (16 decimal) Okay to install newer over existing copy, if present on PalmPilot

0x0020 (32 decimal) Force the PalmPilot to reset after this database is installed

0x0040 (64 decimal) Don't allow copy of file to be beamed to other Pilot.

2versionfile version
4creation dateNo. of seconds since start of January 1, 1904.
4modification date No. of seconds since start of January 1, 1904.
4last backup dateNo. of seconds since start of January 1, 1904.
4modificationNumber
4appInfoIDoffset to start of Application Info (if present) or null
4sortInfoIDoffset to start of Sort Info (if present) or null
4typeSee above table. (For Applications this data will be 'appl')
4creatorSee above table. This program will be launched if the file is tapped
4uniqueIDseedused internally to identify record
4nextRecordListIDOnly used when in-memory on Palm OS. Always set to zero in stored files.
2number of Recordsnumber of records in the file - N
8N record Info List
start of record info entry Repeat N times to end of record info entry
4record Data Offset the offset from the start of the PDB of this record
1record Attributesbit field. The least significant four bits are used to represent the category values. (whatever that means!)

0x10 (16 decimal) Secret record bit.

0x20 (32 decimal) Record in use (busy bit).

0x40 (64 decimal) Dirty record bit.

0x80 (128, unsigned decimal) Delete record on next HotSync.

3UniqueIDThe unique ID for this record. Often just a sequential count from 0
end of record info entry
2?Gap to datatraditionally 2 zero bytes to Info or raw data
?RecordsThe actual data in the file. AppInfoArea (if present), SortInfoArea (if present) and then records sequentially

[edit] PDB Times

The original PDB format used times counting in seconds from 1st January, 1904. This is the base time used by the original Mac OS, and there were close links between Palm OS and Mac OS. Using an unsigned 32-bit integer this will overflow sometime in 2040.

However, the PDB tool written for Perl says that the time should be counted from 1st January 1970 (the Unix base time), and uses a signed 32-bit integer which will overflow sometime in 2038.

This conflict is unfortunate, but there's a simple way to sort out what's been done in a file you are examining.

If the time has the top bit set, it's an unsigned 32-bit number counting from 1st Jan 1904
If the time has the top bit clear, it's a signed 32-bit number counting from 1st Jan 1970.

This can be stated this with some confidence, as otherwise the time would be before 1972 or before 1970, depending on the interpretation and the PDB format wasn't around then.

For either system, overflow will occur in around 30 years time. Hopefully by then everyone will be on some properly documented eBook standard.

Personal tools
MobileRead Networks