1 /* zutil.h -- internal interface and configuration of the compression library
2 * Copyright (C) 1995-1996 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h
6 /* WARNING: this file should *not* be used by applications. It is
7 part of the implementation of the compression library and is
8 subject to change. Applications should only use zlib.h.
11 /* From: zutil.h,v 1.16 1996/07/24 13:41:13 me Exp $ */
26 /* Assume this is a *BSD or SVR4 kernel */
27 #include <sys/types.h>
29 #include <sys/systm.h>
30 #include <sys/module.h>
31 #include <sys/errno.h>
32 #include <sys/param.h>
33 #include <sys/kernel.h>
35 # define memcpy(d, s, n) bcopy((s), (d), (n))
36 # define memset(d, v, n) bzero((d), (n))
40 #if defined(__KERNEL__)
41 /* Assume this is a Linux kernel */
42 #include <linux/string.h>
45 #else /* not kernel */
47 #if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS)
57 #endif /* __KERNEL__ */
63 /* compile with -Dlocal if your debugger can't find static symbols */
65 typedef unsigned char uch;
67 typedef unsigned short ush;
69 typedef unsigned long ulg;
71 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
73 #define ERR_RETURN(strm,err) \
74 return (strm->msg = (const char*)ERR_MSG(err), (err))
75 /* To be used only when the state is known to be valid */
77 /* common constants */
80 # define DEF_WBITS MAX_WBITS
82 /* default windowBits for decompression. MAX_WBITS is for compression only */
84 #if MAX_MEM_LEVEL >= 8
85 # define DEF_MEM_LEVEL 8
87 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
89 /* default memLevel */
91 #define STORED_BLOCK 0
92 #define STATIC_TREES 1
94 /* The three kinds of block type */
98 /* The minimum and maximum match lengths */
100 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
102 /* target dependencies */
105 # define OS_CODE 0x00
108 # else /* MSC or DJGPP */
114 # define OS_CODE 0x06
117 #ifdef WIN32 /* Window 95 & Windows NT */
118 # define OS_CODE 0x0b
121 #if defined(VAXC) || defined(VMS)
122 # define OS_CODE 0x02
123 # define FOPEN(name, mode) \
124 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
128 # define OS_CODE 0x01
131 #if defined(ATARI) || defined(atarist)
132 # define OS_CODE 0x05
136 # define OS_CODE 0x07
139 #ifdef __50SERIES /* Prime/PRIMOS */
140 # define OS_CODE 0x0F
144 # define OS_CODE 0x0a
147 #if defined(_BEOS_) || defined(RISCOS)
148 # define fdopen(fd,mode) NULL /* No fdopen() */
151 /* Common defaults */
154 # define OS_CODE 0x03 /* assume Unix */
158 # define FOPEN(name, mode) fopen((name), (mode))
164 extern char *strerror OF((int));
165 # define zstrerror(errnum) strerror(errnum)
167 # define zstrerror(errnum) ""
173 #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER)
174 /* Use our own functions for small and medium model with MSC <= 5.0.
175 * You may have to use the same strategy for Borland C (untested).
179 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
183 # ifdef SMALL_MEDIUM /* MSDOS small or medium model */
184 # define zmemcpy _fmemcpy
185 # define zmemcmp _fmemcmp
186 # define zmemzero(dest, len) _fmemset(dest, 0, len)
188 # define zmemcpy memcpy
189 # define zmemcmp memcmp
190 # define zmemzero(dest, len) memset(dest, 0, len)
193 extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len));
194 extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len));
195 extern void zmemzero OF((Bytef* dest, uInt len));
198 /* Diagnostic functions */
204 extern void z_error OF((char *m));
205 # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
206 # define Trace(x) fprintf x
207 # define Tracev(x) {if (verbose) fprintf x ;}
208 # define Tracevv(x) {if (verbose>1) fprintf x ;}
209 # define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
210 # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
212 # define Assert(cond,msg)
217 # define Tracecv(c,x)
221 typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len));
223 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
224 void zcfree OF((voidpf opaque, voidpf ptr));
226 #define ZALLOC(strm, items, size) \
227 (*((strm)->zalloc))((strm)->opaque, (items), (size))
228 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
229 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
231 #endif /* _Z_UTIL_H */