author | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
---|---|---|
committer | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
commit | 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 (patch) (unidiff) | |
tree | 96e66fdc18dca4d4ab8611133e072f57dea224b9 /noncore/apps/opie-reader/Reb.h | |
parent | 279fc4fd1986074acbadd3a8e86fcf3968a8dd5c (diff) | |
download | opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.zip opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.gz opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.bz2 |
new opie-reader sources with support for ArriereGo, Reb input and flite output plugins
Diffstat (limited to 'noncore/apps/opie-reader/Reb.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/Reb.h | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/Reb.h b/noncore/apps/opie-reader/Reb.h new file mode 100644 index 0000000..f268eb0 --- a/dev/null +++ b/noncore/apps/opie-reader/Reb.h | |||
@@ -0,0 +1,157 @@ | |||
1 | #ifndef __REB_H | ||
2 | #define __REB_H | ||
3 | #include <stdio.h> | ||
4 | #include <zlib.h> | ||
5 | #include <sys/stat.h> | ||
6 | #ifdef USEQPE | ||
7 | #include <qpe/global.h> | ||
8 | #endif | ||
9 | #include <qmap.h> | ||
10 | |||
11 | #include "CExpander.h" | ||
12 | #include <zlib.h> | ||
13 | |||
14 | #ifdef _WINDOWS | ||
15 | #include <winsock.h> | ||
16 | #endif | ||
17 | |||
18 | #include "mytypes.h" | ||
19 | |||
20 | /* | ||
21 | struct Reb_Segment | ||
22 | { | ||
23 | UInt32 len, page, flags; | ||
24 | Reb_Segment(UInt32 _len = 0, UInt32 _page = 0, UInt32 _flags = 0) | ||
25 | : | ||
26 | len(_len), page(_page), flags(_flags) | ||
27 | {} | ||
28 | }; | ||
29 | */ | ||
30 | |||
31 | class CReb; | ||
32 | |||
33 | class RBPage | ||
34 | { | ||
35 | UInt32 filepos; | ||
36 | UInt32 pageoffset; | ||
37 | UInt32 nochunks, currentchunk, chunkpos, chunklen, chunkoffset; | ||
38 | UInt32 m_pagelen, m_blocksize; | ||
39 | bool m_Compressed; | ||
40 | void readchunk(); | ||
41 | UInt32* chunklist; | ||
42 | UInt8* chunk; | ||
43 | FILE* fin; | ||
44 | UInt32 m_pageno; | ||
45 | void initpage(UInt32 pos, size_t _cp, bool _isCompressed, UInt32 _len); | ||
46 | size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t); | ||
47 | public: | ||
48 | RBPage() : pageoffset(0), nochunks(0), currentchunk(0), chunkpos(0), chunkoffset(0), m_pagelen(0), m_Compressed(false), chunklist(NULL), chunk(NULL) {} | ||
49 | ~RBPage() | ||
50 | { | ||
51 | if (chunk != NULL) delete [] chunk; | ||
52 | if (chunklist != NULL) delete [] chunklist; | ||
53 | } | ||
54 | int getch(CReb*); | ||
55 | unsigned short int getuint(CReb*); | ||
56 | int getint(CReb*); | ||
57 | void startpage(UInt32, UInt32, bool, UInt32); | ||
58 | UInt32 pageno() { return m_pageno; } | ||
59 | UInt32 offset() { return pageoffset+chunkoffset; } | ||
60 | void setoffset(UInt32, size_t, bool, UInt32, UInt32); | ||
61 | void init(FILE* _f, UInt32 _bs, size_t (*_decompress)(UInt8*, size_t, UInt8*, size_t)) | ||
62 | { | ||
63 | fin = _f; | ||
64 | m_blocksize = _bs; | ||
65 | chunk = new UInt8[m_blocksize]; | ||
66 | m_decompress = _decompress; | ||
67 | } | ||
68 | UInt32 length() { return m_pagelen; } | ||
69 | UInt32 m_startoff, m_endoff; | ||
70 | }; | ||
71 | |||
72 | struct Page_detail | ||
73 | { | ||
74 | UInt32 pagestart, len, flags; | ||
75 | Page_detail(UInt32 _ps = 0, UInt32 _l = 0, UInt32 _f = 0) | ||
76 | : | ||
77 | pagestart(_ps), len(_l), flags(_f) | ||
78 | { | ||
79 | } | ||
80 | }; | ||
81 | |||
82 | struct ParaRef | ||
83 | { | ||
84 | int pos, tag; | ||
85 | ParaRef(int _pos = 0, int _tag = 0) : pos(_pos), tag(_tag) | ||
86 | { | ||
87 | //qDebug("New PARAREF:%d, %d", pos, tag); | ||
88 | } | ||
89 | }; | ||
90 | |||
91 | class CReb : public CExpander | ||
92 | { | ||
93 | //friend class RBPage; | ||
94 | size_t (*m_decompress)(UInt8*, size_t, UInt8*, size_t); | ||
95 | RBPage currentpage; | ||
96 | UInt32 nopages, m_homepage, m_blocksize; | ||
97 | |||
98 | QMap<QString, UInt32> m_index; | ||
99 | |||
100 | size_t file_length, text_length; | ||
101 | UInt32 toc; | ||
102 | FILE* fin; | ||
103 | void home(); | ||
104 | void startpage(UInt32); | ||
105 | void startpage(UInt32, bool, UInt32); | ||
106 | void readchunk(); | ||
107 | QString tagstring; | ||
108 | UInt32 tagoffset; | ||
109 | UInt32 pagelength(UInt32); | ||
110 | QImage* getPicture(const QString& ref); | ||
111 | UInt32 page2pos(UInt32); | ||
112 | //UInt32 m_pagelen; | ||
113 | UInt32* m_indexpages; | ||
114 | Page_detail* m_pagedetails; | ||
115 | // void UnZip(size_t bsize); | ||
116 | QMap<QString, int> names; | ||
117 | QString* tags; | ||
118 | ParaRef* paras; | ||
119 | UInt32* joins; | ||
120 | UInt32 nojoins; | ||
121 | UInt32 noparas; | ||
122 | bool m_binary; | ||
123 | void readindex(UInt32); | ||
124 | public: | ||
125 | bool findanchor(const QString& _info); | ||
126 | QString about() { return QString("REB codec (c) Tim Wentford"); } | ||
127 | bool getFile(const QString& href, const QString& nm); | ||
128 | void start2endSection(); | ||
129 | void sizes(unsigned long& _file, unsigned long& _text) | ||
130 | { | ||
131 | _file = file_length; | ||
132 | _text = text_length; | ||
133 | } | ||
134 | bool hasrandomaccess() { return true; } | ||
135 | virtual ~CReb(); | ||
136 | CReb(); | ||
137 | int OpenFile(const char *src); | ||
138 | int getch(); | ||
139 | unsigned int locate(); | ||
140 | void locate(unsigned int n); | ||
141 | CList<Bkmk>* getbkmklist(); | ||
142 | MarkupType PreferredMarkup() | ||
143 | { | ||
144 | return cCHM; | ||
145 | } | ||
146 | #ifdef USEQPE | ||
147 | void suspend(); | ||
148 | void unsuspend(); | ||
149 | #else | ||
150 | void suspend() {} | ||
151 | void unsuspend() {} | ||
152 | #endif | ||
153 | }; | ||
154 | |||
155 | #endif | ||
156 | |||
157 | |||