DB Database Format
------------------

The first database format that DB used was not designed to be
extensible. Any additions to the format would break compatibility for
previous versions. The new database format for DB is designed to be
extensible so that any additional data added to the application
information block will not break databases without that data.


Application Information Block
-----------------------------

The application information block starts with a small header defining
some values that all databases will have. The header is:

  UInt16 flags
  UInt16 num_fields

The remainder of the data in the app info block is stored as
"chunks". Each chunk consists of a simple header followed by the chunk
data itself. All of the chunks sit contiguously in the app info
block. The header of a chunk is:

  UInt16 chunk_type
  UInt16 data_size

The next section describes each chunk. For each chunk, the name and
chunk_type value are given followed by a brief description of the
chunk and its data.

CHUNK_FIELD_NAMES (0)

This chunk holds the name of each field in the database. The chunk
data consists of a series of zero-terminated strings, one for each
name.

CHUNK_FIELD_TYPES (1)

This chunk holds the type of each field in the database. The chunk
data consists of a UInt16 for each field describing the field type:

  0 - String
  1 - Boolean
  2 - Integer
  3 - Date
  4 - Time

CHUNK_LISTVIEW_DEFINITION (64)

This chunk defines a set of columns to be displayed in the list view
mode. Each column is defined by the width of the column in the display
as well as the field from the database that will be displayed. The
chunk data consists of a short header follwed by an entry for each column:

  UInt16 flags
  UInt16 number_of_columns
  char name[32]

  UInt16 field_number
  UInt16 column_width

CHUNK_LISTVIEW_OPTIONS (65)

This chunk stores several of the options that the list view
uses. There should be exactly one copy of this chunk in any DB
database. Its format is as follows:

  UInt16 active_view
  UInt16 first_visible_record

CHUNK_LFIND_OPTIONS (128)

This chunk stores options for the local find dialog. There should be
exactly one copy of this chunk in any DB database. Its format is as
follows:

  UInt16 flags


Record Structure
----------------

Each record in a DB-format database consists of an offset table
followed by the actual field data. The offset table exists so that it
is extremely easy to find a field in the record.

The offset table consists of one 16-bit unsigned integer (called
UInt16 in the PalmOS SDK) for each field. Each entry in the array is
the offset of the start of the corresponding field.

The format of each field type is:

FIELD_TYPE_STRING (0)

This field type is stored as a null-terminated string.

FIELD_TYPE_BOOLEAN (1)

  UInt8 value;

This field type stores simple flag values. For true, value will be
1. For false, value will be 0.

FIELD_TYPE_INTEGER (2)

  Int32 value;

This field type is a 32-bit signed integer.

FIELD_TYPE_DATE (3)

  UInt16 year;
  UInt8  month;
  UInt8  day;

FIELD_TYPE_TIME (4)

  UInt8 hour;
  UInt8 minute;
