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