summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/Aportis.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/Aportis.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Aportis.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/Aportis.cpp b/noncore/apps/opie-reader/Aportis.cpp
index 353996c..37dcc99 100644
--- a/noncore/apps/opie-reader/Aportis.cpp
+++ b/noncore/apps/opie-reader/Aportis.cpp
@@ -49,16 +49,17 @@ CList<Bkmk>* Aportis::getbkmklist()
49 else 49 else
50 { 50 {
51 return NULL; 51 return NULL;
52 } 52 }
53 } 53 }
54*/ 54*/
55 if (bCompressed != 4) return NULL; 55 if (bCompressed != 4) return NULL;
56 CList<Bkmk>* t = new CList<Bkmk>; 56 CList<Bkmk>* t = new CList<Bkmk>;
57 unsuspend();
57 size_t cur = ftell(fin); 58 size_t cur = ftell(fin);
58 for (int i = 0; i < nRecs2; i++) 59 for (int i = 0; i < nRecs2; i++)
59 { 60 {
60 DWORD dwPos; 61 DWORD dwPos;
61 fseek(fin, 0x56 + 8*i, SEEK_SET); 62 fseek(fin, 0x56 + 8*i, SEEK_SET);
62 fread(&dwPos, 4, 1, fin); 63 fread(&dwPos, 4, 1, fin);
63 dwPos = SwapLong(dwPos); 64 dwPos = SwapLong(dwPos);
64 fseek(fin,dwPos,SEEK_SET); 65 fseek(fin,dwPos,SEEK_SET);
@@ -241,16 +242,17 @@ int Aportis::OpenFile(const char *src)
241 242
242int Aportis::getch() 243int Aportis::getch()
243{ 244{
244 if (bCompressed == 1) 245 if (bCompressed == 1)
245 { 246 {
246 if ((dwRecLen == 0) && !refreshbuffer()) return EOF; 247 if ((dwRecLen == 0) && !refreshbuffer()) return EOF;
247 else 248 else
248 { 249 {
250unsuspend();
249 int c = getc(fin); 251 int c = getc(fin);
250 dePeanut(c); 252 dePeanut(c);
251 dwRecLen--; 253 dwRecLen--;
252 currentpos++; 254 currentpos++;
253 return c; 255 return c;
254 } 256 }
255 } 257 }
256 if (outptr != cbptr) 258 if (outptr != cbptr)
@@ -258,16 +260,17 @@ int Aportis::getch()
258 currentpos++; 260 currentpos++;
259 return (circbuf[outptr = (outptr + 1) % 2048]); 261 return (circbuf[outptr = (outptr + 1) % 2048]);
260 } 262 }
261 if ((dwRecLen == 0) && !refreshbuffer()) return EOF; 263 if ((dwRecLen == 0) && !refreshbuffer()) return EOF;
262 currentpos++; 264 currentpos++;
263 int c; 265 int c;
264 266
265 // take a char from the input buffer 267 // take a char from the input buffer
268unsuspend();
266 c = getc(fin); 269 c = getc(fin);
267 dePeanut(c); 270 dePeanut(c);
268 dwRecLen--; 271 dwRecLen--;
269 // separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF 272 // separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF
270 273
271 // codes 1...8 mean copy that many chars; for accented chars & binary 274 // codes 1...8 mean copy that many chars; for accented chars & binary
272 if (c == 0) 275 if (c == 0)
273 { 276 {
@@ -315,17 +318,17 @@ int Aportis::getch()
315 return circbuf[outptr = (outptr+1)%2048]; 318 return circbuf[outptr = (outptr+1)%2048];
316 } 319 }
317} 320}
318 321
319unsigned int Aportis::GetBS(unsigned int bn) 322unsigned int Aportis::GetBS(unsigned int bn)
320{ 323{
321 DWORD dwPos; 324 DWORD dwPos;
322 WORD fs; 325 WORD fs;
323 326unsuspend();
324 fseek(fin, 0x56 + 8*bn, SEEK_SET); 327 fseek(fin, 0x56 + 8*bn, SEEK_SET);
325 fread(&dwPos, 4, 1, fin); 328 fread(&dwPos, 4, 1, fin);
326 dwPos = SwapLong(dwPos); 329 dwPos = SwapLong(dwPos);
327 fseek(fin,dwPos,SEEK_SET); 330 fseek(fin,dwPos,SEEK_SET);
328 331
329// gotorecordnumber(bn+1); 332// gotorecordnumber(bn+1);
330 unsigned char ch; 333 unsigned char ch;
331 fread(&ch,1,1,fin); 334 fread(&ch,1,1,fin);
@@ -338,16 +341,17 @@ unsigned int Aportis::GetBS(unsigned int bn)
338 fs = 0; 341 fs = 0;
339 return fs; 342 return fs;
340} 343}
341 344
342unsigned int Aportis::locate() 345unsigned int Aportis::locate()
343{ 346{
344 if (bCompressed == 4) 347 if (bCompressed == 4)
345 { 348 {
349unsuspend();
346 size_t cur = ftell(fin); 350 size_t cur = ftell(fin);
347 unsigned int clen = 0; 351 unsigned int clen = 0;
348 for (unsigned int i = 0; i < currentrec-1; i++) 352 for (unsigned int i = 0; i < currentrec-1; i++)
349 { 353 {
350 unsigned int bs = GetBS(i); 354 unsigned int bs = GetBS(i);
351 if (bs == 0) break; 355 if (bs == 0) break;
352 clen += bs; 356 clen += bs;
353 } 357 }
@@ -396,16 +400,17 @@ bool Aportis::refreshbuffer()
396{ 400{
397 if (currentrec < nRecs) 401 if (currentrec < nRecs)
398 { 402 {
399 dwRecLen = recordlength(currentrec+1); 403 dwRecLen = recordlength(currentrec+1);
400 gotorecordnumber(currentrec+1); 404 gotorecordnumber(currentrec+1);
401 if (bCompressed == 4) 405 if (bCompressed == 4)
402 { 406 {
403 unsigned char t[3]; 407 unsigned char t[3];
408 unsuspend();
404 fread(t,1,3,fin); 409 fread(t,1,3,fin);
405 if (t[0] != 241) 410 if (t[0] != 241)
406 { 411 {
407 printf("You shouldn't be here!\n"); 412 printf("You shouldn't be here!\n");
408 return false; 413 return false;
409 } 414 }
410 dwRecLen -= 3; 415 dwRecLen -= 3;
411 } 416 }
@@ -425,16 +430,17 @@ bool Aportis::refreshbuffer()
425 return false; 430 return false;
426 } 431 }
427} 432}
428 433
429#include <qimage.h> 434#include <qimage.h>
430 435
431QImage* Aportis::getPicture(unsigned long tgt) 436QImage* Aportis::getPicture(unsigned long tgt)
432{ 437{
438unsuspend();
433 unsigned short tgtrec = tgt+mobiimagerec; 439 unsigned short tgtrec = tgt+mobiimagerec;
434 if (tgtrec > nRecs2) return NULL; 440 if (tgtrec > nRecs2) return NULL;
435 size_t cur = ftell(fin); 441 size_t cur = ftell(fin);
436 unsigned short reclen = recordlength(tgtrec); 442 unsigned short reclen = recordlength(tgtrec);
437 gotorecordnumber(tgtrec); 443 gotorecordnumber(tgtrec);
438 UInt8* imgbuffer = new UInt8[reclen]; 444 UInt8* imgbuffer = new UInt8[reclen];
439 fread(imgbuffer, 1, reclen, fin); 445 fread(imgbuffer, 1, reclen, fin);
440 QByteArray arr; 446 QByteArray arr;