Zutil.h
上传用户:sz83729876
上传日期:2013-03-07
资源大小:4140k
文件大小:6k
源码类别:

OpenGL

开发平台:

Windows_Unix

  1. /* zutil.h -- internal interface and configuration of the compression library
  2.  * Copyright (C) 1995-1998 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. #ifndef _Z_UTIL_H
  10. #define _Z_UTIL_H
  11. #include "zlib.h"
  12. #ifdef STDC
  13. #  include <stddef.h>
  14. #  include <string.h>
  15. #  include <stdlib.h>
  16. #endif
  17. #ifdef NO_ERRNO_H
  18.     extern int errno;
  19. #else
  20. #   include <errno.h>
  21. #endif
  22. #ifndef local
  23. #  define local static
  24. #endif
  25. /* compile with -Dlocal if your debugger can't find static symbols */
  26. typedef unsigned char  uch;
  27. typedef uch FAR uchf;
  28. typedef unsigned short ush;
  29. typedef ush FAR ushf;
  30. typedef unsigned long  ulg;
  31. extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
  32. /* (size given to avoid silly warnings with Visual C++) */
  33. #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
  34. #define ERR_RETURN(strm,err) 
  35.   return (strm->msg = (char*)ERR_MSG(err), (err))
  36. /* To be used only when the state is known to be valid */
  37.         /* common constants */
  38. #ifndef DEF_WBITS
  39. #  define DEF_WBITS MAX_WBITS
  40. #endif
  41. /* default windowBits for decompression. MAX_WBITS is for compression only */
  42. #if MAX_MEM_LEVEL >= 8
  43. #  define DEF_MEM_LEVEL 8
  44. #else
  45. #  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
  46. #endif
  47. /* default memLevel */
  48. #define STORED_BLOCK 0
  49. #define STATIC_TREES 1
  50. #define DYN_TREES    2
  51. /* The three kinds of block type */
  52. #define MIN_MATCH  3
  53. #define MAX_MATCH  258
  54. /* The minimum and maximum match lengths */
  55. #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
  56.         /* target dependencies */
  57. #ifdef MSDOS
  58. #  define OS_CODE  0x00
  59. #  if defined(__TURBOC__) || defined(__BORLANDC__)
  60. #    if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
  61.        /* Allow compilation with ANSI keywords only enabled */
  62.        void _Cdecl farfree( void *block );
  63.        void *_Cdecl farmalloc( unsigned long nbytes );
  64. #    else
  65. #     include <alloc.h>
  66. #    endif
  67. #  else /* MSC or DJGPP */
  68. #    include <malloc.h>
  69. #  endif
  70. #endif
  71. #ifdef OS2
  72. #  define OS_CODE  0x06
  73. #endif
  74. #ifdef WIN32 /* Window 95 & Windows NT */
  75. #  define OS_CODE  0x0b
  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. #ifdef AMIGA
  83. #  define OS_CODE  0x01
  84. #endif
  85. #if defined(ATARI) || defined(atarist)
  86. #  define OS_CODE  0x05
  87. #endif
  88. #if defined(MACOS) || defined(TARGET_OS_MAC)
  89. #  define OS_CODE  0x07
  90. #  if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
  91. #    include <unix.h> /* for fdopen */
  92. #  else
  93. #    ifndef fdopen
  94. #      define fdopen(fd,mode) NULL /* No fdopen() */
  95. #    endif
  96. #  endif
  97. #endif
  98. #ifdef __50SERIES /* Prime/PRIMOS */
  99. #  define OS_CODE  0x0F
  100. #endif
  101. #ifdef TOPS20
  102. #  define OS_CODE  0x0a
  103. #endif
  104. #if defined(_BEOS_) || defined(RISCOS)
  105. #  define fdopen(fd,mode) NULL /* No fdopen() */
  106. #endif
  107. #if (defined(_MSC_VER) && (_MSC_VER > 600))
  108. #  define fdopen(fd,type)  _fdopen(fd,type)
  109. #endif
  110.         /* Common defaults */
  111. #ifndef OS_CODE
  112. #  define OS_CODE  0x03  /* assume Unix */
  113. #endif
  114. #ifndef F_OPEN
  115. #  define F_OPEN(name, mode) fopen((name), (mode))
  116. #endif
  117.          /* functions */
  118. #ifdef HAVE_STRERROR
  119.    extern char *strerror OF((int));
  120. #  define zstrerror(errnum) strerror(errnum)
  121. #else
  122. #  define zstrerror(errnum) ""
  123. #endif
  124. #if defined(pyr)
  125. #  define NO_MEMCPY
  126. #endif
  127. #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
  128.  /* Use our own functions for small and medium model with MSC <= 5.0.
  129.   * You may have to use the same strategy for Borland C (untested).
  130.   * The __SC__ check is for Symantec.
  131.   */
  132. #  define NO_MEMCPY
  133. #endif
  134. #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
  135. #  define HAVE_MEMCPY
  136. #endif
  137. #ifdef HAVE_MEMCPY
  138. #  ifdef SMALL_MEDIUM /* MSDOS small or medium model */
  139. #    define zmemcpy _fmemcpy
  140. #    define zmemcmp _fmemcmp
  141. #    define zmemzero(dest, len) _fmemset(dest, 0, len)
  142. #  else
  143. #    define zmemcpy memcpy
  144. #    define zmemcmp memcmp
  145. #    define zmemzero(dest, len) memset(dest, 0, len)
  146. #  endif
  147. #else
  148.    extern void zmemcpy  OF((Bytef* dest, const Bytef* source, uInt len));
  149.    extern int  zmemcmp  OF((const Bytef* s1, const Bytef* s2, uInt len));
  150.    extern void zmemzero OF((Bytef* dest, uInt len));
  151. #endif
  152. /* Diagnostic functions */
  153. #ifdef DEBUG
  154. #  include <stdio.h>
  155.    extern int z_verbose;
  156.    extern void z_error    OF((char *m));
  157. #  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
  158. #  define Trace(x) {if (z_verbose>=0) fprintf x ;}
  159. #  define Tracev(x) {if (z_verbose>0) fprintf x ;}
  160. #  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
  161. #  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
  162. #  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
  163. #else
  164. #  define Assert(cond,msg)
  165. #  define Trace(x)
  166. #  define Tracev(x)
  167. #  define Tracevv(x)
  168. #  define Tracec(c,x)
  169. #  define Tracecv(c,x)
  170. #endif
  171. typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
  172.        uInt len));
  173. voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
  174. void   zcfree  OF((voidpf opaque, voidpf ptr));
  175. #define ZALLOC(strm, items, size) 
  176.            (*((strm)->zalloc))((strm)->opaque, (items), (size))
  177. #define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  178. #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
  179. #endif /* _Z_UTIL_H */