00001 00002 /* 00003 * This header file defines some structures and types normally found in the 00004 * Palm SDK. However, I don't want to require the presense of the SDK for a 00005 * small utility since most Palm owners won't have it. 00006 * 00007 * $Id: pdb.h,v 1.8 2005/05/05 14:39:34 pohly Exp $ 00008 * 00009 */ 00010 00011 #ifndef __PDB_H__ 00012 #define __PDB_H__ 00013 00014 #ifndef _WINDOWS 00015 #include <netinet/in.h> 00016 #endif 00017 #include <stdio.h> 00018 00019 #include "CExpander.h" 00020 00021 /* Normal Palm typedefs */ 00022 #include "mytypes.h" 00023 typedef UInt32 LocalID; 00024 00025 /* Max length of DB name */ 00026 #define dmDBNameLength 0x20 00027 00028 00029 /************************************************************ 00030 * Structure of a Record entry 00031 *************************************************************/ 00032 typedef struct { 00033 LocalID localChunkID; // local chunkID of a record 00034 UInt8 attributes; // record attributes; 00035 UInt8 uniqueID[3]; // unique ID of record; should 00036 // not be 0 for a legal record. 00037 } RecordEntryType; 00038 00039 00040 /************************************************************ 00041 * Structure of a record list extension. This is used if all 00042 * the database record/resource entries of a database can't fit into 00043 * the database header. 00044 *************************************************************/ 00045 typedef struct { 00046 LocalID nextRecordListID; // local chunkID of next list 00047 UInt16 numRecords; // number of records in this list 00048 UInt16 firstEntry; // array of Record/Rsrc entries 00049 // starts here 00050 } RecordListType; 00051 00052 00053 /************************************************************ 00054 * Structure of a Database Header 00055 *************************************************************/ 00056 typedef struct { 00057 UInt8 name[dmDBNameLength]; // name of database 00058 UInt16 attributes; // database attributes 00059 UInt16 version; // version of database 00060 UInt32 creationDate; // creation date of database 00061 UInt32 modificationDate; // latest modification date 00062 UInt32 lastBackupDate; // latest backup date 00063 UInt32 modificationNumber; // modification number of database 00064 LocalID appInfoID; // application specific info 00065 LocalID sortInfoID; // app specific sorting info 00066 UInt32 type; // database type 00067 UInt32 creator; // database creator 00068 UInt32 uniqueIDSeed; // used to generate unique IDs. 00069 // Note that only the low order 00070 // 3 bytes of this is used (in 00071 // RecordEntryType.uniqueID). 00072 // We are keeping 4 bytes for 00073 // alignment purposes. 00074 RecordListType recordList; // first record list 00075 } DatabaseHdrType; 00076 00077 00078 class Cpdb : public CExpander 00079 { 00080 protected: 00081 size_t file_length; 00082 FILE* fin; 00083 size_t recordpos(int); 00084 size_t recordlength(int); 00085 void gotorecordnumber(int); 00086 DatabaseHdrType head; 00087 bool openpdbfile(const char* src); 00088 Cpdb() : fin(NULL) {} 00089 ~Cpdb(); 00090 #ifdef USEQPE 00091 void suspend(); 00092 void unsuspend(); 00093 #else 00094 void suspend() {} 00095 void unsuspend() {} 00096 #endif 00097 public: 00098 virtual void sizes(unsigned long& _file, unsigned long& _text) = 0; 00099 }; 00100 #endif 00101
1.4.2