annotate zlib/zutil.h @ 3:5a977ccbc7a9 default tip

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