xref: /illumos-gate/usr/src/contrib/ast/src/cmd/INIT/ratz.c (revision b30d1939)
1*b30d1939SAndy Fiddaman /*
2*b30d1939SAndy Fiddaman  * ratz -- read a tar gzip archive from the standard input
3*b30d1939SAndy Fiddaman  *
4*b30d1939SAndy Fiddaman  * coded for portability
5*b30d1939SAndy Fiddaman  * _SEAR_* macros for win32 self extracting archives -- see sear(1).
6*b30d1939SAndy Fiddaman  */
7*b30d1939SAndy Fiddaman 
8*b30d1939SAndy Fiddaman static char id[] = "\n@(#)$Id: ratz (Jean-loup Gailly, Mark Adler, Glenn Fowler) 1.2.3 2010-10-10 $\0\n";
9*b30d1939SAndy Fiddaman 
10*b30d1939SAndy Fiddaman #if _PACKAGE_ast
11*b30d1939SAndy Fiddaman 
12*b30d1939SAndy Fiddaman #include <ast.h>
13*b30d1939SAndy Fiddaman #include <error.h>
14*b30d1939SAndy Fiddaman 
15*b30d1939SAndy Fiddaman static const char usage[] =
16*b30d1939SAndy Fiddaman "[-?\n@(#)$Id: ratz (Jean-loup Gailly, Mark Adler, Glenn Fowler) 1.2.3 2010-10-10 $\n]"
17*b30d1939SAndy Fiddaman "[-author?Jean-loup Gailly]"
18*b30d1939SAndy Fiddaman "[-author?Mark Adler]"
19*b30d1939SAndy Fiddaman "[-author?Glenn Fowler <gsf@research.att.com>]"
20*b30d1939SAndy Fiddaman "[-copyright?Copyright (c) 1995-2005 Jean-loup Gailly and Mark Adler]"
21*b30d1939SAndy Fiddaman "[-license?http://www.opensource.org/licenses/zlib-license]"
22*b30d1939SAndy Fiddaman "[+NAME?ratz - read a tar gzip archive]"
23*b30d1939SAndy Fiddaman "[+DESCRIPTION?\bratz\b extracts files and directories from a tar gzip"
24*b30d1939SAndy Fiddaman "	archive on the standard input. It is a standalone program for systems"
25*b30d1939SAndy Fiddaman "	that do not have \bpax\b(1), \btar\b(1) or \bgunzip\b(1). Only regular"
26*b30d1939SAndy Fiddaman "	files and directories are extracted; all other file types are ignored.]"
27*b30d1939SAndy Fiddaman "[+?\b.exe\b files generated by \bsear\b(1) are fully functional \bratz\b"
28*b30d1939SAndy Fiddaman "	executables, so any \bratz\b option may be used on a \bsear\b file."
29*b30d1939SAndy Fiddaman "	This allows \bsear\b file contents to be examined and extracted without"
30*b30d1939SAndy Fiddaman "	executing any embedded installation scripts.]"
31*b30d1939SAndy Fiddaman "[c:cat|uncompress?Uncompress the standard input and copy it to the standard"
32*b30d1939SAndy Fiddaman "	output.]"
33*b30d1939SAndy Fiddaman #if defined(_SEAR_EXEC) || defined(_SEAR_SEEK)
34*b30d1939SAndy Fiddaman "[i!:install?Execute the sear installation script.]"
35*b30d1939SAndy Fiddaman "[k:keep?Keep the installation temporary directory.]"
36*b30d1939SAndy Fiddaman #endif
37*b30d1939SAndy Fiddaman "[l:local?Reject files that traverse outside the current directory.]"
38*b30d1939SAndy Fiddaman "[m:meter?Display a one line text meter showing archive read progress.]"
39*b30d1939SAndy Fiddaman "[n!:convert?In ebcdic environments convert text archive members from ascii"
40*b30d1939SAndy Fiddaman "	to the native ebcdic.]"
41*b30d1939SAndy Fiddaman "[t:list?List each file path on the standard output but do not extract.]"
42*b30d1939SAndy Fiddaman "[v:verbose?List each file path on the standard output as it is extracted.]"
43*b30d1939SAndy Fiddaman "[V?Print the program version and exit.]"
44*b30d1939SAndy Fiddaman "[+SEE ALSO?\bgunzip\b(1), \bpackage\b(1), \bpax\b(1), \bsear\b(1), \btar\b(1)]"
45*b30d1939SAndy Fiddaman ;
46*b30d1939SAndy Fiddaman 
47*b30d1939SAndy Fiddaman #else
48*b30d1939SAndy Fiddaman 
49*b30d1939SAndy Fiddaman #define NiL		((char*)0)
50*b30d1939SAndy Fiddaman 
51*b30d1939SAndy Fiddaman #endif
52*b30d1939SAndy Fiddaman 
53*b30d1939SAndy Fiddaman #define METER_width	80
54*b30d1939SAndy Fiddaman #define METER_parts	20
55*b30d1939SAndy Fiddaman 
56*b30d1939SAndy Fiddaman #ifndef _GUNZIP_H
57*b30d1939SAndy Fiddaman #define _GUNZIP_H	1
58*b30d1939SAndy Fiddaman 
59*b30d1939SAndy Fiddaman /*
60*b30d1939SAndy Fiddaman  * stripped down zlib containing public gzfopen()+gzread() in one file
61*b30d1939SAndy Fiddaman  * USE THE REAL ZLIB AFTER BOOTSTRAP
62*b30d1939SAndy Fiddaman  */
63*b30d1939SAndy Fiddaman 
64*b30d1939SAndy Fiddaman #define ZLIB_INTERNAL	1
65*b30d1939SAndy Fiddaman #define NO_GZCOMPRESS	1
66*b30d1939SAndy Fiddaman 
67*b30d1939SAndy Fiddaman #define gz_headerp	voidp
68*b30d1939SAndy Fiddaman 
69*b30d1939SAndy Fiddaman #include <stdio.h>
70*b30d1939SAndy Fiddaman #include <sys/types.h>
71*b30d1939SAndy Fiddaman 
72*b30d1939SAndy Fiddaman #if _PACKAGE_ast || defined(__STDC__) || defined(_SEAR_EXEC) || defined(_WIN32)
73*b30d1939SAndy Fiddaman 
74*b30d1939SAndy Fiddaman #define FOPEN_READ	"rb"
75*b30d1939SAndy Fiddaman #define FOPEN_WRITE	"wb"
76*b30d1939SAndy Fiddaman 
77*b30d1939SAndy Fiddaman #else
78*b30d1939SAndy Fiddaman 
79*b30d1939SAndy Fiddaman #define FOPEN_READ	"r"
80*b30d1939SAndy Fiddaman #define FOPEN_WRITE	"w"
81*b30d1939SAndy Fiddaman 
82*b30d1939SAndy Fiddaman #endif
83*b30d1939SAndy Fiddaman 
84*b30d1939SAndy Fiddaman #ifndef O_BINARY
85*b30d1939SAndy Fiddaman #define O_BINARY	0
86*b30d1939SAndy Fiddaman #endif
87*b30d1939SAndy Fiddaman 
88*b30d1939SAndy Fiddaman #if _PACKAGE_ast
89*b30d1939SAndy Fiddaman 
90*b30d1939SAndy Fiddaman #ifndef setmode
91*b30d1939SAndy Fiddaman #define setmode(d,m)
92*b30d1939SAndy Fiddaman #endif
93*b30d1939SAndy Fiddaman 
94*b30d1939SAndy Fiddaman #else
95*b30d1939SAndy Fiddaman 
96*b30d1939SAndy Fiddaman #if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
97*b30d1939SAndy Fiddaman #define _WINIX		1
98*b30d1939SAndy Fiddaman #endif
99*b30d1939SAndy Fiddaman 
100*b30d1939SAndy Fiddaman #if _WIN32 && !_WINIX
101*b30d1939SAndy Fiddaman 
102*b30d1939SAndy Fiddaman #include <direct.h>
103*b30d1939SAndy Fiddaman #include <io.h>
104*b30d1939SAndy Fiddaman #include <fcntl.h>
105*b30d1939SAndy Fiddaman #include <windows.h>
106*b30d1939SAndy Fiddaman 
107*b30d1939SAndy Fiddaman #define access		_access
108*b30d1939SAndy Fiddaman #define chmod		_chmod
109*b30d1939SAndy Fiddaman #define close		_close
110*b30d1939SAndy Fiddaman #define dup		_dup
111*b30d1939SAndy Fiddaman #define lseek		_lseek
112*b30d1939SAndy Fiddaman #define open		_open
113*b30d1939SAndy Fiddaman #define read		_read
114*b30d1939SAndy Fiddaman #define setmode		_setmode
115*b30d1939SAndy Fiddaman #define unlink		_unlink
116*b30d1939SAndy Fiddaman 
117*b30d1939SAndy Fiddaman #define mkdir(a,b)	_mkdir(a)
118*b30d1939SAndy Fiddaman 
119*b30d1939SAndy Fiddaman #else
120*b30d1939SAndy Fiddaman 
121*b30d1939SAndy Fiddaman #define HAVE_UNISTD_H	1
122*b30d1939SAndy Fiddaman 
123*b30d1939SAndy Fiddaman #include <unistd.h>
124*b30d1939SAndy Fiddaman #include <errno.h>
125*b30d1939SAndy Fiddaman 
126*b30d1939SAndy Fiddaman #ifndef setmode
127*b30d1939SAndy Fiddaman #define setmode(d,m)
128*b30d1939SAndy Fiddaman #endif
129*b30d1939SAndy Fiddaman 
130*b30d1939SAndy Fiddaman #endif
131*b30d1939SAndy Fiddaman 
132*b30d1939SAndy Fiddaman #if defined(__STDC__)
133*b30d1939SAndy Fiddaman 
134*b30d1939SAndy Fiddaman #include <stdlib.h>
135*b30d1939SAndy Fiddaman #include <string.h>
136*b30d1939SAndy Fiddaman 
137*b30d1939SAndy Fiddaman #endif
138*b30d1939SAndy Fiddaman 
139*b30d1939SAndy Fiddaman #endif
140*b30d1939SAndy Fiddaman 
141*b30d1939SAndy Fiddaman #ifndef _ZLIB_H
142*b30d1939SAndy Fiddaman #define _ZLIB_H		1
143*b30d1939SAndy Fiddaman 
144*b30d1939SAndy Fiddaman /* zlib.h -- interface of the 'zlib' general purpose compression library
145*b30d1939SAndy Fiddaman   version 1.2.3, July 18th, 2005
146*b30d1939SAndy Fiddaman 
147*b30d1939SAndy Fiddaman   Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
148*b30d1939SAndy Fiddaman 
149*b30d1939SAndy Fiddaman   This software is provided 'as-is', without any express or implied
150*b30d1939SAndy Fiddaman   warranty.  In no event will the authors be held liable for any damages
151*b30d1939SAndy Fiddaman   arising from the use of this software.
152*b30d1939SAndy Fiddaman 
153*b30d1939SAndy Fiddaman   Permission is granted to anyone to use this software for any purpose,
154*b30d1939SAndy Fiddaman   including commercial applications, and to alter it and redistribute it
155*b30d1939SAndy Fiddaman   freely, subject to the following restrictions:
156*b30d1939SAndy Fiddaman 
157*b30d1939SAndy Fiddaman   1. The origin of this software must not be misrepresented; you must not
158*b30d1939SAndy Fiddaman      claim that you wrote the original software. If you use this software
159*b30d1939SAndy Fiddaman      in a product, an acknowledgment in the product documentation would be
160*b30d1939SAndy Fiddaman      appreciated but is not required.
161*b30d1939SAndy Fiddaman   2. Altered source versions must be plainly marked as such, and must not be
162*b30d1939SAndy Fiddaman      misrepresented as being the original software.
163*b30d1939SAndy Fiddaman   3. This notice may not be removed or altered from any source distribution.
164*b30d1939SAndy Fiddaman 
165*b30d1939SAndy Fiddaman   Jean-loup Gailly        Mark Adler
166*b30d1939SAndy Fiddaman   jloup@gzip.org          madler@alumni.caltech.edu
167*b30d1939SAndy Fiddaman 
168*b30d1939SAndy Fiddaman 
169*b30d1939SAndy Fiddaman   The data format used by the zlib library is described by RFCs (Request for
170*b30d1939SAndy Fiddaman   Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
171*b30d1939SAndy Fiddaman   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
172*b30d1939SAndy Fiddaman */
173*b30d1939SAndy Fiddaman 
174*b30d1939SAndy Fiddaman #ifndef _ZCONF_H
175*b30d1939SAndy Fiddaman #define _ZCONF_H	1
176*b30d1939SAndy Fiddaman 
177*b30d1939SAndy Fiddaman #if _PACKAGE_ast
178*b30d1939SAndy Fiddaman #include <ast_std.h>	/* for { _WINIX __IMPORT__ __EXPORT__ } */
179*b30d1939SAndy Fiddaman #define z_off_t		int32_t
180*b30d1939SAndy Fiddaman #if _typ_int64_t
181*b30d1939SAndy Fiddaman #define z_off64_t	int64_t
182*b30d1939SAndy Fiddaman #endif
183*b30d1939SAndy Fiddaman #else
184*b30d1939SAndy Fiddaman #if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
185*b30d1939SAndy Fiddaman #define _WINIX		1
186*b30d1939SAndy Fiddaman #endif
187*b30d1939SAndy Fiddaman #endif
188*b30d1939SAndy Fiddaman 
189*b30d1939SAndy Fiddaman #if _BLD_z && defined(__EXPORT__)
190*b30d1939SAndy Fiddaman #define ZEXTERN		__EXPORT__
191*b30d1939SAndy Fiddaman #define ZEXPORT
192*b30d1939SAndy Fiddaman #endif
193*b30d1939SAndy Fiddaman 
194*b30d1939SAndy Fiddaman #if defined(__MSDOS__) && !defined(MSDOS)
195*b30d1939SAndy Fiddaman #  define MSDOS
196*b30d1939SAndy Fiddaman #endif
197*b30d1939SAndy Fiddaman #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
198*b30d1939SAndy Fiddaman #  define OS2
199*b30d1939SAndy Fiddaman #endif
200*b30d1939SAndy Fiddaman #if defined(_WINDOWS) && !defined(WINDOWS)
201*b30d1939SAndy Fiddaman #  define WINDOWS
202*b30d1939SAndy Fiddaman #endif
203*b30d1939SAndy Fiddaman #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
204*b30d1939SAndy Fiddaman #  ifndef WIN32
205*b30d1939SAndy Fiddaman #    define WIN32
206*b30d1939SAndy Fiddaman #  endif
207*b30d1939SAndy Fiddaman #endif
208*b30d1939SAndy Fiddaman #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
209*b30d1939SAndy Fiddaman #  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
210*b30d1939SAndy Fiddaman #    ifndef SYS16BIT
211*b30d1939SAndy Fiddaman #      define SYS16BIT
212*b30d1939SAndy Fiddaman #    endif
213*b30d1939SAndy Fiddaman #  endif
214*b30d1939SAndy Fiddaman #endif
215*b30d1939SAndy Fiddaman 
216*b30d1939SAndy Fiddaman /*
217*b30d1939SAndy Fiddaman  * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
218*b30d1939SAndy Fiddaman  * than 64k bytes at a time (needed on systems with 16-bit int).
219*b30d1939SAndy Fiddaman  */
220*b30d1939SAndy Fiddaman #ifdef SYS16BIT
221*b30d1939SAndy Fiddaman #  define MAXSEG_64K
222*b30d1939SAndy Fiddaman #endif
223*b30d1939SAndy Fiddaman #ifdef MSDOS
224*b30d1939SAndy Fiddaman #  define UNALIGNED_OK
225*b30d1939SAndy Fiddaman #endif
226*b30d1939SAndy Fiddaman 
227*b30d1939SAndy Fiddaman #ifdef __STDC_VERSION__
228*b30d1939SAndy Fiddaman #  ifndef STDC
229*b30d1939SAndy Fiddaman #    define STDC
230*b30d1939SAndy Fiddaman #  endif
231*b30d1939SAndy Fiddaman #  if __STDC_VERSION__ >= 199901L
232*b30d1939SAndy Fiddaman #    ifndef STDC99
233*b30d1939SAndy Fiddaman #      define STDC99
234*b30d1939SAndy Fiddaman #    endif
235*b30d1939SAndy Fiddaman #  endif
236*b30d1939SAndy Fiddaman #endif
237*b30d1939SAndy Fiddaman #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
238*b30d1939SAndy Fiddaman #  define STDC
239*b30d1939SAndy Fiddaman #endif
240*b30d1939SAndy Fiddaman #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
241*b30d1939SAndy Fiddaman #  define STDC
242*b30d1939SAndy Fiddaman #endif
243*b30d1939SAndy Fiddaman #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
244*b30d1939SAndy Fiddaman #  define STDC
245*b30d1939SAndy Fiddaman #endif
246*b30d1939SAndy Fiddaman #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
247*b30d1939SAndy Fiddaman #  define STDC
248*b30d1939SAndy Fiddaman #endif
249*b30d1939SAndy Fiddaman 
250*b30d1939SAndy Fiddaman #if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
251*b30d1939SAndy Fiddaman #  define STDC
252*b30d1939SAndy Fiddaman #endif
253*b30d1939SAndy Fiddaman 
254*b30d1939SAndy Fiddaman #ifndef STDC
255*b30d1939SAndy Fiddaman #  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
256*b30d1939SAndy Fiddaman #    define const       /* note: need a more gentle solution here */
257*b30d1939SAndy Fiddaman #  endif
258*b30d1939SAndy Fiddaman #endif
259*b30d1939SAndy Fiddaman 
260*b30d1939SAndy Fiddaman /* Some Mac compilers merge all .h files incorrectly: */
261*b30d1939SAndy Fiddaman #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
262*b30d1939SAndy Fiddaman #  define NO_DUMMY_DECL
263*b30d1939SAndy Fiddaman #endif
264*b30d1939SAndy Fiddaman 
265*b30d1939SAndy Fiddaman /* Maximum value for memLevel in deflateInit2 */
266*b30d1939SAndy Fiddaman #ifndef MAX_MEM_LEVEL
267*b30d1939SAndy Fiddaman #  ifdef MAXSEG_64K
268*b30d1939SAndy Fiddaman #    define MAX_MEM_LEVEL 8
269*b30d1939SAndy Fiddaman #  else
270*b30d1939SAndy Fiddaman #    define MAX_MEM_LEVEL 9
271*b30d1939SAndy Fiddaman #  endif
272*b30d1939SAndy Fiddaman #endif
273*b30d1939SAndy Fiddaman 
274*b30d1939SAndy Fiddaman /* Maximum value for windowBits in deflateInit2 and inflateInit2.
275*b30d1939SAndy Fiddaman  * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
276*b30d1939SAndy Fiddaman  * created by gzip. (Files created by minigzip can still be extracted by
277*b30d1939SAndy Fiddaman  * gzip.)
278*b30d1939SAndy Fiddaman  */
279*b30d1939SAndy Fiddaman #ifndef MAX_WBITS
280*b30d1939SAndy Fiddaman #  define MAX_WBITS   15 /* 32K LZ77 window */
281*b30d1939SAndy Fiddaman #endif
282*b30d1939SAndy Fiddaman 
283*b30d1939SAndy Fiddaman /* The memory requirements for deflate are (in bytes):
284*b30d1939SAndy Fiddaman             (1 << (windowBits+2)) +  (1 << (memLevel+9))
285*b30d1939SAndy Fiddaman  that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
286*b30d1939SAndy Fiddaman  plus a few kilobytes for small objects. For example, if you want to reduce
287*b30d1939SAndy Fiddaman  the default memory requirements from 256K to 128K, compile with
288*b30d1939SAndy Fiddaman      make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
289*b30d1939SAndy Fiddaman  Of course this will generally degrade compression (there's no free lunch).
290*b30d1939SAndy Fiddaman 
291*b30d1939SAndy Fiddaman    The memory requirements for inflate are (in bytes) 1 << windowBits
292*b30d1939SAndy Fiddaman  that is, 32K for windowBits=15 (default value) plus a few kilobytes
293*b30d1939SAndy Fiddaman  for small objects.
294*b30d1939SAndy Fiddaman */
295*b30d1939SAndy Fiddaman 
296*b30d1939SAndy Fiddaman                         /* Type declarations */
297*b30d1939SAndy Fiddaman 
298*b30d1939SAndy Fiddaman #ifndef OF /* function prototypes */
299*b30d1939SAndy Fiddaman #  ifdef STDC
300*b30d1939SAndy Fiddaman #    define OF(args)  args
301*b30d1939SAndy Fiddaman #  else
302*b30d1939SAndy Fiddaman #    define OF(args)  ()
303*b30d1939SAndy Fiddaman #  endif
304*b30d1939SAndy Fiddaman #endif
305*b30d1939SAndy Fiddaman 
306*b30d1939SAndy Fiddaman /* The following definitions for FAR are needed only for MSDOS mixed
307*b30d1939SAndy Fiddaman  * model programming (small or medium model with some far allocations).
308*b30d1939SAndy Fiddaman  * This was tested only with MSC; for other MSDOS compilers you may have
309*b30d1939SAndy Fiddaman  * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
310*b30d1939SAndy Fiddaman  * just define FAR to be empty.
311*b30d1939SAndy Fiddaman  */
312*b30d1939SAndy Fiddaman #ifdef SYS16BIT
313*b30d1939SAndy Fiddaman #  if defined(M_I86SM) || defined(M_I86MM)
314*b30d1939SAndy Fiddaman      /* MSC small or medium model */
315*b30d1939SAndy Fiddaman #    define SMALL_MEDIUM
316*b30d1939SAndy Fiddaman #    ifdef _MSC_VER
317*b30d1939SAndy Fiddaman #      define FAR _far
318*b30d1939SAndy Fiddaman #    else
319*b30d1939SAndy Fiddaman #      define FAR far
320*b30d1939SAndy Fiddaman #    endif
321*b30d1939SAndy Fiddaman #  endif
322*b30d1939SAndy Fiddaman #  if (defined(__SMALL__) || defined(__MEDIUM__))
323*b30d1939SAndy Fiddaman      /* Turbo C small or medium model */
324*b30d1939SAndy Fiddaman #    define SMALL_MEDIUM
325*b30d1939SAndy Fiddaman #    ifdef __BORLANDC__
326*b30d1939SAndy Fiddaman #      define FAR _far
327*b30d1939SAndy Fiddaman #    else
328*b30d1939SAndy Fiddaman #      define FAR far
329*b30d1939SAndy Fiddaman #    endif
330*b30d1939SAndy Fiddaman #  endif
331*b30d1939SAndy Fiddaman #endif
332*b30d1939SAndy Fiddaman 
333*b30d1939SAndy Fiddaman #if defined(WINDOWS) || defined(WIN32)
334*b30d1939SAndy Fiddaman    /* If building or using zlib as a DLL, define ZLIB_DLL.
335*b30d1939SAndy Fiddaman     * This is not mandatory, but it offers a little performance increase.
336*b30d1939SAndy Fiddaman     */
337*b30d1939SAndy Fiddaman #  ifdef ZLIB_DLL
338*b30d1939SAndy Fiddaman #    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
339*b30d1939SAndy Fiddaman #      ifdef ZLIB_INTERNAL
340*b30d1939SAndy Fiddaman #        define ZEXTERN extern __declspec(dllexport)
341*b30d1939SAndy Fiddaman #      else
342*b30d1939SAndy Fiddaman #        define ZEXTERN extern __declspec(dllimport)
343*b30d1939SAndy Fiddaman #      endif
344*b30d1939SAndy Fiddaman #    endif
345*b30d1939SAndy Fiddaman #  endif  /* ZLIB_DLL */
346*b30d1939SAndy Fiddaman    /* If building or using zlib with the WINAPI/WINAPIV calling convention,
347*b30d1939SAndy Fiddaman     * define ZLIB_WINAPI.
348*b30d1939SAndy Fiddaman     * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
349*b30d1939SAndy Fiddaman     */
350*b30d1939SAndy Fiddaman #  ifdef ZLIB_WINAPI
351*b30d1939SAndy Fiddaman #    ifdef FAR
352*b30d1939SAndy Fiddaman #      undef FAR
353*b30d1939SAndy Fiddaman #    endif
354*b30d1939SAndy Fiddaman #    include <windows.h>
355*b30d1939SAndy Fiddaman      /* No need for _export, use ZLIB.DEF instead. */
356*b30d1939SAndy Fiddaman      /* For complete Windows compatibility, use WINAPI, not __stdcall. */
357*b30d1939SAndy Fiddaman #    define ZEXPORT WINAPI
358*b30d1939SAndy Fiddaman #    ifdef WIN32
359*b30d1939SAndy Fiddaman #      define ZEXPORTVA WINAPIV
360*b30d1939SAndy Fiddaman #    else
361*b30d1939SAndy Fiddaman #      define ZEXPORTVA FAR CDECL
362*b30d1939SAndy Fiddaman #    endif
363*b30d1939SAndy Fiddaman #  endif
364*b30d1939SAndy Fiddaman #endif
365*b30d1939SAndy Fiddaman 
366*b30d1939SAndy Fiddaman #if defined (__BEOS__)
367*b30d1939SAndy Fiddaman #  ifdef ZLIB_DLL
368*b30d1939SAndy Fiddaman #    ifdef ZLIB_INTERNAL
369*b30d1939SAndy Fiddaman #      define ZEXPORT   __declspec(dllexport)
370*b30d1939SAndy Fiddaman #      define ZEXPORTVA __declspec(dllexport)
371*b30d1939SAndy Fiddaman #    else
372*b30d1939SAndy Fiddaman #      define ZEXPORT   __declspec(dllimport)
373*b30d1939SAndy Fiddaman #      define ZEXPORTVA __declspec(dllimport)
374*b30d1939SAndy Fiddaman #    endif
375*b30d1939SAndy Fiddaman #  endif
376*b30d1939SAndy Fiddaman #endif
377*b30d1939SAndy Fiddaman 
378*b30d1939SAndy Fiddaman #ifndef ZEXTERN
379*b30d1939SAndy Fiddaman #  define ZEXTERN extern
380*b30d1939SAndy Fiddaman #endif
381*b30d1939SAndy Fiddaman #ifndef ZEXPORT
382*b30d1939SAndy Fiddaman #  define ZEXPORT
383*b30d1939SAndy Fiddaman #endif
384*b30d1939SAndy Fiddaman #ifndef ZEXPORTVA
385*b30d1939SAndy Fiddaman #  define ZEXPORTVA
386*b30d1939SAndy Fiddaman #endif
387*b30d1939SAndy Fiddaman 
388*b30d1939SAndy Fiddaman #ifndef FAR
389*b30d1939SAndy Fiddaman #  define FAR
390*b30d1939SAndy Fiddaman #endif
391*b30d1939SAndy Fiddaman 
392*b30d1939SAndy Fiddaman #if !defined(__MACTYPES__)
393*b30d1939SAndy Fiddaman typedef unsigned char  Byte;  /* 8 bits */
394*b30d1939SAndy Fiddaman #endif
395*b30d1939SAndy Fiddaman typedef unsigned int   uInt;  /* 16 bits or more */
396*b30d1939SAndy Fiddaman typedef unsigned long  uLong; /* 32 bits or more */
397*b30d1939SAndy Fiddaman 
398