Diffstat (limited to 'noncore/apps/opie-reader/ztxt.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/ztxt.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/noncore/apps/opie-reader/ztxt.h b/noncore/apps/opie-reader/ztxt.h index 6352cfc..7be45c0 100644 --- a/noncore/apps/opie-reader/ztxt.h +++ b/noncore/apps/opie-reader/ztxt.h | |||
@@ -1,103 +1,105 @@ | |||
1 | #ifndef __ztxt_h | 1 | #ifndef __ztxt_h |
2 | #define __ztxt_h | 2 | #define __ztxt_h |
3 | 3 | ||
4 | #include "CExpander.h" | 4 | #include "CExpander.h" |
5 | #include "zlib/zlib.h" | 5 | #include <zlib.h> |
6 | //#include <zlib.h> | ||
7 | #include "pdb.h" | 6 | #include "pdb.h" |
8 | /* | 7 | /* |
9 | * Stuff common to both Weasel Reader and makeztxt | 8 | * Stuff common to both Weasel Reader and makeztxt |
10 | * | 9 | * |
11 | * $Id$ | 10 | * $Id$ |
12 | * | 11 | * |
13 | */ | 12 | */ |
14 | 13 | ||
15 | #ifndef _WEASEL_COMMON_H_ | 14 | #ifndef _WEASEL_COMMON_H_ |
16 | #define _WEASEL_COMMON_H_ 1 | 15 | #define _WEASEL_COMMON_H_ 1 |
17 | 16 | ||
18 | 17 | ||
19 | /* Padding is no good */ | 18 | /* Padding is no good */ |
20 | #if defined(__GNUC__) && defined(__UNIX__) | 19 | #if defined(__GNUC__) && defined(__UNIX__) |
21 | # pragma pack(2) | 20 | # pragma pack(2) |
22 | #endif | 21 | #endif |
23 | 22 | ||
24 | /* The default creator is Weasel Reader 'GPlm' */ | 23 | /* The default creator is Weasel Reader 'GPlm' */ |
25 | #define GPLM_CREATOR_ID "GPlm" | 24 | #define GPLM_CREATOR_ID "GPlm" |
26 | /* Databases of type 'zTXT' */ | 25 | /* Databases of type 'zTXT' */ |
27 | #define ZTXT_TYPE_ID "zTXT" | 26 | #define ZTXT_TYPE_ID "zTXT" |
28 | /* Size of one database record */ | 27 | /* Size of one database record */ |
29 | #define RECORD_SIZE 8192 | 28 | #define RECORD_SIZE 8192 |
30 | /* Allow largest WBIT size for data. Lower with command line options | 29 | /* Allow largest WBIT size for data. Lower with command line options |
31 | in makeztxt */ | 30 | in makeztxt */ |
32 | #define MAXWBITS 15 | 31 | #define MAXWBITS 15 |
33 | /* Max length for a bookmark/annotation title */ | 32 | /* Max length for a bookmark/annotation title */ |
34 | #define MAX_BMRK_LENGTH 20 | 33 | #define MAX_BMRK_LENGTH 20 |
35 | 34 | ||
36 | 35 | ||
37 | /***************************************************** | 36 | /***************************************************** |
38 | * This is the zTXT document header (record #0) * | 37 | * This is the zTXT document header (record #0) * |
39 | * ----zTXT version 1.42---- * | 38 | * ----zTXT version 1.42---- * |
40 | *****************************************************/ | 39 | *****************************************************/ |
41 | typedef struct zTXT_record0Type { | 40 | typedef struct zTXT_record0Type { |
42 | UInt16 version; /* zTXT format version */ | 41 | UInt16 version; /* zTXT format version */ |
43 | UInt16 numRecords; /* Number of data (TEXT) records */ | 42 | UInt16 numRecords; /* Number of data (TEXT) records */ |
44 | UInt32 size; /* Size in bytes of uncomp. data */ | 43 | UInt32 size; /* Size in bytes of uncomp. data */ |
45 | UInt16 recordSize; /* Size of a single data record */ | 44 | UInt16 recordSize; /* Size of a single data record */ |
46 | UInt16 numBookmarks; /* Number of bookmarks in DB */ | 45 | UInt16 numBookmarks; /* Number of bookmarks in DB */ |
47 | UInt16 bookmarkRecord; /* Record containing bookmarks */ | 46 | UInt16 bookmarkRecord; /* Record containing bookmarks */ |
48 | UInt16 numAnnotations; /* Number of annotation records */ | 47 | UInt16 numAnnotations; /* Number of annotation records */ |
49 | UInt16 annotationRecord; /* Record # of annotation index */ | 48 | UInt16 annotationRecord; /* Record # of annotation index */ |
50 | UInt8 randomAccess; /* 1 if compressed w/Z_FULL_FLUSH */ | 49 | UInt8 randomAccess; /* 1 if compressed w/Z_FULL_FLUSH */ |
51 | UInt8 padding[0x20 - 19]; /* Pad to a size of 0x20 bytes */ | 50 | UInt8 padding[0x20 - 19]; /* Pad to a size of 0x20 bytes */ |
52 | } zTXT_record0; | 51 | } zTXT_record0; |
53 | 52 | ||
54 | struct zTXTbkmk | 53 | struct zTXTbkmk |
55 | { | 54 | { |
56 | UInt32 offset; | 55 | UInt32 offset; |
57 | tchar title[MAX_BMRK_LENGTH]; | 56 | tchar title[MAX_BMRK_LENGTH]; |
58 | }; | 57 | }; |
59 | 58 | ||
60 | #endif | 59 | #endif |
61 | 60 | ||
62 | 61 | ||
63 | const UInt32 ZTXT_ID = 0x5458547a; | 62 | const UInt32 ZTXT_ID = 0x5458547a; |
64 | 63 | ||
65 | class ztxt : public CExpander, Cpdb | 64 | class ztxt : public CExpander, Cpdb |
66 | { | 65 | { |
67 | bool bInit; | 66 | bool bInit; |
68 | UInt32 buffersize; | 67 | UInt32 buffersize; |
69 | UInt32 buffercontent; | 68 | UInt32 buffercontent; |
70 | UInt8* expandedtextbuffer; | 69 | UInt8* expandedtextbuffer; |
71 | UInt8* compressedtextbuffer; | 70 | UInt8* compressedtextbuffer; |
72 | z_stream zstream; | 71 | z_stream zstream; |
73 | size_t bufferpos; | 72 | size_t bufferpos; |
74 | UInt16 bufferrec; | 73 | UInt16 bufferrec; |
75 | zTXT_record0 hdr0; | 74 | zTXT_record0 hdr0; |
76 | size_t currentpos; | 75 | size_t currentpos; |
77 | void home(); | 76 | void home(); |
78 | public: | 77 | public: |
79 | virtual void sizes(unsigned long& _file, unsigned long& _text) | 78 | virtual void sizes(unsigned long& _file, unsigned long& _text) |
80 | { | 79 | { |
81 | _file = file_length; | 80 | _file = file_length; |
82 | _text = ntohl(hdr0.size); | 81 | _text = ntohl(hdr0.size); |
83 | } | 82 | } |
84 | virtual bool hasrandomaccess() { return (hdr0.randomAccess != 0); } | 83 | virtual bool hasrandomaccess() { return (hdr0.randomAccess != 0); } |
85 | virtual ~ztxt() | 84 | virtual ~ztxt() |
86 | { | 85 | { |
87 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; | 86 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; |
88 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; | 87 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; |
89 | if (bInit) | 88 | if (bInit) |
90 | { | 89 | { |
91 | inflateEnd(&zstream); | 90 | inflateEnd(&zstream); |
92 | } | 91 | } |
93 | } | 92 | } |
94 | ztxt(); | 93 | ztxt(); |
95 | virtual int openfile(const char *src); | 94 | virtual int openfile(const char *src); |
96 | virtual int getch(); | 95 | virtual int getch(); |
97 | virtual unsigned int locate(); | 96 | virtual unsigned int locate(); |
98 | virtual void locate(unsigned int n); | 97 | virtual void locate(unsigned int n); |
99 | virtual CList<Bkmk>* getbkmklist(); | 98 | virtual CList<Bkmk>* getbkmklist(); |
99 | virtual MarkupType PreferredMarkup() | ||
100 | { | ||
101 | return cTEXT; | ||
102 | } | ||
100 | }; | 103 | }; |
101 | 104 | ||
102 | #endif | 105 | #endif |
103 | |||