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