summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/iSilo.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/iSilo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/iSilo.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/noncore/apps/opie-reader/iSilo.cpp b/noncore/apps/opie-reader/iSilo.cpp
index 5f14b96..1f727fe 100644
--- a/noncore/apps/opie-reader/iSilo.cpp
+++ b/noncore/apps/opie-reader/iSilo.cpp
@@ -1,16 +1,16 @@
1#include "iSilo.h" 1#include "iSilo.h"
2#ifdef _WINDOWS 2#ifdef _WINDOWS
3#include <winsock.h> 3#include <winsock.h>
4#endif 4#endif
5u_int8_t *rodata = (u_int8_t *) 5u_int8_t *rodata = (u_int8_t *)
6 "\x10\x11\x12\x00\x08\x07\x09\x06\x0a\x05\x0b\x04\x0c\x03\x0d\x02\x0e\x01\x0f"; 6 "\x10\x11\x12\x00\x08\x07\x09\x06\x0a\x05\x0b\x04\x0c\x03\x0d\x02\x0e\x01\x0f";
7 7
8u_int16_t *rsize_min = (u_int16_t *) 8u_int16_t *rsize_min = (u_int16_t *)
9 "\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0d" 9 "\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0d"
10"\x00\x0f\x00\x11\x00\x13\x00\x17\x00\x1b\x00\x1f\x00\x23\x00\x2b\x00\x33\x00" 10"\x00\x0f\x00\x11\x00\x13\x00\x17\x00\x1b\x00\x1f\x00\x23\x00\x2b\x00\x33\x00"
11"\x3b\x00\x43\x00\x53\x00\x63\x00\x73\x00\x83\x00\xa3\x00\xc3\x00\xe3\x00\x02" 11"\x3b\x00\x43\x00\x53\x00\x63\x00\x73\x00\x83\x00\xa3\x00\xc3\x00\xe3\x00\x02"
12"\x01"; 12"\x01";
13 13
14u_int8_t *rsize_delta = (u_int8_t *) 14u_int8_t *rsize_delta = (u_int8_t *)
15 "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x01\x01\x02\x02\x02\x02\x03\x03\x03" 15 "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x01\x01\x02\x02\x02\x02\x03\x03\x03"
16"\x03\x04\x04\x04\x04\x05\x05\x05\x05\x00"; 16"\x03\x04\x04\x04\x04\x05\x05\x05\x05\x00";
@@ -285,24 +285,25 @@ bool iSilo::reset_trees()
285} 285}
286u_int32_t iSilo::get_bits(int num) { 286u_int32_t iSilo::get_bits(int num) {
287 int i, r; 287 int i, r;
288 u_int32_t result = 0; 288 u_int32_t result = 0;
289 289
290 if (num == 0) { 290 if (num == 0) {
291 pos = 0; 291 pos = 0;
292 return(0); 292 return(0);
293 } 293 }
294 294
295 for (i = 0; i < num; i++) { 295 for (i = 0; i < num; i++) {
296 if (pos == 0) { 296 if (pos == 0) {
297 unsuspend();
297 r = fread(buf, sizeof(u_int32_t), 256, fin); 298 r = fread(buf, sizeof(u_int32_t), 256, fin);
298 if (r <= 0) { 299 if (r <= 0) {
299 qDebug("ERROR: Unexpected end of file"); 300 qDebug("ERROR: Unexpected end of file");
300 exit(-1); /* FIXME */ 301 exit(-1); /* FIXME */
301 } 302 }
302 pos = 32*256; 303 pos = 32*256;
303 } 304 }
304 305
305 pos--; 306 pos--;
306 result <<= 1; 307 result <<= 1;
307 result |= (ntohl(buf[255 - (pos/32)]) >> (31-(pos % 32))) & 1; 308 result |= (ntohl(buf[255 - (pos/32)]) >> (31-(pos % 32))) & 1;
308 } 309 }
@@ -552,30 +553,30 @@ void iSilo::read_attr()
552 } 553 }
553 if (attr_rec >= attr_start && attr_rec < attr_end) 554 if (attr_rec >= attr_start && attr_rec < attr_end)
554 { 555 {
555 gotorecordnumber(attr_rec); 556 gotorecordnumber(attr_rec);
556 fread(buffer, 1, 4, fin); 557 fread(buffer, 1, 4, fin);
557 fread(&attr_num, sizeof(attr_num), 1, fin); 558 fread(&attr_num, sizeof(attr_num), 1, fin);
558 attr_num = ntohs(attr_num)+1; 559 attr_num = ntohs(attr_num)+1;
559 attr = new s_attrib[attr_num]; 560 attr = new s_attrib[attr_num];
560 for (int j = 0; j < attr_num; j++) 561 for (int j = 0; j < attr_num; j++)
561 { 562 {
562 fread(&attr[j].offset, 2, 1, fin); 563 fread(&attr[j].offset, 2, 1, fin);
563 attr[j].offset = htons(attr[j].offset); 564 attr[j].offset = htons(attr[j].offset);
564 } 565 }
565#ifdef _WINDOWS 566#ifdef _WINDOWS
566 for (j = 0; j < attr_num; j++) 567 for (j = 0; j < attr_num; j++)
567#else 568#else
568 for (int j = 0; j < attr_num; j++) 569 for (int j = 0; j < attr_num; j++)
569#endif 570#endif
570 { 571 {
571 fread(&attr[j].value, 2, 1, fin); 572 fread(&attr[j].value, 2, 1, fin);
572 if (attr[j].offset < last_pos) 573 if (attr[j].offset < last_pos)
573 { 574 {
574 pos_hi++; 575 pos_hi++;
575 } 576 }
576 577
577 if ((attr[j].offset == last_pos) && (attr[j].value == last_value)) 578 if ((attr[j].offset == last_pos) && (attr[j].value == last_value))
578 { 579 {
579 pos_hi++; 580 pos_hi++;
580 } 581 }
581 582