Added a command to make the output directory. This is to fix the XCode build that...
[cmake.git] / Utilities / cmcompress / cmcompress.h
blobfdb0d90b77c1f862a2a25a98dd157a58b85b9e1c
1 /*
2 * Copyright (c) 1985, 1986 The Regents of the University of California.
3 * All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * James A. Woods, derived from original work by Spencer Thomas
7 * and Joseph Orost.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
38 #ifndef __cmcompress__h_
39 #define __cmcompress__h_
41 #include <stdio.h>
43 #ifdef __cplusplus
44 extern "C"
46 #endif
49 * Set USERMEM to the maximum amount of physical user memory available
50 * in bytes. USERMEM is used to determine the maximum BITS that can be used
51 * for compression.
53 * SACREDMEM is the amount of physical memory saved for others; compress
54 * will hog the rest.
56 #ifndef SACREDMEM
57 #define SACREDMEM 0
58 #endif
60 #ifndef USERMEM
61 # define USERMEM 450000 /* default user memory */
62 #endif
64 #ifdef pdp11
65 # define BITS 12 /* max bits/code for 16-bit machine */
66 # define NO_UCHAR /* also if "unsigned char" functions as signed char */
67 # undef USERMEM
68 #endif /* pdp11 */ /* don't forget to compile with -i */
70 #ifdef USERMEM
71 # if USERMEM >= (433484+SACREDMEM)
72 # define PBITS 16
73 # else
74 # if USERMEM >= (229600+SACREDMEM)
75 # define PBITS 15
76 # else
77 # if USERMEM >= (127536+SACREDMEM)
78 # define PBITS 14
79 # else
80 # if USERMEM >= (73464+SACREDMEM)
81 # define PBITS 13
82 # else
83 # define PBITS 12
84 # endif
85 # endif
86 # endif
87 # endif
88 # undef USERMEM
89 #endif /* USERMEM */
91 #ifdef PBITS /* Preferred BITS for this memory size */
92 # ifndef BITS
93 # define BITS PBITS
94 # endif /* BITS */
95 #endif /* PBITS */
97 #if BITS == 16
98 # define HSIZE 69001 /* 95% occupancy */
99 #endif
100 #if BITS == 15
101 # define HSIZE 35023 /* 94% occupancy */
102 #endif
103 #if BITS == 14
104 # define HSIZE 18013 /* 91% occupancy */
105 #endif
106 #if BITS == 13
107 # define HSIZE 9001 /* 91% occupancy */
108 #endif
109 #if BITS <= 12
110 # define HSIZE 5003 /* 80% occupancy */
111 #endif
114 * a code_int must be able to hold 2**BITS values of type int, and also -1
116 #if BITS > 15
117 typedef long int code_int;
118 #else
119 typedef int code_int;
120 #endif
122 #ifdef SIGNED_COMPARE_SLOW
123 typedef unsigned long int count_int;
124 typedef unsigned short int count_short;
125 #else
126 typedef long int count_int;
127 #endif
129 #ifdef NO_UCHAR
130 typedef char char_type;
131 #else
132 typedef unsigned char char_type;
133 #endif /* UCHAR */
137 struct cmcompress_stream
139 int n_bits; /* number of bits/code */
140 int maxbits; /* user settable max # bits/code */
141 code_int maxcode; /* maximum code, given n_bits */
142 code_int maxmaxcode; /* should NEVER generate this code */
144 count_int htab [HSIZE];
145 unsigned short codetab [HSIZE];
147 code_int hsize; /* for dynamic table sizing */
148 code_int free_ent; /* first unused entry */
149 int nomagic; /* Use a 3-byte magic number header, unless old file */
152 * block compression parameters -- after all codes are used up,
153 * and compression rate changes, start over.
155 int block_compress;
156 int clear_flg;
157 long int ratio;
158 count_int checkpoint;
160 #ifdef DEBUG
161 int debug;
162 int verbose;
163 #endif
165 /* compress internals */
166 int offset;
167 long int in_count; /* length of input */
168 long int bytes_out; /* length of compressed output */
169 long int out_count; /* # of codes output (for debugging) */
171 /* internals */
172 code_int ent;
173 code_int hsize_reg;
174 int hshift;
176 long fcode;
177 int first_pass;
179 /* For input and output */
180 int (*input_stream)(void*);
181 int (*output_stream)(void*, const char*,int);
182 void* client_data;
185 int cmcompress_compress_initialize(struct cmcompress_stream* cdata);
186 int cmcompress_compress_start(struct cmcompress_stream* cdata);
187 int cmcompress_compress(struct cmcompress_stream* cdata, void* buff, size_t n);
188 int cmcompress_compress_finalize(struct cmcompress_stream* cdata);
190 #ifdef __cplusplus
192 #endif
195 #endif /* __cmcompress__h_ */