Eneboo - Documentación para desarrolladores
|
00001 /* zutil.h -- internal interface and configuration of the compression library 00002 * Copyright (C) 1995-2003 Jean-loup Gailly. 00003 * For conditions of distribution and use, see copyright notice in zlib.h 00004 */ 00005 00006 /* WARNING: this file should *not* be used by applications. It is 00007 part of the implementation of the compression library and is 00008 subject to change. Applications should only use zlib.h. 00009 */ 00010 00011 /* @(#) $Id: qt/zutil.h 3.3.8 edited Jun 27 2004 $ */ 00012 00013 #ifndef ZUTIL_H 00014 #define ZUTIL_H 00015 00016 #define ZLIB_INTERNAL 00017 #include "zlib.h" 00018 00019 #ifdef STDC 00020 # include <stddef.h> 00021 # include <string.h> 00022 # include <stdlib.h> 00023 #endif 00024 #ifdef NO_ERRNO_H 00025 extern int errno; 00026 #else 00027 # include <errno.h> 00028 #endif 00029 00030 #ifndef local 00031 # define local static 00032 #endif 00033 /* compile with -Dlocal if your debugger can't find static symbols */ 00034 00035 typedef unsigned char uch; 00036 typedef uch FAR uchf; 00037 typedef unsigned short ush; 00038 typedef ush FAR ushf; 00039 typedef unsigned long ulg; 00040 00041 extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 00042 /* (size given to avoid silly warnings with Visual C++) */ 00043 00044 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 00045 00046 #define ERR_RETURN(strm,err) \ 00047 return (strm->msg = (char*)ERR_MSG(err), (err)) 00048 /* To be used only when the state is known to be valid */ 00049 00050 /* common constants */ 00051 00052 #ifndef DEF_WBITS 00053 # define DEF_WBITS MAX_WBITS 00054 #endif 00055 /* default windowBits for decompression. MAX_WBITS is for compression only */ 00056 00057 #if MAX_MEM_LEVEL >= 8 00058 # define DEF_MEM_LEVEL 8 00059 #else 00060 # define DEF_MEM_LEVEL MAX_MEM_LEVEL 00061 #endif 00062 /* default memLevel */ 00063 00064 #define STORED_BLOCK 0 00065 #define STATIC_TREES 1 00066 #define DYN_TREES 2 00067 /* The three kinds of block type */ 00068 00069 #define MIN_MATCH 3 00070 #define MAX_MATCH 258 00071 /* The minimum and maximum match lengths */ 00072 00073 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 00074 00075 /* target dependencies */ 00076 00077 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 00078 # define OS_CODE 0x00 00079 # if defined(__TURBOC__) || defined(__BORLANDC__) 00080 # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 00081 /* Allow compilation with ANSI keywords only enabled */ 00082 void _Cdecl farfree( void *block ); 00083 void *_Cdecl farmalloc( unsigned long nbytes ); 00084 # else 00085 # include <alloc.h> 00086 # endif 00087 # else /* MSC or DJGPP */ 00088 # include <malloc.h> 00089 # endif 00090 #endif 00091 00092 #ifdef AMIGA 00093 # define OS_CODE 0x01 00094 #endif 00095 00096 #if defined(VAXC) || defined(VMS) 00097 # define OS_CODE 0x02 00098 # define F_OPEN(name, mode) \ 00099 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 00100 #endif 00101 00102 #if defined(ATARI) || defined(atarist) 00103 # define OS_CODE 0x05 00104 #endif 00105 00106 #ifdef OS2 00107 # define OS_CODE 0x06 00108 #endif 00109 00110 #if defined(MACOS) || defined(TARGET_OS_MAC) 00111 # define OS_CODE 0x07 00112 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 00113 # include <unix.h> /* for fdopen */ 00114 # else 00115 # ifndef fdopen 00116 # define fdopen(fd,mode) NULL /* No fdopen() */ 00117 # endif 00118 # endif 00119 #endif 00120 00121 #ifdef TOPS20 00122 # define OS_CODE 0x0a 00123 #endif 00124 00125 #ifdef WIN32 00126 # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 00127 # define OS_CODE 0x0b 00128 # endif 00129 #endif 00130 00131 #ifdef __50SERIES /* Prime/PRIMOS */ 00132 # define OS_CODE 0x0f 00133 #endif 00134 00135 #if defined(_BEOS_) || defined(RISCOS) 00136 # define fdopen(fd,mode) NULL /* No fdopen() */ 00137 #endif 00138 00139 #if (defined(_MSC_VER) && (_MSC_VER > 600)) 00140 # if defined(_WIN32_WCE) 00141 # define fdopen(fd,mode) NULL /* No fdopen() */ 00142 # ifndef _PTRDIFF_T_DEFINED 00143 typedef int ptrdiff_t; 00144 # define _PTRDIFF_T_DEFINED 00145 # endif 00146 # else 00147 # define fdopen(fd,type) _fdopen(fd,type) 00148 # endif 00149 #endif 00150 00151 /* common defaults */ 00152 00153 #ifndef OS_CODE 00154 # define OS_CODE 0x03 /* assume Unix */ 00155 #endif 00156 00157 #ifndef F_OPEN 00158 # define F_OPEN(name, mode) fopen((name), (mode)) 00159 #endif 00160 00161 /* functions */ 00162 00163 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) 00164 # ifndef HAVE_VSNPRINTF 00165 # define HAVE_VSNPRINTF 00166 # endif 00167 #endif 00168 #if defined(__CYGWIN__) 00169 # ifndef HAVE_VSNPRINTF 00170 # define HAVE_VSNPRINTF 00171 # endif 00172 #endif 00173 #ifndef HAVE_VSNPRINTF 00174 # ifdef MSDOS 00175 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), 00176 but for now we just assume it doesn't. */ 00177 # define NO_vsnprintf 00178 # endif 00179 # ifdef __TURBOC__ 00180 # define NO_vsnprintf 00181 # endif 00182 # ifdef WIN32 00183 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ 00184 # if !defined(vsnprintf) && !defined(NO_vsnprintf) 00185 # define vsnprintf _vsnprintf 00186 # endif 00187 # endif 00188 # ifdef __SASC 00189 # define NO_vsnprintf 00190 # endif 00191 #endif 00192 #ifdef VMS 00193 # define NO_vsnprintf 00194 #endif 00195 00196 #ifdef HAVE_STRERROR 00197 # ifndef VMS 00198 extern char *strerror OF((int)); 00199 # endif 00200 # define zstrerror(errnum) strerror(errnum) 00201 #else 00202 # define zstrerror(errnum) "" 00203 #endif 00204 00205 #if defined(pyr) 00206 # define NO_MEMCPY 00207 #endif 00208 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 00209 /* Use our own functions for small and medium model with MSC <= 5.0. 00210 * You may have to use the same strategy for Borland C (untested). 00211 * The __SC__ check is for Symantec. 00212 */ 00213 # define NO_MEMCPY 00214 #endif 00215 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 00216 # define HAVE_MEMCPY 00217 #endif 00218 #ifdef HAVE_MEMCPY 00219 # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 00220 # define zmemcpy _fmemcpy 00221 # define zmemcmp _fmemcmp 00222 # define zmemzero(dest, len) _fmemset(dest, 0, len) 00223 # else 00224 # define zmemcpy memcpy 00225 # define zmemcmp memcmp 00226 # define zmemzero(dest, len) memset(dest, 0, len) 00227 # endif 00228 #else 00229 extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 00230 extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 00231 extern void zmemzero OF((Bytef* dest, uInt len)); 00232 #endif 00233 00234 /* Diagnostic functions */ 00235 #ifdef DEBUG 00236 # include <stdio.h> 00237 extern int z_verbose; 00238 extern void z_error OF((char *m)); 00239 # define Assert(cond,msg) {if(!(cond)) z_error(msg);} 00240 # define Trace(x) {if (z_verbose>=0) fprintf x ;} 00241 # define Tracev(x) {if (z_verbose>0) fprintf x ;} 00242 # define Tracevv(x) {if (z_verbose>1) fprintf x ;} 00243 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 00244 # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 00245 #else 00246 # define Assert(cond,msg) 00247 # define Trace(x) 00248 # define Tracev(x) 00249 # define Tracevv(x) 00250 # define Tracec(c,x) 00251 # define Tracecv(c,x) 00252 #endif 00253 00254 00255 voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); 00256 void zcfree OF((voidpf opaque, voidpf ptr)); 00257 00258 #define ZALLOC(strm, items, size) \ 00259 (*((strm)->zalloc))((strm)->opaque, (items), (size)) 00260 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 00261 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 00262 00263 #endif /* ZUTIL_H */