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