暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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