summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/Aportis.cpp
Unidiff
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, 4 insertions, 4 deletions
diff --git a/noncore/apps/opie-reader/Aportis.cpp b/noncore/apps/opie-reader/Aportis.cpp
index b4988da..2f8cdc3 100644
--- a/noncore/apps/opie-reader/Aportis.cpp
+++ b/noncore/apps/opie-reader/Aportis.cpp
@@ -7,56 +7,56 @@
7Aportis::Aportis() : peanutfile(false) { /*printf("constructing:%x\n",fin);*/ } 7Aportis::Aportis() : peanutfile(false) { /*printf("constructing:%x\n",fin);*/ }
8 8
9void Aportis::dePeanut(int& ch) 9void Aportis::dePeanut(int& ch)
10{ 10{
11 if (peanutfile && ch != EOF) 11 if (peanutfile && ch != EOF)
12 { 12 {
13 unsigned char c = ch; 13 unsigned char c = ch;
14 if (peanutfile) c ^= 0xa5; 14 if (peanutfile) c ^= 0xa5;
15 ch = c; 15 ch = c;
16 } 16 }
17} 17}
18 18
19CList<Bkmk>* Aportis::getbkmklist() 19CList<Bkmk>* Aportis::getbkmklist()
20{ 20{
21/* 21/*
22 if (peanutfile) 22 if (peanutfile)
23 { 23 {
24 if (nRecs2 > nRecs) 24 if (nRecs2 > nRecs)
25 { 25 {
26 CList<Bkmk>* t = new CList<Bkmk>; 26 CList<Bkmk>* t = new CList<Bkmk>;
27 for (int i = nRecs; i < nRecs2; i++) 27 for (int i = nRecs; i < nRecs2; i++)
28 { 28 {
29 char name[17]; 29 char name[17];
30 name[16] = '\0'; 30 name[16] = '\0';
31 qDebug("Record:%d, Length:%u",i,recordlength(i)); 31 // qDebug("Record:%d, Length:%u",i,recordlength(i));
32 gotorecordnumber(i); 32 gotorecordnumber(i);
33 fread(name,1,16,fin); 33 fread(name,1,16,fin);
34 unsigned long lcn; 34 unsigned long lcn;
35 fread(&lcn,sizeof(lcn),1,fin); 35 fread(&lcn,sizeof(lcn),1,fin);
36 lcn ^= 0xa5a5a5a5; 36 lcn ^= 0xa5a5a5a5;
37 lcn = SwapLong(lcn); 37 lcn = SwapLong(lcn);
38 qDebug("Bookmark:%s:%u", name,lcn); 38 // qDebug("Bookmark:%s:%u", name,lcn);
39 tchar tname[17]; 39 tchar tname[17];
40 memset(tname, 0, sizeof(tname)); 40 memset(tname, 0, sizeof(tname));
41 for (int i = 0; name[i] != 0; i++) 41 for (int i = 0; name[i] != 0; i++)
42 { 42 {
43 tname[i] = name[i] ^ 0xa5; 43 tname[i] = name[i] ^ 0xa5;
44 } 44 }
45 t->push_back(Bkmk(tname, NULL, lcn)); 45 t->push_back(Bkmk(tname, NULL, lcn));
46 } 46 }
47 return t; 47 return t;
48 } 48 }
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 size_t cur = ftell(fin); 57 size_t cur = ftell(fin);
58 for (int i = 0; i < nRecs2; i++) 58 for (int i = 0; i < nRecs2; i++)
59 { 59 {
60 DWORD dwPos; 60 DWORD dwPos;
61 fseek(fin, 0x56 + 8*i, SEEK_SET); 61 fseek(fin, 0x56 + 8*i, SEEK_SET);
62 fread(&dwPos, 4, 1, fin); 62 fread(&dwPos, 4, 1, fin);
@@ -100,49 +100,49 @@ int Aportis::OpenFile(const char *src)
100 if (head.creator != 0x64414552 // 'dAER' 100 if (head.creator != 0x64414552 // 'dAER'
101 || head.type != 0x74584554) // 'tXET') 101 || head.type != 0x74584554) // 'tXET')
102 { 102 {
103 103
104 if (memcmp(&head.creator, "PPrs", 4) == 0 && memcmp(&head.type, "PNRd", 4) == 0) 104 if (memcmp(&head.creator, "PPrs", 4) == 0 && memcmp(&head.type, "PNRd", 4) == 0)
105 { 105 {
106 peanutfile = true; 106 peanutfile = true;
107 } 107 }
108 else 108 else
109 { 109 {
110 return -2; 110 return -2;
111 } 111 }
112 } 112 }
113 113
114 nRecs2 = nRecs = SwapWord(head.recordList.numRecords) - 1; 114 nRecs2 = nRecs = SwapWord(head.recordList.numRecords) - 1;
115 fseek(fin,0,SEEK_END); 115 fseek(fin,0,SEEK_END);
116 dwLen = ftell(fin); 116 dwLen = ftell(fin);
117 117
118 if (peanutfile) 118 if (peanutfile)
119 { 119 {
120 120
121 PeanutHeader hdr0; 121 PeanutHeader hdr0;
122 gotorecordnumber(0); 122 gotorecordnumber(0);
123 fread(&hdr0, sizeof(hdr0), 1, fin); 123 fread(&hdr0, sizeof(hdr0), 1, fin);
124 qDebug("Version:%x", ntohs(hdr0.Version)); 124// qDebug("Version:%x", ntohs(hdr0.Version));
125 if (hdr0.Version && 0x0200) 125 if (hdr0.Version && 0x0200)
126 { 126 {
127 bCompressed = 2; 127 bCompressed = 2;
128 } 128 }
129 else 129 else
130 { 130 {
131 bCompressed = 1; 131 bCompressed = 1;
132 } 132 }
133 BlockSize = 4096; 133 BlockSize = 4096;
134 nRecs = SwapWord(hdr0.Records)-1; 134 nRecs = SwapWord(hdr0.Records)-1;
135 dwTLen = nRecs*BlockSize; 135 dwTLen = nRecs*BlockSize;
136 } 136 }
137 else 137 else
138 { 138 {
139 gotorecordnumber(0); 139 gotorecordnumber(0);
140 tDocRecord0 hdr0; 140 tDocRecord0 hdr0;
141 fread(&hdr0, sizeof(hdr0), 1, fin); 141 fread(&hdr0, sizeof(hdr0), 1, fin);
142 bCompressed = SwapWord(hdr0.wVersion); 142 bCompressed = SwapWord(hdr0.wVersion);
143 if (bCompressed!=1 && bCompressed!=2 && bCompressed != 4) { 143 if (bCompressed!=1 && bCompressed!=2 && bCompressed != 4) {
144 ret = bCompressed; 144 ret = bCompressed;
145 bCompressed = 2; 145 bCompressed = 2;
146 } 146 }
147 switch (bCompressed) 147 switch (bCompressed)
148 { 148 {
@@ -161,49 +161,49 @@ int Aportis::OpenFile(const char *src)
161 } 161 }
162 break; 162 break;
163 case 1: 163 case 1:
164 case 2: 164 case 2:
165 default: 165 default:
166 nRecs = SwapWord(hdr0.wNumRecs); 166 nRecs = SwapWord(hdr0.wNumRecs);
167 dwTLen = SwapLong(hdr0.dwStoryLen); 167 dwTLen = SwapLong(hdr0.dwStoryLen);
168 BlockSize = SwapWord(hdr0.wRecSize); 168 BlockSize = SwapWord(hdr0.wRecSize);
169 if (BlockSize == 0) 169 if (BlockSize == 0)
170 { 170 {
171 BlockSize = 4096; 171 BlockSize = 4096;
172 printf("WARNING: Blocksize not set in source file\n"); 172 printf("WARNING: Blocksize not set in source file\n");
173 } 173 }
174 } 174 }
175 } 175 }
176 176
177 177
178 178
179 // this is the main record buffer 179 // this is the main record buffer
180 // it knows how to stretch to accomodate the decompress 180 // it knows how to stretch to accomodate the decompress
181 currentrec = 0; 181 currentrec = 0;
182 cbptr = 0; 182 cbptr = 0;
183 outptr = 0; 183 outptr = 0;
184 refreshbuffer(); 184 refreshbuffer();
185 qDebug("Number of records:[%u,%u]", nRecs, nRecs2); 185// qDebug("Number of records:[%u,%u]", nRecs, nRecs2);
186 return ret; 186 return ret;
187} 187}
188 188
189int Aportis::getch() 189int Aportis::getch()
190{ 190{
191 if (bCompressed == 1) 191 if (bCompressed == 1)
192 { 192 {
193 if ((dwRecLen == 0) && !refreshbuffer()) return EOF; 193 if ((dwRecLen == 0) && !refreshbuffer()) return EOF;
194 else 194 else
195 { 195 {
196 int c = getc(fin); 196 int c = getc(fin);
197 dePeanut(c); 197 dePeanut(c);
198 dwRecLen--; 198 dwRecLen--;
199 currentpos++; 199 currentpos++;
200 return c; 200 return c;
201 } 201 }
202 } 202 }
203 if (outptr != cbptr) 203 if (outptr != cbptr)
204 { 204 {
205 currentpos++; 205 currentpos++;
206 return (circbuf[outptr = (outptr + 1) % 2048]); 206 return (circbuf[outptr = (outptr + 1) % 2048]);
207 } 207 }
208 if ((dwRecLen == 0) && !refreshbuffer()) return EOF; 208 if ((dwRecLen == 0) && !refreshbuffer()) return EOF;
209 currentpos++; 209 currentpos++;