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