istereo

annotate libs/zlib/zutil.h @ 33:33e9eedad390

ah.. blunder
author John Tsiombikas <nuclear@mutantstargoat.com>
date Fri, 09 Sep 2011 00:03:37 +0300
parents
children
rev   line source
nuclear@26 1 /* zutil.h -- internal interface and configuration of the compression library
nuclear@26 2 * Copyright (C) 1995-2005 Jean-loup Gailly.
nuclear@26 3 * For conditions of distribution and use, see copyright notice in zlib.h
nuclear@26 4 */
nuclear@26 5
nuclear@26 6 /* WARNING: this file should *not* be used by applications. It is
nuclear@26 7 part of the implementation of the compression library and is
nuclear@26 8 subject to change. Applications should only use zlib.h.
nuclear@26 9 */
nuclear@26 10
nuclear@26 11 /* @(#) $Id$ */
nuclear@26 12
nuclear@26 13 #ifndef ZUTIL_H
nuclear@26 14 #define ZUTIL_H
nuclear@26 15
nuclear@26 16 #define ZLIB_INTERNAL
nuclear@26 17 #include "zlib.h"
nuclear@26 18
nuclear@26 19 #ifdef STDC
nuclear@26 20 # ifndef _WIN32_WCE
nuclear@26 21 # include <stddef.h>
nuclear@26 22 # endif
nuclear@26 23 # include <string.h>
nuclear@26 24 # include <stdlib.h>
nuclear@26 25 #endif
nuclear@26 26 #ifdef NO_ERRNO_H
nuclear@26 27 # ifdef _WIN32_WCE
nuclear@26 28 /* The Microsoft C Run-Time Library for Windows CE doesn't have
nuclear@26 29 * errno. We define it as a global variable to simplify porting.
nuclear@26 30 * Its value is always 0 and should not be used. We rename it to
nuclear@26 31 * avoid conflict with other libraries that use the same workaround.
nuclear@26 32 */
nuclear@26 33 # define errno z_errno
nuclear@26 34 # endif
nuclear@26 35 extern int errno;
nuclear@26 36 #else
nuclear@26 37 # ifndef _WIN32_WCE
nuclear@26 38 # include <errno.h>
nuclear@26 39 # endif
nuclear@26 40 #endif
nuclear@26 41
nuclear@26 42 #ifndef local
nuclear@26 43 # define local static
nuclear@26 44 #endif
nuclear@26 45 /* compile with -Dlocal if your debugger can't find static symbols */
nuclear@26 46
nuclear@26 47 typedef unsigned char uch;
nuclear@26 48 typedef uch FAR uchf;
nuclear@26 49 typedef unsigned short ush;
nuclear@26 50 typedef ush FAR ushf;
nuclear@26 51 typedef unsigned long ulg;
nuclear@26 52
nuclear@26 53 extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
nuclear@26 54 /* (size given to avoid silly warnings with Visual C++) */
nuclear@26 55
nuclear@26 56 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
nuclear@26 57
nuclear@26 58 #define ERR_RETURN(strm,err) \
nuclear@26 59 return (strm->msg = (char*)ERR_MSG(err), (err))
nuclear@26 60 /* To be used only when the state is known to be valid */
nuclear@26 61
nuclear@26 62 /* common constants */
nuclear@26 63
nuclear@26 64 #ifndef DEF_WBITS
nuclear@26 65 # define DEF_WBITS MAX_WBITS
nuclear@26 66 #endif
nuclear@26 67 /* default windowBits for decompression. MAX_WBITS is for compression only */
nuclear@26 68
nuclear@26 69 #if MAX_MEM_LEVEL >= 8
nuclear@26 70 # define DEF_MEM_LEVEL 8
nuclear@26 71 #else
nuclear@26 72 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
nuclear@26 73 #endif
nuclear@26 74 /* default memLevel */
nuclear@26 75
nuclear@26 76 #define STORED_BLOCK 0
nuclear@26 77 #define STATIC_TREES 1
nuclear@26 78 #define DYN_TREES 2
nuclear@26 79 /* The three kinds of block type */
nuclear@26 80
nuclear@26 81 #define MIN_MATCH 3
nuclear@26 82 #define MAX_MATCH 258
nuclear@26 83 /* The minimum and maximum match lengths */
nuclear@26 84
nuclear@26 85 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
nuclear@26 86
nuclear@26 87 /* target dependencies */
nuclear@26 88
nuclear@26 89 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
nuclear@26 90 # define OS_CODE 0x00
nuclear@26 91 # if defined(__TURBOC__) || defined(__BORLANDC__)
nuclear@26 92 # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
nuclear@26 93 /* Allow compilation with ANSI keywords only enabled */
nuclear@26 94 void _Cdecl farfree( void *block );
nuclear@26 95 void *_Cdecl farmalloc( unsigned long nbytes );
nuclear@26 96 # else
nuclear@26 97 # include <alloc.h>
nuclear@26 98 # endif
nuclear@26 99 # else /* MSC or DJGPP */
nuclear@26 100 # include <malloc.h>
nuclear@26 101 # endif
nuclear@26 102 #endif
nuclear@26 103
nuclear@26 104 #ifdef AMIGA
nuclear@26 105 # define OS_CODE 0x01
nuclear@26 106 #endif
nuclear@26 107
nuclear@26 108 #if defined(VAXC) || defined(VMS)
nuclear@26 109 # define OS_CODE 0x02
nuclear@26 110 # define F_OPEN(name, mode) \
nuclear@26 111 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
nuclear@26 112 #endif
nuclear@26 113
nuclear@26 114 #if defined(ATARI) || defined(atarist)
nuclear@26 115 # define OS_CODE 0x05
nuclear@26 116 #endif
nuclear@26 117
nuclear@26 118 #ifdef OS2
nuclear@26 119 # define OS_CODE 0x06
nuclear@26 120 # ifdef M_I86
nuclear@26 121 #include <malloc.h>
nuclear@26 122 # endif
nuclear@26 123 #endif
nuclear@26 124
nuclear@26 125 #if defined(MACOS) || defined(TARGET_OS_MAC)
nuclear@26 126 # define OS_CODE 0x07
nuclear@26 127 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
nuclear@26 128 # include <unix.h> /* for fdopen */
nuclear@26 129 # else
nuclear@26 130 # ifndef fdopen
nuclear@26 131 # define fdopen(fd,mode) NULL /* No fdopen() */
nuclear@26 132 # endif
nuclear@26 133 # endif
nuclear@26 134 #endif
nuclear@26 135
nuclear@26 136 #ifdef TOPS20
nuclear@26 137 # define OS_CODE 0x0a
nuclear@26 138 #endif
nuclear@26 139
nuclear@26 140 #ifdef WIN32
nuclear@26 141 # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
nuclear@26 142 # define OS_CODE 0x0b
nuclear@26 143 # endif
nuclear@26 144 #endif
nuclear@26 145
nuclear@26 146 #ifdef __50SERIES /* Prime/PRIMOS */
nuclear@26 147 # define OS_CODE 0x0f
nuclear@26 148 #endif
nuclear@26 149
nuclear@26 150 #if defined(_BEOS_) || defined(RISCOS)
nuclear@26 151 # define fdopen(fd,mode) NULL /* No fdopen() */
nuclear@26 152 #endif
nuclear@26 153
nuclear@26 154 #if (defined(_MSC_VER) && (_MSC_VER > 600))
nuclear@26 155 # if defined(_WIN32_WCE)
nuclear@26 156 # define fdopen(fd,mode) NULL /* No fdopen() */
nuclear@26 157 # ifndef _PTRDIFF_T_DEFINED
nuclear@26 158 typedef int ptrdiff_t;
nuclear@26 159 # define _PTRDIFF_T_DEFINED
nuclear@26 160 # endif
nuclear@26 161 # else
nuclear@26 162 # define fdopen(fd,type) _fdopen(fd,type)
nuclear@26 163 # endif
nuclear@26 164 #endif
nuclear@26 165
nuclear@26 166 /* common defaults */
nuclear@26 167
nuclear@26 168 #ifndef OS_CODE
nuclear@26 169 # define OS_CODE 0x03 /* assume Unix */
nuclear@26 170 #endif
nuclear@26 171
nuclear@26 172 #ifndef F_OPEN
nuclear@26 173 # define F_OPEN(name, mode) fopen((name), (mode))
nuclear@26 174 #endif
nuclear@26 175
nuclear@26 176 /* functions */
nuclear@26 177
nuclear@26 178 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
nuclear@26 179 # ifndef HAVE_VSNPRINTF
nuclear@26 180 # define HAVE_VSNPRINTF
nuclear@26 181 # endif
nuclear@26 182 #endif
nuclear@26 183 #if defined(__CYGWIN__)
nuclear@26 184 # ifndef HAVE_VSNPRINTF
nuclear@26 185 # define HAVE_VSNPRINTF
nuclear@26 186 # endif
nuclear@26 187 #endif
nuclear@26 188 #ifndef HAVE_VSNPRINTF
nuclear@26 189 # ifdef MSDOS
nuclear@26 190 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
nuclear@26 191 but for now we just assume it doesn't. */
nuclear@26 192 # define NO_vsnprintf
nuclear@26 193 # endif
nuclear@26 194 # ifdef __TURBOC__
nuclear@26 195 # define NO_vsnprintf
nuclear@26 196 # endif
nuclear@26 197 # ifdef WIN32
nuclear@26 198 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
nuclear@26 199 # if !defined(vsnprintf) && !defined(NO_vsnprintf)
nuclear@26 200 # define vsnprintf _vsnprintf
nuclear@26 201 # endif
nuclear@26 202 # endif
nuclear@26 203 # ifdef __SASC
nuclear@26 204 # define NO_vsnprintf
nuclear@26 205 # endif
nuclear@26 206 #endif
nuclear@26 207 #ifdef VMS
nuclear@26 208 # define NO_vsnprintf
nuclear@26 209 #endif
nuclear@26 210
nuclear@26 211 #if defined(pyr)
nuclear@26 212 # define NO_MEMCPY
nuclear@26 213 #endif
nuclear@26 214 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
nuclear@26 215 /* Use our own functions for small and medium model with MSC <= 5.0.
nuclear@26 216 * You may have to use the same strategy for Borland C (untested).
nuclear@26 217 * The __SC__ check is for Symantec.
nuclear@26 218 */
nuclear@26 219 # define NO_MEMCPY
nuclear@26 220 #endif
nuclear@26 221 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
nuclear@26 222 # define HAVE_MEMCPY
nuclear@26 223 #endif
nuclear@26 224 #ifdef HAVE_MEMCPY
nuclear@26 225 # ifdef SMALL_MEDIUM /* MSDOS small or medium model */
nuclear@26 226 # define zmemcpy _fmemcpy
nuclear@26 227 # define zmemcmp _fmemcmp
nuclear@26 228 # define zmemzero(dest, len) _fmemset(dest, 0, len)
nuclear@26 229 # else
nuclear@26 230 # define zmemcpy memcpy
nuclear@26 231 # define zmemcmp memcmp
nuclear@26 232 # define zmemzero(dest, len) memset(dest, 0, len)
nuclear@26 233 # endif
nuclear@26 234 #else
nuclear@26 235 extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
nuclear@26 236 extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
nuclear@26 237 extern void zmemzero OF((Bytef* dest, uInt len));
nuclear@26 238 #endif
nuclear@26 239
nuclear@26 240 /* Diagnostic functions */
nuclear@26 241 #ifdef DEBUG
nuclear@26 242 # include <stdio.h>
nuclear@26 243 extern int z_verbose;
nuclear@26 244 extern void z_error OF((char *m));
nuclear@26 245 # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
nuclear@26 246 # define Trace(x) {if (z_verbose>=0) fprintf x ;}
nuclear@26 247 # define Tracev(x) {if (z_verbose>0) fprintf x ;}
nuclear@26 248 # define Tracevv(x) {if (z_verbose>1) fprintf x ;}
nuclear@26 249 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
nuclear@26 250 # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
nuclear@26 251 #else
nuclear@26 252 # define Assert(cond,msg)
nuclear@26 253 # define Trace(x)
nuclear@26 254 # define Tracev(x)
nuclear@26 255 # define Tracevv(x)
nuclear@26 256 # define Tracec(c,x)
nuclear@26 257 # define Tracecv(c,x)
nuclear@26 258 #endif
nuclear@26 259
nuclear@26 260
nuclear@26 261 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
nuclear@26 262 void zcfree OF((voidpf opaque, voidpf ptr));
nuclear@26 263
nuclear@26 264 #define ZALLOC(strm, items, size) \
nuclear@26 265 (*((strm)->zalloc))((strm)->opaque, (items), (size))
nuclear@26 266 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
nuclear@26 267 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
nuclear@26 268
nuclear@26 269 #endif /* ZUTIL_H */