hunzip.hxx 1.1 KB

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