| 1 |
#ifndef ZUTIL_H_ |
| 2 |
#define ZUTIL_H_ |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#include "zbuild.h" |
| 14 |
#ifdef ZLIB_COMPAT |
| 15 |
# include "zlib.h" |
| 16 |
#else |
| 17 |
# include "zlib-ng.h" |
| 18 |
#endif |
| 19 |
|
| 20 |
typedef unsigned char uch; |
| 21 |
typedef uint16_t ush; |
| 22 |
typedef unsigned long ulg; |
| 23 |
|
| 24 |
extern z_const char * const PREFIX(z_errmsg)[10]; |
| 25 |
|
| 26 |
|
| 27 |
#define ERR_MSG(err) PREFIX(z_errmsg)[Z_NEED_DICT-(err)] |
| 28 |
|
| 29 |
#define ERR_RETURN(strm, err) return (strm->msg = ERR_MSG(err), (err)) |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#ifndef DEF_WBITS |
| 35 |
# define DEF_WBITS MAX_WBITS |
| 36 |
#endif |
| 37 |
|
| 38 |
|
| 39 |
#if MAX_MEM_LEVEL >= 8 |
| 40 |
# define DEF_MEM_LEVEL 8 |
| 41 |
#else |
| 42 |
# define DEF_MEM_LEVEL MAX_MEM_LEVEL |
| 43 |
#endif |
| 44 |
|
| 45 |
|
| 46 |
#define STORED_BLOCK 0 |
| 47 |
#define STATIC_TREES 1 |
| 48 |
#define DYN_TREES 2 |
| 49 |
|
| 50 |
|
| 51 |
#define STD_MIN_MATCH 3 |
| 52 |
#define STD_MAX_MATCH 258 |
| 53 |
|
| 54 |
|
| 55 |
#define WANT_MIN_MATCH 4 |
| 56 |
|
| 57 |
|
| 58 |
#define PRESET_DICT 0x20 |
| 59 |
|
| 60 |
#define ADLER32_INITIAL_VALUE 1 |
| 61 |
#define CRC32_INITIAL_VALUE 0 |
| 62 |
|
| 63 |
#define ZLIB_WRAPLEN 6 |
| 64 |
#define GZIP_WRAPLEN 18 |
| 65 |
|
| 66 |
#define DEFLATE_HEADER_BITS 3 |
| 67 |
#define DEFLATE_EOBS_BITS 15 |
| 68 |
#define DEFLATE_PAD_BITS 6 |
| 69 |
#define DEFLATE_BLOCK_OVERHEAD ((DEFLATE_HEADER_BITS + DEFLATE_EOBS_BITS + DEFLATE_PAD_BITS) >> 3) |
| 70 |
|
| 71 |
|
| 72 |
#define DEFLATE_QUICK_LIT_MAX_BITS 9 |
| 73 |
#define DEFLATE_QUICK_OVERHEAD(x) ((x * (DEFLATE_QUICK_LIT_MAX_BITS - 8) + 7) >> 3) |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
#ifdef AMIGA |
| 80 |
# define OS_CODE 1 |
| 81 |
#endif |
| 82 |
|
| 83 |
#ifdef __370__ |
| 84 |
# if __TARGET_LIB__ < 0x20000000 |
| 85 |
# define OS_CODE 4 |
| 86 |
# elif __TARGET_LIB__ < 0x40000000 |
| 87 |
# define OS_CODE 11 |
| 88 |
# else |
| 89 |
# define OS_CODE 8 |
| 90 |
# endif |
| 91 |
#endif |
| 92 |
|
| 93 |
#if defined(ATARI) || defined(atarist) |
| 94 |
# define OS_CODE 5 |
| 95 |
#endif |
| 96 |
|
| 97 |
#ifdef OS2 |
| 98 |
# define OS_CODE 6 |
| 99 |
#endif |
| 100 |
|
| 101 |
#if defined(MACOS) || defined(TARGET_OS_MAC) |
| 102 |
# define OS_CODE 7 |
| 103 |
#endif |
| 104 |
|
| 105 |
#ifdef __acorn |
| 106 |
# define OS_CODE 13 |
| 107 |
#endif |
| 108 |
|
| 109 |
#if defined(_WIN32) && !defined(__CYGWIN__) |
| 110 |
# define OS_CODE 10 |
| 111 |
#endif |
| 112 |
|
| 113 |
#ifdef __APPLE__ |
| 114 |
# define OS_CODE 19 |
| 115 |
#endif |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
#ifndef OS_CODE |
| 120 |
# define OS_CODE 3 |
| 121 |
#endif |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
#define CHECK_VER_STSIZE(_ver,_stsize) ((_ver) == NULL || (_ver)[0] != PREFIX2(VERSION)[0] || (_stsize) != (int32_t)sizeof(PREFIX3(stream))) |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
void Z_INTERNAL *zng_calloc(void *opaque, unsigned items, unsigned size); |
| 130 |
void Z_INTERNAL zng_cfree(void *opaque, void *ptr); |
| 131 |
|
| 132 |
typedef void *zng_calloc_func(void *opaque, unsigned items, unsigned size); |
| 133 |
typedef void zng_cfree_func(void *opaque, void *ptr); |
| 134 |
|
| 135 |
void Z_INTERNAL *zng_alloc_aligned(zng_calloc_func zalloc, void *opaque, unsigned items, unsigned size, unsigned align); |
| 136 |
void Z_INTERNAL zng_free_aligned(zng_cfree_func zfree, void *opaque, void *ptr); |
| 137 |
|
| 138 |
#define ZALLOC(strm, items, size) zng_alloc_aligned((strm)->zalloc, (strm)->opaque, (items), (size), 64) |
| 139 |
#define ZFREE(strm, addr) zng_free_aligned((strm)->zfree, (strm)->opaque, (void *)(addr)) |
| 140 |
|
| 141 |
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} |
| 142 |
|
| 143 |
#endif |