summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/Aportis.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/Aportis.cpp') (more/less context) (show 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
@@ -45,24 +45,25 @@ CList<Bkmk>* Aportis::getbkmklist()
t->push_back(Bkmk(tname, NULL, lcn));
}
return t;
}
else
{
return NULL;
}
}
*/
if (bCompressed != 4) return NULL;
CList<Bkmk>* t = new CList<Bkmk>;
+ unsuspend();
size_t cur = ftell(fin);
for (int i = 0; i < nRecs2; i++)
{
DWORD dwPos;
fseek(fin, 0x56 + 8*i, SEEK_SET);
fread(&dwPos, 4, 1, fin);
dwPos = SwapLong(dwPos);
fseek(fin,dwPos,SEEK_SET);
unsigned char ch;
fread(&ch,1,1,fin);
if (ch != 241)
{
@@ -237,41 +238,43 @@ int Aportis::OpenFile(const char *src)
qDebug("Number of records:[%u,%u]", nRecs, nRecs2);
return ret;
}
int Aportis::getch()
{
if (bCompressed == 1)
{
if ((dwRecLen == 0) && !refreshbuffer()) return EOF;
else
{
+unsuspend();
int c = getc(fin);
dePeanut(c);
dwRecLen--;
currentpos++;
return c;
}
}
if (outptr != cbptr)
{
currentpos++;
return (circbuf[outptr = (outptr + 1) % 2048]);
}
if ((dwRecLen == 0) && !refreshbuffer()) return EOF;
currentpos++;
int c;
// take a char from the input buffer
+unsuspend();
c = getc(fin);
dePeanut(c);
dwRecLen--;
// separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF
// codes 1...8 mean copy that many chars; for accented chars & binary
if (c == 0)
{
circbuf[outptr = cbptr = (cbptr+1)%2048] = c;
return c;
}
else if (c >= 0x09 && c <= 0x7F)
@@ -311,47 +314,48 @@ int Aportis::getch()
else if (c >= 0xC0 && c <= 0xFF)
{
circbuf[cbptr = (cbptr+1)%2048] = ' ';
circbuf[cbptr = (cbptr+1)%2048] = c^0x80;
return circbuf[outptr = (outptr+1)%2048];
}
}
unsigned int Aportis::GetBS(unsigned int bn)
{
DWORD dwPos;
WORD fs;
-
+unsuspend();
fseek(fin, 0x56 + 8*bn, SEEK_SET);
fread(&dwPos, 4, 1, fin);
dwPos = SwapLong(dwPos);
fseek(fin,dwPos,SEEK_SET);
// gotorecordnumber(bn+1);
unsigned char ch;
fread(&ch,1,1,fin);
if (ch == 241)
{
fread(&fs,sizeof(fs),1,fin);
fs = SwapWord(fs);
}
else
fs = 0;
return fs;
}
unsigned int Aportis::locate()
{
if (bCompressed == 4)
{
+unsuspend();
size_t cur = ftell(fin);
unsigned int clen = 0;
for (unsigned int i = 0; i < currentrec-1; i++)
{
unsigned int bs = GetBS(i);
if (bs == 0) break;
clen += bs;
}
fseek(fin,cur,SEEK_SET);
return clen+currentpos;
}
else
@@ -392,24 +396,25 @@ void Aportis::locate(unsigned int n)
while (currentpos < offset && getch() != EOF);
}
bool Aportis::refreshbuffer()
{
if (currentrec < nRecs)
{
dwRecLen = recordlength(currentrec+1);
gotorecordnumber(currentrec+1);
if (bCompressed == 4)
{
unsigned char t[3];
+ unsuspend();
fread(t,1,3,fin);
if (t[0] != 241)
{
printf("You shouldn't be here!\n");
return false;
}
dwRecLen -= 3;
}
/*
int n = fread(t.buf, 1, dwRecLen, fin);
t.len = n;
// if(bCompressed)
@@ -421,24 +426,25 @@ bool Aportis::refreshbuffer()
currentrec++;
return true;
}
else {
return false;
}
}
#include <qimage.h>
QImage* Aportis::getPicture(unsigned long tgt)
{
+unsuspend();
unsigned short tgtrec = tgt+mobiimagerec;
if (tgtrec > nRecs2) return NULL;
size_t cur = ftell(fin);
unsigned short reclen = recordlength(tgtrec);
gotorecordnumber(tgtrec);
UInt8* imgbuffer = new UInt8[reclen];
fread(imgbuffer, 1, reclen, fin);
QByteArray arr;
arr.assign((const char*)imgbuffer, reclen);
QImage* qimage = new QImage(arr);
fseek(fin, cur, SEEK_SET);