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 memset(d, v, n) bzero((d), (n))
39 #if defined(__KERNEL__)
40 /* Assume this is a Linux kernel */
41 #include <linux/string.h>
44 #else /* not kernel */
46 #if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS)
56 #endif /* __KERNEL__ */
62 /* compile with -Dlocal if your debugger can't find static symbols */
64 typedef unsigned char uch;
66 typedef unsigned short ush;
68 typedef unsigned long ulg;
70 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
72 #define ERR_RETURN(strm,err) \
73 return (strm->msg = (const char*)ERR_MSG(err), (err))
74 /* To be used only when the state is known to be valid */
76 /* common constants */
79 # define DEF_WBITS MAX_WBITS
81 /* default windowBits for decompression. MAX_WBITS is for compression only */
83 #if MAX_MEM_LEVEL >= 8
84 # define DEF_MEM_LEVEL 8
86 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
88 /* default memLevel */
90 #define STORED_BLOCK 0
91 #define STATIC_TREES 1
93 /* The three kinds of block type */
97 /* The minimum and maximum match lengths */
99 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
101 /* target dependencies */
104 # define OS_CODE 0x00
107 # else /* MSC or DJGPP */
113 # define OS_CODE 0x06
116 #ifdef WIN32 /* Window 95 & Windows NT */
117 # define OS_CODE 0x0b
120 #if defined(VAXC) || defined(VMS)
121 # define OS_CODE 0x02
122 # define FOPEN(name, mode) \
123 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
127 # define OS_CODE 0x01
130 #if defined(ATARI) || defined(atarist)
131 # define OS_CODE 0x05
135 # define OS_CODE 0x07
138 #ifdef __50SERIES /* Prime/PRIMOS */
139 # define OS_CODE 0x0F
143 # define OS_CODE 0x0a
146 #if defined(_BEOS_) || defined(RISCOS)
147 # define fdopen(fd,mode) NULL /* No fdopen() */
150 /* Common defaults */
153 # define OS_CODE 0x03 /* assume Unix */
157 # define FOPEN(name, mode) fopen((name), (mode))
163 extern char *strerror OF((int));
164 # define zstrerror(errnum) strerror(errnum)
166 # define zstrerror(errnum) ""
172 #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER)
173 /* Use our own functions for small and medium model with MSC <= 5.0.
174 * You may have to use the same strategy for Borland C (untested).
178 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
182 # ifdef SMALL_MEDIUM /* MSDOS small or medium model */
183 # define zmemcpy _fmemcpy
184 # define zmemcmp _fmemcmp
185 # define zmemzero(dest, len) _fmemset(dest, 0, len)
187 # define zmemcpy memcpy
188 # define zmemcmp memcmp
189 # define zmemzero(dest, len) memset(dest, 0, len)
192 extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len));
193 extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len));
194 extern void zmemzero OF((Bytef* dest, uInt len));
197 /* Diagnostic functions */
203 extern void z_error OF((char *m));
204 # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
205 # define Trace(x) fprintf x
206 # define Tracev(x) {if (verbose) fprintf x ;}
207 # define Tracevv(x) {if (verbose>1) fprintf x ;}
208 # define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
209 # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
211 # define Assert(cond,msg)
216 # define Tracecv(c,x)
220 typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len));
222 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
223 void zcfree OF((voidpf opaque, voidpf ptr));
225 #define ZALLOC(strm, items, size) \
226 (*((strm)->zalloc))((strm)->opaque, (items), (size))
227 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
228 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
230 #endif /* _Z_UTIL_H */