#ifndef FLIPDB_H #define FLIPDB_H #define flipCreatorId 'PILF' /* database name used if we create a new database */ #define flipDbName "Words-FLIP" #define flipDbType 'DATA' /* * Types and structures. */ /* Structure of records in memory (not in database). */ typedef struct { UInt8 known; MemHandle word1; MemHandle word2; Boolean valid; } UnpackedWord; /* Structure of records in the database. */ typedef struct { UInt8 known; char word1[1]; // two null-terminated strings after each other } PackedWord; /* Meta-data about a database */ typedef struct { UInt16 cardNo; LocalID dbID; char name[32]; } FlipDBInfo; #define INVALID_UNPACKED_WORD { known: false, word1: NULL, word2: NULL, valid: false, } extern UInt16 GetNumWords(DmOpenRef dbR); extern char *GetWordPtr(PackedWord * packed, Boolean whichWord); extern UInt8 IsKnown(DmOpenRef dbR, UInt16 index); extern void SetKnown(DmOpenRef dbR, UInt16 index, UInt8 known); extern void SetAllKnown(DmOpenRef dbR, UInt8 known); extern void UnpackWord(MemHandle recordH, UnpackedWord * unpacked); extern void FreeUnpackedWord(UnpackedWord * unpacked); extern void PackWord(MemHandle recordH, UnpackedWord * unpacked); extern Err FlipNumDatabases(UInt16 * numDBs); extern Err FlipGetDatabase(UInt16 index, FlipDBInfo * info); extern Err FlipGetOpenDatabase(DmOpenRef dbR, FlipDBInfo * info); extern Err FlipGetDatabaseIndex(UInt16 * index, FlipDBInfo * info); extern Err SwitchDB(DmOpenRef *dbRPtr, FlipDBInfo *dbInfo, UInt16 index); extern Err AddWord(DmOpenRef dbR, UInt16 * indexPtr, char *word1, char *word2); extern Err RemoveWord(DmOpenRef dbR, UInt16 index); extern Err CreateEmptyDB(void); #endif