1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/zlib/zutil.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,275 @@ 1.4 +/* zutil.h -- internal interface and configuration of the compression library 1.5 + * Copyright (C) 1995-2010 Jean-loup Gailly. 1.6 + * For conditions of distribution and use, see copyright notice in zlib.h 1.7 + */ 1.8 + 1.9 +/* WARNING: this file should *not* be used by applications. It is 1.10 + part of the implementation of the compression library and is 1.11 + subject to change. Applications should only use zlib.h. 1.12 + */ 1.13 + 1.14 +/* @(#) $Id$ */ 1.15 + 1.16 +#ifndef ZUTIL_H 1.17 +#define ZUTIL_H 1.18 + 1.19 +#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) 1.20 +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 1.21 +#else 1.22 +# define ZLIB_INTERNAL 1.23 +#endif 1.24 + 1.25 +#include "zlib.h" 1.26 + 1.27 +#ifdef STDC 1.28 +# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) 1.29 +# include <stddef.h> 1.30 +# endif 1.31 +# include <string.h> 1.32 +# include <stdlib.h> 1.33 +#endif 1.34 + 1.35 +#ifndef local 1.36 +# define local static 1.37 +#endif 1.38 +/* compile with -Dlocal if your debugger can't find static symbols */ 1.39 + 1.40 +typedef unsigned char uch; 1.41 +typedef uch FAR uchf; 1.42 +typedef unsigned short ush; 1.43 +typedef ush FAR ushf; 1.44 +typedef unsigned long ulg; 1.45 + 1.46 +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 1.47 +/* (size given to avoid silly warnings with Visual C++) */ 1.48 + 1.49 +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 1.50 + 1.51 +#define ERR_RETURN(strm,err) \ 1.52 + return (strm->msg = (char*)ERR_MSG(err), (err)) 1.53 +/* To be used only when the state is known to be valid */ 1.54 + 1.55 + /* common constants */ 1.56 + 1.57 +#ifndef DEF_WBITS 1.58 +# define DEF_WBITS MAX_WBITS 1.59 +#endif 1.60 +/* default windowBits for decompression. MAX_WBITS is for compression only */ 1.61 + 1.62 +#if MAX_MEM_LEVEL >= 8 1.63 +# define DEF_MEM_LEVEL 8 1.64 +#else 1.65 +# define DEF_MEM_LEVEL MAX_MEM_LEVEL 1.66 +#endif 1.67 +/* default memLevel */ 1.68 + 1.69 +#define STORED_BLOCK 0 1.70 +#define STATIC_TREES 1 1.71 +#define DYN_TREES 2 1.72 +/* The three kinds of block type */ 1.73 + 1.74 +#define MIN_MATCH 3 1.75 +#define MAX_MATCH 258 1.76 +/* The minimum and maximum match lengths */ 1.77 + 1.78 +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 1.79 + 1.80 + /* target dependencies */ 1.81 + 1.82 +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 1.83 +# define OS_CODE 0x00 1.84 +# if defined(__TURBOC__) || defined(__BORLANDC__) 1.85 +# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 1.86 + /* Allow compilation with ANSI keywords only enabled */ 1.87 + void _Cdecl farfree( void *block ); 1.88 + void *_Cdecl farmalloc( unsigned long nbytes ); 1.89 +# else 1.90 +# include <alloc.h> 1.91 +# endif 1.92 +# else /* MSC or DJGPP */ 1.93 +# include <malloc.h> 1.94 +# endif 1.95 +#endif 1.96 + 1.97 +#ifdef AMIGA 1.98 +# define OS_CODE 0x01 1.99 +#endif 1.100 + 1.101 +#if defined(VAXC) || defined(VMS) 1.102 +# define OS_CODE 0x02 1.103 +# define F_OPEN(name, mode) \ 1.104 + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 1.105 +#endif 1.106 + 1.107 +#if defined(ATARI) || defined(atarist) 1.108 +# define OS_CODE 0x05 1.109 +#endif 1.110 + 1.111 +#ifdef OS2 1.112 +# define OS_CODE 0x06 1.113 +# ifdef M_I86 1.114 +# include <malloc.h> 1.115 +# endif 1.116 +#endif 1.117 + 1.118 +#if defined(MACOS) || defined(TARGET_OS_MAC) 1.119 +# define OS_CODE 0x07 1.120 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 1.121 +# include <unix.h> /* for fdopen */ 1.122 +# else 1.123 +# ifndef fdopen 1.124 +# define fdopen(fd,mode) NULL /* No fdopen() */ 1.125 +# endif 1.126 +# endif 1.127 +#endif 1.128 + 1.129 +#ifdef TOPS20 1.130 +# define OS_CODE 0x0a 1.131 +#endif 1.132 + 1.133 +#ifdef WIN32 1.134 +# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 1.135 +# define OS_CODE 0x0b 1.136 +# endif 1.137 +#endif 1.138 + 1.139 +#ifdef __50SERIES /* Prime/PRIMOS */ 1.140 +# define OS_CODE 0x0f 1.141 +#endif 1.142 + 1.143 +#if defined(_BEOS_) || defined(RISCOS) 1.144 +# define fdopen(fd,mode) NULL /* No fdopen() */ 1.145 +#endif 1.146 + 1.147 +#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX 1.148 +# if defined(_WIN32_WCE) 1.149 +# define fdopen(fd,mode) NULL /* No fdopen() */ 1.150 +# ifndef _PTRDIFF_T_DEFINED 1.151 + typedef int ptrdiff_t; 1.152 +# define _PTRDIFF_T_DEFINED 1.153 +# endif 1.154 +# else 1.155 +# define fdopen(fd,type) _fdopen(fd,type) 1.156 +# endif 1.157 +#endif 1.158 + 1.159 +#if defined(__BORLANDC__) 1.160 + #pragma warn -8004 1.161 + #pragma warn -8008 1.162 + #pragma warn -8066 1.163 +#endif 1.164 + 1.165 +/* provide prototypes for these when building zlib without LFS */ 1.166 +#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 1.167 + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); 1.168 + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); 1.169 +#endif 1.170 + 1.171 + /* common defaults */ 1.172 + 1.173 +#ifndef OS_CODE 1.174 +# define OS_CODE 0x03 /* assume Unix */ 1.175 +#endif 1.176 + 1.177 +#ifndef F_OPEN 1.178 +# define F_OPEN(name, mode) fopen((name), (mode)) 1.179 +#endif 1.180 + 1.181 + /* functions */ 1.182 + 1.183 +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) || \ 1.184 + (defined(_MSC_VER) && _MSC_VER >= 1500) 1.185 +# ifndef HAVE_VSNPRINTF 1.186 +# define HAVE_VSNPRINTF 1.187 +# endif 1.188 +#endif 1.189 +#if defined(__CYGWIN__) 1.190 +# ifndef HAVE_VSNPRINTF 1.191 +# define HAVE_VSNPRINTF 1.192 +# endif 1.193 +#endif 1.194 +#ifndef HAVE_VSNPRINTF 1.195 +# ifdef MSDOS 1.196 + /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), 1.197 + but for now we just assume it doesn't. */ 1.198 +# define NO_vsnprintf 1.199 +# endif 1.200 +# ifdef __TURBOC__ 1.201 +# define NO_vsnprintf 1.202 +# endif 1.203 +# ifdef WIN32 1.204 + /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ 1.205 +# if !defined(vsnprintf) && !defined(NO_vsnprintf) 1.206 +# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) 1.207 +# define vsnprintf _vsnprintf 1.208 +# endif 1.209 +# endif 1.210 +# endif 1.211 +# ifdef __SASC 1.212 +# define NO_vsnprintf 1.213 +# endif 1.214 +#endif 1.215 +#ifdef VMS 1.216 +# define NO_vsnprintf 1.217 +#endif 1.218 + 1.219 +#if defined(pyr) 1.220 +# define NO_MEMCPY 1.221 +#endif 1.222 +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 1.223 + /* Use our own functions for small and medium model with MSC <= 5.0. 1.224 + * You may have to use the same strategy for Borland C (untested). 1.225 + * The __SC__ check is for Symantec. 1.226 + */ 1.227 +# define NO_MEMCPY 1.228 +#endif 1.229 +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 1.230 +# define HAVE_MEMCPY 1.231 +#endif 1.232 +#ifdef HAVE_MEMCPY 1.233 +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 1.234 +# define zmemcpy _fmemcpy 1.235 +# define zmemcmp _fmemcmp 1.236 +# define zmemzero(dest, len) _fmemset(dest, 0, len) 1.237 +# else 1.238 +# define zmemcpy memcpy 1.239 +# define zmemcmp memcmp 1.240 +# define zmemzero(dest, len) memset(dest, 0, len) 1.241 +# endif 1.242 +#else 1.243 + void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 1.244 + int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 1.245 + void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); 1.246 +#endif 1.247 + 1.248 +/* Diagnostic functions */ 1.249 +#ifdef DEBUG 1.250 +# include <stdio.h> 1.251 + extern int ZLIB_INTERNAL z_verbose; 1.252 + extern void ZLIB_INTERNAL z_error OF((char *m)); 1.253 +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} 1.254 +# define Trace(x) {if (z_verbose>=0) fprintf x ;} 1.255 +# define Tracev(x) {if (z_verbose>0) fprintf x ;} 1.256 +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} 1.257 +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 1.258 +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 1.259 +#else 1.260 +# define Assert(cond,msg) 1.261 +# define Trace(x) 1.262 +# define Tracev(x) 1.263 +# define Tracevv(x) 1.264 +# define Tracec(c,x) 1.265 +# define Tracecv(c,x) 1.266 +#endif 1.267 + 1.268 + 1.269 +voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, 1.270 + unsigned size)); 1.271 +void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); 1.272 + 1.273 +#define ZALLOC(strm, items, size) \ 1.274 + (*((strm)->zalloc))((strm)->opaque, (items), (size)) 1.275 +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 1.276 +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 1.277 + 1.278 +#endif /* ZUTIL_H */