summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/iSilo.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/iSilo.h') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/opie-reader/iSilo.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/iSilo.h b/noncore/apps/opie-reader/iSilo.h
new file mode 100755
index 0000000..9ef6a7f
--- a/dev/null
+++ b/noncore/apps/opie-reader/iSilo.h
@@ -0,0 +1,104 @@
1#include <sys/types.h>
2#include <sys/stat.h>
3#ifndef _WINDOWS
4#include <netinet/in.h>
5#include <unistd.h>
6#include <stdlib.h>
7#else
8typedef unsigned char u_int8_t;
9typedef unsigned short u_int16_t;
10typedef unsigned long u_int32_t;
11#endif
12#include <fcntl.h>
13#include <stdio.h>
14#include <string.h>
15
16#include "pdb.h"
17
18#define VERSION "deSilo version 0.4a by Clement"
19
20
21struct s_tree {
22 struct s_tree *branch[2];
23 u_int32_t value;
24};
25
26struct s_attrib {
27 u_int32_t offset;
28 u_int16_t value;
29};
30
31struct s_huffman {
32 struct s_tree *tree;
33 u_int8_t *size;
34 u_int16_t *code;
35 u_int32_t num;
36};
37
38#define HM_SHORT 0x10
39#define HM_MEDIUM 0x11
40#define HM_LONG 0x12
41
42class iSilo : public Cpdb
43{
44 CStyle mystyle;
45 u_int16_t BlockSize;
46 int pos;
47 u_int32_t buf[256];
48 struct s_huffman *master, *lz, *text;
49 u_int32_t cur_rec;
50 u_int8_t buffer[4096];
51 u_int32_t buffer_size;
52 u_int16_t current_pos, bsize;
53 u_int32_t filepos, filesize, textsize;
54 u_int16_t attr_start, attr_end, attr_num, current_attr, attr_rec;
55 u_int16_t pos_hi;
56 u_int16_t last_pos, last_value;
57
58
59 s_attrib* attr;
60
61
62 void init_tables(void);
63 int code2tree(struct s_huffman *h);
64 u_int32_t swap_bits(u_int32_t n, int num);
65 u_int32_t *huffman_get(struct s_huffman *h);
66 int size2code(struct s_huffman *h);
67 void read_attr();
68 struct s_huffman *huffman_create(u_int32_t num);
69 void kill_tree(struct s_tree *tree);
70 void kill_huffman(struct s_huffman *h);
71 int read_size(struct s_huffman *prev, struct s_huffman *h);
72 void mymemcpy(u_int8_t *dst, u_int8_t *src, u_int32_t num);
73 int read_tree(struct s_huffman *prev, struct s_huffman *curr);
74 bool reset_trees();
75 u_int32_t get_bits(int num);
76 u_int32_t get_swapped(int num);
77 int read_text();
78 u_int32_t getreccode();
79 bool process_record();
80public:
81 iSilo() : pos(0), master(NULL), lz(NULL), text(NULL), cur_rec(0), buffer_size(4096), current_pos(0), bsize(0), BlockSize(4096)
82 {
83 }
84 ~iSilo();
85 int getch();
86 void getch(tchar& ch, CStyle& sty, unsigned long& pos);
87 MarkupType PreferredMarkup()
88 {
89 return cNONE;
90 }
91 void sizes(unsigned long& _file, unsigned long& _text)
92 {
93 _file = filesize;
94 _text = textsize;
95 }
96 bool hasrandomaccess() { return false; }
97 int OpenFile(const char* src);
98 unsigned int locate()
99 {
100 return filepos;
101 }
102 void locate(unsigned int n);
103 QString about();
104};