home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / FREEZE-2.ZIP / freeze.h < prev    next >
C/C++ Source or Header  |  1992-07-18  |  4KB  |  181 lines

  1. #include <stdio.h>
  2.  
  3. #ifdef SUN4
  4. #include <sys/stdtypes.h>
  5. #else   /* SUN4 */
  6. # ifndef __EMX__
  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. # endif
  14. #endif  /* SUN4 */
  15.  
  16. #if !defined(MSDOS) && defined(__MSDOS__)
  17. #define MSDOS
  18. #endif
  19.  
  20. #ifdef MSDOS
  21. #define DOS
  22. # include <fcntl.h>
  23. #endif  /* MSDOS */
  24.  
  25. #ifdef TOS
  26. #define DOS
  27. #define O_TEXT        0x01
  28. #define O_BINARY    0x02
  29. #endif
  30.  
  31. #include <ctype.h>
  32. #include <signal.h>
  33.  
  34. #ifndef TOS
  35. #include <sys/types.h>
  36. #include <sys/stat.h>
  37. #else
  38. #include <tos.h>
  39. #include <types.h>
  40. #endif
  41.  
  42. #if !defined(__TURBOC__) && (!defined(M_XENIX) || defined(M_I386))
  43. #ifdef UTIMES
  44. #include <sys/time.h>
  45. #else
  46. #include <sys/utime.h>      /* Some systems have sys/utime.h instead of utime.h */
  47. #endif /* UTIMES */
  48. #else
  49. #ifdef M_XENIX
  50. struct utimbuf {
  51.     time_t actime;
  52.     time_t modtime;
  53. };
  54.  
  55. extern int utime();
  56. #endif
  57. #endif
  58.  
  59. /* for MAXNAMLEN only !!! */
  60. #ifdef unix
  61. #ifndef BSD
  62. #include <dirent.h>
  63. #else
  64. #include <sys/dir.h>
  65. #endif /* BSD */
  66. #endif /* unix */
  67.  
  68. #if !defined(MAXNAMLEN)
  69. #define MAXNAMLEN       255
  70. #else
  71. #if MAXNAMLEN < 255
  72. #undef MAXNAMLEN
  73. #define MAXNAMLEN       255
  74. #endif
  75. #endif
  76.  
  77. #ifdef DEBUG
  78. #include <assert.h>
  79. #endif  /* DEBUG */
  80.  
  81. #ifdef DOS
  82. # include <stdlib.h>
  83. #endif  /* DOS */
  84.  
  85. #ifdef __TURBOC__
  86. # ifdef MSDOS
  87. #  include <io.h>
  88. #  include <alloc.h>
  89. # else /* TOS */
  90. #  include <ext.h>
  91. # endif  /* MSDOS */
  92. #if !defined(SIGTYPE)
  93. #define SIGTYPE void
  94. #endif
  95. #endif /* __TURBOC__ */
  96.  
  97. typedef unsigned short us_t;
  98. typedef unsigned char uc_t;
  99. typedef unsigned long ul_t;
  100.  
  101. #if defined(BITS) && BITS > 14
  102. typedef ul_t hash_t;
  103. #else
  104. typedef us_t hash_t;
  105. #endif  /* BITS */
  106.  
  107. #ifdef  lint
  108. #define N2              256
  109. #else   /* lint */
  110. #define N2              8192    /* buffer size */
  111. #endif  /* lint */
  112.  
  113. #define F2              256     /* pre-sence buffer size */
  114. #define THRESHOLD    2
  115.  
  116. #define N_CHAR2         (256 - THRESHOLD + F2 + 1) /* code: 0 .. N_CHARi - 1 */
  117. #define T2              (N_CHAR2 * 2 - 1)       /* size of table */
  118.  
  119. #define ENDOF           256                     /* pseudo-literal */
  120.  
  121. extern uc_t    Table2[];
  122.  
  123. extern long     in_count, bytes_out, file_length;
  124.  
  125. extern uc_t      text_buf[];
  126.  
  127. extern long     indc_threshold, indc_count;
  128.  
  129. extern short    do_melt, topipe, greedy, quiet, force;  /* useful flags */
  130.  
  131. #define MAGIC1          ((uc_t)'\037')
  132. #define MAGIC2_1        ((uc_t)'\236')          /* freeze vers. 1.X */
  133. #define MAGIC2_2        ((uc_t)'\237')
  134.  
  135. extern int exit_stat;
  136.  
  137. #ifdef DEBUG
  138. extern short debug;
  139. extern short verbose;
  140. extern char * pr_char();
  141. extern long symbols_out, refers_out;
  142. #endif /* DEBUG */
  143.  
  144. #ifdef GATHER_STAT
  145. extern long node_steps, node_matches;
  146. #endif
  147.  
  148. extern short DecodeChar(), DecodePosition(), GetNBits();
  149. extern void melt2(), (*meltfunc)(), writeerr(), prratio(), prbits(), freeze();
  150.  
  151. #ifdef COMPAT
  152. #include "compat.h"
  153. #endif
  154.  
  155. #define INDICATOR \
  156. if (quiet < 0 && (in_count > indc_count)) {\
  157.     if (ferror(stdout))\
  158.         writeerr();\
  159.     if (file_length) {\
  160.         static int percents, old_percents = -1;\
  161.         if ((percents = ftell(stdin) * 100 / file_length) !=\
  162.             old_percents) {\
  163.             fprintf(stderr, " %2d%%\b\b\b\b", percents);\
  164.             old_percents = percents;\
  165.         }\
  166.         indc_count += indc_threshold;\
  167.     } else {\
  168.         fprintf(stderr, " %5ldK\b\b\b\b\b\b\b", in_count / 1024);\
  169.         indc_count += indc_threshold;\
  170.         indc_threshold += 1024;\
  171.     }\
  172.     fflush (stderr);\
  173. }
  174.  
  175. #ifdef BSD
  176. #define strchr index
  177. #define strrchr rindex
  178. #endif
  179.  
  180. extern char *strchr(), *strrchr();
  181.