home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / arc / freeze.lzh / freeze.h < prev    next >
C/C++ Source or Header  |  1991-11-05  |  3KB  |  140 lines

  1.  
  2. #include <stdio.h>
  3.  
  4. #ifdef SUN4
  5. #include <sys/stdtypes.h>
  6. #else   /* SUN4 */
  7. # ifndef getc
  8. #   define getc(p)         (--(p)->_cnt < 0 ? _filbuf(p) : (int) *(p)->_ptr++)
  9. # endif
  10. # ifndef putc
  11. #   define putc(x, p)      (--(p)->_cnt < 0 ? _flsbuf((unsigned char) (x), (p)) : (int) (*(p)->_ptr++ = (unsigned char) (x)))
  12. # endif
  13. #ifndef BSD4_2
  14. typedef unsigned short u_short;
  15. #endif  /* BSD4_2 */
  16. #endif  /* SUN4 */
  17.  
  18. #include <ctype.h>
  19. #include <signal.h>
  20. #include <sys/types.h>
  21. #include <sys/stat.h>
  22.  
  23. /* for MAXNAMLEN only !!! */
  24. #ifdef unix
  25. #ifndef BSD4_2
  26. #include <dirent.h>
  27. #else
  28. #include <sys/dir.h>
  29. #endif /* BSD4_2 */
  30. #endif /* unix */
  31.  
  32. #if !defined(MAXNAMLEN)
  33. #define MAXNAMLEN       255
  34. #else
  35. #if MAXNAMLEN < 255
  36. #undef MAXNAMLEN
  37. #define MAXNAMLEN       255
  38. #endif
  39. #endif
  40.  
  41. #ifdef DEBUG
  42. #include <assert.h>
  43. #endif  /* DEBUG */
  44.  
  45. #ifdef __TURBOC__
  46. #define MSDOS
  47. #include <io.h>
  48. #include <alloc.h>
  49. #endif  /* __TURBOC__ */
  50.  
  51. #ifdef MSDOS
  52. #include <stdlib.h>
  53. #include <fcntl.h>
  54. #endif  /* MSDOS */
  55.  
  56. typedef unsigned char uchar;
  57.  
  58. #if defined(BITS) && BITS > 14
  59. typedef unsigned long hash_t;
  60. #else
  61. typedef u_short hash_t;
  62. #endif  /* BITS */
  63.  
  64. #ifdef  lint
  65. #define N2              256
  66. #else   /* lint */
  67. #define N2              8192    /* buffer size */
  68. #endif  /* lint */
  69.  
  70. #define F2              256     /* pre-sence buffer size */
  71. #define THRESHOLD    2
  72.  
  73. #define N_CHAR2         (256 - THRESHOLD + F2 + 1) /* code: 0 .. N_CHARi - 1 */
  74. #define T2              (N_CHAR2 * 2 - 1)       /* size of table */
  75.  
  76. #define ENDOF           256                     /* pseudo-literal */
  77.  
  78. extern uchar    Table2[];
  79.  
  80. extern long     in_count, bytes_out, file_length;
  81.  
  82. extern uchar    text_buf[];
  83. extern u_short  match_position, match_length;
  84.  
  85. extern short    quiet, force;      /* useful flags */
  86.  
  87. /* Note ind_threshold is triangle number of Kbytes */
  88.  
  89. extern long indc_threshold, indc_count;
  90.  
  91. extern short    do_melt, topipe, greedy;
  92.  
  93. #define MAGIC1          ((uchar)'\037')
  94. #define MAGIC2_1        ((uchar)'\236')          /* freeze vers. 1.X */
  95. #define MAGIC2_2        ((uchar)'\237')
  96.  
  97. extern int exit_stat;
  98.  
  99. #ifdef DEBUG
  100. extern short debug;
  101. extern short verbose;
  102. extern char * pr_char();
  103. extern long symbols_out, refers_out;
  104. #endif /* DEBUG */
  105.  
  106. #ifdef GATHER_STAT
  107. extern long node_steps, node_matches;
  108. #endif
  109.  
  110. extern short DecodeChar(), DecodePosition(), GetNBits();
  111. extern void melt2(), (*meltfunc)(), writeerr(), prratio(), prbits(), freeze();
  112.  
  113. #if defined(BSD42) && !defined(BSD4_2)
  114. #define BSD4_2
  115. #endif
  116.  
  117. #ifdef COMPAT
  118. #include "compat.h"
  119. #endif
  120.  
  121. #define INDICATOR \
  122. if (quiet < 0 && (in_count > indc_count)) {\
  123.     if (ferror(stdout))\
  124.         writeerr();\
  125.     if (file_length) {\
  126.         fprintf(stderr, " %2d%%\b\b\b\b",\
  127.             ftell(stdin) * 100 / file_length);\
  128.         indc_count += indc_threshold;\
  129.     } else {\
  130.         fprintf(stderr, " %5ldK\b\b\b\b\b\b\b", in_count / 1024);\
  131.         indc_count += indc_threshold;\
  132.         indc_threshold += 1024;\
  133.     }\
  134.     fflush (stderr);\
  135. }
  136.  
  137. #ifdef BSD4_2
  138. #define strchr index
  139. #endif
  140.