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