Diffstat (limited to 'noncore/apps/opie-reader/Bkmks.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.h | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/noncore/apps/opie-reader/Bkmks.h b/noncore/apps/opie-reader/Bkmks.h index b38184a..ee528e4 100644 --- a/noncore/apps/opie-reader/Bkmks.h +++ b/noncore/apps/opie-reader/Bkmks.h | |||
@@ -1,53 +1,70 @@ | |||
1 | #ifndef __Bkmks_h | 1 | #ifndef __Bkmks_h |
2 | #define __Bkmks_h | 2 | #define __Bkmks_h |
3 | 3 | ||
4 | #include "config.h" | 4 | #include "config.h" |
5 | #include "Filedata.h" | ||
5 | #include <stdio.h> | 6 | #include <stdio.h> |
6 | 7 | ||
7 | template<class T> | 8 | template<class T> |
8 | class CList; | 9 | class CList; |
9 | 10 | ||
10 | class Bkmk | 11 | class Bkmk |
11 | { | 12 | { |
12 | friend class BkmkFile; | 13 | friend class BkmkFile; |
13 | tchar* m_name; | 14 | unsigned char* m_name; |
14 | tchar* m_anno; | 15 | unsigned short m_namelen; |
16 | unsigned char* m_anno; | ||
17 | unsigned short m_annolen; | ||
15 | unsigned int m_position; | 18 | unsigned int m_position; |
19 | void init(const void*, unsigned short, const void*, unsigned short, unsigned int); | ||
16 | public: | 20 | public: |
17 | Bkmk() : m_name(NULL), m_anno(NULL), m_position(0) {}; | 21 | Bkmk() : m_name(NULL), m_namelen(0), m_anno(NULL), m_annolen(0), m_position(0) {}; |
22 | Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); | ||
23 | Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); | ||
18 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); | 24 | Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); |
19 | Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL) | 25 | Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL) |
20 | { | 26 | { |
21 | *this = rhs; | 27 | *this = rhs; |
22 | } | 28 | } |
23 | ~Bkmk(); | 29 | ~Bkmk(); |
24 | unsigned int value() const { return m_position; } | 30 | unsigned int value() const { return m_position; } |
25 | tchar *name() const { return m_name; } | 31 | void value(unsigned int _v) { m_position = _v; } |
26 | tchar *anno() const { return m_anno; } | 32 | tchar *name() const { return (tchar*)m_name; } |
33 | tchar *anno() const { return (tchar*)m_anno; } | ||
27 | bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } | 34 | bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); } |
28 | Bkmk& operator=(const Bkmk& rhs); | 35 | Bkmk& operator=(const Bkmk& rhs); |
29 | bool operator==(const Bkmk& rhs); | 36 | bool operator==(const Bkmk& rhs); |
30 | void setAnno(tchar* t); | 37 | void setAnno(tchar* t); |
38 | void setAnno(unsigned char* t, unsigned short len); | ||
39 | unsigned char* filedata() | ||
40 | { | ||
41 | CFiledata fd(anno()); | ||
42 | return m_anno+fd.length(); | ||
43 | } | ||
44 | unsigned short filedatalen() | ||
45 | { | ||
46 | CFiledata fd(anno()); | ||
47 | return m_annolen - fd.length(); | ||
48 | } | ||
31 | }; | 49 | }; |
32 | 50 | ||
33 | class BkmkFile | 51 | class BkmkFile |
34 | { | 52 | { |
35 | FILE* f; | 53 | FILE* f; |
36 | bool wt; | 54 | bool wt; |
37 | bool isUpgraded; | 55 | bool isUpgraded; |
38 | static const unsigned long magic; | 56 | static const unsigned long magic; |
39 | private: | 57 | private: |
40 | Bkmk* read(); | 58 | static Bkmk* read06(FILE*); |
41 | Bkmk* read03(); | 59 | static Bkmk* read05(FILE*); |
42 | CList<Bkmk>* readall03(); | 60 | static Bkmk* read03(FILE*); |
43 | CList<Bkmk>* readall04(); | 61 | CList<Bkmk>* readall00(Bkmk*(*fn)(FILE*)); |
44 | void write(tchar* nm, tchar* an, const unsigned int& pos); | ||
45 | void write(const Bkmk& b); | 62 | void write(const Bkmk& b); |
46 | public: | 63 | public: |
47 | bool upgraded() { return isUpgraded; } | 64 | bool upgraded() { return isUpgraded; } |
48 | BkmkFile(const char *fnm, bool w = false); | 65 | BkmkFile(const char *fnm, bool w = false); |
49 | ~BkmkFile(); | 66 | ~BkmkFile(); |
50 | void write(CList<Bkmk>& bl); | 67 | void write(CList<Bkmk>& bl); |
51 | CList<Bkmk>* readall(); | 68 | CList<Bkmk>* readall(); |
52 | }; | 69 | }; |
53 | #endif | 70 | #endif |