00001
00002
00003
00004
00005
00006
00007
00008 #ifndef ZUTIL_H
00009 #define ZUTIL_H
00010
00011 #define ZLIB_INTERNAL
00012 #include "zlib.h"
00013
00014 #ifdef STDC
00015 # ifndef _WIN32_WCE
00016 # include <stddef.h>
00017 # endif
00018 # include <string.h>
00019 # include <stdlib.h>
00020 #endif
00021 #ifdef NO_ERRNO_H
00022 # ifdef _WIN32_WCE
00023
00024 # define errno z_errno
00025 # endif
00026 extern int errno;
00027 #else
00028 # ifndef _WIN32_WCE
00029 # include <errno.h>
00030 # endif
00031 #endif
00032
00033 #ifndef local
00034 # define local static
00035 #endif
00036
00037 typedef unsigned char uch;
00038 typedef uch FAR uchf;
00039 typedef unsigned short ush;
00040 typedef ush FAR ushf;
00041 typedef unsigned long ulg;
00042
00043 extern const char * const z_errmsg[10];
00044
00045 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
00046
00047 #define ERR_RETURN(strm,err) \
00048 return (strm->msg = (char*)ERR_MSG(err), (err))
00049
00050
00051
00052 #ifndef DEF_WBITS
00053 # define DEF_WBITS MAX_WBITS
00054 #endif
00055
00056 #if MAX_MEM_LEVEL >= 8
00057 # define DEF_MEM_LEVEL 8
00058 #else
00059 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
00060 #endif
00061
00062 #define STORED_BLOCK 0
00063 #define STATIC_TREES 1
00064 #define DYN_TREES 2
00065
00066 #define MIN_MATCH 3
00067 #define MAX_MATCH 258
00068
00069 #define PRESET_DICT 0x20
00070
00071
00072
00073 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
00074 # define OS_CODE 0x00
00075 # if defined(__TURBOC__) || defined(__BORLANDC__)
00076 # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
00077
00078 void _Cdecl farfree( void *block );
00079 void *_Cdecl farmalloc( unsigned long nbytes );
00080 # else
00081 # include <alloc.h>
00082 # endif
00083 # else
00084 # include <malloc.h>
00085 # endif
00086 #endif
00087
00088 #ifdef AMIGA
00089 # define OS_CODE 0x01
00090 #endif
00091
00092 #if defined(VAXC) || defined(VMS)
00093 # define OS_CODE 0x02
00094 # define F_OPEN(name, mode) \
00095 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
00096 #endif
00097
00098 #if defined(ATARI) || defined(atarist)
00099 # define OS_CODE 0x05
00100 #endif
00101
00102 #ifdef OS2
00103 # define OS_CODE 0x06
00104 # ifdef M_I86
00105 #include <malloc.h>
00106 # endif
00107 #endif
00108
00109 #if defined(MACOS) || defined(TARGET_OS_MAC)
00110 # define OS_CODE 0x07
00111 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
00112 # include <unix.h>
00113 # else
00114 # ifndef fdopen
00115 # define fdopen(fd,mode) NULL
00116 # endif
00117 # endif
00118 #endif
00119
00120 #ifdef TOPS20
00121 # define OS_CODE 0x0a
00122 #endif
00123
00124 #ifdef WIN32
00125 # ifndef __CYGWIN__
00126 # define OS_CODE 0x0b
00127 # endif
00128 #endif
00129
00130 #ifdef __50SERIES
00131 # define OS_CODE 0x0f
00132 #endif
00133
00134 #if defined(_BEOS_) || defined(RISCOS)
00135 # define fdopen(fd,mode) NULL
00136 #endif
00137
00138 #if (defined(_MSC_VER) && (_MSC_VER > 600))
00139 # if defined(_WIN32_WCE)
00140 # define fdopen(fd,mode) NULL
00141 # ifndef _PTRDIFF_T_DEFINED
00142 typedef int ptrdiff_t;
00143 # define _PTRDIFF_T_DEFINED
00144 # endif
00145 # else
00146 # define fdopen(fd,type) _fdopen(fd,type)
00147 # endif
00148 #endif
00149
00150
00151
00152 #ifndef OS_CODE
00153 # define OS_CODE 0x03
00154 #endif
00155
00156 #ifndef F_OPEN
00157 # define F_OPEN(name, mode) fopen((name), (mode))
00158 #endif
00159
00160
00161
00162 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
00163 # ifndef HAVE_VSNPRINTF
00164 # define HAVE_VSNPRINTF
00165 # endif
00166 #endif
00167 #if defined(__CYGWIN__)
00168 # ifndef HAVE_VSNPRINTF
00169 # define HAVE_VSNPRINTF
00170 # endif
00171 #endif
00172 #ifndef HAVE_VSNPRINTF
00173 # ifdef MSDOS
00174
00175 # define NO_vsnprintf
00176 # endif
00177 # ifdef __TURBOC__
00178 # define NO_vsnprintf
00179 # endif
00180 # ifdef WIN32
00181
00182 # if !defined(vsnprintf) && !defined(NO_vsnprintf)
00183 # define vsnprintf _vsnprintf
00184 # endif
00185 # endif
00186 # ifdef __SASC
00187 # define NO_vsnprintf
00188 # endif
00189 #endif
00190 #ifdef VMS
00191 # define NO_vsnprintf
00192 #endif
00193
00194 #if defined(pyr)
00195 # define NO_MEMCPY
00196 #endif
00197 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
00198
00199 # define NO_MEMCPY
00200 #endif
00201 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
00202 # define HAVE_MEMCPY
00203 #endif
00204 #ifdef HAVE_MEMCPY
00205 # ifdef SMALL_MEDIUM
00206 # define zmemcpy _fmemcpy
00207 # define zmemcmp _fmemcmp
00208 # define zmemzero(dest, len) _fmemset(dest, 0, len)
00209 # else
00210 # define zmemcpy memcpy
00211 # define zmemcmp memcmp
00212 # define zmemzero(dest, len) memset(dest, 0, len)
00213 # endif
00214 #else
00215 extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
00216 extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
00217 extern void zmemzero OF((Bytef* dest, uInt len));
00218 #endif
00219
00220 #ifdef DEBUG
00221 # include <stdio.h>
00222 extern int z_verbose;
00223 extern void z_error OF((char *m));
00224 # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
00225 # define Trace(x) {if (z_verbose>=0) fprintf x ;}
00226 # define Tracev(x) {if (z_verbose>0) fprintf x ;}
00227 # define Tracevv(x) {if (z_verbose>1) fprintf x ;}
00228 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
00229 # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
00230 #else
00231 # define Assert(cond,msg)
00232 # define Trace(x)
00233 # define Tracev(x)
00234 # define Tracevv(x)
00235 # define Tracec(c,x)
00236 # define Tracecv(c,x)
00237 #endif
00238
00239 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
00240 void zcfree OF((voidpf opaque, voidpf ptr));
00241
00242 #define ZALLOC(strm, items, size) \
00243 (*((strm)->zalloc))((strm)->opaque, (items), (size))
00244 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
00245 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
00246
00247 #endif