Main MRPT website > C++ reference for MRPT 1.5.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-2017, 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) \
63  return (strm->msg = (char*)ERR_MSG(err), (err))
64 /* To be used only when the state is known to be valid */
65 
66  /* common constants */
67 
68 #ifndef DEF_WBITS
69 # define DEF_WBITS MAX_WBITS
70 #endif
71 /* default windowBits for decompression. MAX_WBITS is for compression only */
72 
73 #if MAX_MEM_LEVEL >= 8
74 # define DEF_MEM_LEVEL 8
75 #else
76 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
77 #endif
78 /* default memLevel */
79 
80 #define STORED_BLOCK 0
81 #define STATIC_TREES 1
82 #define DYN_TREES 2
83 /* The three kinds of block type */
84 
85 #define MIN_MATCH 3
86 #define MAX_MATCH 258
87 /* The minimum and maximum match lengths */
88 
89 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
90 
91  /* target dependencies */
92 
93 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
94 # define OS_CODE 0x00
95 # if defined(__TURBOC__) || defined(__BORLANDC__)
96 # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
97  /* Allow compilation with ANSI keywords only enabled */
98  void _Cdecl farfree( void *block );
99  void *_Cdecl farmalloc( unsigned long nbytes );
100 # else
101 # include <alloc.h>
102 # endif
103 # else /* MSC or DJGPP */
104 # include <malloc.h>
105 # endif
106 #endif
107 
108 #ifdef AMIGA
109 # define OS_CODE 0x01
110 #endif
111 
112 #if defined(VAXC) || defined(VMS)
113 # define OS_CODE 0x02
114 # define F_OPEN(name, mode) \
115  fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
116 #endif
117 
118 #if defined(ATARI) || defined(atarist)
119 # define OS_CODE 0x05
120 #endif
121 
122 #ifdef OS2
123 # define OS_CODE 0x06
124 # ifdef M_I86
125  #include <malloc.h>
126 # endif
127 #endif
128 
129 #if defined(MACOS) || defined(TARGET_OS_MAC)
130 # define OS_CODE 0x07
131 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
132 # include <unix.h> /* for fdopen */
133 # else
134 # ifndef fdopen
135 # define fdopen(fd,mode) NULL /* No fdopen() */
136 # endif
137 # endif
138 #endif
139 
140 #ifdef TOPS20
141 # define OS_CODE 0x0a
142 #endif
143 
144 #ifdef WIN32
145 # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
146 # define OS_CODE 0x0b
147 # endif
148 #endif
149 
150 #ifdef __50SERIES /* Prime/PRIMOS */
151 # define OS_CODE 0x0f
152 #endif
153 
154 #if defined(_BEOS_) || defined(RISCOS)
155 # define fdopen(fd,mode) NULL /* No fdopen() */
156 #endif
157 
158 #if (defined(_MSC_VER) && (_MSC_VER > 600))
159 # if defined(_WIN32_WCE)
160 # define fdopen(fd,mode) NULL /* No fdopen() */
161 # ifndef _PTRDIFF_T_DEFINED
162  typedef int ptrdiff_t;
163 # define _PTRDIFF_T_DEFINED
164 # endif
165 # else
166 # define fdopen(fd,type) _fdopen(fd,type)
167 # endif
168 #endif
169 
170  /* common defaults */
171 
172 #ifndef OS_CODE
173 # define OS_CODE 0x03 /* assume Unix */
174 #endif
175 
176 #ifndef F_OPEN
177 # define F_OPEN(name, mode) fopen((name), (mode))
178 #endif
179 
180  /* functions */
181 
182 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
183 # ifndef HAVE_VSNPRINTF
184 # define HAVE_VSNPRINTF
185 # endif
186 #endif
187 #if defined(__CYGWIN__)
188 # ifndef HAVE_VSNPRINTF
189 # define HAVE_VSNPRINTF
190 # endif
191 #endif
192 #ifndef HAVE_VSNPRINTF
193 # ifdef MSDOS
194  /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
195  but for now we just assume it doesn't. */
196 # define NO_vsnprintf
197 # endif
198 # ifdef __TURBOC__
199 # define NO_vsnprintf
200 # endif
201 # ifdef WIN32
202  /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
203 # if !defined(vsnprintf) && !defined(NO_vsnprintf)
204 # define vsnprintf _vsnprintf
205 # endif
206 # endif
207 # ifdef __SASC
208 # define NO_vsnprintf
209 # endif
210 #endif
211 #ifdef VMS
212 # define NO_vsnprintf
213 #endif
214 
215 #if defined(pyr)
216 # define NO_MEMCPY
217 #endif
218 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
219  /* Use our own functions for small and medium model with MSC <= 5.0.
220  * You may have to use the same strategy for Borland C (untested).
221  * The __SC__ check is for Symantec.
222  */
223 # define NO_MEMCPY
224 #endif
225 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
226 # define HAVE_MEMCPY
227 #endif
228 #ifdef HAVE_MEMCPY
229 # ifdef SMALL_MEDIUM /* MSDOS small or medium model */
230 # define zmemcpy _fmemcpy
231 # define zmemcmp _fmemcmp
232 # define zmemzero(dest, len) _fmemset(dest, 0, len)
233 # else
234 # define zmemcpy memcpy
235 # define zmemcmp memcmp
236 # define zmemzero(dest, len) memset(dest, 0, len)
237 # endif
238 #else
239  extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
240  extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
241  extern void zmemzero OF((Bytef* dest, uInt len));
242 #endif
243 
244 /* Diagnostic functions */
245 #ifdef DEBUG
246 # include <stdio.h>
247  extern int z_verbose;
248  extern void z_error OF((char *m));
249 # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
250 # define Trace(x) {if (z_verbose>=0) fprintf x ;}
251 # define Tracev(x) {if (z_verbose>0) fprintf x ;}
252 # define Tracevv(x) {if (z_verbose>1) fprintf x ;}
253 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
254 # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
255 #else
256 # define Assert(cond,msg)
257 # define Trace(x)
258 # define Tracev(x)
259 # define Tracevv(x)
260 # define Tracec(c,x)
261 # define Tracecv(c,x)
262 #endif
263 
264 
265 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
266 void zcfree OF((voidpf opaque, voidpf ptr));
267 
268 #define ZALLOC(strm, items, size) \
269  (*((strm)->zalloc))((strm)->opaque, (items), (size))
270 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
271 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
272 
273 #endif /* ZUTIL_H */
ush FAR ushf
Definition: zutil.h:54
GLenum GLsizei len
Definition: glext.h:4349
Byte FAR Bytef
Definition: zconf.h:274
#define zmemzero(dest, len)
Definition: zutil.h:236
#define zmemcmp
Definition: zutil.h:235
unsigned short ush
Definition: zutil.h:53
_W64 int ptrdiff_t
Definition: glew.h:133
const char *const z_errmsg[10]
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size))
GLsizei GLsizei GLchar * source
Definition: glext.h:3908
unsigned char uch
Definition: zutil.h:51
unsigned long ulg
Definition: zutil.h:55
#define zmemcpy
Definition: zutil.h:234
GLsizeiptr size
Definition: glext.h:3779
#define FAR
Definition: zconf.h:261
void FAR * voidpf
Definition: zconf.h:283
uch FAR uchf
Definition: zutil.h:52
unsigned int uInt
Definition: zconf.h:267



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020