Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

zutil.h

00001 /* zutil.h -- internal interface and configuration of the compression library
00002  * Copyright (C) 1995-1998 Jean-loup Gailly.
00003  * For conditions of distribution and use, see copyright notice in zlib.h
00004  */
00005 
00006 /* WARNING: this file should *not* be used by applications. It is
00007    part of the implementation of the compression library and is
00008    subject to change. Applications should only use zlib.h.
00009  */
00010 
00011 /* @(#) $Id: zutil_8h-source.html,v 1.3 2002/06/20 20:23:10 mgruner Exp $ */
00012 
00013 #ifndef _Z_UTIL_H
00014 #define _Z_UTIL_H
00015 
00016 #include "zlib.h"
00017 
00018 #ifdef STDC
00019 #  include <stddef.h>
00020 #  include <string.h>
00021 #  include <stdlib.h>
00022 #endif
00023 #ifdef NO_ERRNO_H
00024     extern int errno;
00025 #else
00026 #   include <errno.h>
00027 #endif
00028 
00029 #ifndef local
00030 #  define local static
00031 #endif
00032 /* compile with -Dlocal if your debugger can't find static symbols */
00033 
00034 typedef unsigned char  uch;
00035 typedef uch FAR uchf;
00036 typedef unsigned short ush;
00037 typedef ush FAR ushf;
00038 typedef unsigned long  ulg;
00039 
00040 extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
00041 /* (size given to avoid silly warnings with Visual C++) */
00042 
00043 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
00044 
00045 #define ERR_RETURN(strm,err) \
00046   return (strm->msg = (char*)ERR_MSG(err), (err))
00047 /* To be used only when the state is known to be valid */
00048 
00049         /* common constants */
00050 
00051 #ifndef DEF_WBITS
00052 #  define DEF_WBITS MAX_WBITS
00053 #endif
00054 /* default windowBits for decompression. MAX_WBITS is for compression only */
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 /* default memLevel */
00062 
00063 #define STORED_BLOCK 0
00064 #define STATIC_TREES 1
00065 #define DYN_TREES    2
00066 /* The three kinds of block type */
00067 
00068 #define MIN_MATCH  3
00069 #define MAX_MATCH  258
00070 /* The minimum and maximum match lengths */
00071 
00072 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
00073 
00074         /* target dependencies */
00075 
00076 #ifdef MSDOS
00077 #  define OS_CODE  0x00
00078 #  if defined(__TURBOC__) || defined(__BORLANDC__)
00079 #    if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
00080        /* Allow compilation with ANSI keywords only enabled */
00081        void _Cdecl farfree( void *block );
00082        void *_Cdecl farmalloc( unsigned long nbytes );
00083 #    else
00084 #     include <alloc.h>
00085 #    endif
00086 #  else /* MSC or DJGPP */
00087 #    include <malloc.h>
00088 #  endif
00089 #endif
00090 
00091 #ifdef OS2
00092 #  define OS_CODE  0x06
00093 #endif
00094 
00095 #ifdef WIN32 /* Window 95 & Windows NT */
00096 #  define OS_CODE  0x0b
00097 #endif
00098 
00099 #if defined(VAXC) || defined(VMS)
00100 #  define OS_CODE  0x02
00101 #  define F_OPEN(name, mode) \
00102      fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
00103 #endif
00104 
00105 #ifdef AMIGA
00106 #  define OS_CODE  0x01
00107 #endif
00108 
00109 #if defined(ATARI) || defined(atarist)
00110 #  define OS_CODE  0x05
00111 #endif
00112 
00113 #if defined(MACOS) || defined(TARGET_OS_MAC)
00114 #  define OS_CODE  0x07
00115 #  if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
00116 #    include <unix.h> /* for fdopen */
00117 #  else
00118 #    ifndef fdopen
00119 #      define fdopen(fd,mode) NULL /* No fdopen() */
00120 #    endif
00121 #  endif
00122 #endif
00123 
00124 #ifdef __50SERIES /* Prime/PRIMOS */
00125 #  define OS_CODE  0x0F
00126 #endif
00127 
00128 #ifdef TOPS20
00129 #  define OS_CODE  0x0a
00130 #endif
00131 
00132 #if defined(_BEOS_) || defined(RISCOS)
00133 #  define fdopen(fd,mode) NULL /* No fdopen() */
00134 #endif
00135 
00136 #if (defined(_MSC_VER) && (_MSC_VER > 600))
00137 #  define fdopen(fd,type)  _fdopen(fd,type)
00138 #endif
00139 
00140 
00141         /* Common defaults */
00142 
00143 #ifndef OS_CODE
00144 #  define OS_CODE  0x03  /* assume Unix */
00145 #endif
00146 
00147 #ifndef F_OPEN
00148 #  define F_OPEN(name, mode) fopen((name), (mode))
00149 #endif
00150 
00151          /* functions */
00152 
00153 #ifdef HAVE_STRERROR
00154    extern char *strerror OF((int));
00155 #  define zstrerror(errnum) strerror(errnum)
00156 #else
00157 #  define zstrerror(errnum) ""
00158 #endif
00159 
00160 #if defined(pyr)
00161 #  define NO_MEMCPY
00162 #endif
00163 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
00164  /* Use our own functions for small and medium model with MSC <= 5.0.
00165   * You may have to use the same strategy for Borland C (untested).
00166   * The __SC__ check is for Symantec.
00167   */
00168 #  define NO_MEMCPY
00169 #endif
00170 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
00171 #  define HAVE_MEMCPY
00172 #endif
00173 #ifdef HAVE_MEMCPY
00174 #  ifdef SMALL_MEDIUM /* MSDOS small or medium model */
00175 #    define zmemcpy _fmemcpy
00176 #    define zmemcmp _fmemcmp
00177 #    define zmemzero(dest, len) _fmemset(dest, 0, len)
00178 #  else
00179 #    define zmemcpy memcpy
00180 #    define zmemcmp memcmp
00181 #    define zmemzero(dest, len) memset(dest, 0, len)
00182 #  endif
00183 #else
00184    extern void zmemcpy  OF((Bytef* dest, const Bytef* source, uInt len));
00185    extern int  zmemcmp  OF((const Bytef* s1, const Bytef* s2, uInt len));
00186    extern void zmemzero OF((Bytef* dest, uInt len));
00187 #endif
00188 
00189 /* Diagnostic functions */
00190 #ifdef DEBUG
00191 #  include <stdio.h>
00192    extern int z_verbose;
00193    extern void z_error    OF((char *m));
00194 #  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
00195 #  define Trace(x) {if (z_verbose>=0) fprintf x ;}
00196 #  define Tracev(x) {if (z_verbose>0) fprintf x ;}
00197 #  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
00198 #  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
00199 #  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
00200 #else
00201 #  define Assert(cond,msg)
00202 #  define Trace(x)
00203 #  define Tracev(x)
00204 #  define Tracevv(x)
00205 #  define Tracec(c,x)
00206 #  define Tracecv(c,x)
00207 #endif
00208 
00209 
00210 typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
00211                                        uInt len));
00212 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
00213 void   zcfree  OF((voidpf opaque, voidpf ptr));
00214 
00215 #define ZALLOC(strm, items, size) \
00216            (*((strm)->zalloc))((strm)->opaque, (items), (size))
00217 #define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
00218 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
00219 
00220 #endif /* _Z_UTIL_H */

Generated on Thu Jun 20 22:13:01 2002 for The Sword Project by doxygen1.2.15