/modules/freetype2/src/gzip/zutil.h

http://github.com/zpao/v8monkey · C Header · 215 lines · 151 code · 39 blank · 25 comment · 23 complexity · 0d77f751c819cb6415e0c001ef2eb25c MD5 · raw file

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