summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/ztxt.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/ztxt.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/ztxt.h18
1 files changed, 4 insertions, 14 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,37 +1,36 @@
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 */
@@ -49,56 +48,47 @@ typedef struct zTXT_record0Type {
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
58struct zTXTbkmk 57struct 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
67const UInt32 ZTXT_ID = 0x5458547a; 66const UInt32 ZTXT_ID = 0x5458547a;
68 67
69class ztxt : public CExpander, Cpdb 68class 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();
82public: 81public:
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 {