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>
37 #if defined(__KERNEL__)
38 /* Assume this is a Linux kernel */
39 #include <linux/string.h>
42 #else /* not kernel */
44 #if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS)
54 #endif /* __KERNEL__ */
60 /* compile with -Dlocal if your debugger can't find static symbols */
62 typedef unsigned char uch;
64 typedef unsigned short ush;
66 typedef unsigned long ulg;
68 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
70 #define ERR_RETURN(strm,err) \
71 return (strm->msg = (const char*)ERR_MSG(err), (err))
72 /* To be used only when the state is known to be valid */
74 /* common constants */
77 # define DEF_WBITS MAX_WBITS
79 /* default windowBits for decompression. MAX_WBITS is for compression only */
81 #if MAX_MEM_LEVEL >= 8
82 # define DEF_MEM_LEVEL 8
84 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
86 /* default memLevel */
88 #define STORED_BLOCK 0
89 #define STATIC_TREES 1
91 /* The three kinds of block type */
95 /* The minimum and maximum match lengths */
97 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
99 /* target dependencies */
102 # define OS_CODE 0x00
105 # else /* MSC or DJGPP */
111 # define OS_CODE 0x06
114 #ifdef WIN32 /* Window 95 & Windows NT */
115 # define OS_CODE 0x0b
118 #if defined(VAXC) || defined(VMS)
119 # define OS_CODE 0x02
120 # define FOPEN(name, mode) \
121 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
125 # define OS_CODE 0x01
128 #if defined(ATARI) || defined(atarist)
129 # define OS_CODE 0x05
133 # define OS_CODE 0x07
136 #ifdef __50SERIES /* Prime/PRIMOS */
137 # define OS_CODE 0x0F
141 # define OS_CODE 0x0a
144 #if defined(_BEOS_) || defined(RISCOS)
145 # define fdopen(fd,mode) NULL /* No fdopen() */
148 /* Common defaults */
151 # define OS_CODE 0x03 /* assume Unix */
155 # define FOPEN(name, mode) fopen((name), (mode))
161 extern char *strerror OF((int));
162 # define zstrerror(errnum) strerror(errnum)
164 # define zstrerror(errnum) ""
170 #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER)
171 /* Use our own functions for small and medium model with MSC <= 5.0.
172 * You may have to use the same strategy for Borland C (untested).
176 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
180 # ifdef SMALL_MEDIUM /* MSDOS small or medium model */
181 # define zmemcpy _fmemcpy
182 # define zmemcmp _fmemcmp
183 # define zmemzero(dest, len) _fmemset(dest, 0, len)
185 # define zmemcpy memcpy
186 # define zmemcmp memcmp
187 # define zmemzero(dest, len) memset(dest, 0, len)
190 extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len));
191 extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len));
192 extern void zmemzero OF((Bytef* dest, uInt len));
195 /* Diagnostic functions */
201 extern void z_error OF((char *m));
202 # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
203 # define Trace(x) fprintf x
204 # define Tracev(x) {if (verbose) fprintf x ;}
205 # define Tracevv(x) {if (verbose>1) fprintf x ;}
206 # define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
207 # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
209 # define Assert(cond,msg)
214 # define Tracecv(c,x)
218 typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len));
220 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
221 void zcfree OF((voidpf opaque, voidpf ptr));
223 #define ZALLOC(strm, items, size) \
224 (*((strm)->zalloc))((strm)->opaque, (items), (size))
225 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
226 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
228 #endif /* _Z_UTIL_H */