dbf-halloween2015

diff libs/zlib/zutil.h @ 1:c3f5c32cb210

barfed all the libraries in the source tree to make porting easier
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 01 Nov 2015 00:36:56 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/zlib/zutil.h	Sun Nov 01 00:36:56 2015 +0200
     1.3 @@ -0,0 +1,269 @@
     1.4 +/* zutil.h -- internal interface and configuration of the compression library
     1.5 + * Copyright (C) 1995-2005 Jean-loup Gailly.
     1.6 + * For conditions of distribution and use, see copyright notice in zlib.h
     1.7 + */
     1.8 +
     1.9 +/* WARNING: this file should *not* be used by applications. It is
    1.10 +   part of the implementation of the compression library and is
    1.11 +   subject to change. Applications should only use zlib.h.
    1.12 + */
    1.13 +
    1.14 +/* @(#) $Id$ */
    1.15 +
    1.16 +#ifndef ZUTIL_H
    1.17 +#define ZUTIL_H
    1.18 +
    1.19 +#define ZLIB_INTERNAL
    1.20 +#include "zlib.h"
    1.21 +
    1.22 +#ifdef STDC
    1.23 +#  ifndef _WIN32_WCE
    1.24 +#    include <stddef.h>
    1.25 +#  endif
    1.26 +#  include <string.h>
    1.27 +#  include <stdlib.h>
    1.28 +#endif
    1.29 +#ifdef NO_ERRNO_H
    1.30 +#   ifdef _WIN32_WCE
    1.31 +      /* The Microsoft C Run-Time Library for Windows CE doesn't have
    1.32 +       * errno.  We define it as a global variable to simplify porting.
    1.33 +       * Its value is always 0 and should not be used.  We rename it to
    1.34 +       * avoid conflict with other libraries that use the same workaround.
    1.35 +       */
    1.36 +#     define errno z_errno
    1.37 +#   endif
    1.38 +    extern int errno;
    1.39 +#else
    1.40 +#  ifndef _WIN32_WCE
    1.41 +#    include <errno.h>
    1.42 +#  endif
    1.43 +#endif
    1.44 +
    1.45 +#ifndef local
    1.46 +#  define local static
    1.47 +#endif
    1.48 +/* compile with -Dlocal if your debugger can't find static symbols */
    1.49 +
    1.50 +typedef unsigned char  uch;
    1.51 +typedef uch FAR uchf;
    1.52 +typedef unsigned short ush;
    1.53 +typedef ush FAR ushf;
    1.54 +typedef unsigned long  ulg;
    1.55 +
    1.56 +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
    1.57 +/* (size given to avoid silly warnings with Visual C++) */
    1.58 +
    1.59 +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
    1.60 +
    1.61 +#define ERR_RETURN(strm,err) \
    1.62 +  return (strm->msg = (char*)ERR_MSG(err), (err))
    1.63 +/* To be used only when the state is known to be valid */
    1.64 +
    1.65 +        /* common constants */
    1.66 +
    1.67 +#ifndef DEF_WBITS
    1.68 +#  define DEF_WBITS MAX_WBITS
    1.69 +#endif
    1.70 +/* default windowBits for decompression. MAX_WBITS is for compression only */
    1.71 +
    1.72 +#if MAX_MEM_LEVEL >= 8
    1.73 +#  define DEF_MEM_LEVEL 8
    1.74 +#else
    1.75 +#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
    1.76 +#endif
    1.77 +/* default memLevel */
    1.78 +
    1.79 +#define STORED_BLOCK 0
    1.80 +#define STATIC_TREES 1
    1.81 +#define DYN_TREES    2
    1.82 +/* The three kinds of block type */
    1.83 +
    1.84 +#define MIN_MATCH  3
    1.85 +#define MAX_MATCH  258
    1.86 +/* The minimum and maximum match lengths */
    1.87 +
    1.88 +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
    1.89 +
    1.90 +        /* target dependencies */
    1.91 +
    1.92 +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
    1.93 +#  define OS_CODE  0x00
    1.94 +#  if defined(__TURBOC__) || defined(__BORLANDC__)
    1.95 +#    if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
    1.96 +       /* Allow compilation with ANSI keywords only enabled */
    1.97 +       void _Cdecl farfree( void *block );
    1.98 +       void *_Cdecl farmalloc( unsigned long nbytes );
    1.99 +#    else
   1.100 +#      include <alloc.h>
   1.101 +#    endif
   1.102 +#  else /* MSC or DJGPP */
   1.103 +#    include <malloc.h>
   1.104 +#  endif
   1.105 +#endif
   1.106 +
   1.107 +#ifdef AMIGA
   1.108 +#  define OS_CODE  0x01
   1.109 +#endif
   1.110 +
   1.111 +#if defined(VAXC) || defined(VMS)
   1.112 +#  define OS_CODE  0x02
   1.113 +#  define F_OPEN(name, mode) \
   1.114 +     fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
   1.115 +#endif
   1.116 +
   1.117 +#if defined(ATARI) || defined(atarist)
   1.118 +#  define OS_CODE  0x05
   1.119 +#endif
   1.120 +
   1.121 +#ifdef OS2
   1.122 +#  define OS_CODE  0x06
   1.123 +#  ifdef M_I86
   1.124 +     #include <malloc.h>
   1.125 +#  endif
   1.126 +#endif
   1.127 +
   1.128 +#if defined(MACOS) || defined(TARGET_OS_MAC)
   1.129 +#  define OS_CODE  0x07
   1.130 +#  if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
   1.131 +#    include <unix.h> /* for fdopen */
   1.132 +#  else
   1.133 +#    ifndef fdopen
   1.134 +#      define fdopen(fd,mode) NULL /* No fdopen() */
   1.135 +#    endif
   1.136 +#  endif
   1.137 +#endif
   1.138 +
   1.139 +#ifdef TOPS20
   1.140 +#  define OS_CODE  0x0a
   1.141 +#endif
   1.142 +
   1.143 +#ifdef WIN32
   1.144 +#  ifndef __CYGWIN__  /* Cygwin is Unix, not Win32 */
   1.145 +#    define OS_CODE  0x0b
   1.146 +#  endif
   1.147 +#endif
   1.148 +
   1.149 +#ifdef __50SERIES /* Prime/PRIMOS */
   1.150 +#  define OS_CODE  0x0f
   1.151 +#endif
   1.152 +
   1.153 +#if defined(_BEOS_) || defined(RISCOS)
   1.154 +#  define fdopen(fd,mode) NULL /* No fdopen() */
   1.155 +#endif
   1.156 +
   1.157 +#if (defined(_MSC_VER) && (_MSC_VER > 600))
   1.158 +#  if defined(_WIN32_WCE)
   1.159 +#    define fdopen(fd,mode) NULL /* No fdopen() */
   1.160 +#    ifndef _PTRDIFF_T_DEFINED
   1.161 +       typedef int ptrdiff_t;
   1.162 +#      define _PTRDIFF_T_DEFINED
   1.163 +#    endif
   1.164 +#  else
   1.165 +#    define fdopen(fd,type)  _fdopen(fd,type)
   1.166 +#  endif
   1.167 +#endif
   1.168 +
   1.169 +        /* common defaults */
   1.170 +
   1.171 +#ifndef OS_CODE
   1.172 +#  define OS_CODE  0x03  /* assume Unix */
   1.173 +#endif
   1.174 +
   1.175 +#ifndef F_OPEN
   1.176 +#  define F_OPEN(name, mode) fopen((name), (mode))
   1.177 +#endif
   1.178 +
   1.179 +         /* functions */
   1.180 +
   1.181 +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
   1.182 +#  ifndef HAVE_VSNPRINTF
   1.183 +#    define HAVE_VSNPRINTF
   1.184 +#  endif
   1.185 +#endif
   1.186 +#if defined(__CYGWIN__)
   1.187 +#  ifndef HAVE_VSNPRINTF
   1.188 +#    define HAVE_VSNPRINTF
   1.189 +#  endif
   1.190 +#endif
   1.191 +#ifndef HAVE_VSNPRINTF
   1.192 +#  ifdef MSDOS
   1.193 +     /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
   1.194 +        but for now we just assume it doesn't. */
   1.195 +#    define NO_vsnprintf
   1.196 +#  endif
   1.197 +#  ifdef __TURBOC__
   1.198 +#    define NO_vsnprintf
   1.199 +#  endif
   1.200 +#  ifdef WIN32
   1.201 +     /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
   1.202 +#    if !defined(vsnprintf) && !defined(NO_vsnprintf)
   1.203 +#      define vsnprintf _vsnprintf
   1.204 +#    endif
   1.205 +#  endif
   1.206 +#  ifdef __SASC
   1.207 +#    define NO_vsnprintf
   1.208 +#  endif
   1.209 +#endif
   1.210 +#ifdef VMS
   1.211 +#  define NO_vsnprintf
   1.212 +#endif
   1.213 +
   1.214 +#if defined(pyr)
   1.215 +#  define NO_MEMCPY
   1.216 +#endif
   1.217 +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
   1.218 + /* Use our own functions for small and medium model with MSC <= 5.0.
   1.219 +  * You may have to use the same strategy for Borland C (untested).
   1.220 +  * The __SC__ check is for Symantec.
   1.221 +  */
   1.222 +#  define NO_MEMCPY
   1.223 +#endif
   1.224 +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
   1.225 +#  define HAVE_MEMCPY
   1.226 +#endif
   1.227 +#ifdef HAVE_MEMCPY
   1.228 +#  ifdef SMALL_MEDIUM /* MSDOS small or medium model */
   1.229 +#    define zmemcpy _fmemcpy
   1.230 +#    define zmemcmp _fmemcmp
   1.231 +#    define zmemzero(dest, len) _fmemset(dest, 0, len)
   1.232 +#  else
   1.233 +#    define zmemcpy memcpy
   1.234 +#    define zmemcmp memcmp
   1.235 +#    define zmemzero(dest, len) memset(dest, 0, len)
   1.236 +#  endif
   1.237 +#else
   1.238 +   extern void zmemcpy  OF((Bytef* dest, const Bytef* source, uInt len));
   1.239 +   extern int  zmemcmp  OF((const Bytef* s1, const Bytef* s2, uInt len));
   1.240 +   extern void zmemzero OF((Bytef* dest, uInt len));
   1.241 +#endif
   1.242 +
   1.243 +/* Diagnostic functions */
   1.244 +#ifdef DEBUG
   1.245 +#  include <stdio.h>
   1.246 +   extern int z_verbose;
   1.247 +   extern void z_error    OF((char *m));
   1.248 +#  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
   1.249 +#  define Trace(x) {if (z_verbose>=0) fprintf x ;}
   1.250 +#  define Tracev(x) {if (z_verbose>0) fprintf x ;}
   1.251 +#  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
   1.252 +#  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
   1.253 +#  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
   1.254 +#else
   1.255 +#  define Assert(cond,msg)
   1.256 +#  define Trace(x)
   1.257 +#  define Tracev(x)
   1.258 +#  define Tracevv(x)
   1.259 +#  define Tracec(c,x)
   1.260 +#  define Tracecv(c,x)
   1.261 +#endif
   1.262 +
   1.263 +
   1.264 +voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
   1.265 +void   zcfree  OF((voidpf opaque, voidpf ptr));
   1.266 +
   1.267 +#define ZALLOC(strm, items, size) \
   1.268 +           (*((strm)->zalloc))((strm)->opaque, (items), (size))
   1.269 +#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
   1.270 +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
   1.271 +
   1.272 +#endif /* ZUTIL_H */