File indexing completed on 2025-05-11 08:24:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ZUTIL_H
0014 #define ZUTIL_H
0015
0016 #ifdef HAVE_HIDDEN
0017 # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
0018 #else
0019 # define ZLIB_INTERNAL
0020 #endif
0021
0022 #include "zlib.h"
0023
0024 #if defined(STDC) && !defined(Z_SOLO)
0025 # if !(defined(_WIN32_WCE) && defined(_MSC_VER))
0026 # include <stddef.h>
0027 # endif
0028 # include <string.h>
0029 # include <stdlib.h>
0030 #endif
0031
0032 #ifndef local
0033 # define local static
0034 #endif
0035
0036
0037
0038
0039 typedef unsigned char uch;
0040 typedef uch FAR uchf;
0041 typedef unsigned short ush;
0042 typedef ush FAR ushf;
0043 typedef unsigned long ulg;
0044
0045 #ifndef __rtems__
0046 #if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
0047 # include <limits.h>
0048 # if (ULONG_MAX == 0xffffffffffffffff)
0049 # define Z_U8 unsigned long
0050 # elif (ULLONG_MAX == 0xffffffffffffffff)
0051 # define Z_U8 unsigned long long
0052 # elif (UINT_MAX == 0xffffffffffffffff)
0053 # define Z_U8 unsigned
0054 # endif
0055 #endif
0056 #else
0057 #define Z_U8 uint64_t
0058 #endif
0059
0060 extern z_const char * const z_errmsg[10];
0061
0062
0063 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
0064
0065 #define ERR_RETURN(strm,err) \
0066 return (strm->msg = ERR_MSG(err), (err))
0067
0068
0069
0070
0071 #ifndef DEF_WBITS
0072 # define DEF_WBITS MAX_WBITS
0073 #endif
0074
0075
0076 #if MAX_MEM_LEVEL >= 8
0077 # define DEF_MEM_LEVEL 8
0078 #else
0079 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
0080 #endif
0081
0082
0083 #define STORED_BLOCK 0
0084 #define STATIC_TREES 1
0085 #define DYN_TREES 2
0086
0087
0088 #define MIN_MATCH 3
0089 #define MAX_MATCH 258
0090
0091
0092 #define PRESET_DICT 0x20
0093
0094
0095
0096 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
0097 # define OS_CODE 0x00
0098 # ifndef Z_SOLO
0099 # if defined(__TURBOC__) || defined(__BORLANDC__)
0100 # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
0101
0102 void _Cdecl farfree( void *block );
0103 void *_Cdecl farmalloc( unsigned long nbytes );
0104 # else
0105 # include <alloc.h>
0106 # endif
0107 # else
0108 # include <malloc.h>
0109 # endif
0110 # endif
0111 #endif
0112
0113 #ifdef AMIGA
0114 # define OS_CODE 1
0115 #endif
0116
0117 #if defined(VAXC) || defined(VMS)
0118 # define OS_CODE 2
0119 # define F_OPEN(name, mode) \
0120 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
0121 #endif
0122
0123 #ifdef __370__
0124 # if __TARGET_LIB__ < 0x20000000
0125 # define OS_CODE 4
0126 # elif __TARGET_LIB__ < 0x40000000
0127 # define OS_CODE 11
0128 # else
0129 # define OS_CODE 8
0130 # endif
0131 #endif
0132
0133 #if defined(ATARI) || defined(atarist)
0134 # define OS_CODE 5
0135 #endif
0136
0137 #ifdef OS2
0138 # define OS_CODE 6
0139 # if defined(M_I86) && !defined(Z_SOLO)
0140 # include <malloc.h>
0141 # endif
0142 #endif
0143
0144 #if defined(MACOS) || defined(TARGET_OS_MAC)
0145 # define OS_CODE 7
0146 # ifndef Z_SOLO
0147 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
0148 # include <unix.h> /* for fdopen */
0149 # else
0150 # ifndef fdopen
0151 # define fdopen(fd,mode) NULL
0152 # endif
0153 # endif
0154 # endif
0155 #endif
0156
0157 #ifdef __acorn
0158 # define OS_CODE 13
0159 #endif
0160
0161 #if defined(WIN32) && !defined(__CYGWIN__)
0162 # define OS_CODE 10
0163 #endif
0164
0165 #ifdef _BEOS_
0166 # define OS_CODE 16
0167 #endif
0168
0169 #ifdef __TOS_OS400__
0170 # define OS_CODE 18
0171 #endif
0172
0173 #ifdef __APPLE__
0174 # define OS_CODE 19
0175 #endif
0176
0177 #if defined(_BEOS_) || defined(RISCOS)
0178 # define fdopen(fd,mode) NULL
0179 #endif
0180
0181 #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
0182 # if defined(_WIN32_WCE)
0183 # define fdopen(fd,mode) NULL
0184 # else
0185 # define fdopen(fd,type) _fdopen(fd,type)
0186 # endif
0187 #endif
0188
0189 #if defined(__BORLANDC__) && !defined(MSDOS)
0190 #pragma warn -8004
0191 #pragma warn -8008
0192 #pragma warn -8066
0193 #endif
0194
0195
0196 #if !defined(_WIN32) && \
0197 (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
0198 ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
0199 ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
0200 ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
0201 #endif
0202
0203
0204
0205 #ifndef OS_CODE
0206 # define OS_CODE 3
0207 #endif
0208
0209 #ifndef F_OPEN
0210 # define F_OPEN(name, mode) fopen((name), (mode))
0211 #endif
0212
0213
0214
0215 #if defined(pyr) || defined(Z_SOLO)
0216 # define NO_MEMCPY
0217 #endif
0218 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
0219
0220
0221
0222
0223 # define NO_MEMCPY
0224 #endif
0225 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
0226 # define HAVE_MEMCPY
0227 #endif
0228 #ifdef HAVE_MEMCPY
0229 # ifdef SMALL_MEDIUM
0230 # define zmemcpy _fmemcpy
0231 # define zmemcmp _fmemcmp
0232 # define zmemzero(dest, len) _fmemset(dest, 0, len)
0233 # else
0234 # define zmemcpy memcpy
0235 # define zmemcmp memcmp
0236 # define zmemzero(dest, len) memset(dest, 0, len)
0237 # endif
0238 #else
0239 void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
0240 int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
0241 void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
0242 #endif
0243
0244
0245 #ifdef ZLIB_DEBUG
0246 # include <stdio.h>
0247 extern int ZLIB_INTERNAL z_verbose;
0248 extern void ZLIB_INTERNAL z_error OF((char *m));
0249 # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
0250 # define Trace(x) {if (z_verbose>=0) fprintf x ;}
0251 # define Tracev(x) {if (z_verbose>0) fprintf x ;}
0252 # define Tracevv(x) {if (z_verbose>1) fprintf x ;}
0253 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
0254 # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
0255 #else
0256 # define Assert(cond,msg)
0257 # define Trace(x)
0258 # define Tracev(x)
0259 # define Tracevv(x)
0260 # define Tracec(c,x)
0261 # define Tracecv(c,x)
0262 #endif
0263
0264 #ifndef Z_SOLO
0265 voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
0266 unsigned size));
0267 void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
0268 #endif
0269
0270 #define ZALLOC(strm, items, size) \
0271 (*((strm)->zalloc))((strm)->opaque, (items), (size))
0272 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
0273 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
0274
0275
0276 #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
0277 (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
0278
0279 #endif