aboutsummaryrefslogtreecommitdiffstats
path: root/doc/api-documentation/html/zutil_8h-source.html
blob: 58ed5947b58d25f5fb7a45c3d66fde9b4107afa7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>zutil.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </center>
<hr><h1>zutil.h</h1><div class="fragment"><pre>00001 <font class="comment">/* zutil.h -- internal interface and configuration of the compression library</font>
00002 <font class="comment"> * Copyright (C) 1995-1998 Jean-loup Gailly.</font>
00003 <font class="comment"> * For conditions of distribution and use, see copyright notice in zlib.h</font>
00004 <font class="comment"> */</font>
00005 
00006 <font class="comment">/* WARNING: this file should *not* be used by applications. It is</font>
00007 <font class="comment">   part of the implementation of the compression library and is</font>
00008 <font class="comment">   subject to change. Applications should only use zlib.h.</font>
00009 <font class="comment"> */</font>
00010 
00011 <font class="comment">/* @(#) $Id: zutil_8h-source.html,v 1.3 2002/06/20 20:23:10 mgruner Exp $ */</font>
00012 
00013 <font class="preprocessor">#ifndef _Z_UTIL_H</font>
00014 <font class="preprocessor"></font><font class="preprocessor">#define _Z_UTIL_H</font>
00015 <font class="preprocessor"></font>
00016 <font class="preprocessor">#include "zlib.h"</font>
00017 
00018 <font class="preprocessor">#ifdef STDC</font>
00019 <font class="preprocessor"></font><font class="preprocessor">#  include &lt;stddef.h&gt;</font>
00020 <font class="preprocessor">#  include &lt;string.h&gt;</font>
00021 <font class="preprocessor">#  include &lt;stdlib.h&gt;</font>
00022 <font class="preprocessor">#endif</font>
00023 <font class="preprocessor"></font><font class="preprocessor">#ifdef NO_ERRNO_H</font>
00024 <font class="preprocessor"></font>    <font class="keyword">extern</font> <font class="keywordtype">int</font> errno;
00025 <font class="preprocessor">#else</font>
00026 <font class="preprocessor"></font><font class="preprocessor">#   include &lt;errno.h&gt;</font>
00027 <font class="preprocessor">#endif</font>
00028 <font class="preprocessor"></font>
00029 <font class="preprocessor">#ifndef local</font>
00030 <font class="preprocessor"></font><font class="preprocessor">#  define local static</font>
00031 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00032 <font class="preprocessor"></font><font class="comment">/* compile with -Dlocal if your debugger can't find static symbols */</font>
00033 
00034 <font class="keyword">typedef</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>  uch;
00035 <font class="keyword">typedef</font> uch FAR uchf;
00036 <font class="keyword">typedef</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> ush;
00037 <font class="keyword">typedef</font> ush FAR ushf;
00038 <font class="keyword">typedef</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font>  ulg;
00039 
00040 <font class="keyword">extern</font> <font class="keyword">const</font> <font class="keywordtype">char</font> *z_errmsg[10]; <font class="comment">/* indexed by 2-zlib_error */</font>
00041 <font class="comment">/* (size given to avoid silly warnings with Visual C++) */</font>
00042 
00043 <font class="preprocessor">#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]</font>
00044 <font class="preprocessor"></font>
00045 <font class="preprocessor">#define ERR_RETURN(strm,err) \</font>
00046 <font class="preprocessor">  return (strm-&gt;msg = (char*)ERR_MSG(err), (err))</font>
00047 <font class="preprocessor"></font><font class="comment">/* To be used only when the state is known to be valid */</font>
00048 
00049         <font class="comment">/* common constants */</font>
00050 
00051 <font class="preprocessor">#ifndef DEF_WBITS</font>
00052 <font class="preprocessor"></font><font class="preprocessor">#  define DEF_WBITS MAX_WBITS</font>
00053 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00054 <font class="preprocessor"></font><font class="comment">/* default windowBits for decompression. MAX_WBITS is for compression only */</font>
00055 
00056 <font class="preprocessor">#if MAX_MEM_LEVEL &gt;= 8</font>
00057 <font class="preprocessor"></font><font class="preprocessor">#  define DEF_MEM_LEVEL 8</font>
00058 <font class="preprocessor"></font><font class="preprocessor">#else</font>
00059 <font class="preprocessor"></font><font class="preprocessor">#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL</font>
00060 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00061 <font class="preprocessor"></font><font class="comment">/* default memLevel */</font>
00062 
00063 <font class="preprocessor">#define STORED_BLOCK 0</font>
00064 <font class="preprocessor"></font><font class="preprocessor">#define STATIC_TREES 1</font>
00065 <font class="preprocessor"></font><font class="preprocessor">#define DYN_TREES    2</font>
00066 <font class="preprocessor"></font><font class="comment">/* The three kinds of block type */</font>
00067 
00068 <font class="preprocessor">#define MIN_MATCH  3</font>
00069 <font class="preprocessor"></font><font class="preprocessor">#define MAX_MATCH  258</font>
00070 <font class="preprocessor"></font><font class="comment">/* The minimum and maximum match lengths */</font>
00071 
00072 <font class="preprocessor">#define PRESET_DICT 0x20 </font><font class="comment">/* preset dictionary flag in zlib header */</font>
00073 
00074         <font class="comment">/* target dependencies */</font>
00075 
00076 <font class="preprocessor">#ifdef MSDOS</font>
00077 <font class="preprocessor"></font><font class="preprocessor">#  define OS_CODE  0x00</font>
00078 <font class="preprocessor"></font><font class="preprocessor">#  if defined(__TURBOC__) || defined(__BORLANDC__)</font>
00079 <font class="preprocessor"></font><font class="preprocessor">#    if(__STDC__ == 1) &amp;&amp; (defined(__LARGE__) || defined(__COMPACT__))</font>
00080 <font class="preprocessor"></font>       <font class="comment">/* Allow compilation with ANSI keywords only enabled */</font>
00081        <font class="keywordtype">void</font> _Cdecl farfree( <font class="keywordtype">void</font> *block );
00082        <font class="keywordtype">void</font> *_Cdecl farmalloc( <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> nbytes );
00083 <font class="preprocessor">#    else</font>
00084 <font class="preprocessor"></font><font class="preprocessor">#     include &lt;alloc.h&gt;</font>
00085 <font class="preprocessor">#    endif</font>
00086 <font class="preprocessor"></font><font class="preprocessor">#  else </font><font class="comment">/* MSC or DJGPP */</font>
00087 <font class="preprocessor">#    include &lt;malloc.h&gt;</font>
00088 <font class="preprocessor">#  endif</font>
00089 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00090 <font class="preprocessor"></font>
00091 <font class="preprocessor">#ifdef OS2</font>
00092 <font class="preprocessor"></font><font class="preprocessor">#  define OS_CODE  0x06</font>
00093 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00094 <font class="preprocessor"></font>
00095 <font class="preprocessor">#ifdef WIN32 </font><font class="comment">/* Window 95 &amp; Windows NT */</font>
00096 <font class="preprocessor">#  define OS_CODE  0x0b</font>
00097 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00098 <font class="preprocessor"></font>
00099 <font class="preprocessor">#if defined(VAXC) || defined(VMS)</font>
00100 <font class="preprocessor"></font><font class="preprocessor">#  define OS_CODE  0x02</font>
00101 <font class="preprocessor"></font><font class="preprocessor">#  define F_OPEN(name, mode) \</font>
00102 <font class="preprocessor">     fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")</font>
00103 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00104 <font class="preprocessor"></font>
00105 <font class="preprocessor">#ifdef AMIGA</font>
00106 <font class="preprocessor"></font><font class="preprocessor">#  define OS_CODE  0x01</font>
00107 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00108 <font class="preprocessor"></font>
00109 <font class="preprocessor">#if defined(ATARI) || defined(atarist)</font>
00110 <font class="preprocessor"></font><font class="preprocessor">#  define OS_CODE  0x05</font>
00111 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00112 <font class="preprocessor"></font>
00113 <font class="preprocessor">#if defined(MACOS) || defined(TARGET_OS_MAC)</font>
00114 <font class="preprocessor"></font><font class="preprocessor">#  define OS_CODE  0x07</font>
00115 <font class="preprocessor"></font><font class="preprocessor">#  if defined(__MWERKS__) &amp;&amp; __dest_os != __be_os &amp;&amp; __dest_os != __win32_os</font>
00116 <font class="preprocessor"></font><font class="preprocessor">#    include &lt;unix.h&gt;</font> <font class="comment">/* for fdopen */</font>
00117 <font class="preprocessor">#  else</font>
00118 <font class="preprocessor"></font><font class="preprocessor">#    ifndef fdopen</font>
00119 <font class="preprocessor"></font><font class="preprocessor">#      define fdopen(fd,mode) NULL </font><font class="comment">/* No fdopen() */</font>
00120 <font class="preprocessor">#    endif</font>
00121 <font class="preprocessor"></font><font class="preprocessor">#  endif</font>
00122 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00123 <font class="preprocessor"></font>
00124 <font class="preprocessor">#ifdef __50SERIES </font><font class="comment">/* Prime/PRIMOS */</font>
00125 <font class="preprocessor">#  define OS_CODE  0x0F</font>
00126 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00127 <font class="preprocessor"></font>
00128 <font class="preprocessor">#ifdef TOPS20</font>
00129 <font class="preprocessor"></font><font class="preprocessor">#  define OS_CODE  0x0a</font>
00130 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00131 <font class="preprocessor"></font>
00132 <font class="preprocessor">#if defined(_BEOS_) || defined(RISCOS)</font>
00133 <font class="preprocessor"></font><font class="preprocessor">#  define fdopen(fd,mode) NULL </font><font class="comment">/* No fdopen() */</font>
00134 <font class="preprocessor">#endif</font>
00135 <font class="preprocessor"></font>
00136 <font class="preprocessor">#if (defined(_MSC_VER) &amp;&amp; (_MSC_VER &gt; 600))</font>
00137 <font class="preprocessor"></font><font class="preprocessor">#  define fdopen(fd,type)  _fdopen(fd,type)</font>
00138 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00139 <font class="preprocessor"></font>
00140 
00141         <font class="comment">/* Common defaults */</font>
00142 
00143 <font class="preprocessor">#ifndef OS_CODE</font>
00144 <font class="preprocessor"></font><font class="preprocessor">#  define OS_CODE  0x03  </font><font class="comment">/* assume Unix */</font>
00145 <font class="preprocessor">#endif</font>
00146 <font class="preprocessor"></font>
00147 <font class="preprocessor">#ifndef F_OPEN</font>
00148 <font class="preprocessor"></font><font class="preprocessor">#  define F_OPEN(name, mode) fopen((name), (mode))</font>
00149 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00150 <font class="preprocessor"></font>
00151          <font class="comment">/* functions */</font>
00152 
00153 <font class="preprocessor">#ifdef HAVE_STRERROR</font>
00154 <font class="preprocessor"></font>   <font class="keyword">extern</font> <font class="keywordtype">char</font> *strerror OF((<font class="keywordtype">int</font>));
00155 <font class="preprocessor">#  define zstrerror(errnum) strerror(errnum)</font>
00156 <font class="preprocessor"></font><font class="preprocessor">#else</font>
00157 <font class="preprocessor"></font><font class="preprocessor">#  define zstrerror(errnum) ""</font>
00158 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00159 <font class="preprocessor"></font>
00160 <font class="preprocessor">#if defined(pyr)</font>
00161 <font class="preprocessor"></font><font class="preprocessor">#  define NO_MEMCPY</font>
00162 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00163 <font class="preprocessor"></font><font class="preprocessor">#if defined(SMALL_MEDIUM) &amp;&amp; !defined(_MSC_VER) &amp;&amp; !defined(__SC__)</font>
00164 <font class="preprocessor"></font> <font class="comment">/* Use our own functions for small and medium model with MSC &lt;= 5.0.</font>
00165 <font class="comment">  * You may have to use the same strategy for Borland C (untested).</font>
00166 <font class="comment">  * The __SC__ check is for Symantec.</font>
00167 <font class="comment">  */</font>
00168 <font class="preprocessor">#  define NO_MEMCPY</font>
00169 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00170 <font class="preprocessor"></font><font class="preprocessor">#if defined(STDC) &amp;&amp; !defined(HAVE_MEMCPY) &amp;&amp; !defined(NO_MEMCPY)</font>
00171 <font class="preprocessor"></font><font class="preprocessor">#  define HAVE_MEMCPY</font>
00172 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00173 <font class="preprocessor"></font><font class="preprocessor">#ifdef HAVE_MEMCPY</font>
00174 <font class="preprocessor"></font><font class="preprocessor">#  ifdef SMALL_MEDIUM </font><font class="comment">/* MSDOS small or medium model */</font>
00175 <font class="preprocessor">#    define zmemcpy _fmemcpy</font>
00176 <font class="preprocessor"></font><font class="preprocessor">#    define zmemcmp _fmemcmp</font>
00177 <font class="preprocessor"></font><font class="preprocessor">#    define zmemzero(dest, len) _fmemset(dest, 0, len)</font>
00178 <font class="preprocessor"></font><font class="preprocessor">#  else</font>
00179 <font class="preprocessor"></font><font class="preprocessor">#    define zmemcpy memcpy</font>
00180 <font class="preprocessor"></font><font class="preprocessor">#    define zmemcmp memcmp</font>
00181 <font class="preprocessor"></font><font class="preprocessor">#    define zmemzero(dest, len) memset(dest, 0, len)</font>
00182 <font class="preprocessor"></font><font class="preprocessor">#  endif</font>
00183 <font class="preprocessor"></font><font class="preprocessor">#else</font>
00184 <font class="preprocessor"></font>   <font class="keyword">extern</font> <font class="keywordtype">void</font> zmemcpy  OF((Bytef* dest, <font class="keyword">const</font> Bytef* source, uInt len));
00185    <font class="keyword">extern</font> <font class="keywordtype">int</font>  zmemcmp  OF((<font class="keyword">const</font> Bytef* s1, <font class="keyword">const</font> Bytef* s2, uInt len));
00186    <font class="keyword">extern</font> <font class="keywordtype">void</font> zmemzero OF((Bytef* dest, uInt len));
00187 <font class="preprocessor">#endif</font>
00188 <font class="preprocessor"></font>
00189 <font class="comment">/* Diagnostic functions */</font>
00190 <font class="preprocessor">#ifdef DEBUG</font>
00191 <font class="preprocessor"></font><font class="preprocessor">#  include &lt;stdio.h&gt;</font>
00192    <font class="keyword">extern</font> <font class="keywordtype">int</font> z_verbose;
00193    <font class="keyword">extern</font> <font class="keywordtype">void</font> z_error    OF((<font class="keywordtype">char</font> *m));
00194 <font class="preprocessor">#  define Assert(cond,msg) {if(!(cond)) z_error(msg);}</font>
00195 <font class="preprocessor"></font><font class="preprocessor">#  define Trace(x) {if (z_verbose&gt;=0) fprintf x ;}</font>
00196 <font class="preprocessor"></font><font class="preprocessor">#  define Tracev(x) {if (z_verbose&gt;0) fprintf x ;}</font>
00197 <font class="preprocessor"></font><font class="preprocessor">#  define Tracevv(x) {if (z_verbose&gt;1) fprintf x ;}</font>
00198 <font class="preprocessor"></font><font class="preprocessor">#  define Tracec(c,x) {if (z_verbose&gt;0 &amp;&amp; (c)) fprintf x ;}</font>
00199 <font class="preprocessor"></font><font class="preprocessor">#  define Tracecv(c,x) {if (z_verbose&gt;1 &amp;&amp; (c)) fprintf x ;}</font>
00200 <font class="preprocessor"></font><font class="preprocessor">#else</font>
00201 <font class="preprocessor"></font><font class="preprocessor">#  define Assert(cond,msg)</font>
00202 <font class="preprocessor"></font><font class="preprocessor">#  define Trace(x)</font>
00203 <font class="preprocessor"></font><font class="preprocessor">#  define Tracev(x)</font>
00204 <font class="preprocessor"></font><font class="preprocessor">#  define Tracevv(x)</font>
00205 <font class="preprocessor"></font><font class="preprocessor">#  define Tracec(c,x)</font>
00206 <font class="preprocessor"></font><font class="preprocessor">#  define Tracecv(c,x)</font>
00207 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00208 <font class="preprocessor"></font>
00209 
00210 <font class="keyword">typedef</font> uLong (ZEXPORT *check_func) OF((uLong check, <font class="keyword">const</font> Bytef *buf,
00211                                        uInt len));
00212 voidpf zcalloc OF((voidpf opaque, <font class="keywordtype">unsigned</font> items, <font class="keywordtype">unsigned</font> size));
00213 <font class="keywordtype">void</font>   zcfree  OF((voidpf opaque, voidpf ptr));
00214 
00215 <font class="preprocessor">#define ZALLOC(strm, items, size) \</font>
00216 <font class="preprocessor">           (*((strm)-&gt;zalloc))((strm)-&gt;opaque, (items), (size))</font>
00217 <font class="preprocessor"></font><font class="preprocessor">#define ZFREE(strm, addr)  (*((strm)-&gt;zfree))((strm)-&gt;opaque, (voidpf)(addr))</font>
00218 <font class="preprocessor"></font><font class="preprocessor">#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}</font>
00219 <font class="preprocessor"></font>
00220 <font class="preprocessor">#endif </font><font class="comment">/* _Z_UTIL_H */</font>
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:01 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>