ZUTIL.H
Upload User: wep9318
Upload Date: 2007-01-07
Package Size: 893k
Code Size: 5k
Category:

Picture Viewer

Development Platform:

Visual C++

  1. /* zutil.h -- internal interface and configuration of the compression library
  2.  * Copyright (C) 1995-1996 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: zutil.h,v 1.16 1996/07/24 13:41:13 me Exp $ */
  10. #ifndef _Z_UTIL_H
  11. #define _Z_UTIL_H
  12. #include "zlib.h"
  13. #if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS)
  14. #   include <stddef.h>
  15. #   include <errno.h>
  16. #else
  17.     extern int errno;
  18. #endif
  19. #ifdef STDC
  20. #  include <string.h>
  21. #  include <stdlib.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. extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
  33. /* (size given to avoid silly warnings with Visual C++) */
  34. #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
  35. #define ERR_RETURN(strm,err) 
  36.   return (strm->msg = (char*)ERR_MSG(err), (err))
  37. /* To be used only when the state is known to be valid */
  38.         /* common constants */
  39. #ifndef DEF_WBITS
  40. #  define DEF_WBITS MAX_WBITS
  41. #endif
  42. /* default windowBits for decompression. MAX_WBITS is for compression only */
  43. #if MAX_MEM_LEVEL >= 8
  44. #  define DEF_MEM_LEVEL 8
  45. #else
  46. #  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
  47. #endif
  48. /* default memLevel */
  49. #define STORED_BLOCK 0
  50. #define STATIC_TREES 1
  51. #define DYN_TREES    2
  52. /* The three kinds of block type */
  53. #define MIN_MATCH  3
  54. #define MAX_MATCH  258
  55. /* The minimum and maximum match lengths */
  56. #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
  57.         /* target dependencies */
  58. #ifdef MSDOS
  59. #  define OS_CODE  0x00
  60. #  ifdef __TURBOC__
  61. #    include <alloc.h>
  62. #  else /* MSC or DJGPP */
  63. #    include <malloc.h>
  64. #  endif
  65. #endif
  66. #ifdef OS2
  67. #  define OS_CODE  0x06
  68. #endif
  69. #ifdef WIN32 /* Window 95 & Windows NT */
  70. #  define OS_CODE  0x0b
  71. #endif
  72. #if defined(VAXC) || defined(VMS)
  73. #  define OS_CODE  0x02
  74. #  define FOPEN(name, mode) 
  75.      fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
  76. #endif
  77. #ifdef AMIGA
  78. #  define OS_CODE  0x01
  79. #endif
  80. #if defined(ATARI) || defined(atarist)
  81. #  define OS_CODE  0x05
  82. #endif
  83. #ifdef MACOS
  84. #  define OS_CODE  0x07
  85. #endif
  86. #ifdef __50SERIES /* Prime/PRIMOS */
  87. #  define OS_CODE  0x0F
  88. #endif
  89. #ifdef TOPS20
  90. #  define OS_CODE  0x0a
  91. #endif
  92. #if defined(_BEOS_) || defined(RISCOS)
  93. #  define fdopen(fd,mode) NULL /* No fdopen() */
  94. #endif
  95.         /* Common defaults */
  96. #ifndef OS_CODE
  97. #  define OS_CODE  0x03  /* assume Unix */
  98. #endif
  99. #ifndef FOPEN
  100. #  define FOPEN(name, mode) fopen((name), (mode))
  101. #endif
  102.          /* functions */
  103. #ifdef HAVE_STRERROR
  104.    extern char *strerror OF((int));
  105. #  define zstrerror(errnum) strerror(errnum)
  106. #else
  107. #  define zstrerror(errnum) ""
  108. #endif
  109. #if defined(pyr)
  110. #  define NO_MEMCPY
  111. #endif
  112. #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER)
  113.  /* Use our own functions for small and medium model with MSC <= 5.0.
  114.   * You may have to use the same strategy for Borland C (untested).
  115.   */
  116. #  define NO_MEMCPY
  117. #endif
  118. #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
  119. #  define HAVE_MEMCPY
  120. #endif
  121. #ifdef HAVE_MEMCPY
  122. #  ifdef SMALL_MEDIUM /* MSDOS small or medium model */
  123. #    define zmemcpy _fmemcpy
  124. #    define zmemcmp _fmemcmp
  125. #    define zmemzero(dest, len) _fmemset(dest, 0, len)
  126. #  else
  127. #    define zmemcpy memcpy
  128. #    define zmemcmp memcmp
  129. #    define zmemzero(dest, len) memset(dest, 0, len)
  130. #  endif
  131. #else
  132.    extern void zmemcpy  OF((Bytef* dest, Bytef* source, uInt len));
  133.    extern int  zmemcmp  OF((Bytef* s1,   Bytef* s2, uInt len));
  134.    extern void zmemzero OF((Bytef* dest, uInt len));
  135. #endif
  136. /* Diagnostic functions */
  137. #ifdef DEBUG
  138. #  include <stdio.h>
  139. #  ifndef verbose
  140. #    define verbose 0
  141. #  endif
  142.    extern void z_error    OF((char *m));
  143. #  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
  144. #  define Trace(x) fprintf x
  145. #  define Tracev(x) {if (verbose) fprintf x ;}
  146. #  define Tracevv(x) {if (verbose>1) fprintf x ;}
  147. #  define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
  148. #  define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
  149. #else
  150. #  define Assert(cond,msg)
  151. #  define Trace(x)
  152. #  define Tracev(x)
  153. #  define Tracevv(x)
  154. #  define Tracec(c,x)
  155. #  define Tracecv(c,x)
  156. #endif
  157. typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len));
  158. voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
  159. void   zcfree  OF((voidpf opaque, voidpf ptr));
  160. #define ZALLOC(strm, items, size) 
  161.            (*((strm)->zalloc))((strm)->opaque, (items), (size))
  162. #define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  163. #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
  164. #endif /* _Z_UTIL_H */