home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume35 / freeze / part02 / freeze.h < prev    next >
C/C++ Source or Header  |  1993-02-21  |  4KB  |  193 lines

  1. #include <stdio.h>
  2. #include "config.h"
  3.  
  4. #ifdef HAVE_SYS_STDTYPES_H
  5. # include <sys/stdtypes.h>
  6. #endif
  7.  
  8. #ifndef getc
  9. # ifdef m88k                   /* Green Hill C library bug. */
  10. #  define getc(p)         (--(p)->_cnt < 0 ? __filbuf(p) : (int) *(p)->_ptr++)
  11. # else
  12. #  define getc(p)         (--(p)->_cnt < 0 ? _filbuf(p) : (int) *(p)->_ptr++)
  13. # endif
  14. #endif
  15. #ifndef putc
  16. # ifdef m88k                   /* Green Hill C library bug. */
  17. #  define putc(x, p)      (--(p)->_cnt < 0 ? __flsbuf((unsigned char) (x), (p)) : (int) (*(p)->_ptr++ = (unsigned char) (x)))
  18. # else
  19. #  define putc(x, p)      (--(p)->_cnt < 0 ? _flsbuf((unsigned char) (x), (p)) : (int) (*(p)->_ptr++ = (unsigned char) (x)))
  20. # endif
  21. #endif
  22.  
  23. #if !defined(MSDOS) && defined(__MSDOS__)
  24. # define MSDOS
  25. #endif
  26.  
  27. #ifdef MSDOS
  28. # define DOS
  29. # include <fcntl.h>
  30. #endif  /* MSDOS */
  31.  
  32. #ifdef TOS
  33. # define DOS
  34. # define O_TEXT          0x01
  35. # define O_BINARY        0x02
  36. #endif
  37.  
  38. #include <ctype.h>
  39. #include <signal.h>
  40.  
  41. #ifndef RETSIGTYPE
  42. # define RETSIGTYPE void
  43. #endif /* RETSIGTYPE */
  44.  
  45. #ifndef TOS
  46. # include <sys/types.h>
  47. # include <sys/stat.h>
  48. #else
  49. # include <tos.h>
  50. # include <types.h>
  51. #endif
  52.  
  53. #ifdef SYSTIME
  54. # include <sys/time.h>
  55. # define UTIMES
  56. #else
  57. # ifdef UTIME
  58. #  include <utime.h>
  59. # else
  60. #  ifdef SYSUTIME
  61. #   include <sys/utime.h>
  62. #  else
  63. #   ifdef unix
  64. /*      UNIX without any declaration of utimbuf .... Strange! */
  65. struct utimbuf {
  66.     time_t actime;
  67.     time_t modtime;
  68. };
  69. extern int utime();
  70. #   else
  71. #    ifndef DOS
  72. #     define BITS no_utimbuf_definition_on_unknown_system
  73. #    endif
  74. #   endif
  75. #  endif
  76. # endif
  77. #endif
  78.  
  79. /* for MAXNAMLEN only !!! */
  80. #ifdef DIRENT
  81. # include <dirent.h>
  82. #else
  83. # ifdef SYSNDIR
  84. #  include <sys/ndir.h>
  85. # else
  86. #  ifdef SYSDIR
  87. #   include <sys/dir.h>
  88. #  endif
  89. # endif
  90. #endif
  91.  
  92. #ifndef MAXNAMLEN
  93. # define MAXNAMLEN       255
  94. #endif
  95.  
  96. #if MAXNAMLEN < 255
  97. # undef MAXNAMLEN
  98. # define MAXNAMLEN       255
  99. #endif
  100.  
  101. #ifdef DEBUG
  102. # include <assert.h>
  103. #endif  /* DEBUG */
  104.  
  105. #ifdef DOS
  106. # include <stdlib.h>
  107. #endif  /* DOS */
  108.  
  109. #ifdef __TURBOC__
  110. # ifdef MSDOS
  111. #  include <io.h>
  112. #  include <alloc.h>
  113. # else /* TOS */
  114. #  include <ext.h>
  115. # endif  /* MSDOS */
  116. #endif /* __TURBOC__ */
  117.  
  118. typedef unsigned short us_t;
  119. typedef unsigned char uc_t;
  120. typedef unsigned long ul_t;
  121.  
  122. #define LOOKAHEAD       256     /* pre-sence buffer size */
  123. #define MAXDIST         7936
  124. #define WINSIZE         (MAXDIST + LOOKAHEAD)   /* must be a power of 2 */
  125. #define WINMASK         (WINSIZE - 1)
  126.  
  127. #define THRESHOLD    2
  128.  
  129. #define N_CHAR2         (256 - THRESHOLD + LOOKAHEAD + 1) /* code: 0 .. N_CHARi - 1 */
  130. #define T2              (N_CHAR2 * 2 - 1)       /* size of table */
  131.  
  132. #define ENDOF           256                     /* pseudo-literal */
  133.  
  134. extern uc_t    Table2[];
  135.  
  136. extern long     in_count;
  137. extern off_t    file_length;
  138.  
  139. extern uc_t     text_buf[];
  140.  
  141. extern long     indc_threshold, indc_count;
  142.  
  143. extern int      do_melt, topipe, greedy, quiet, force;  /* useful flags */
  144.  
  145. #define MAGIC1          ((uc_t)'\037')
  146. #define MAGIC2_1        ((uc_t)'\236')          /* freeze vers. 1.X */
  147. #define MAGIC2_2        ((uc_t)'\237')
  148.  
  149. extern int exit_stat;
  150.  
  151. #ifdef DEBUG
  152. extern int debug, verbose;
  153. extern char * pr_char();
  154. #endif /* DEBUG */
  155.  
  156. #if defined(GATHER_STAT) || defined(DEBUG)
  157. extern long refers_out, symbols_out;
  158. #endif
  159.  
  160. extern void melt2(), (*meltfunc)(), writeerr(), prratio(), prbits(), freeze();
  161.  
  162. #ifdef COMPAT
  163. #include "compat.h"
  164. #endif
  165.  
  166. #define INDICATOR \
  167. if (quiet < 0 && (in_count > indc_count)) {\
  168.     if (ferror(stdout))\
  169.         writeerr();\
  170.     if (file_length) {\
  171.         static int percents, old_percents = -1;\
  172.         if ((percents = ftell(stdin) * 100 / file_length) !=\
  173.             old_percents) {\
  174.             fprintf(stderr, " %2d%%\b\b\b\b", percents);\
  175.             old_percents = percents;\
  176.         }\
  177.         indc_count += indc_threshold;\
  178.     } else {\
  179.         fprintf(stderr, " %5ldK\b\b\b\b\b\b\b", in_count / 1024);\
  180.         indc_count += indc_threshold;\
  181.         indc_threshold += 1024;\
  182.     }\
  183.     fflush (stderr);\
  184. }
  185.  
  186. #ifdef HAVE_RINDEX
  187. #define strchr index
  188. #define strrchr rindex
  189. #endif
  190.  
  191. extern char *strchr(), *strrchr();
  192.  
  193.