]> git.saurik.com Git - apple/security.git/blob - SecurityServer/MacYarrow/zlib/zutil.h
Security-29.tar.gz
[apple/security.git] / SecurityServer / MacYarrow / zlib / zutil.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
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
22 */
23
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.
27 */
28
29 /* @(#) $Id: zutil.h,v 1.1.1.1 2001/05/18 23:14:03 mb Exp $ */
30
31 #ifndef _Z_UTIL_H
32 #define _Z_UTIL_H
33
34 #include "zlib.h"
35
36 #ifdef STDC
37 # include <stddef.h>
38 # include <string.h>
39 # include <stdlib.h>
40 #endif
41 #ifdef NO_ERRNO_H
42 extern int errno;
43 #else
44 # include <errno.h>
45 #endif
46
47 #ifndef local
48 # define local static
49 #endif
50 /* compile with -Dlocal if your debugger can't find static symbols */
51
52 typedef unsigned char uch;
53 typedef uch FAR uchf;
54 typedef unsigned short ush;
55 typedef ush FAR ushf;
56 typedef unsigned long ulg;
57
58 extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
59 /* (size given to avoid silly warnings with Visual C++) */
60
61 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
62
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 */
66
67 /* common constants */
68
69 #ifndef DEF_WBITS
70 # define DEF_WBITS MAX_WBITS
71 #endif
72 /* default windowBits for decompression. MAX_WBITS is for compression only */
73
74 #if MAX_MEM_LEVEL >= 8
75 # define DEF_MEM_LEVEL 8
76 #else
77 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
78 #endif
79 /* default memLevel */
80
81 #define STORED_BLOCK 0
82 #define STATIC_TREES 1
83 #define DYN_TREES 2
84 /* The three kinds of block type */
85
86 #define MIN_MATCH 3
87 #define MAX_MATCH 258
88 /* The minimum and maximum match lengths */
89
90 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
91
92 /* target dependencies */
93
94 #ifdef MSDOS
95 # define OS_CODE 0x00
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 );
101 # else
102 # include <alloc.h>
103 # endif
104 # else /* MSC or DJGPP */
105 # include <malloc.h>
106 # endif
107 #endif
108
109 #ifdef OS2
110 # define OS_CODE 0x06
111 #endif
112
113 #ifdef WIN32 /* Window 95 & Windows NT */
114 # define OS_CODE 0x0b
115 #endif
116
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")
121 #endif
122
123 #ifdef AMIGA
124 # define OS_CODE 0x01
125 #endif
126
127 #if defined(ATARI) || defined(atarist)
128 # define OS_CODE 0x05
129 #endif
130
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 */
135 # else
136 # ifndef fdopen
137 # define fdopen(fd,mode) NULL /* No fdopen() */
138 # endif
139 # endif
140 #endif
141
142 #ifdef __50SERIES /* Prime/PRIMOS */
143 # define OS_CODE 0x0F
144 #endif
145
146 #ifdef TOPS20
147 # define OS_CODE 0x0a
148 #endif
149
150 #if defined(_BEOS_) || defined(RISCOS)
151 # define fdopen(fd,mode) NULL /* No fdopen() */
152 #endif
153
154 #if (defined(_MSC_VER) && (_MSC_VER > 600))
155 # define fdopen(fd,type) _fdopen(fd,type)
156 #endif
157
158
159 /* Common defaults */
160
161 #ifndef OS_CODE
162 # define OS_CODE 0x03 /* assume Unix */
163 #endif
164
165 #ifndef F_OPEN
166 # define F_OPEN(name, mode) fopen((name), (mode))
167 #endif
168
169 /* functions */
170
171 #ifdef HAVE_STRERROR
172 extern char *strerror OF((int));
173 # define zstrerror(errnum) strerror(errnum)
174 #else
175 # define zstrerror(errnum) ""
176 #endif
177
178 #if defined(pyr)
179 # define NO_MEMCPY
180 #endif
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.
185 */
186 # define NO_MEMCPY
187 #endif
188 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
189 # define HAVE_MEMCPY
190 #endif
191 #ifdef HAVE_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)
196 # else
197 # define zmemcpy memcpy
198 # define zmemcmp memcmp
199 # define zmemzero(dest, len) memset(dest, 0, len)
200 # endif
201 #else
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));
205 #endif
206
207 /* Diagnostic functions */
208 #ifdef DEBUG
209 # include <stdio.h>
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 ;}
218 #else
219 # define Assert(cond,msg)
220 # define Trace(x)
221 # define Tracev(x)
222 # define Tracevv(x)
223 # define Tracec(c,x)
224 # define Tracecv(c,x)
225 #endif
226
227
228 typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
229 uInt len));
230 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
231 void zcfree OF((voidpf opaque, voidpf ptr));
232
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);}
237
238 #endif /* _Z_UTIL_H */