summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/ztxt.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/ztxt.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/ztxt.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/ztxt.cpp b/noncore/apps/opie-reader/ztxt.cpp
index c30e4fd..289b13a 100644
--- a/noncore/apps/opie-reader/ztxt.cpp
+++ b/noncore/apps/opie-reader/ztxt.cpp
@@ -1,27 +1,29 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <string.h> 2#include <string.h>
3#include "ztxt.h" 3#include "ztxt.h"
4#include "my_list.h"
5#include "Bkmks.h"
4 6
5ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ } 7ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ }
6 8
7 9
8int ztxt::openfile(const char *src) 10int ztxt::openfile(const char *src)
9{ 11{
10 if (!Cpdb::openfile(src)) 12 if (!Cpdb::openfile(src))
11 { 13 {
12 return -1; 14 return -1;
13 } 15 }
14 16
15//printf("Okay %u\n", 4); 17//printf("Okay %u\n", 4);
16 18
17 if (head.type != ZTXT_ID) return -1; 19 if (head.type != ZTXT_ID) return -1;
18 20
19 gotorecordnumber(0); 21 gotorecordnumber(0);
20 fread(&hdr0, 1, sizeof(hdr0), fin); 22 fread(&hdr0, 1, sizeof(hdr0), fin);
21//printf("Okay %u\n", 5); 23//printf("Okay %u\n", 5);
22 buffersize = ntohl(hdr0.size); 24 buffersize = ntohl(hdr0.size);
23 compressedtextbuffer = new UInt8[buffersize]; 25 compressedtextbuffer = new UInt8[buffersize];
24 expandedtextbuffer = new UInt8[buffersize]; 26 expandedtextbuffer = new UInt8[buffersize];
25//printf("Okay %u\n", 6); 27//printf("Okay %u\n", 6);
26 28
27 home(); 29 home();
@@ -131,29 +133,29 @@ void ztxt::home()
131// printf("Inflate : %d\n", ret); 133// printf("Inflate : %d\n", ret);
132 bufferpos = 0; 134 bufferpos = 0;
133 bufferrec = 1; 135 bufferrec = 1;
134 currentpos = 0; 136 currentpos = 0;
135 buffercontent = buffersize - zstream.avail_out; 137 buffercontent = buffersize - zstream.avail_out;
136 //printf("buffercontent:%u\n", buffercontent); 138 //printf("buffercontent:%u\n", buffercontent);
137} 139}
138 140
139CList<Bkmk>* ztxt::getbkmklist() 141CList<Bkmk>* ztxt::getbkmklist()
140{ 142{
141 UInt16 recno = ntohs(hdr0.bookmarkRecord); 143 UInt16 recno = ntohs(hdr0.bookmarkRecord);
142 144
143// printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); 145// printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks));
144 146
145 if (recno == 0) return NULL; 147 if (recno == 0) return NULL;
146 148
147 CList<Bkmk>* t = new CList<Bkmk>; 149 CList<Bkmk>* t = new CList<Bkmk>;
148 size_t cur = ftell(fin); 150 size_t cur = ftell(fin);
149 gotorecordnumber(recno); 151 gotorecordnumber(recno);
150 for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) 152 for (int i = 0; i < ntohs(hdr0.numBookmarks); i++)
151 { 153 {
152 zTXTbkmk bkmk; 154 zTXTbkmk bkmk;
153 if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; 155 if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break;
154// printf("Bookmark number:%d:%.20s\n", i, bkmk.title); 156// printf("Bookmark number:%d:%.20s\n", i, bkmk.title);
155 t->push_back(Bkmk(bkmk.title, ntohl(bkmk.offset))); 157 t->push_back(Bkmk(bkmk.title, NULL, ntohl(bkmk.offset)));
156 } 158 }
157 fseek(fin, cur, SEEK_SET); 159 fseek(fin, cur, SEEK_SET);
158 return t; 160 return t;
159} 161}