home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / ARCHIVERS / lhasrc.lzh / slidehuf.h < prev    next >
Text File  |  1992-05-12  |  4KB  |  157 lines

  1. /*
  2.  * slidehuf.h -- part of LHa for UNIX
  3.  *
  4.  *    modified: Dec. 5, 1991, Masaru Oki.
  5.  */
  6.  
  7. #ifndef NULL
  8. #include <stdio.h>
  9. #endif
  10.  
  11. #ifndef _ERRNO
  12. #include <errno.h>
  13. #endif
  14.  
  15. #if defined(__STDC__) || defined(OSK)
  16.  
  17. #include <limits.h>
  18.  
  19. #else
  20.  
  21. #ifndef CHAR_BIT
  22. #define CHAR_BIT  8
  23. #endif
  24. #ifndef UCHAR_MAX
  25. #define UCHAR_MAX ((1<<(sizeof(unsigned char)*8))-1)
  26. #endif
  27. #ifndef USHRT_MAX
  28. #define USHRT_MAX ((1<<(sizeof(unsigned short)*8))-1)
  29. #endif
  30. #ifndef SHRT_MAX
  31. #define SHRT_MAX ((1<<(sizeof(short)*8-1))-1)
  32. #endif
  33. #ifndef SHRT_MIN
  34. #define SHRT_MIN (SHRT_MAX-USHRT_MAX)
  35. #endif
  36.  
  37. #endif /* not __STDC__ */
  38.  
  39. /* #include "errmes.h" */
  40. /* Your C-Compiler has no 'void' (from lharc.h) */
  41. #ifdef NO_VOID
  42. #define void
  43. #endif
  44.  
  45. struct encode_option {
  46. #ifndef NO_VOID
  47.     void (*output)();
  48.     void (*encode_start)();
  49.     void (*encode_end)();
  50. #else
  51.     int (*output)();
  52.     int (*encode_start)();
  53.     int (*encode_end)();
  54. #endif
  55. };
  56.  
  57. struct decode_option {
  58.     unsigned short (*decode_c)();
  59.     unsigned short (*decode_p)();
  60. #ifndef NO_VOID
  61.     void (*decode_start)();
  62. #else
  63.     int (*decode_start)();
  64. #endif
  65. };
  66.  
  67. /* from slide.c */
  68. #define MAX_DICBIT 13 
  69. #define MAX_DICSIZ (1 << MAX_DICBIT)
  70. #define MATCHBIT   8    /* bits for MAXMATCH - THRESHOLD */
  71. #define MAXMATCH 256    /* formerly F (not more than UCHAR_MAX + 1) */
  72. #define THRESHOLD  3    /* choose optimal value */
  73.  
  74. extern int errno;
  75. extern int unpackable;
  76. extern unsigned long origsize, compsize;
  77. extern unsigned short dicbit;
  78. extern unsigned short maxmatch;
  79. extern unsigned long count;
  80. extern unsigned short loc;
  81. extern unsigned char *text;
  82.  
  83. /* from huf.c */
  84. #define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD)
  85.             /* alphabet = {0, 1, 2, ..., NC - 1} */
  86. #define CBIT 9  /* $\lfloor \log_2 NC \rfloor + 1$ */
  87. #define USHRT_BIT 16    /* (CHAR_BIT * sizeof(ushort)) */
  88.  
  89. extern unsigned short    left[], right[];
  90. extern unsigned char    c_len[], pt_len[];
  91. extern unsigned short    c_freq[], c_table[], c_code[],
  92.                         p_freq[], pt_table[], pt_code[],
  93.                         t_freq[];
  94.  
  95. void output_st1();
  96. unsigned char *alloc_buf();
  97. void encode_start_st1();
  98. void encode_end_st1();
  99. unsigned short decode_c_st1();
  100. unsigned short decode_p_st1();
  101. void decode_start_st1();
  102.  
  103. /* from shuf.c */
  104. void decode_start_st0();
  105. void encode_p_st0(/*unsigned short j*/);
  106. void encode_start_fix();
  107. void decode_start_fix();
  108. unsigned short decode_c_st0();
  109. unsigned short decode_p_st0();
  110.  
  111. /* from dhuf.c */
  112. extern unsigned int n_max;
  113.  
  114. void start_c_dyn();
  115. void decode_start_dyn();
  116. unsigned short decode_c_dyn();
  117. unsigned short decode_p_dyn();
  118. void output_dyn(/*int code, unsigned int pos*/);
  119. void encode_end_dyn();
  120.  
  121. /* from larc.c */
  122. unsigned short decode_c_lzs();
  123. unsigned short decode_p_lzs();
  124. unsigned short decode_c_lz5();
  125. unsigned short decode_p_lz5();
  126. void decode_start_lzs();
  127. void decode_start_lz5();
  128.  
  129. /* from maketbl.c */
  130. /* void make_table(short nchar, uchar bitlen[],
  131.                    short tablebits, ushort table[]); */
  132. void make_table(/*int nchar, uchar bitlen[],int tablebits, ushort table[]*/);
  133.  
  134. /* from maketree.c */
  135. /* void make_code(short n, uchar len[], ushort code[]);
  136. short make_tree(short nparm, ushort freqparm[], 
  137.                 uchar lenparm[], ushort codeparam[]); */
  138. void make_code(/*int n, uchar len[], ushort code[]*/);
  139. short make_tree(/*int nparm, ushort freqparm[],
  140.                 uchar lenparm[], ushort codeparam[]*/);
  141.  
  142. /* from crcio.c */
  143. extern FILE *infile, *outfile;
  144. extern unsigned short crc, bitbuf;
  145. extern int dispflg;
  146.  
  147. void make_crctable();
  148. unsigned short calccrc(/*uchar *p, uint n*/);
  149. void fillbuf(/*uchar n*/);
  150. unsigned short getbits(/*uchar n*/);
  151. void putcode(/*uchar n, ushort x*/);
  152. void putbits(/*uchar n, ushort x*/);
  153. int fread_crc(/*uchar *p, int n, FILE *f*/);
  154. void fwrite_crc(/*uchar *p, int n, FILE *f*/);
  155. void init_getbits();
  156. void init_putbits();
  157.