OLD | NEW |
| (Empty) |
1 /* hunzip: file decompression for sorted dictionaries with optional encryption, | |
2 * algorithm: prefix-suffix encoding and 16-bit Huffman encoding */ | |
3 | |
4 #ifndef _HUNZIP_HXX_ | |
5 #define _HUNZIP_HXX_ | |
6 | |
7 #include "hunvisapi.h" | |
8 | |
9 #include <stdio.h> | |
10 | |
11 #define BUFSIZE 65536 | |
12 #define HZIP_EXTENSION ".hz" | |
13 | |
14 #define MSG_OPEN "error: %s: cannot open\n" | |
15 #define MSG_FORMAT "error: %s: not in hzip format\n" | |
16 #define MSG_MEMORY "error: %s: missing memory\n" | |
17 #define MSG_KEY "error: %s: missing or bad password\n" | |
18 | |
19 struct bit { | |
20 unsigned char c[2]; | |
21 int v[2]; | |
22 }; | |
23 | |
24 class LIBHUNSPELL_DLL_EXPORTED Hunzip | |
25 { | |
26 | |
27 protected: | |
28 char * filename; | |
29 FILE * fin; | |
30 int bufsiz, lastbit, inc, inbits, outc; | |
31 struct bit * dec; // code table | |
32 char in[BUFSIZE]; // input buffer | |
33 char out[BUFSIZE + 1]; // Huffman-decoded buffer | |
34 char line[BUFSIZE + 50]; // decoded line | |
35 int getcode(const char * key); | |
36 int getbuf(); | |
37 int fail(const char * err, const char * par); | |
38 | |
39 public: | |
40 Hunzip(const char * filename, const char * key = NULL); | |
41 ~Hunzip(); | |
42 const char * getline(); | |
43 }; | |
44 | |
45 #endif | |
OLD | NEW |