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