forked from sumatrapdfreader/sumatrapdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPalmDbReader.h
More file actions
67 lines (55 loc) · 1.62 KB
/
Copy pathPalmDbReader.h
File metadata and controls
67 lines (55 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Copyright 2022 the SumatraPDF project authors (see AUTHORS file).
License: Simplified BSD (see COPYING.BSD) */
// http://en.wikipedia.org/wiki/PDB_(Palm_OS)
// http://wiki.mobileread.com/wiki/PDB
struct PdbHeader {
/* 31 chars + 1 null terminator */
char name[32]{};
u16 attributes = 0;
u16 version = 0;
u32 createTime = 0;
u32 modifyTime = 0;
u32 backupTime = 0;
u32 modificationNumber = 0;
u32 appInfoID = 0;
u32 sortInfoID = 0;
// 8 bytes in the file +1 for zero termination
char typeCreator[8 + 1]{};
u32 idSeed = 0;
u32 nextRecordList = 0;
u16 numRecords = 0;
};
struct PdbRecordHeader {
u32 offset = 0;
u8 flags = 0; // deleted, dirty, busy, secret, category
char uniqueID[3]{};
};
class PdbReader {
// content of pdb file
const u8* data = nullptr;
size_t dataSize = 0;
// offset of each pdb record within the file + a sentinel
// value equal to file size to simplify use
Vec<PdbRecordHeader> recInfos;
bool ParseHeader();
public:
PdbHeader hdr;
PdbReader() = default;
~PdbReader();
bool Parse(const ByteSlice&);
const char* GetDbType();
size_t GetRecordCount();
ByteSlice GetRecord(size_t recNo);
static PdbReader* CreateFromData(const ByteSlice&);
static PdbReader* CreateFromFile(const char* path);
static PdbReader* CreateFromStream(IStream* stream);
};
// stuff for mobi format
enum class PdbDocType {
Unknown,
Mobipocket,
PalmDoc,
TealDoc,
Plucker
};
PdbDocType GetPdbDocType(const char* typeCreator);