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