Diffstat (limited to 'noncore/apps/opie-reader/Aportis.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/Aportis.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/Aportis.h b/noncore/apps/opie-reader/Aportis.h new file mode 100644 index 0000000..08016f4 --- a/dev/null +++ b/noncore/apps/opie-reader/Aportis.h | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
2 | Derived from makedoc9 by Pat Beirne | ||
3 | */ | ||
4 | |||
5 | #ifndef __Aportis_h | ||
6 | #define __Aportis_h | ||
7 | |||
8 | #include "CExpander.h" | ||
9 | #include "pdb.h" | ||
10 | |||
11 | typedef UInt32 DWORD; | ||
12 | typedef UInt16 WORD; | ||
13 | |||
14 | #define DISP_BITS 11 | ||
15 | #define COUNT_BITS 3 | ||
16 | /* | ||
17 | // all numbers in these structs are big-endian, MAC format | ||
18 | struct tDocHeader { | ||
19 | char sName[32]; | ||
20 | DWORD dwUnknown1; | ||
21 | DWORD dwTime1; | ||
22 | DWORD dwTime2; | ||
23 | DWORD dwTime3; | ||
24 | DWORD dwLastSync; | ||
25 | DWORD ofsSort; | ||
26 | DWORD ofsCatagories; | ||
27 | DWORD dwCreator; | ||
28 | DWORD dwType; | ||
29 | DWORD dwUnknown2; | ||
30 | DWORD dwUnknown3; | ||
31 | WORD wNumRecs; | ||
32 | }; | ||
33 | */ | ||
34 | struct tDocRecord0 { | ||
35 | WORD wVersion;// 1=plain text, 2=compressed | ||
36 | WORD wSpare; | ||
37 | DWORD dwStoryLen; // in chars, when decompressed | ||
38 | WORD wNumRecs; // text records only; equals tDocHeader.wNumRecs-1 | ||
39 | WORD wRecSize; // usually 0x1000 | ||
40 | DWORD dwSpare2; | ||
41 | }; | ||
42 | |||
43 | ////////////// utilities ////////////////////////////////////// | ||
44 | |||
45 | inline WORD SwapWord(WORD r) | ||
46 | { | ||
47 | return (r>>8) + (r<<8); | ||
48 | } | ||
49 | |||
50 | inline DWORD SwapLong(DWORD r) | ||
51 | { | ||
52 | return ((r>>24) & 0xFF) + (r<<24) + ((r>>8) & 0xFF00) + ((r<<8) & 0xFF0000); | ||
53 | } | ||
54 | |||
55 | class Aportis : public CExpander, Cpdb { | ||
56 | DWORD dwLen; | ||
57 | WORD nRecs2; | ||
58 | DWORD dwTLen; | ||
59 | WORD nRecs; | ||
60 | WORD BlockSize; | ||
61 | DWORD dwRecLen; | ||
62 | int currentrec, currentpos; | ||
63 | unsigned int cbptr; | ||
64 | unsigned int outptr; | ||
65 | unsigned char circbuf[2048]; | ||
66 | char bCompressed; | ||
67 | public: | ||
68 | virtual void sizes(unsigned long& _file, unsigned long& _text) | ||
69 | { | ||
70 | _file = dwLen; | ||
71 | _text = dwTLen; | ||
72 | } | ||
73 | virtual bool hasrandomaccess() { return true; } | ||
74 | virtual ~Aportis() {} | ||
75 | Aportis(); | ||
76 | virtual int openfile(const char *src); | ||
77 | virtual int getch(); | ||
78 | virtual unsigned int locate(); | ||
79 | virtual void locate(unsigned int n); | ||
80 | virtual CList<Bkmk>* getbkmklist(); | ||
81 | private: | ||
82 | bool refreshbuffer(); | ||
83 | unsigned int GetBS(unsigned int bn); | ||
84 | }; | ||
85 | |||
86 | #endif | ||