istereo2

annotate libs/zlib/zutil.h @ 16:1b7776cb800b

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