| 1 | /* zutil.h -- internal interface and configuration of the compression library |
|---|
| 2 | * Copyright (C) 1995-1998 Jean-loup Gailly. |
|---|
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 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. |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | /* |
|---|
| 12 | * $Id: //suprahd/releases/suprahd_163/suprahd_ztvapp640_163/drivers/graphics/ZLIB/zutil.h#1 $ |
|---|
| 13 | * $Revision: #1 $ |
|---|
| 14 | * $DateTime: 2006/02/24 17:51:46 $ |
|---|
| 15 | * $Change: 42566 $ |
|---|
| 16 | * $Author: pryush.sharma $ |
|---|
| 17 | */ |
|---|
| 18 | |
|---|
| 19 | #ifndef _Z_UTIL_H |
|---|
| 20 | #define _Z_UTIL_H |
|---|
| 21 | |
|---|
| 22 | #include "zlib.h" |
|---|
| 23 | |
|---|
| 24 | #ifdef STDC |
|---|
| 25 | //BKTEMP # include <stddef.h> |
|---|
| 26 | //BKTEMP # include <string.h> |
|---|
| 27 | //BKTEMP # include <stdlib.h> |
|---|
| 28 | #include "bstd.h"//BKTEMP |
|---|
| 29 | #include "ministd.h"//BKTEMP |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | #endif |
|---|
| 33 | #ifdef NO_ERRNO_H |
|---|
| 34 | extern int errno; |
|---|
| 35 | #else |
|---|
| 36 | # include <errno.h> |
|---|
| 37 | #endif |
|---|
| 38 | |
|---|
| 39 | #ifndef local |
|---|
| 40 | # define local static |
|---|
| 41 | #endif |
|---|
| 42 | /* compile with -Dlocal if your debugger can't find static symbols */ |
|---|
| 43 | |
|---|
| 44 | typedef unsigned char uch; |
|---|
| 45 | typedef uch FAR uchf; |
|---|
| 46 | typedef unsigned short ush; |
|---|
| 47 | typedef ush FAR ushf; |
|---|
| 48 | typedef unsigned long ulg; |
|---|
| 49 | |
|---|
| 50 | extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ |
|---|
| 51 | /* (size given to avoid silly warnings with Visual C++) */ |
|---|
| 52 | |
|---|
| 53 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] |
|---|
| 54 | |
|---|
| 55 | #define ERR_RETURN(strm,err) \ |
|---|
| 56 | return (strm->msg = (char*)ERR_MSG(err), (err)) |
|---|
| 57 | /* To be used only when the state is known to be valid */ |
|---|
| 58 | |
|---|
| 59 | /* common constants */ |
|---|
| 60 | |
|---|
| 61 | #ifndef DEF_WBITS |
|---|
| 62 | # define DEF_WBITS MAX_WBITS |
|---|
| 63 | #endif |
|---|
| 64 | /* default windowBits for decompression. MAX_WBITS is for compression only */ |
|---|
| 65 | |
|---|
| 66 | #if MAX_MEM_LEVEL >= 8 |
|---|
| 67 | # define DEF_MEM_LEVEL 8 |
|---|
| 68 | #else |
|---|
| 69 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL |
|---|
| 70 | #endif |
|---|
| 71 | /* default memLevel */ |
|---|
| 72 | |
|---|
| 73 | #define STORED_BLOCK 0 |
|---|
| 74 | #define STATIC_TREES 1 |
|---|
| 75 | #define DYN_TREES 2 |
|---|
| 76 | /* The three kinds of block type */ |
|---|
| 77 | |
|---|
| 78 | #define MIN_MATCH 3 |
|---|
| 79 | #define MAX_MATCH 258 |
|---|
| 80 | /* The minimum and maximum match lengths */ |
|---|
| 81 | |
|---|
| 82 | #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ |
|---|
| 83 | |
|---|
| 84 | /* target dependencies */ |
|---|
| 85 | |
|---|
| 86 | #ifdef MSDOS |
|---|
| 87 | # define OS_CODE 0x00 |
|---|
| 88 | # if defined(__TURBOC__) || defined(__BORLANDC__) |
|---|
| 89 | # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) |
|---|
| 90 | /* Allow compilation with ANSI keywords only enabled */ |
|---|
| 91 | void _Cdecl farfree( void *block ); |
|---|
| 92 | void *_Cdecl farmalloc( unsigned long nbytes ); |
|---|
| 93 | # else |
|---|
| 94 | # include <alloc.h> |
|---|
| 95 | # endif |
|---|
| 96 | # else /* MSC or DJGPP */ |
|---|
| 97 | # include <malloc.h> |
|---|
| 98 | # endif |
|---|
| 99 | #endif |
|---|
| 100 | |
|---|
| 101 | #ifdef OS2 |
|---|
| 102 | # define OS_CODE 0x06 |
|---|
| 103 | #endif |
|---|
| 104 | |
|---|
| 105 | #ifdef WIN32 /* Window 95 & Windows NT */ |
|---|
| 106 | # define OS_CODE 0x0b |
|---|
| 107 | #endif |
|---|
| 108 | |
|---|
| 109 | #if defined(VAXC) || defined(VMS) |
|---|
| 110 | # define OS_CODE 0x02 |
|---|
| 111 | # define F_OPEN(name, mode) \ |
|---|
| 112 | fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") |
|---|
| 113 | #endif |
|---|
| 114 | |
|---|
| 115 | #ifdef AMIGA |
|---|
| 116 | # define OS_CODE 0x01 |
|---|
| 117 | #endif |
|---|
| 118 | |
|---|
| 119 | #if defined(ATARI) || defined(atarist) |
|---|
| 120 | # define OS_CODE 0x05 |
|---|
| 121 | #endif |
|---|
| 122 | |
|---|
| 123 | #if defined(MACOS) || defined(TARGET_OS_MAC) |
|---|
| 124 | # define OS_CODE 0x07 |
|---|
| 125 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os |
|---|
| 126 | # include <unix.h> /* for fdopen */ |
|---|
| 127 | # else |
|---|
| 128 | # ifndef fdopen |
|---|
| 129 | # define fdopen(fd,mode) NULL /* No fdopen() */ |
|---|
| 130 | # endif |
|---|
| 131 | # endif |
|---|
| 132 | #endif |
|---|
| 133 | |
|---|
| 134 | #ifdef __50SERIES /* Prime/PRIMOS */ |
|---|
| 135 | # define OS_CODE 0x0F |
|---|
| 136 | #endif |
|---|
| 137 | |
|---|
| 138 | #ifdef TOPS20 |
|---|
| 139 | # define OS_CODE 0x0a |
|---|
| 140 | #endif |
|---|
| 141 | |
|---|
| 142 | #if defined(_BEOS_) || defined(RISCOS) |
|---|
| 143 | # define fdopen(fd,mode) NULL /* No fdopen() */ |
|---|
| 144 | #endif |
|---|
| 145 | |
|---|
| 146 | #if (defined(_MSC_VER) && (_MSC_VER > 600)) |
|---|
| 147 | # define fdopen(fd,type) _fdopen(fd,type) |
|---|
| 148 | #endif |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | /* Common defaults */ |
|---|
| 152 | |
|---|
| 153 | #ifndef OS_CODE |
|---|
| 154 | # define OS_CODE 0x03 /* assume Unix */ |
|---|
| 155 | #endif |
|---|
| 156 | |
|---|
| 157 | #ifndef F_OPEN |
|---|
| 158 | # define F_OPEN(name, mode) fopen((name), (mode)) |
|---|
| 159 | #endif |
|---|
| 160 | |
|---|
| 161 | /* functions */ |
|---|
| 162 | |
|---|
| 163 | #ifdef HAVE_STRERROR |
|---|
| 164 | extern char *strerror OF((int)); |
|---|
| 165 | # define zstrerror(errnum) strerror(errnum) |
|---|
| 166 | #else |
|---|
| 167 | # define zstrerror(errnum) "" |
|---|
| 168 | #endif |
|---|
| 169 | |
|---|
| 170 | #if defined(pyr) |
|---|
| 171 | # define NO_MEMCPY |
|---|
| 172 | #endif |
|---|
| 173 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) |
|---|
| 174 | /* Use our own functions for small and medium model with MSC <= 5.0. |
|---|
| 175 | * You may have to use the same strategy for Borland C (untested). |
|---|
| 176 | * The __SC__ check is for Symantec. |
|---|
| 177 | */ |
|---|
| 178 | # define NO_MEMCPY |
|---|
| 179 | #endif |
|---|
| 180 | #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) |
|---|
| 181 | # define HAVE_MEMCPY |
|---|
| 182 | #endif |
|---|
| 183 | #ifdef HAVE_MEMCPY |
|---|
| 184 | # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ |
|---|
| 185 | # define zmemcpy _fmemcpy |
|---|
| 186 | # define zmemcmp _fmemcmp |
|---|
| 187 | # define zmemzero(dest, len) _fmemset(dest, 0, len) |
|---|
| 188 | # else |
|---|
| 189 | # define zmemcpy memcpy |
|---|
| 190 | # define zmemcmp memcmp |
|---|
| 191 | # define zmemzero(dest, len) memset(dest, 0, len) |
|---|
| 192 | # endif |
|---|
| 193 | #else |
|---|
| 194 | extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); |
|---|
| 195 | extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); |
|---|
| 196 | extern void zmemzero OF((Bytef* dest, uInt len)); |
|---|
| 197 | #endif |
|---|
| 198 | |
|---|
| 199 | /* Diagnostic functions */ |
|---|
| 200 | extern void z_error OF((char *m)); |
|---|
| 201 | #if /* TL_DEBUG */ 0 /* cannot use fprintf */ |
|---|
| 202 | # include <stdio.h> |
|---|
| 203 | extern int z_verbose; |
|---|
| 204 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} |
|---|
| 205 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} |
|---|
| 206 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} |
|---|
| 207 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} |
|---|
| 208 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} |
|---|
| 209 | # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} |
|---|
| 210 | #else |
|---|
| 211 | # define z_verbose 0 |
|---|
| 212 | # define Assert(cond,msg) |
|---|
| 213 | # define Trace(x) |
|---|
| 214 | # define Tracev(x) |
|---|
| 215 | # define Tracevv(x) |
|---|
| 216 | # define Tracec(c,x) |
|---|
| 217 | # define Tracecv(c,x) |
|---|
| 218 | #endif |
|---|
| 219 | |
|---|
| 220 | |
|---|
| 221 | typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, |
|---|
| 222 | uInt len)); |
|---|
| 223 | voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); |
|---|
| 224 | void zcfree OF((voidpf opaque, voidpf ptr)); |
|---|
| 225 | |
|---|
| 226 | #define ZALLOC(strm, items, size) \ |
|---|
| 227 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) |
|---|
| 228 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |
|---|
| 229 | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} |
|---|
| 230 | |
|---|
| 231 | #endif /* _Z_UTIL_H */ |
|---|