summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/pdb.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/pdb.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/pdb.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/noncore/apps/opie-reader/pdb.cpp b/noncore/apps/opie-reader/pdb.cpp
index dca67ff..39551cc 100644
--- a/noncore/apps/opie-reader/pdb.cpp
+++ b/noncore/apps/opie-reader/pdb.cpp
@@ -3,6 +3,30 @@
3#include <winsock2.h> 3#include <winsock2.h>
4#endif 4#endif
5 5
6#include "useqpe.h"
7
8#ifdef USEQPE
9void Cpdb::suspend()
10{
11 CExpander::suspend(fin);
12}
13void Cpdb::unsuspend()
14{
15 CExpander::unsuspend(fin);
16}
17#endif
18
19Cpdb::~Cpdb()
20{
21 if (fin != NULL)
22 {
23#ifdef USEQPE
24 unsuspend();
25#endif
26 fclose(fin);
27 }
28}
29
6size_t Cpdb::recordpos(int n) 30size_t Cpdb::recordpos(int n)
7{ 31{
8 UInt16 mxn = ntohs(head.recordList.numRecords); 32 UInt16 mxn = ntohs(head.recordList.numRecords);
@@ -32,11 +56,11 @@ void Cpdb::gotorecordnumber(int n)
32 fseek(fin, recordpos(n), SEEK_SET); 56 fseek(fin, recordpos(n), SEEK_SET);
33} 57}
34 58
35bool Cpdb::openfile(const char *src) 59bool Cpdb::openpdbfile(const char *src)
36{ 60{
61 //qDebug("cpdb openfile:%s", src);
37 62
38 // printf("In openfile\n"); 63 // printf("In openfile\n");
39 int ret = 0;
40 // printf("closing fin:%x\n",fin); 64 // printf("closing fin:%x\n",fin);
41 if (fin != NULL) fclose(fin); 65 if (fin != NULL) fclose(fin);
42 // printf("opening fin\n"); 66 // printf("opening fin\n");
@@ -49,12 +73,18 @@ bool Cpdb::openfile(const char *src)
49 73
50 // just holds the first few chars of the file 74 // just holds the first few chars of the file
51 //char buf[0x100]; 75 //char buf[0x100];
52 fseek(fin,0,SEEK_END); 76 struct stat _stat;
53 file_length = ftell(fin); 77 stat(src,&_stat);
78 file_length = _stat.st_size;
79 // fseek(fin,0,SEEK_END);
80 // file_length = ftell(fin);
54 81
55 fseek(fin,0,SEEK_SET); 82 fseek(fin,0,SEEK_SET);
56 83
57 fread(&head, 1, sizeof(head), fin); 84 fread(&head, 1, sizeof(head), fin);
58 85
86 qDebug("Database name:%s", head.name);
87 qDebug("Total number of records:%u", ntohs(head.recordList.numRecords));
88
59 return true; 89 return true;
60} 90}