vrshoot

annotate libs/zlib/zutil.h @ 2:334d17aed7de

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