Main MRPT website > C++ reference for MRPT 1.9.9
zutil.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 /* WARNING: this file should *not* be used by applications. It is
11  part of the implementation of the compression library and is
12  subject to change. Applications should only use zlib.h.
13  */
14 
15 /* @(#) $Id: zutil.h 35458 2005-09-10 21:15:17Z MW $ */
16 
17 #ifndef ZUTIL_H
18 #define ZUTIL_H
19 
20 #define ZLIB_INTERNAL
21 #include "zlib.h"
22 
23 #ifdef STDC
24 #ifndef _WIN32_WCE
25 #include <stddef.h>
26 #endif
27 #include <string.h>
28 #include <stdlib.h>
29 #endif
30 #ifdef NO_ERRNO_H
31 #ifdef _WIN32_WCE
32 /* The Microsoft C Run-Time Library for Windows CE doesn't have
33  * errno. We define it as a global variable to simplify porting.
34  * Its value is always 0 and should not be used. We rename it to
35  * avoid conflict with other libraries that use the same workaround.
36  */
37 #define errno z_errno
38 #endif
39 extern int errno;
40 #else
41 #ifndef _WIN32_WCE
42 #include <errno.h>
43 #endif
44 #endif
45 
46 #ifndef local
47 #define local static
48 #endif
49 /* compile with -Dlocal if your debugger can't find static symbols */
50 
51 typedef unsigned char uch;
52 typedef uch FAR uchf;
53 typedef unsigned short ush;
54 typedef ush FAR ushf;
55 typedef unsigned long ulg;
56 
57 extern const char* const z_errmsg[10]; /* indexed by 2-zlib_error */
58 /* (size given to avoid silly warnings with Visual C++) */
59 
60 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT - (err)]
61 
62 #define ERR_RETURN(strm, err) return (strm->msg = (char*)ERR_MSG(err), (err))
63 /* To be used only when the state is known to be valid */
64 
65 /* common constants */
66 
67 #ifndef DEF_WBITS
68 #define DEF_WBITS MAX_WBITS
69 #endif
70 /* default windowBits for decompression. MAX_WBITS is for compression only */
71 
72 #if MAX_MEM_LEVEL >= 8
73 #define DEF_MEM_LEVEL 8
74 #else
75 #define DEF_MEM_LEVEL MAX_MEM_LEVEL
76 #endif
77 /* default memLevel */
78 
79 #define STORED_BLOCK 0
80 #define STATIC_TREES 1
81 #define DYN_TREES 2
82 /* The three kinds of block type */
83 
84 #define MIN_MATCH 3
85 #define MAX_MATCH 258
86 /* The minimum and maximum match lengths */
87 
88 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
89 
90 /* target dependencies */
91 
92 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
93 #define OS_CODE 0x00
94 #if defined(__TURBOC__)
95 #if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
96 /* Allow compilation with ANSI keywords only enabled */
97 void _Cdecl farfree(void* block);
98 void* _Cdecl farmalloc(unsigned long nbytes);
99 #else
100 #include <alloc.h>
101 #endif
102 #else /* MSC or DJGPP */
103 #include <malloc.h>
104 #endif
105 #endif
106 
107 #ifdef AMIGA
108 #define OS_CODE 0x01
109 #endif
110 
111 #if defined(VAXC) || defined(VMS)
112 #define OS_CODE 0x02
113 #define F_OPEN(name, mode) \
114  fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
115 #endif
116 
117 #if defined(ATARI) || defined(atarist)
118 #define OS_CODE 0x05
119 #endif
120 
121 #ifdef OS2
122 #define OS_CODE 0x06
123 #ifdef M_I86
124 #include <malloc.h>
125 #endif
126 #endif
127 
128 #if defined(MACOS) || defined(TARGET_OS_MAC)
129 #define OS_CODE 0x07
130 #if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
131 #include <unix.h> /* for fdopen */
132 #else
133 #ifndef fdopen
134 #define fdopen(fd, mode) nullptr /* No fdopen() */
135 #endif
136 #endif
137 #endif
138 
139 #ifdef TOPS20
140 #define OS_CODE 0x0a
141 #endif
142 
143 #ifdef WIN32
144 #ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
145 #define OS_CODE 0x0b
146 #endif
147 #endif
148 
149 #ifdef __50SERIES /* Prime/PRIMOS */
150 #define OS_CODE 0x0f
151 #endif
152 
153 #if defined(_BEOS_) || defined(RISCOS)
154 #define fdopen(fd, mode) nullptr /* No fdopen() */
155 #endif
156 
157 #if (defined(_MSC_VER) && (_MSC_VER > 600))
158 #if defined(_WIN32_WCE)
159 #define fdopen(fd, mode) nullptr /* No fdopen() */
160 #ifndef _PTRDIFF_T_DEFINED
161 typedef int ptrdiff_t;
162 #define _PTRDIFF_T_DEFINED
163 #endif
164 #else
165 #define fdopen(fd, type) _fdopen(fd, type)
166 #endif
167 #endif
168 
169 /* common defaults */
170 
171 #ifndef OS_CODE
172 #define OS_CODE 0x03 /* assume Unix */
173 #endif
174 
175 #ifndef F_OPEN
176 #define F_OPEN(name, mode) fopen((name), (mode))
177 #endif
178 
179 /* functions */
180 
181 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
182 #ifndef HAVE_VSNPRINTF
183 #define HAVE_VSNPRINTF
184 #endif
185 #endif
186 #if defined(__CYGWIN__)
187 #ifndef HAVE_VSNPRINTF
188 #define HAVE_VSNPRINTF
189 #endif
190 #endif
191 #ifndef HAVE_VSNPRINTF
192 #ifdef MSDOS
193 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
194  but for now we just assume it doesn't. */
195 #define NO_vsnprintf
196 #endif
197 #ifdef __TURBOC__
198 #define NO_vsnprintf
199 #endif
200 #ifdef WIN32
201 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
202 #if !defined(vsnprintf) && !defined(NO_vsnprintf)
203 #define vsnprintf _vsnprintf
204 #endif
205 #endif
206 #ifdef __SASC
207 #define NO_vsnprintf
208 #endif
209 #endif
210 #ifdef VMS
211 #define NO_vsnprintf
212 #endif
213 
214 #if defined(pyr)
215 #define NO_MEMCPY
216 #endif
217 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
218 /* Use our own functions for small and medium model with MSC <= 5.0.
219  * You may have to use the same strategy for Borland C (untested).
220  * The __SC__ check is for Symantec.
221  */
222 #define NO_MEMCPY
223 #endif
224 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
225 #define HAVE_MEMCPY
226 #endif
227 #ifdef HAVE_MEMCPY
228 #ifdef SMALL_MEDIUM /* MSDOS small or medium model */
229 #define zmemcpy _fmemcpy
230 #define zmemcmp _fmemcmp
231 #define zmemzero(dest, len) _fmemset(dest, 0, len)
232 #else
233 #define zmemcpy memcpy
234 #define zmemcmp memcmp
235 #define zmemzero(dest, len) memset(dest, 0, len)
236 #endif
237 #else
238 extern void zmemcpy OF((Bytef * dest, const Bytef* source, uInt len));
239 extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
240 extern void zmemzero OF((Bytef * dest, uInt len));
241 #endif
242 
243 /* Diagnostic functions */
244 #ifdef DEBUG
245 #include <stdio.h>
246 extern int z_verbose;
247 extern void z_error OF((char* m));
248 #define Assert(cond, msg) \
249  { \
250  if (!(cond)) z_error(msg); \
251  }
252 #define Trace(x) \
253  { \
254  if (z_verbose >= 0) fprintf x; \
255  }
256 #define Tracev(x) \
257  { \
258  if (z_verbose > 0) fprintf x; \
259  }
260 #define Tracevv(x) \
261  { \
262  if (z_verbose > 1) fprintf x; \
263  }
264 #define Tracec(c, x) \
265  { \
266  if (z_verbose > 0 && (c)) fprintf x; \
267  }
268 #define Tracecv(c, x) \
269  { \
270  if (z_verbose > 1 && (c)) fprintf x; \
271  }
272 #else
273 #define Assert(cond, msg)
274 #define Trace(x)
275 #define Tracev(x)
276 #define Tracevv(x)
277 #define Tracec(c, x)
278 #define Tracecv(c, x)
279 #endif
280 
281 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
282 void zcfree OF((voidpf opaque, voidpf ptr));
283 
284 #define ZALLOC(strm, items, size) \
285  (*((strm)->zalloc))((strm)->opaque, (items), (size))
286 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
287 #define TRY_FREE(s, p) \
288  { \
289  if (p) ZFREE(s, p); \
290  }
291 
292 #endif /* ZUTIL_H */
Bytef
Byte FAR Bytef
Definition: zconf.h:275
voidpf
void FAR * voidpf
Definition: zconf.h:284
uch
unsigned char uch
Definition: zutil.h:51
uchf
uch FAR uchf
Definition: zutil.h:52
zmemcmp
#define zmemcmp
Definition: zutil.h:234
source
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
ush
unsigned short ush
Definition: zutil.h:53
OF
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size))
FAR
#define FAR
Definition: zconf.h:262
ushf
ush FAR ushf
Definition: zutil.h:54
zmemzero
#define zmemzero(dest, len)
Definition: zutil.h:235
len
GLenum GLsizei len
Definition: glext.h:4712
zmemcpy
#define zmemcpy
Definition: zutil.h:233
z_errmsg
const char *const z_errmsg[10]
uInt
unsigned int uInt
Definition: zconf.h:268
ptrdiff_t
_W64 int ptrdiff_t
Definition: glew.h:137
ulg
unsigned long ulg
Definition: zutil.h:55
size
GLsizeiptr size
Definition: glext.h:3923
zlib.h



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST