]>
git.saurik.com Git - apple/security.git/blob - SecurityServer/MacYarrow/zlib/zutil.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
19 /* zutil.h -- internal interface and configuration of the compression library
20 * Copyright (C) 1995-1998 Jean-loup Gailly.
21 * For conditions of distribution and use, see copyright notice in zlib.h
24 /* WARNING: this file should *not* be used by applications. It is
25 part of the implementation of the compression library and is
26 subject to change. Applications should only use zlib.h.
29 /* @(#) $Id: zutil.h,v 1.1.1.1 2001/05/18 23:14:03 mb Exp $ */
50 /* compile with -Dlocal if your debugger can't find static symbols */
52 typedef unsigned char uch
;
54 typedef unsigned short ush
;
56 typedef unsigned long ulg
;
58 extern const char *z_errmsg
[10]; /* indexed by 2-zlib_error */
59 /* (size given to avoid silly warnings with Visual C++) */
61 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
63 #define ERR_RETURN(strm,err) \
64 return (strm->msg = (char*)ERR_MSG(err), (err))
65 /* To be used only when the state is known to be valid */
67 /* common constants */
70 # define DEF_WBITS MAX_WBITS
72 /* default windowBits for decompression. MAX_WBITS is for compression only */
74 #if MAX_MEM_LEVEL >= 8
75 # define DEF_MEM_LEVEL 8
77 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
79 /* default memLevel */
81 #define STORED_BLOCK 0
82 #define STATIC_TREES 1
84 /* The three kinds of block type */
88 /* The minimum and maximum match lengths */
90 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
92 /* target dependencies */
96 # if defined(__TURBOC__) || defined(__BORLANDC__)
97 # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
98 /* Allow compilation with ANSI keywords only enabled */
99 void _Cdecl
farfree( void *block
);
100 void *_Cdecl
farmalloc( unsigned long nbytes
);
104 # else /* MSC or DJGPP */
110 # define OS_CODE 0x06
113 #ifdef WIN32 /* Window 95 & Windows NT */
114 # define OS_CODE 0x0b
117 #if defined(VAXC) || defined(VMS)
118 # define OS_CODE 0x02
119 # define F_OPEN(name, mode) \
120 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
124 # define OS_CODE 0x01
127 #if defined(ATARI) || defined(atarist)
128 # define OS_CODE 0x05
131 #if defined(MACOS) || defined(TARGET_OS_MAC)
132 # define OS_CODE 0x07
133 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
134 # include <unix.h> /* for fdopen */
137 # define fdopen(fd,mode) NULL /* No fdopen() */
142 #ifdef __50SERIES /* Prime/PRIMOS */
143 # define OS_CODE 0x0F
147 # define OS_CODE 0x0a
150 #if defined(_BEOS_) || defined(RISCOS)
151 # define fdopen(fd,mode) NULL /* No fdopen() */
154 #if (defined(_MSC_VER) && (_MSC_VER > 600))
155 # define fdopen(fd,type) _fdopen(fd,type)
159 /* Common defaults */
162 # define OS_CODE 0x03 /* assume Unix */
166 # define F_OPEN(name, mode) fopen((name), (mode))
172 extern char *strerror
OF((int));
173 # define zstrerror(errnum) strerror(errnum)
175 # define zstrerror(errnum) ""
181 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
182 /* Use our own functions for small and medium model with MSC <= 5.0.
183 * You may have to use the same strategy for Borland C (untested).
184 * The __SC__ check is for Symantec.
188 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
192 # ifdef SMALL_MEDIUM /* MSDOS small or medium model */
193 # define zmemcpy _fmemcpy
194 # define zmemcmp _fmemcmp
195 # define zmemzero(dest, len) _fmemset(dest, 0, len)
197 # define zmemcpy memcpy
198 # define zmemcmp memcmp
199 # define zmemzero(dest, len) memset(dest, 0, len)
202 extern void zmemcpy
OF((Bytef
* dest
, const Bytef
* source
, uInt len
));
203 extern int zmemcmp
OF((const Bytef
* s1
, const Bytef
* s2
, uInt len
));
204 extern void zmemzero
OF((Bytef
* dest
, uInt len
));
207 /* Diagnostic functions */
210 extern int z_verbose
;
211 extern void z_error
OF((char *m
));
212 # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
213 # define Trace(x) {if (z_verbose>=0) fprintf x ;}
214 # define Tracev(x) {if (z_verbose>0) fprintf x ;}
215 # define Tracevv(x) {if (z_verbose>1) fprintf x ;}
216 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
217 # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
219 # define Assert(cond,msg)
224 # define Tracecv(c,x)
228 typedef uLong (ZEXPORT
*check_func
) OF((uLong check
, const Bytef
*buf
,
230 voidpf zcalloc
OF((voidpf opaque
, unsigned items
, unsigned size
));
231 void zcfree
OF((voidpf opaque
, voidpf ptr
));
233 #define ZALLOC(strm, items, size) \
234 (*((strm)->zalloc))((strm)->opaque, (items), (size))
235 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
236 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
238 #endif /* _Z_UTIL_H */