home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / DOS / Programa / ZLIB095.ZIP / ZUTIL.H < prev   
Encoding:
C/C++ Source or Header  |  1995-08-13  |  4.6 KB  |  193 lines

  1. /* zutil.h -- internal interface and configuration of the compression library
  2.  * Copyright (C) 1995 Jean-loup Gailly.
  3.  * For conditions of distribution and use, see copyright notice in zlib.h
  4.  */
  5.  
  6. /* WARNING: this file should *not* be used by applications. It is
  7.    part of the implementation of the compression library and is
  8.    subject to change. Applications should only use zlib.h.
  9.  */
  10.  
  11. /* $Id: zutil.h,v 1.9 1995/05/03 17:27:12 jloup Exp $ */
  12.  
  13. #ifndef _Z_UTIL_H
  14. #define _Z_UTIL_H
  15.  
  16. #include "zlib.h"
  17.  
  18. #if defined(MSDOS) || defined(VMS)
  19. #   include <stddef.h>
  20. #   include <errno.h>
  21. #else
  22.     extern int errno;
  23. #endif
  24. #ifdef STDC
  25. #  include <string.h>
  26. #endif
  27.  
  28. #ifndef local
  29. #  define local static
  30. #endif
  31. /* compile with -Dlocal if your debugger can't find static symbols */
  32.  
  33. typedef unsigned char  uch;
  34. typedef uch FAR uchf;
  35. typedef unsigned short ush;
  36. typedef ush FAR ushf;
  37. typedef unsigned long  ulg;
  38.  
  39. extern char *z_errmsg[]; /* indexed by 1-zlib_error */
  40.  
  41. #define ERR_RETURN(strm,err) return (strm->msg=z_errmsg[1-err], err)
  42. /* To be used only when the state is known to be valid */
  43.  
  44.         /* common constants */
  45.  
  46. #define DEFLATED   8
  47.  
  48. #ifndef DEF_WBITS
  49. #  define DEF_WBITS MAX_WBITS
  50. #endif
  51. /* default windowBits for decompression. MAX_WBITS is for compression only */
  52.  
  53. #if MAX_MEM_LEVEL >= 8
  54. #  define DEF_MEM_LEVEL 8
  55. #else
  56. #  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
  57. #endif
  58. /* default memLevel */
  59.  
  60. #define STORED_BLOCK 0
  61. #define STATIC_TREES 1
  62. #define DYN_TREES    2
  63. /* The three kinds of block type */
  64.  
  65. #define MIN_MATCH  3
  66. #define MAX_MATCH  258
  67. /* The minimum and maximum match lengths */
  68.  
  69.         /* target dependencies */
  70.  
  71. #ifdef MSDOS
  72. #  define OS_CODE  0x00
  73. #  ifdef __TURBOC__
  74. #    include <alloc.h>
  75. #  else /* MSC or DJGPP */
  76. #    include <malloc.h>
  77. #  endif
  78. #endif
  79.  
  80. #ifdef OS2
  81. #  define OS_CODE  0x06
  82. #endif
  83.  
  84. #ifdef WIN32 /* Windows NT */
  85. #  define OS_CODE  0x0b
  86. #endif
  87.  
  88. #if defined(VAXC) || defined(VMS)
  89. #  define OS_CODE  0x02
  90. #  define FOPEN(name, mode) \
  91.      fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
  92. #endif
  93.  
  94. #ifdef AMIGA
  95. #  define OS_CODE  0x01
  96. #endif
  97.  
  98. #if defined(ATARI) || defined(atarist)
  99. #  define OS_CODE  0x05
  100. #endif
  101.  
  102. #ifdef MACOS
  103. #  define OS_CODE  0x07
  104. #endif
  105.  
  106. #ifdef __50SERIES /* Prime/PRIMOS */
  107. #  define OS_CODE  0x0F
  108. #endif
  109.  
  110. #ifdef TOPS20
  111. #  define OS_CODE  0x0a
  112. #endif
  113.  
  114.         /* Common defaults */
  115.  
  116. #ifndef OS_CODE
  117. #  define OS_CODE  0x03  /* assume Unix */
  118. #endif
  119.  
  120. #ifndef FOPEN
  121. #  define FOPEN(name, mode) fopen((name), (mode))
  122. #endif
  123.  
  124.          /* functions */
  125.  
  126. #ifdef HAVE_STRERROR
  127.    extern char *strerror OF((int));
  128. #  define zstrerror(errnum) strerror(errnum)
  129. #else
  130. #  define zstrerror(errnum) ""
  131. #endif
  132.  
  133. #if defined(pyr)
  134. #  define NO_MEMCPY
  135. #endif
  136. #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(_MSC_VER)
  137.  /* Use our own functions for small and medium model with MSC <= 5.0.
  138.   * You may have to use the same strategy for Borland C (untested).
  139.   */
  140. #  define NO_MEMCPY
  141. #endif
  142. #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
  143. #  define HAVE_MEMCPY
  144. #endif
  145. #ifdef HAVE_MEMCPY
  146. #  if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */
  147. #    define zmemcpy _fmemcpy
  148. #    define zmemzero(dest, len) _fmemset(dest, 0, len)
  149. #  else
  150. #    define zmemcpy memcpy
  151. #    define zmemzero(dest, len) memset(dest, 0, len)
  152. #  endif
  153. #else
  154.    extern void zmemcpy  OF((Bytef* dest, Bytef* source, uInt len));
  155.    extern void zmemzero OF((Bytef* dest, uInt len));
  156. #endif
  157.  
  158. /* Diagnostic functions */
  159. #ifdef DEBUG
  160. #  include <stdio.h>
  161. #  ifndef verbose
  162. #    define verbose 0
  163. #  endif
  164. #  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
  165. #  define Trace(x) fprintf x
  166. #  define Tracev(x) {if (verbose) fprintf x ;}
  167. #  define Tracevv(x) {if (verbose>1) fprintf x ;}
  168. #  define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
  169. #  define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
  170. #else
  171. #  define Assert(cond,msg)
  172. #  define Trace(x)
  173. #  define Tracev(x)
  174. #  define Tracevv(x)
  175. #  define Tracec(c,x)
  176. #  define Tracecv(c,x)
  177. #endif
  178.  
  179.  
  180. typedef uLong (*check_func) OF((uLong check, Bytef *buf, uInt len));
  181.  
  182. extern void z_error    OF((char *m));
  183.  
  184. voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
  185. void   zcfree  OF((voidpf opaque, voidpf ptr));
  186.  
  187. #define ZALLOC(strm, items, size) \
  188.            (*((strm)->zalloc))((strm)->opaque, (items), (size))
  189. #define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
  190. #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
  191.  
  192. #endif /* _Z_UTIL_H */
  193.