annotate src/zlib-1.2.8/zutil.h @ 169:223a55898ab9 tip default

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