Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
7.0 KiB

  1. /* zutil.h -- internal interface and configuration of the compression library
  2. * Copyright (C) 1995-2010 Jean-loup Gailly.
  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. #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
  13. # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
  14. #else
  15. # define ZLIB_INTERNAL
  16. #endif
  17. #include "zlib.h"
  18. #ifdef STDC
  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. /* compile with -Dlocal if your debugger can't find static symbols */
  29. typedef unsigned char uch;
  30. typedef uch FAR uchf;
  31. typedef unsigned short ush;
  32. typedef ush FAR ushf;
  33. typedef unsigned long ulg;
  34. extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
  35. /* (size given to avoid silly warnings with Visual C++) */
  36. #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
  37. #define ERR_RETURN(strm,err) \
  38. return (strm->msg = (char*)ERR_MSG(err), (err))
  39. /* To be used only when the state is known to be valid */
  40. /* common constants */
  41. #ifndef DEF_WBITS
  42. # define DEF_WBITS MAX_WBITS
  43. #endif
  44. /* default windowBits for decompression. MAX_WBITS is for compression only */
  45. #if MAX_MEM_LEVEL >= 8
  46. # define DEF_MEM_LEVEL 8
  47. #else
  48. # define DEF_MEM_LEVEL MAX_MEM_LEVEL
  49. #endif
  50. /* default memLevel */
  51. #define STORED_BLOCK 0
  52. #define STATIC_TREES 1
  53. #define DYN_TREES 2
  54. /* The three kinds of block type */
  55. #define MIN_MATCH 3
  56. #define MAX_MATCH 258
  57. /* The minimum and maximum match lengths */
  58. #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
  59. /* target dependencies */
  60. #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
  61. # define OS_CODE 0x00
  62. # if defined(__TURBOC__) || defined(__BORLANDC__)
  63. # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
  64. /* Allow compilation with ANSI keywords only enabled */
  65. void _Cdecl farfree( void *block );
  66. void *_Cdecl farmalloc( unsigned long nbytes );
  67. # else
  68. # include <alloc.h>
  69. # endif
  70. # else /* MSC or DJGPP */
  71. # include <malloc.h>
  72. # endif
  73. #endif
  74. #ifdef AMIGA
  75. # define OS_CODE 0x01
  76. #endif
  77. #if defined(VAXC) || defined(VMS)
  78. # define OS_CODE 0x02
  79. # define F_OPEN(name, mode) \
  80. fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
  81. #endif
  82. #if defined(ATARI) || defined(atarist)
  83. # define OS_CODE 0x05
  84. #endif
  85. #ifdef OS2
  86. # define OS_CODE 0x06
  87. # ifdef M_I86
  88. # include <malloc.h>
  89. # endif
  90. #endif
  91. #if defined(MACOS) || defined(TARGET_OS_MAC)
  92. # define OS_CODE 0x07
  93. # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
  94. # include <unix.h> /* for fdopen */
  95. # else
  96. # ifndef fdopen
  97. # define fdopen(fd,mode) NULL /* No fdopen() */
  98. # endif
  99. # endif
  100. #endif
  101. #ifdef TOPS20
  102. # define OS_CODE 0x0a
  103. #endif
  104. #ifdef WIN32
  105. # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
  106. # define OS_CODE 0x0b
  107. # endif
  108. #endif
  109. #ifdef __50SERIES /* Prime/PRIMOS */
  110. # define OS_CODE 0x0f
  111. #endif
  112. #if defined(_BEOS_) || defined(RISCOS)
  113. # define fdopen(fd,mode) NULL /* No fdopen() */
  114. #endif
  115. #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
  116. # if defined(_WIN32_WCE)
  117. # define fdopen(fd,mode) NULL /* No fdopen() */
  118. # ifndef _PTRDIFF_T_DEFINED
  119. typedef int ptrdiff_t;
  120. # define _PTRDIFF_T_DEFINED
  121. # endif
  122. # else
  123. # define fdopen(fd,type) _fdopen(fd,type)
  124. # endif
  125. #endif
  126. #if defined(__BORLANDC__)
  127. #pragma warn -8004
  128. #pragma warn -8008
  129. #pragma warn -8066
  130. #endif
  131. /* provide prototypes for these when building zlib without LFS */
  132. #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
  133. ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
  134. ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
  135. #endif
  136. /* common defaults */
  137. #ifndef OS_CODE
  138. # define OS_CODE 0x03 /* assume Unix */
  139. #endif
  140. #ifndef F_OPEN
  141. # define F_OPEN(name, mode) fopen((name), (mode))
  142. #endif
  143. /* functions */
  144. #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
  145. # ifndef HAVE_VSNPRINTF
  146. # define HAVE_VSNPRINTF
  147. # endif
  148. #endif
  149. #if defined(__CYGWIN__)
  150. # ifndef HAVE_VSNPRINTF
  151. # define HAVE_VSNPRINTF
  152. # endif
  153. #endif
  154. #ifndef HAVE_VSNPRINTF
  155. # ifdef MSDOS
  156. /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
  157. but for now we just assume it doesn't. */
  158. # define NO_vsnprintf
  159. # endif
  160. # ifdef __TURBOC__
  161. # define NO_vsnprintf
  162. # endif
  163. # ifdef WIN32
  164. /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
  165. # if !defined(vsnprintf) && !defined(NO_vsnprintf)
  166. # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
  167. # define vsnprintf _vsnprintf
  168. # endif
  169. # endif
  170. # endif
  171. # ifdef __SASC
  172. # define NO_vsnprintf
  173. # endif
  174. #endif
  175. #ifdef VMS
  176. # define NO_vsnprintf
  177. #endif
  178. #if defined(pyr)
  179. # define NO_MEMCPY
  180. #endif
  181. #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
  182. /* Use our own functions for small and medium model with MSC <= 5.0.
  183. * You may have to use the same strategy for Borland C (untested).
  184. * The __SC__ check is for Symantec.
  185. */
  186. # define NO_MEMCPY
  187. #endif
  188. #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
  189. # define HAVE_MEMCPY
  190. #endif
  191. #ifdef HAVE_MEMCPY
  192. # ifdef SMALL_MEDIUM /* MSDOS small or medium model */
  193. # define zmemcpy _fmemcpy
  194. # define zmemcmp _fmemcmp
  195. # define zmemzero(dest, len) _fmemset(dest, 0, len)
  196. # else
  197. # define zmemcpy memcpy
  198. # define zmemcmp memcmp
  199. # define zmemzero(dest, len) memset(dest, 0, len)
  200. # endif
  201. #else
  202. void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
  203. int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
  204. void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
  205. #endif
  206. /* Diagnostic functions */
  207. #ifdef DEBUG
  208. # include <stdio.h>
  209. extern int ZLIB_INTERNAL z_verbose;
  210. extern void ZLIB_INTERNAL z_error OF((char *m));
  211. # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
  212. # define Trace(x) {if (z_verbose>=0) fprintf x ;}
  213. # define Tracev(x) {if (z_verbose>0) fprintf x ;}
  214. # define Tracevv(x) {if (z_verbose>1) fprintf x ;}
  215. # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
  216. # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
  217. #else
  218. # define Assert(cond,msg)
  219. # define Trace(x)
  220. # define Tracev(x)
  221. # define Tracevv(x)
  222. # define Tracec(c,x)
  223. # define Tracecv(c,x)
  224. #endif
  225. voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
  226. unsigned size));
  227. void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
  228. #define ZALLOC(strm, items, size) \
  229. (*((strm)->zalloc))((strm)->opaque, (items), (size))
  230. #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  231. #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
  232. #endif /* ZUTIL_H */