pdb

package
v0.0.0-...-7268a21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package pdb implements reading and writing PalmDB databases.

Index

Constants

View Source
const PalmDBHeaderLength = 78 // 0x4F
View Source
const RecordHeaderLength = 8 // 0x08

Variables

Endian describes the byte-order of integers in Palm databases.

Functions

This section is empty.

Types

type Database

type Database struct {
	Name    string
	Date    time.Time
	Records []Record
}

Database represents an in-memory Palm database.

func NewDatabase

func NewDatabase(name string, date time.Time) Database

NewDatabase creates an empty Palm database with name.

func ReadDatabase

func ReadDatabase(r io.Reader) (*Database, error)

ReadDatabase reads an uninterpreted Palm database from r.

func (*Database) AddRecord

func (d *Database) AddRecord(r Record) int

AddRecord adds a generic record to the Palm database.

Returns the index of the inserted record.

func (*Database) Idx

func (d *Database) Idx() int

Idx returns the index of the last inserted record.

func (*Database) ReplaceRecord

func (d *Database) ReplaceRecord(i int, r Record)

ReplaceRecord overrides the record at index i in the Palm database.

Panics if index i is out of range.

func (Database) Write

func (d Database) Write(w io.Writer) error

Write writes out the binary representation of the Palm database to w.

type PalmDBHeader

type PalmDBHeader struct {
	Name               [32]byte
	FileAttributes     uint16
	Version            uint16
	CreationTime       uint32 // Timestamp
	ModificationTime   uint32 // Timestamp
	BackupTime         uint32 // Timestamp
	ModificationNumber uint32
	AppInfo            uint32
	SortInfo           uint32
	Type               [4]byte // BOOK
	Creator            [4]byte // MOBI
	LastRecordUID      uint32
	NextRecordList     uint32 // Always zero
	NumRecords         uint16
}

func NewPalmDBHeader

func NewPalmDBHeader(name string, dateTime time.Time, numRecords uint16, lastRecordUID uint32) PalmDBHeader

type RawRecord

type RawRecord []byte

RawRecord represents an uninterpreted Palm database record.

func (RawRecord) Write

func (r RawRecord) Write(w io.Writer) error

type Record

type Record interface {
	Write(io.Writer) error
}

Record represents a generic Palm database record.

type RecordHeader

type RecordHeader struct {
	Offset    uint32
	Attribute byte
	Skip      byte
	UniqueID  uint16
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL