Diffstat (limited to 'noncore/apps/opie-reader/pdb.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/pdb.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/pdb.h b/noncore/apps/opie-reader/pdb.h new file mode 100644 index 0000000..143c5cb --- a/dev/null +++ b/noncore/apps/opie-reader/pdb.h | |||
@@ -0,0 +1,90 @@ | |||
1 | |||
2 | /* | ||
3 | * This header file defines some structures and types normally found in the | ||
4 | * Palm SDK. However, I don't want to require the presense of the SDK for a | ||
5 | * small utility since most Palm owners won't have it. | ||
6 | * | ||
7 | * $Id$ | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | #ifndef __PDB_H__ | ||
12 | #define __PDB_H__ | ||
13 | |||
14 | #include <netinet/in.h> | ||
15 | #include <stdio.h> | ||
16 | |||
17 | /* Normal Palm typedefs */ | ||
18 | typedef unsigned char UInt8; | ||
19 | typedef unsigned short UInt16; | ||
20 | typedef unsigned long UInt32; | ||
21 | typedef UInt32 LocalID; | ||
22 | |||
23 | /* Max length of DB name */ | ||
24 | #define dmDBNameLength 0x20 | ||
25 | |||
26 | |||
27 | /************************************************************ | ||
28 | * Structure of a Record entry | ||
29 | *************************************************************/ | ||
30 | typedef struct { | ||
31 | LocalID localChunkID; // local chunkID of a record | ||
32 | UInt8 attributes; // record attributes; | ||
33 | UInt8 uniqueID[3]; // unique ID of record; should | ||
34 | // not be 0 for a legal record. | ||
35 | } RecordEntryType; | ||
36 | |||
37 | |||
38 | /************************************************************ | ||
39 | * Structure of a record list extension. This is used if all | ||
40 | * the database record/resource entries of a database can't fit into | ||
41 | * the database header. | ||
42 | *************************************************************/ | ||
43 | typedef struct { | ||
44 | LocalID nextRecordListID; // local chunkID of next list | ||
45 | UInt16 numRecords; // number of records in this list | ||
46 | UInt16 firstEntry; // array of Record/Rsrc entries | ||
47 | // starts here | ||
48 | } RecordListType; | ||
49 | |||
50 | |||
51 | /************************************************************ | ||
52 | * Structure of a Database Header | ||
53 | *************************************************************/ | ||
54 | typedef struct { | ||
55 | UInt8 name[dmDBNameLength]; // name of database | ||
56 | UInt16 attributes; // database attributes | ||
57 | UInt16 version; // version of database | ||
58 | UInt32 creationDate; // creation date of database | ||
59 | UInt32 modificationDate; // latest modification date | ||
60 | UInt32 lastBackupDate; // latest backup date | ||
61 | UInt32 modificationNumber; // modification number of database | ||
62 | LocalID appInfoID; // application specific info | ||
63 | LocalID sortInfoID; // app specific sorting info | ||
64 | UInt32 type; // database type | ||
65 | UInt32 creator; // database creator | ||
66 | UInt32 uniqueIDSeed; // used to generate unique IDs. | ||
67 | // Note that only the low order | ||
68 | // 3 bytes of this is used (in | ||
69 | // RecordEntryType.uniqueID). | ||
70 | // We are keeping 4 bytes for | ||
71 | // alignment purposes. | ||
72 | RecordListType recordList; // first record list | ||
73 | } DatabaseHdrType; | ||
74 | |||
75 | |||
76 | class Cpdb | ||
77 | { | ||
78 | protected: | ||
79 | size_t file_length; | ||
80 | FILE* fin; | ||
81 | size_t recordpos(int); | ||
82 | size_t recordlength(int); | ||
83 | void gotorecordnumber(int); | ||
84 | DatabaseHdrType head; | ||
85 | bool openfile(const char* src); | ||
86 | Cpdb() : fin(NULL) {} | ||
87 | ~Cpdb() { if (fin != NULL) fclose(fin); } | ||
88 | }; | ||
89 | #endif | ||
90 | |||