zutil.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* zutil.h -- internal interface and configuration of the compression library
  2. * Copyright (C) 1995-2005 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. #define ZLIB_INTERNAL
  13. #include "zlib.h"
  14. #ifdef STDC
  15. # ifndef _WIN32_WCE
  16. # include <stddef.h>
  17. # endif
  18. # include <string.h>
  19. # include <stdlib.h>
  20. #endif
  21. #ifdef NO_ERRNO_H
  22. # ifdef _WIN32_WCE
  23. /* The Microsoft C Run-Time Library for Windows CE doesn't have
  24. * errno. We define it as a global variable to simplify porting.
  25. * Its value is always 0 and should not be used. We rename it to
  26. * avoid conflict with other libraries that use the same workaround.
  27. */
  28. # define errno z_errno
  29. # endif
  30. extern int errno;
  31. #else
  32. # ifndef _WIN32_WCE
  33. # include <errno.h>
  34. # endif
  35. #endif
  36. #ifndef local
  37. # define local static
  38. #endif
  39. /* compile with -Dlocal if your debugger can't find static symbols */
  40. typedef unsigned char uch;
  41. typedef uch FAR uchf;
  42. typedef unsigned short ush;
  43. typedef ush FAR ushf;
  44. typedef unsigned long ulg;
  45. extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
  46. /* (size given to avoid silly warnings with Visual C++) */
  47. #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
  48. #define ERR_RETURN(strm,err) \
  49. return (strm->msg = (char*)ERR_MSG(err), (err))
  50. /* To be used only when the state is known to be valid */
  51. /* common constants */
  52. #ifndef DEF_WBITS
  53. # define DEF_WBITS MAX_WBITS
  54. #endif
  55. /* default windowBits for decompression. MAX_WBITS is for compression only */
  56. #if MAX_MEM_LEVEL >= 8
  57. # define DEF_MEM_LEVEL 8
  58. #else
  59. # define DEF_MEM_LEVEL MAX_MEM_LEVEL
  60. #endif
  61. /* default memLevel */
  62. #define STORED_BLOCK 0
  63. #define STATIC_TREES 1
  64. #define DYN_TREES 2
  65. /* The three kinds of block type */
  66. #define MIN_MATCH 3
  67. #define MAX_MATCH 258
  68. /* The minimum and maximum match lengths */
  69. /* functions */
  70. #ifdef CONFIG_GZIP_COMPRESSED
  71. #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
  72. # define OS_CODE 0x03 /* assume Unix */
  73. #endif
  74. #include <linux/string.h>
  75. #define zmemcpy memcpy
  76. #define zmemcmp memcmp
  77. #define zmemzero(dest, len) memset(dest, 0, len)
  78. /* Diagnostic functions */
  79. #ifdef DEBUG
  80. /* Not valid for U-Boot
  81. # include <stdio.h> */
  82. extern int z_verbose;
  83. extern void z_error OF((char *m));
  84. # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
  85. # define Trace(x) {if (z_verbose>=0) fprintf x ;}
  86. # define Tracev(x) {if (z_verbose>0) fprintf x ;}
  87. # define Tracevv(x) {if (z_verbose>1) fprintf x ;}
  88. # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
  89. # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
  90. #else
  91. # define Assert(cond,msg)
  92. # define Trace(x)
  93. # define Tracev(x)
  94. # define Tracevv(x)
  95. # define Tracec(c,x)
  96. # define Tracecv(c,x)
  97. #endif
  98. voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
  99. void zcfree OF((voidpf opaque, voidpf ptr, unsigned size));
  100. #define ZALLOC(strm, items, size) \
  101. (*((strm)->zalloc))((strm)->opaque, (items), (size))
  102. #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr), 0)
  103. #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
  104. #endif /* ZUTIL_H */