Diffstat (limited to 'noncore/apps/opie-reader/ztxt.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/ztxt.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/noncore/apps/opie-reader/ztxt.cpp b/noncore/apps/opie-reader/ztxt.cpp index 8091d32..79c5fa4 100644 --- a/noncore/apps/opie-reader/ztxt.cpp +++ b/noncore/apps/opie-reader/ztxt.cpp | |||
@@ -1,36 +1,37 @@ | |||
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" | 4 | #include "my_list.h" |
5 | #include "Bkmks.h" | 5 | #include "Bkmks.h" |
6 | #include "static.h" | ||
6 | 7 | ||
7 | ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ } | 8 | ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ } |
8 | 9 | ||
9 | 10 | ||
10 | int ztxt::OpenFile(const char *src) | 11 | int ztxt::OpenFile(const char *src) |
11 | { | 12 | { |
12 | if (!Cpdb::openfile(src)) | 13 | if (!Cpdb::openpdbfile(src)) |
13 | { | 14 | { |
14 | return -1; | 15 | return -1; |
15 | } | 16 | } |
16 | 17 | ||
17 | //printf("Okay %u\n", 4); | 18 | //printf("Okay %u\n", 4); |
18 | 19 | ||
19 | if (head.type != ZTXT_ID) return -1; | 20 | if (head.type != ZTXT_ID) return -1; |
20 | 21 | ||
21 | gotorecordnumber(0); | 22 | gotorecordnumber(0); |
22 | fread(&hdr0, 1, sizeof(hdr0), fin); | 23 | fread(&hdr0, 1, sizeof(hdr0), fin); |
23 | //printf("Okay %u\n", 5); | 24 | //printf("Okay %u\n", 5); |
24 | buffersize = ntohl(hdr0.size); | 25 | buffersize = ntohl(hdr0.size); |
25 | compressedtextbuffer = new UInt8[buffersize]; | 26 | compressedtextbuffer = new UInt8[buffersize]; |
26 | expandedtextbuffer = new UInt8[buffersize]; | 27 | expandedtextbuffer = new UInt8[buffersize]; |
27 | //printf("Okay %u\n", 6); | 28 | //printf("Okay %u\n", 6); |
28 | 29 | ||
29 | home(); | 30 | home(); |
30 | //printf("Okay %u\n", 7); | 31 | //printf("Okay %u\n", 7); |
31 | 32 | ||
32 | // printf("Returning 0\n"); | 33 | // printf("Returning 0\n"); |
33 | 34 | ||
34 | return 0; | 35 | return 0; |
35 | } | 36 | } |
36 | 37 | ||
@@ -133,29 +134,41 @@ void ztxt::home() | |||
133 | // printf("Inflate : %d\n", ret); | 134 | // printf("Inflate : %d\n", ret); |
134 | bufferpos = 0; | 135 | bufferpos = 0; |
135 | bufferrec = 1; | 136 | bufferrec = 1; |
136 | currentpos = 0; | 137 | currentpos = 0; |
137 | buffercontent = buffersize - zstream.avail_out; | 138 | buffercontent = buffersize - zstream.avail_out; |
138 | //printf("buffercontent:%u\n", buffercontent); | 139 | //printf("buffercontent:%u\n", buffercontent); |
139 | } | 140 | } |
140 | 141 | ||
141 | CList<Bkmk>* ztxt::getbkmklist() | 142 | CList<Bkmk>* ztxt::getbkmklist() |
142 | { | 143 | { |
143 | UInt16 recno = ntohs(hdr0.bookmarkRecord); | 144 | UInt16 recno = ntohs(hdr0.bookmarkRecord); |
144 | 145 | ||
145 | // printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); | 146 | // printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); |
146 | 147 | ||
147 | if (recno == 0) return NULL; | 148 | if (recno == 0) return NULL; |
148 | 149 | ||
149 | CList<Bkmk>* t = new CList<Bkmk>; | 150 | CList<Bkmk>* t = new CList<Bkmk>; |
150 | size_t cur = ftell(fin); | 151 | size_t cur = ftell(fin); |
151 | gotorecordnumber(recno); | 152 | gotorecordnumber(recno); |
152 | for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) | 153 | for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) |
153 | { | 154 | { |
154 | zTXTbkmk bkmk; | 155 | zTXTbkmk bkmk; |
155 | if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; | 156 | if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; |
156 | // printf("Bookmark number:%d:%.20s\n", i, bkmk.title); | 157 | // printf("Bookmark number:%d:%.20s\n", i, bkmk.title); |
157 | t->push_back(Bkmk(bkmk.title, NULL, ntohl(bkmk.offset))); | 158 | tchar title[MAX_BMRK_LENGTH]; |
159 | for (int j = 0; j < MAX_BMRK_LENGTH; j++) | ||
160 | { | ||
161 | title[j] = bkmk.title[j]; | ||
162 | } | ||
163 | t->push_back(Bkmk(title, NULL, ntohl(bkmk.offset))); | ||
158 | } | 164 | } |
159 | fseek(fin, cur, SEEK_SET); | 165 | fseek(fin, cur, SEEK_SET); |
160 | return t; | 166 | return t; |
161 | } | 167 | } |
168 | |||
169 | #ifndef __STATIC | ||
170 | extern "C" | ||
171 | { | ||
172 | CExpander* newcodec() { return new ztxt; } | ||
173 | } | ||
174 | #endif | ||