annotate lib/zlib/zutil.h @ 460:62ca9e2e1432

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