source: SVN/cambria/redboot/packages/services/compress/zlib/current/src/zutil.h @ 1

Last change on this file since 1 was 1, checked in by Tim Harvey, 2 years ago

restored latest version of files from server backup

Signed-off-by: Tim Harvey <tharvey@…>

File size: 6.5 KB
Line 
1/* zutil.h -- internal interface and configuration of the compression library
2 * Copyright (C) 1995-2003 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$ */
12
13#ifndef ZUTIL_H
14#define ZUTIL_H
15
16#define ZLIB_INTERNAL
17#ifdef __ECOS__
18#include <cyg/compress/zlib.h>
19#include <cyg/crc/crc.h>
20#undef  crc32
21#define crc32 cyg_ether_crc32_accumulate
22#else
23#include "zlib.h"
24#endif // __ECOS__
25
26#ifdef STDC
27#  include <stddef.h>
28#  include <string.h>
29#  include <stdlib.h>
30#endif
31#ifdef NO_ERRNO_H
32    extern int errno;
33#else
34#   include <errno.h>
35#endif
36
37#ifndef local
38#  define local static
39#endif
40/* compile with -Dlocal if your debugger can't find static symbols */
41
42typedef unsigned char  uch;
43typedef uch FAR uchf;
44typedef unsigned short ush;
45typedef ush FAR ushf;
46typedef unsigned long  ulg;
47
48extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
49/* (size given to avoid silly warnings with Visual C++) */
50
51#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
52
53#define ERR_RETURN(strm,err) \
54  return (strm->msg = (char*)ERR_MSG(err), (err))
55/* To be used only when the state is known to be valid */
56
57        /* common constants */
58
59#ifndef DEF_WBITS
60#  define DEF_WBITS MAX_WBITS
61#endif
62/* default windowBits for decompression. MAX_WBITS is for compression only */
63
64#if MAX_MEM_LEVEL >= 8
65#  define DEF_MEM_LEVEL 8
66#else
67#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
68#endif
69/* default memLevel */
70
71#define STORED_BLOCK 0
72#define STATIC_TREES 1
73#define DYN_TREES    2
74/* The three kinds of block type */
75
76#define MIN_MATCH  3
77#define MAX_MATCH  258
78/* The minimum and maximum match lengths */
79
80#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
81
82        /* target dependencies */
83
84#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
85#  define OS_CODE  0x00
86#  if defined(__TURBOC__) || defined(__BORLANDC__)
87#    if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
88       /* Allow compilation with ANSI keywords only enabled */
89       void _Cdecl farfree( void *block );
90       void *_Cdecl farmalloc( unsigned long nbytes );
91#    else
92#      include <alloc.h>
93#    endif
94#  else /* MSC or DJGPP */
95#    include <malloc.h>
96#  endif
97#endif
98
99#ifdef AMIGA
100#  define OS_CODE  0x01
101#endif
102
103#if defined(VAXC) || defined(VMS)
104#  define OS_CODE  0x02
105#  define F_OPEN(name, mode) \
106     fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
107#endif
108
109#if defined(ATARI) || defined(atarist)
110#  define OS_CODE  0x05
111#endif
112
113#ifdef OS2
114#  define OS_CODE  0x06
115#endif
116
117#if defined(MACOS) || defined(TARGET_OS_MAC)
118#  define OS_CODE  0x07
119#  if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
120#    include <unix.h> /* for fdopen */
121#  else
122#    ifndef fdopen
123#      define fdopen(fd,mode) NULL /* No fdopen() */
124#    endif
125#  endif
126#endif
127
128#ifdef TOPS20
129#  define OS_CODE  0x0a
130#endif
131
132#ifdef WIN32
133#  ifndef __CYGWIN__  /* Cygwin is Unix, not Win32 */
134#    define OS_CODE  0x0b
135#  endif
136#endif
137
138#ifdef __50SERIES /* Prime/PRIMOS */
139#  define OS_CODE  0x0f
140#endif
141
142#if defined(_BEOS_) || defined(RISCOS)
143#  define fdopen(fd,mode) NULL /* No fdopen() */
144#endif
145
146#if (defined(_MSC_VER) && (_MSC_VER > 600))
147#  if defined(_WIN32_WCE)
148#    define fdopen(fd,mode) NULL /* No fdopen() */
149#    ifndef _PTRDIFF_T_DEFINED
150       typedef int ptrdiff_t;
151#      define _PTRDIFF_T_DEFINED
152#    endif
153#  else
154#    define fdopen(fd,type)  _fdopen(fd,type)
155#  endif
156#endif
157
158        /* common defaults */
159
160#ifndef OS_CODE
161#  define OS_CODE  0x03  /* assume Unix */
162#endif
163
164#ifndef F_OPEN
165#  define F_OPEN(name, mode) fopen((name), (mode))
166#endif
167
168         /* functions */
169
170#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
171#  ifndef HAVE_VSNPRINTF
172#    define HAVE_VSNPRINTF
173#  endif
174#endif
175#if defined(__CYGWIN__)
176#  ifndef HAVE_VSNPRINTF
177#    define HAVE_VSNPRINTF
178#  endif
179#endif
180#ifndef HAVE_VSNPRINTF
181#  ifdef MSDOS
182     /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
183        but for now we just assume it doesn't. */
184#    define NO_vsnprintf
185#  endif
186#  ifdef __TURBOC__
187#    define NO_vsnprintf
188#  endif
189#  ifdef WIN32
190     /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
191#    if !defined(vsnprintf) && !defined(NO_vsnprintf)
192#      define vsnprintf _vsnprintf
193#    endif
194#  endif
195#  ifdef __SASC
196#    define NO_vsnprintf
197#  endif
198#endif
199
200#ifdef HAVE_STRERROR
201   extern char *strerror OF((int));
202#  define zstrerror(errnum) strerror(errnum)
203#else
204#  define zstrerror(errnum) ""
205#endif
206
207#if defined(pyr)
208#  define NO_MEMCPY
209#endif
210#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
211 /* Use our own functions for small and medium model with MSC <= 5.0.
212  * You may have to use the same strategy for Borland C (untested).
213  * The __SC__ check is for Symantec.
214  */
215#  define NO_MEMCPY
216#endif
217#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
218#  define HAVE_MEMCPY
219#endif
220#ifdef HAVE_MEMCPY
221#  ifdef SMALL_MEDIUM /* MSDOS small or medium model */
222#    define zmemcpy _fmemcpy
223#    define zmemcmp _fmemcmp
224#    define zmemzero(dest, len) _fmemset(dest, 0, len)
225#  else
226#    define zmemcpy memcpy
227#    define zmemcmp memcmp
228#    define zmemzero(dest, len) memset(dest, 0, len)
229#  endif
230#else
231   extern void zmemcpy  OF((Bytef* dest, const Bytef* source, uInt len));
232   extern int  zmemcmp  OF((const Bytef* s1, const Bytef* s2, uInt len));
233   extern void zmemzero OF((Bytef* dest, uInt len));
234#endif
235
236/* Diagnostic functions */
237#ifdef DEBUG
238#  include <stdio.h>
239   extern int z_verbose;
240   extern void z_error    OF((char *m));
241#  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
242#  define Trace(x) {if (z_verbose>=0) fprintf x ;}
243#  define Tracev(x) {if (z_verbose>0) fprintf x ;}
244#  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
245#  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
246#  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
247#else
248#  define Assert(cond,msg)
249#  define Trace(x)
250#  define Tracev(x)
251#  define Tracevv(x)
252#  define Tracec(c,x)
253#  define Tracecv(c,x)
254#endif
255
256
257voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
258void   zcfree  OF((voidpf opaque, voidpf ptr));
259
260#define ZALLOC(strm, items, size) \
261           (*((strm)->zalloc))((strm)->opaque, (items), (size))
262#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
263#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
264
265#endif /* ZUTIL_H */
Note: See TracBrowser for help on using the repository browser.