]> git.cworth.org Git - gzip/blob - tailor.h
Avoid creating an undersized buffer for the hufts table.
[gzip] / tailor.h
1 /* tailor.h -- target dependent definitions
2
3    Copyright (C) 1997, 1998, 1999, 2002, 2006 Free Software Foundation, Inc.
4    Copyright (C) 1992-1993 Jean-loup Gailly
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software Foundation,
18    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19
20 /* The target dependent definitions should be defined here only.
21  * The target dependent functions should be defined in tailor.c.
22  */
23
24 /* $Id: tailor.h,v 1.5 2006/12/07 06:58:13 eggert Exp $ */
25
26 #if defined(__MSDOS__) && !defined(MSDOS)
27 #  define MSDOS
28 #endif
29
30 #if defined(__OS2__) && !defined(OS2)
31 #  define OS2
32 #endif
33
34 #if defined(OS2) && defined(MSDOS) /* MS C under OS/2 */
35 #  undef MSDOS
36 #endif
37
38 #ifdef MSDOS
39 #  ifdef __GNUC__
40      /* DJGPP version 1.09+ on MS-DOS.
41       * The DJGPP 1.09 stat() function must be upgraded before gzip will
42       * fully work.
43       * No need for HAVE_DIRENT_H, since <unistd.h> defines POSIX_SOURCE which
44       * implies HAVE_DIRENT_H.
45       */
46 #    define near
47 #  else
48 #    define MAXSEG_64K
49 #    ifdef __TURBOC__
50 #      define off_t long
51 #      ifdef __BORLANDC__
52 #        define HAVE_DIRENT_H
53 #      endif
54 #      define HAVE_UTIME_H
55 #    else /* MSC */
56 #      define HAVE_SYS_UTIME_H
57 #    endif
58 #  endif
59 #  define PATH_SEP2 '\\'
60 #  define PATH_SEP3 ':'
61 #  define MAX_PATH_LEN  128
62 #  define NO_MULTIPLE_DOTS
63 #  define MAX_EXT_CHARS 3
64 #  define Z_SUFFIX "z"
65 #  define PROTO
66 #  define STDC_HEADERS
67 #  define NO_SIZE_CHECK
68 #  define UNLINK_READONLY_BUG
69 #  define casemap(c) tolow(c) /* Force file names to lower case */
70 #  include <io.h>
71 #  define OS_CODE  0x00
72 #  define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
73 #  if !defined(NO_ASM) && !defined(ASMV)
74 #    define ASMV
75 #  endif
76 #else
77 #  define near
78 #endif
79
80 #ifdef OS2
81 #  define PATH_SEP2 '\\'
82 #  define PATH_SEP3 ':'
83 #  define MAX_PATH_LEN  260
84 #  ifdef OS2FAT
85 #    define NO_MULTIPLE_DOTS
86 #    define MAX_EXT_CHARS 3
87 #    define Z_SUFFIX "z"
88 #    define casemap(c) tolow(c)
89 #  endif
90 #  define PROTO
91 #  define STDC_HEADERS
92 #  define UNLINK_READONLY_BUG
93 #  include <io.h>
94 #  define OS_CODE  0x06
95 #  define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
96 #  ifdef _MSC_VER
97 #    define HAVE_SYS_UTIME_H
98 #    define MAXSEG_64K
99 #    undef near
100 #    define near _near
101 #  endif
102 #  ifdef __EMX__
103 #    define HAVE_SYS_UTIME_H
104 #    define HAVE_DIRENT_H
105 #    define EXPAND(argc,argv) \
106        {_response(&argc, &argv); _wildcard(&argc, &argv);}
107 #  endif
108 #  ifdef __BORLANDC__
109 #    define HAVE_DIRENT_H
110 #    define HAVE_UTIME_H
111 #  endif
112 #  ifdef __ZTC__
113 #    define NO_DIR 1
114 #    include <dos.h>
115 #    define EXPAND(argc,argv) \
116        {response_expand(&argc, &argv);}
117 #  endif
118 #endif
119
120 #ifdef WIN32 /* Windows NT */
121 #  define HAVE_SYS_UTIME_H
122 #  define PATH_SEP2 '\\'
123 #  define PATH_SEP3 ':'
124 #  define MAX_PATH_LEN  260
125 #  define PROTO
126 #  define STDC_HEADERS
127 #  define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
128 #  define UNLINK_READONLY_BUG
129 #  include <io.h>
130 #  include <malloc.h>
131 #  ifdef NTFAT
132 #    define NO_MULTIPLE_DOTS
133 #    define MAX_EXT_CHARS 3
134 #    define Z_SUFFIX "z"
135 #    define casemap(c) tolow(c) /* Force file names to lower case */
136 #  endif
137 #  define OS_CODE  0x0b
138 #endif
139
140 #ifdef MSDOS
141 #  ifdef __TURBOC__
142 #    include <alloc.h>
143 #    define DYN_ALLOC
144      /* Turbo C 2.0 does not accept static allocations of large arrays */
145      void * fcalloc (unsigned items, unsigned size);
146      void fcfree (void *ptr);
147 #  else /* MSC */
148 #    include <malloc.h>
149 #    define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize))
150 #    define fcfree(ptr) hfree(ptr)
151 #  endif
152 #else
153 #  ifdef MAXSEG_64K
154 #    define fcalloc(items,size) calloc((items),(size))
155 #  else
156 #    define fcalloc(items,size) malloc((size_t)(items)*(size_t)(size))
157 #  endif
158 #  define fcfree(ptr) free(ptr)
159 #endif
160
161 #if defined(VAXC) || defined(VMS)
162 #  define PATH_SEP ']'
163 #  define PATH_SEP2 ':'
164 #  define SUFFIX_SEP ';'
165 #  define NO_MULTIPLE_DOTS
166 #  define Z_SUFFIX "-gz"
167 #  define RECORD_IO 1
168 #  define casemap(c) tolow(c)
169 #  define OS_CODE  0x02
170 #  define OPTIONS_VAR "GZIP_OPT"
171 #  define STDC_HEADERS
172 #  define EXPAND(argc,argv) vms_expand_args(&argc,&argv);
173 #  include <file.h>
174 #  define unlink delete
175 #  ifdef VAXC
176 #    include <unixio.h>
177 #  else
178 #    define HAVE_FCNTL_H
179 #  endif
180 #endif
181
182 #ifdef AMIGA
183 #  define PATH_SEP2 ':'
184 #  define STDC_HEADERS
185 #  define OS_CODE  0x01
186 #  define ASMV
187 #  ifdef __GNUC__
188 #    define HAVE_DIRENT_H
189 #    define HAVE_FCNTL_H
190 #    define HAVE_UNISTD_H
191 #    define HAVE_CHOWN
192 #    define HAVE_LSTAT
193 #  else /* SASC */
194 #    define NO_STDIN_FSTAT
195 #    define HAVE_SYS_DIR_H
196 #    include <fcntl.h> /* for read() and write() */
197 #    define direct dirent
198      extern void _expand_args(int *argc, char ***argv);
199 #    define EXPAND(argc,argv) _expand_args(&argc,&argv);
200 #    undef  O_BINARY /* disable useless --ascii option */
201 #  endif
202 #endif
203
204 #if defined(ATARI) || defined(atarist)
205 #  ifndef STDC_HEADERS
206 #    define STDC_HEADERS
207 #    define HAVE_UNISTD_H
208 #    define HAVE_DIRENT_H
209 #  endif
210 #  define ASMV
211 #  define OS_CODE  0x05
212 #  ifdef TOSFS
213 #    define PATH_SEP2 '\\'
214 #    define PATH_SEP3 ':'
215 #    define MAX_PATH_LEN  128
216 #    define NO_MULTIPLE_DOTS
217 #    define MAX_EXT_CHARS 3
218 #    define Z_SUFFIX "z"
219 #    define casemap(c) tolow(c) /* Force file names to lower case */
220 #  endif
221 #endif
222
223 #ifdef MACOS
224 #  define PATH_SEP ':'
225 #  define DYN_ALLOC
226 #  define PROTO
227 #  define NO_STDIN_FSTAT
228 #  define chmod(file, mode) (0)
229 #  define OPEN(name, flags, mode) open(name, flags)
230 #  define OS_CODE  0x07
231 #  ifdef MPW
232 #    define isatty(fd) ((fd) <= 2)
233 #  endif
234 #endif
235
236 #ifdef __50SERIES /* Prime/PRIMOS */
237 #  define PATH_SEP '>'
238 #  define STDC_HEADERS
239 #  define NO_STDIN_FSTAT
240 #  define NO_SIZE_CHECK
241 #  define RECORD_IO  1
242 #  define casemap(c)  tolow(c) /* Force file names to lower case */
243 #  define put_char(c) put_byte((c) & 0x7F)
244 #  define get_char(c) ascii2pascii(get_byte())
245 #  define OS_CODE  0x0F    /* temporary, subject to change */
246 #  ifdef SIGTERM
247 #    undef SIGTERM         /* We don't want a signal handler for SIGTERM */
248 #  endif
249 #endif
250
251 #if defined(pyr) && !defined(NOMEMCPY) /* Pyramid */
252 #  define NOMEMCPY /* problem with overlapping copies */
253 #endif
254
255 #ifdef TOPS20
256 #  define OS_CODE  0x0a
257 #endif
258
259
260         /* Common defaults */
261
262 #ifndef OS_CODE
263 #  define OS_CODE  0x03  /* assume Unix */
264 #endif
265
266 #ifndef PATH_SEP
267 #  define PATH_SEP '/'
268 #endif
269
270 #ifndef casemap
271 #  define casemap(c) (c)
272 #endif
273
274 #ifndef OPTIONS_VAR
275 #  define OPTIONS_VAR "GZIP"
276 #endif
277
278 #ifndef Z_SUFFIX
279 #  define Z_SUFFIX ".gz"
280 #endif
281
282 #ifdef MAX_EXT_CHARS
283 #  define MAX_SUFFIX  MAX_EXT_CHARS
284 #else
285 #  define MAX_SUFFIX  30
286 #endif
287
288 #ifndef MAKE_LEGAL_NAME
289 #  ifdef NO_MULTIPLE_DOTS
290 #    define MAKE_LEGAL_NAME(name)   make_simple_name(name)
291 #  else
292 #    define MAKE_LEGAL_NAME(name)
293 #  endif
294 #endif
295
296 #ifndef MIN_PART
297 #  define MIN_PART 3
298    /* keep at least MIN_PART chars between dots in a file name. */
299 #endif
300
301 #ifndef EXPAND
302 #  define EXPAND(argc,argv)
303 #endif
304
305 #ifndef RECORD_IO
306 #  define RECORD_IO 0
307 #endif
308
309 #ifndef SET_BINARY_MODE
310 #  define SET_BINARY_MODE(fd)
311 #endif
312
313 #ifndef OPEN
314 #  define OPEN(name, flags, mode) open_safer (name, flags, mode)
315 #endif
316
317 #ifndef get_char
318 #  define get_char() get_byte()
319 #endif
320
321 #ifndef put_char
322 #  define put_char(c) put_byte(c)
323 #endif