sl@0
|
1 |
/* zutil.h -- internal interface and configuration of the compression library
|
sl@0
|
2 |
* Copyright (C) 1995-1998 Jean-loup Gailly.
|
sl@0
|
3 |
* For conditions of distribution and use, see copyright notice in zlib.h
|
sl@0
|
4 |
*/
|
sl@0
|
5 |
|
sl@0
|
6 |
/* WARNING: this file should *not* be used by applications. It is
|
sl@0
|
7 |
part of the implementation of the compression library and is
|
sl@0
|
8 |
subject to change. Applications should only use zlib.h.
|
sl@0
|
9 |
*/
|
sl@0
|
10 |
|
sl@0
|
11 |
/* @(#) $Id$ */
|
sl@0
|
12 |
|
sl@0
|
13 |
#ifndef _Z_UTIL_H
|
sl@0
|
14 |
#define _Z_UTIL_H
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <e32std.h>
|
sl@0
|
17 |
#include "OldEZlib.h"
|
sl@0
|
18 |
|
sl@0
|
19 |
/*
|
sl@0
|
20 |
#ifdef STDC
|
sl@0
|
21 |
# include <stddef.h>
|
sl@0
|
22 |
# include <string.h>
|
sl@0
|
23 |
# include <stdlib.h>
|
sl@0
|
24 |
#endif
|
sl@0
|
25 |
#ifdef NO_ERRNO_H
|
sl@0
|
26 |
extern int errno;
|
sl@0
|
27 |
#else
|
sl@0
|
28 |
# include <errno.h>
|
sl@0
|
29 |
#endif
|
sl@0
|
30 |
*/
|
sl@0
|
31 |
|
sl@0
|
32 |
#ifndef local
|
sl@0
|
33 |
# define local static
|
sl@0
|
34 |
#endif
|
sl@0
|
35 |
/* compile with -Dlocal if your debugger can't find static symbols */
|
sl@0
|
36 |
|
sl@0
|
37 |
typedef unsigned char uch;
|
sl@0
|
38 |
typedef uch FAR uchf;
|
sl@0
|
39 |
typedef unsigned short ush;
|
sl@0
|
40 |
typedef ush FAR ushf;
|
sl@0
|
41 |
typedef unsigned long ulg;
|
sl@0
|
42 |
|
sl@0
|
43 |
extern const char *const z_errmsg[10]; /* indexed by 2-zlib_error */
|
sl@0
|
44 |
/* (size given to avoid silly warnings with Visual C++) */
|
sl@0
|
45 |
|
sl@0
|
46 |
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
sl@0
|
47 |
|
sl@0
|
48 |
#define ERR_RETURN(strm,err) \
|
sl@0
|
49 |
return (strm->msg = (char*)ERR_MSG(err), (err))
|
sl@0
|
50 |
/* To be used only when the state is known to be valid */
|
sl@0
|
51 |
|
sl@0
|
52 |
/* common constants */
|
sl@0
|
53 |
|
sl@0
|
54 |
#ifndef DEF_WBITS
|
sl@0
|
55 |
# define DEF_WBITS MAX_WBITS
|
sl@0
|
56 |
#endif
|
sl@0
|
57 |
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
sl@0
|
58 |
|
sl@0
|
59 |
#if MAX_MEM_LEVEL >= 8
|
sl@0
|
60 |
# define DEF_MEM_LEVEL 8
|
sl@0
|
61 |
#else
|
sl@0
|
62 |
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
sl@0
|
63 |
#endif
|
sl@0
|
64 |
/* default memLevel */
|
sl@0
|
65 |
|
sl@0
|
66 |
#define STORED_BLOCK 0
|
sl@0
|
67 |
#define STATIC_TREES 1
|
sl@0
|
68 |
#define DYN_TREES 2
|
sl@0
|
69 |
/* The three kinds of block type */
|
sl@0
|
70 |
|
sl@0
|
71 |
#define MIN_MATCH 3
|
sl@0
|
72 |
#define MAX_MATCH 258
|
sl@0
|
73 |
/* The minimum and maximum match lengths */
|
sl@0
|
74 |
|
sl@0
|
75 |
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
sl@0
|
76 |
|
sl@0
|
77 |
/* target dependencies */
|
sl@0
|
78 |
|
sl@0
|
79 |
|
sl@0
|
80 |
|
sl@0
|
81 |
//#ifdef MSDOS
|
sl@0
|
82 |
//# define OS_CODE 0x00
|
sl@0
|
83 |
//# if defined(__TURBOC__) || defined(__BORLANDC__)
|
sl@0
|
84 |
//# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
sl@0
|
85 |
/* Allow compilation with ANSI keywords only enabled */
|
sl@0
|
86 |
// void _Cdecl farfree( void *block );
|
sl@0
|
87 |
// void *_Cdecl farmalloc( unsigned long nbytes );
|
sl@0
|
88 |
//# else
|
sl@0
|
89 |
//# include <alloc.h>
|
sl@0
|
90 |
//# endif
|
sl@0
|
91 |
//# else /* MSC or DJGPP */
|
sl@0
|
92 |
//# include <malloc.h>
|
sl@0
|
93 |
//# endif
|
sl@0
|
94 |
//#endif
|
sl@0
|
95 |
|
sl@0
|
96 |
#ifdef OS2
|
sl@0
|
97 |
# define OS_CODE 0x06
|
sl@0
|
98 |
#endif
|
sl@0
|
99 |
|
sl@0
|
100 |
#ifdef WIN32 /* Window 95 & Windows NT */
|
sl@0
|
101 |
# define OS_CODE 0x0b
|
sl@0
|
102 |
#endif
|
sl@0
|
103 |
|
sl@0
|
104 |
#if defined(VAXC) || defined(VMS)
|
sl@0
|
105 |
# define OS_CODE 0x02
|
sl@0
|
106 |
# define F_OPEN(name, mode) \
|
sl@0
|
107 |
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
sl@0
|
108 |
#endif
|
sl@0
|
109 |
|
sl@0
|
110 |
#ifdef AMIGA
|
sl@0
|
111 |
# define OS_CODE 0x01
|
sl@0
|
112 |
#endif
|
sl@0
|
113 |
|
sl@0
|
114 |
#if defined(ATARI) || defined(atarist)
|
sl@0
|
115 |
# define OS_CODE 0x05
|
sl@0
|
116 |
#endif
|
sl@0
|
117 |
|
sl@0
|
118 |
//#if defined(MACOS) || defined(TARGET_OS_MAC)
|
sl@0
|
119 |
//# define OS_CODE 0x07
|
sl@0
|
120 |
//# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
sl@0
|
121 |
//# include <unix.h> /* for fdopen */
|
sl@0
|
122 |
//# else
|
sl@0
|
123 |
//# ifndef fdopen
|
sl@0
|
124 |
//# define fdopen(fd,mode) NULL /* No fdopen() */
|
sl@0
|
125 |
//# endif
|
sl@0
|
126 |
//# endif
|
sl@0
|
127 |
//#endif
|
sl@0
|
128 |
|
sl@0
|
129 |
#ifdef __50SERIES /* Prime/PRIMOS */
|
sl@0
|
130 |
# define OS_CODE 0x0F
|
sl@0
|
131 |
#endif
|
sl@0
|
132 |
|
sl@0
|
133 |
#ifdef TOPS20
|
sl@0
|
134 |
# define OS_CODE 0x0a
|
sl@0
|
135 |
#endif
|
sl@0
|
136 |
|
sl@0
|
137 |
#if defined(_BEOS_) || defined(RISCOS)
|
sl@0
|
138 |
# define fdopen(fd,mode) NULL /* No fdopen() */
|
sl@0
|
139 |
#endif
|
sl@0
|
140 |
|
sl@0
|
141 |
/*
|
sl@0
|
142 |
#if (defined(_MSC_VER) && (_MSC_VER > 600) && defined(__WINS__))
|
sl@0
|
143 |
# define fdopen(fd,type) _fdopen(fd,type)
|
sl@0
|
144 |
#endif
|
sl@0
|
145 |
*/
|
sl@0
|
146 |
|
sl@0
|
147 |
/* Common defaults */
|
sl@0
|
148 |
|
sl@0
|
149 |
#ifndef OS_CODE
|
sl@0
|
150 |
# define OS_CODE 0x03 /* assume Unix */
|
sl@0
|
151 |
#endif
|
sl@0
|
152 |
|
sl@0
|
153 |
#ifndef F_OPEN
|
sl@0
|
154 |
# define F_OPEN(name, mode) fopen((name), (mode))
|
sl@0
|
155 |
#endif
|
sl@0
|
156 |
|
sl@0
|
157 |
/* functions */
|
sl@0
|
158 |
|
sl@0
|
159 |
#ifdef HAVE_STRERROR
|
sl@0
|
160 |
extern char *strerror OF((int));
|
sl@0
|
161 |
# define zstrerror(errnum) strerror(errnum)
|
sl@0
|
162 |
#else
|
sl@0
|
163 |
# define zstrerror(errnum) ""
|
sl@0
|
164 |
#endif
|
sl@0
|
165 |
|
sl@0
|
166 |
#if defined(pyr)
|
sl@0
|
167 |
# define NO_MEMCPY
|
sl@0
|
168 |
#endif
|
sl@0
|
169 |
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
sl@0
|
170 |
/* Use our own functions for small and medium model with MSC <= 5.0.
|
sl@0
|
171 |
* You may have to use the same strategy for Borland C (untested).
|
sl@0
|
172 |
* The __SC__ check is for Symantec.
|
sl@0
|
173 |
*/
|
sl@0
|
174 |
# define NO_MEMCPY
|
sl@0
|
175 |
#endif
|
sl@0
|
176 |
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
sl@0
|
177 |
# define HAVE_MEMCPY
|
sl@0
|
178 |
#endif
|
sl@0
|
179 |
#ifdef HAVE_MEMCPY
|
sl@0
|
180 |
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
sl@0
|
181 |
# define zmemcpy _fmemcpy
|
sl@0
|
182 |
# define zmemcmp _fmemcmp
|
sl@0
|
183 |
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
sl@0
|
184 |
# else
|
sl@0
|
185 |
# define zmemcpy memcpy
|
sl@0
|
186 |
# define zmemcmp memcmp
|
sl@0
|
187 |
# define zmemzero(dest, len) memset(dest, 0, len)
|
sl@0
|
188 |
# endif
|
sl@0
|
189 |
#else
|
sl@0
|
190 |
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
sl@0
|
191 |
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
sl@0
|
192 |
extern void zmemzero OF((Bytef* dest, uInt len));
|
sl@0
|
193 |
#endif
|
sl@0
|
194 |
|
sl@0
|
195 |
// EPOC memory functions Mark Ryan, Symbian, 14/9/99
|
sl@0
|
196 |
|
sl@0
|
197 |
#define HAVE_MEMCPY
|
sl@0
|
198 |
#undef zmemcpy
|
sl@0
|
199 |
#undef zmemcmp
|
sl@0
|
200 |
#undef zmemzero
|
sl@0
|
201 |
#define zmemcpy Mem::Copy
|
sl@0
|
202 |
#define zmemcmp(s1,s2,len) Mem::Compare(s1,len,s2,len)
|
sl@0
|
203 |
#define zmemzero(dest, len) Mem::FillZ(dest, len)
|
sl@0
|
204 |
|
sl@0
|
205 |
|
sl@0
|
206 |
|
sl@0
|
207 |
/* Diagnostic functions */
|
sl@0
|
208 |
#ifdef DEBUG
|
sl@0
|
209 |
# include <stdio.h>
|
sl@0
|
210 |
extern int z_verbose;
|
sl@0
|
211 |
extern void z_error OF((char *m));
|
sl@0
|
212 |
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
sl@0
|
213 |
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
sl@0
|
214 |
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
sl@0
|
215 |
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
sl@0
|
216 |
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
sl@0
|
217 |
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
sl@0
|
218 |
#else
|
sl@0
|
219 |
# define Assert(cond,msg)
|
sl@0
|
220 |
# define Trace(x)
|
sl@0
|
221 |
# define Tracev(x)
|
sl@0
|
222 |
# define Tracevv(x)
|
sl@0
|
223 |
# define Tracec(c,x)
|
sl@0
|
224 |
# define Tracecv(c,x)
|
sl@0
|
225 |
#endif
|
sl@0
|
226 |
|
sl@0
|
227 |
|
sl@0
|
228 |
typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
|
sl@0
|
229 |
uInt len));
|
sl@0
|
230 |
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
|
sl@0
|
231 |
void zcfree OF((voidpf opaque, voidpf ptr));
|
sl@0
|
232 |
|
sl@0
|
233 |
#define ZALLOC(strm, items, size) \
|
sl@0
|
234 |
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
sl@0
|
235 |
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
sl@0
|
236 |
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
sl@0
|
237 |
|
sl@0
|
238 |
#endif /* _Z_UTIL_H */
|