1 /* zutil.h -- internal interface and configuration of the compression library
\r
2 * Copyright (C) 1995-2010 Jean-loup Gailly.
\r
3 * For conditions of distribution and use, see copyright notice in zlib.h
\r
6 /* WARNING: this file should *not* be used by applications. It is
\r
7 part of the implementation of the compression library and is
\r
8 subject to change. Applications should only use zlib.h.
\r
16 #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) && !defined(_WIN32)
\r
17 # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
\r
19 # define ZLIB_INTERNAL
\r
25 # if !(defined(_WIN32_WCE) && defined(_MSC_VER))
\r
26 # include <stddef.h>
\r
28 # include <string.h>
\r
29 # include <stdlib.h>
\r
33 # define local static
\r
35 /* compile with -Dlocal if your debugger can't find static symbols */
\r
37 typedef unsigned char uch;
\r
38 typedef uch FAR uchf;
\r
39 typedef unsigned short ush;
\r
40 typedef ush FAR ushf;
\r
41 typedef unsigned long ulg;
\r
43 extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
\r
44 /* (size given to avoid silly warnings with Visual C++) */
\r
46 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
\r
48 #define ERR_RETURN(strm,err) \
\r
49 return (strm->msg = (char*)ERR_MSG(err), (err))
\r
50 /* To be used only when the state is known to be valid */
\r
52 /* common constants */
\r
55 # define DEF_WBITS MAX_WBITS
\r
57 /* default windowBits for decompression. MAX_WBITS is for compression only */
\r
59 #if MAX_MEM_LEVEL >= 8
\r
60 # define DEF_MEM_LEVEL 8
\r
62 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
\r
64 /* default memLevel */
\r
66 #define STORED_BLOCK 0
\r
67 #define STATIC_TREES 1
\r
69 /* The three kinds of block type */
\r
72 #define MAX_MATCH 258
\r
73 /* The minimum and maximum match lengths */
\r
75 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
\r
77 /* target dependencies */
\r
79 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
\r
80 # define OS_CODE 0x00
\r
81 # if defined(__TURBOC__) || defined(__BORLANDC__)
\r
82 # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
\r
83 /* Allow compilation with ANSI keywords only enabled */
\r
84 void _Cdecl farfree( void *block );
\r
85 void *_Cdecl farmalloc( unsigned long nbytes );
\r
89 # else /* MSC or DJGPP */
\r
90 # include <malloc.h>
\r
95 # define OS_CODE 0x01
\r
98 #if defined(VAXC) || defined(VMS)
\r
99 # define OS_CODE 0x02
\r
100 # define F_OPEN(name, mode) \
\r
101 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
\r
104 #if defined(ATARI) || defined(atarist)
\r
105 # define OS_CODE 0x05
\r
109 # define OS_CODE 0x06
\r
111 # include <malloc.h>
\r
115 #if defined(MACOS) || defined(TARGET_OS_MAC)
\r
116 # define OS_CODE 0x07
\r
117 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
\r
118 # include <unix.h> /* for fdopen */
\r
121 # define fdopen(fd,mode) NULL /* No fdopen() */
\r
127 # define OS_CODE 0x0a
\r
131 # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
\r
132 # define OS_CODE 0x0b
\r
136 #ifdef __50SERIES /* Prime/PRIMOS */
\r
137 # define OS_CODE 0x0f
\r
140 #if defined(_BEOS_) || defined(RISCOS)
\r
141 # define fdopen(fd,mode) NULL /* No fdopen() */
\r
144 #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
\r
145 # if defined(_WIN32_WCE)
\r
146 # define fdopen(fd,mode) NULL /* No fdopen() */
\r
147 # ifndef _PTRDIFF_T_DEFINED
\r
148 typedef int ptrdiff_t;
\r
149 # define _PTRDIFF_T_DEFINED
\r
152 # define fdopen(fd,type) _fdopen(fd,type)
\r
156 #if defined(__BORLANDC__)
\r
162 /* provide prototypes for these when building zlib without LFS */
\r
163 #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
\r
164 ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
\r
165 ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
\r
168 /* common defaults */
\r
171 # define OS_CODE 0x03 /* assume Unix */
\r
175 # define F_OPEN(name, mode) fopen((name), (mode))
\r
180 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
\r
181 # ifndef HAVE_VSNPRINTF
\r
182 # define HAVE_VSNPRINTF
\r
185 #if defined(__CYGWIN__)
\r
186 # ifndef HAVE_VSNPRINTF
\r
187 # define HAVE_VSNPRINTF
\r
190 #ifndef HAVE_VSNPRINTF
\r
192 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
\r
193 but for now we just assume it doesn't. */
\r
194 # define NO_vsnprintf
\r
197 # define NO_vsnprintf
\r
200 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
\r
201 # if !defined(vsnprintf) && !defined(NO_vsnprintf)
\r
202 # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
\r
203 # define vsnprintf _vsnprintf
\r
208 # define NO_vsnprintf
\r
212 # define NO_vsnprintf
\r
218 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
\r
219 /* Use our own functions for small and medium model with MSC <= 5.0.
\r
220 * You may have to use the same strategy for Borland C (untested).
\r
221 * The __SC__ check is for Symantec.
\r
225 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
\r
226 # define HAVE_MEMCPY
\r
229 # ifdef SMALL_MEDIUM /* MSDOS small or medium model */
\r
230 # define zmemcpy _fmemcpy
\r
231 # define zmemcmp _fmemcmp
\r
232 # define zmemzero(dest, len) _fmemset(dest, 0, len)
\r
234 # define zmemcpy memcpy
\r
235 # define zmemcmp memcmp
\r
236 # define zmemzero(dest, len) memset(dest, 0, len)
\r
239 void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
\r
240 int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
\r
241 void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
\r
244 /* Diagnostic functions */
\r
246 # include <stdio.h>
\r
247 extern int ZLIB_INTERNAL z_verbose;
\r
248 extern void ZLIB_INTERNAL z_error OF((char *m));
\r
249 # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
\r
250 # define Trace(x) {if (z_verbose>=0) fprintf x ;}
\r
251 # define Tracev(x) {if (z_verbose>0) fprintf x ;}
\r
252 # define Tracevv(x) {if (z_verbose>1) fprintf x ;}
\r
253 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
\r
254 # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
\r
256 # define Assert(cond,msg)
\r
259 # define Tracevv(x)
\r
260 # define Tracec(c,x)
\r
261 # define Tracecv(c,x)
\r
265 voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
\r
267 void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
\r
269 #define ZALLOC(strm, items, size) \
\r
270 (*((strm)->zalloc))((strm)->opaque, (items), (size))
\r
271 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
\r
272 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
\r
274 #endif /* ZUTIL_H */
\r