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.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/ztxt.cpp b/noncore/apps/opie-reader/ztxt.cpp
index 35db05e..e04eaa0 100644
--- a/noncore/apps/opie-reader/ztxt.cpp
+++ b/noncore/apps/opie-reader/ztxt.cpp
@@ -58,24 +58,25 @@ int ztxt::getch()
58} 58}
59 59
60unsigned int ztxt::locate() 60unsigned int ztxt::locate()
61{ 61{
62 return currentpos; 62 return currentpos;
63} 63}
64 64
65void ztxt::locate(unsigned int n) 65void ztxt::locate(unsigned int n)
66{ 66{
67 67
68 if (hasrandomaccess()) 68 if (hasrandomaccess())
69 { 69 {
70 unsuspend();
70 bufferrec = n / ntohs(hdr0.recordSize) + 1; 71 bufferrec = n / ntohs(hdr0.recordSize) + 1;
71 if (bufferrec == 1) 72 if (bufferrec == 1)
72 { 73 {
73 inflateEnd(&zstream); 74 inflateEnd(&zstream);
74 } 75 }
75 size_t reclen = recordlength(bufferrec); 76 size_t reclen = recordlength(bufferrec);
76 if (reclen == 0) return; 77 if (reclen == 0) return;
77 gotorecordnumber(bufferrec); 78 gotorecordnumber(bufferrec);
78 fread(compressedtextbuffer, reclen, sizeof(char), fin); 79 fread(compressedtextbuffer, reclen, sizeof(char), fin);
79 80
80 zstream.next_in = compressedtextbuffer; 81 zstream.next_in = compressedtextbuffer;
81 zstream.next_out = expandedtextbuffer; 82 zstream.next_out = expandedtextbuffer;
@@ -98,24 +99,25 @@ void ztxt::locate(unsigned int n)
98 currentpos = n - n % ntohs(hdr0.recordSize); 99 currentpos = n - n % ntohs(hdr0.recordSize);
99 while (currentpos < n) getch(); 100 while (currentpos < n) getch();
100 } 101 }
101 else 102 else
102 { 103 {
103 home(); 104 home();
104 while (currentpos < n && getch() != EOF); 105 while (currentpos < n && getch() != EOF);
105 } 106 }
106} 107}
107 108
108void ztxt::home() 109void ztxt::home()
109{ 110{
111unsuspend();
110 if (bInit) 112 if (bInit)
111 { 113 {
112 inflateEnd(&zstream); 114 inflateEnd(&zstream);
113 } 115 }
114 bInit = true; 116 bInit = true;
115 size_t reclen = recordlength(1); 117 size_t reclen = recordlength(1);
116 gotorecordnumber(1); 118 gotorecordnumber(1);
117 fread(compressedtextbuffer, reclen, sizeof(char), fin); 119 fread(compressedtextbuffer, reclen, sizeof(char), fin);
118 120
119 zstream.next_in = compressedtextbuffer; 121 zstream.next_in = compressedtextbuffer;
120 zstream.next_out = expandedtextbuffer; 122 zstream.next_out = expandedtextbuffer;
121 zstream.avail_out = buffersize; 123 zstream.avail_out = buffersize;
@@ -138,24 +140,25 @@ void ztxt::home()
138 //printf("buffercontent:%u\n", buffercontent); 140 //printf("buffercontent:%u\n", buffercontent);
139} 141}
140 142
141CList<Bkmk>* ztxt::getbkmklist() 143CList<Bkmk>* ztxt::getbkmklist()
142{ 144{
143 UInt16 recno = ntohs(hdr0.bookmarkRecord); 145 UInt16 recno = ntohs(hdr0.bookmarkRecord);
144 146
145// printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); 147// printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks));
146 148
147 if (recno == 0) return NULL; 149 if (recno == 0) return NULL;
148 150
149 CList<Bkmk>* t = new CList<Bkmk>; 151 CList<Bkmk>* t = new CList<Bkmk>;
152 unsuspend();
150 size_t cur = ftell(fin); 153 size_t cur = ftell(fin);
151 gotorecordnumber(recno); 154 gotorecordnumber(recno);
152 for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) 155 for (int i = 0; i < ntohs(hdr0.numBookmarks); i++)
153 { 156 {
154 zTXTbkmk bkmk; 157 zTXTbkmk bkmk;
155 if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; 158 if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break;
156// printf("Bookmark number:%d:%.20s\n", i, bkmk.title); 159// printf("Bookmark number:%d:%.20s\n", i, bkmk.title);
157 tchar title[MAX_BMRK_LENGTH]; 160 tchar title[MAX_BMRK_LENGTH];
158 for (int j = 0; j < MAX_BMRK_LENGTH; j++) 161 for (int j = 0; j < MAX_BMRK_LENGTH; j++)
159 { 162 {
160 title[j] = bkmk.title[j]; 163 title[j] = bkmk.title[j];
161 } 164 }