chiark / gitweb /
Add mandatory build-{arch,indep} targets (Closes: #821966)
[bible-kjv.git] / squish.h
1 /* $Id: squish.h,v 2.2 2005/01/22 17:15:57 matthew Exp $*/
2 #ifndef __SQUISH_H__
3 #define __SQUISH_H__
4
5 #include <stdio.h>
6
7 /*
8  * machine variants which require cc -Dmachine:  pdp11, z8000, pcxt
9  */
10
11 /*
12  * Set USERMEM to the maximum amount of physical user memory available
13  * in bytes.  USERMEM is used to determine the maximum BITS that can be used
14  * for compression.
15  *
16  * SACREDMEM is the amount of physical memory saved for others; compress
17  * will hog the rest.
18  */
19 #ifndef SACREDMEM
20 #define SACREDMEM       0
21 #endif
22
23 #ifndef USERMEM
24 # define USERMEM        450000  /* default user memory */
25 #endif
26
27 #ifdef interdata                /* (Perkin-Elmer) */
28 #define SIGNED_COMPARE_SLOW     /* signed compare is slower than unsigned */
29 #endif
30
31 #ifdef pdp11
32 # define BITS   12      /* max bits/code for 16-bit machine */
33 # define NO_UCHAR       /* also if "unsigned char" functions as signed char */
34 # undef USERMEM 
35 #endif /* pdp11 */      /* don't forget to compile with -i */
36
37 #ifdef z8000
38 # define BITS   12
39 # undef vax             /* weird preprocessor */
40 # undef USERMEM 
41 #endif /* z8000 */
42
43 #ifdef pcxt
44 # define BITS   12
45 # undef USERMEM
46 #endif /* pcxt */
47
48 #ifdef USERMEM
49 # if USERMEM >= (433484+SACREDMEM)
50 #  define PBITS 16
51 # else
52 #  if USERMEM >= (229600+SACREDMEM)
53 #   define PBITS        15
54 #  else
55 #   if USERMEM >= (127536+SACREDMEM)
56 #    define PBITS       14
57 #   else
58 #    if USERMEM >= (73464+SACREDMEM)
59 #     define PBITS      13
60 #    else
61 #     define PBITS      12
62 #    endif
63 #   endif
64 #  endif
65 # endif
66 # undef USERMEM
67 #endif /* USERMEM */
68
69 #ifdef PBITS            /* Preferred BITS for this memory size */
70 # ifndef BITS
71 #  define BITS PBITS
72 # endif /* BITS */
73 #endif /* PBITS */
74
75 #if BITS == 16
76 # define HSIZE  69001           /* 95% occupancy */
77 #endif
78 #if BITS == 15
79 # define HSIZE  35023           /* 94% occupancy */
80 #endif
81 #if BITS == 14
82 # define HSIZE  18013           /* 91% occupancy */
83 #endif
84 #if BITS == 13
85 # define HSIZE  9001            /* 91% occupancy */
86 #endif
87 #if BITS <= 12
88 # define HSIZE  5003            /* 80% occupancy */
89 #endif
90
91 #ifdef M_XENIX                  /* Stupid compiler can't handle arrays with */
92 # if BITS == 16                 /* more than 65535 bytes - so we fake it */
93 #  define XENIX_16
94 # else
95 #  if BITS > 13                 /* Code only handles BITS = 12, 13, or 16 */
96 #   define BITS 13
97 #  endif
98 # endif
99 #endif
100
101 /*
102  * a code_int must be able to hold 2**BITS values of type int, and also -1
103  */
104 #if BITS > 15
105 typedef long int        code_int;
106 #else
107 typedef int             code_int;
108 #endif
109
110 #ifdef SIGNED_COMPARE_SLOW
111 typedef unsigned long int count_int;
112 typedef unsigned short int count_short;
113 #else
114 typedef long int          count_int;
115 #endif
116
117 #ifdef NO_UCHAR
118  typedef char   char_type;
119 #else
120  typedef        unsigned char   char_type;
121 #endif /* UCHAR */
122 char_type magic_header[] = { "\037\235" };      /* 1F 9D */
123
124 /* Defines for third byte of header */
125 #define BIT_MASK        0x1f
126 #define BLOCK_MASK      0x80
127 /* Masks 0x40 and 0x20 are free.  I think 0x20 should mean that there is
128    a fourth header byte (for expansion).
129 */
130 #define INIT_BITS 9                     /* initial number of bits/code */
131
132
133 void Usage(void);
134 void compress(void);
135 void output(code_int code);
136 void decompress(void);
137 code_int getcode(void);
138 void writeerr(void);
139 int foreground(void);
140 void onintr (void);
141 void oops (void);
142 void cl_block (void);
143 void do_clearblock(void);
144 void cl_hash(count_int lhsize);
145 void prratio(FILE *stream,long int num,long int den);
146 void version(void);
147
148 #endif /*__SQUISH_H__*/