|
version 1.1, 2012/02/17 15:09:30
|
version 1.1.1.2, 2013/10/14 07:51:14
|
|
Line 1
|
Line 1
|
| /* zutil.h -- internal interface and configuration of the compression library |
/* zutil.h -- internal interface and configuration of the compression library |
| * Copyright (C) 1995-2005 Jean-loup Gailly. | * Copyright (C) 1995-2013 Jean-loup Gailly. |
| * For conditions of distribution and use, see copyright notice in zlib.h |
* For conditions of distribution and use, see copyright notice in zlib.h |
| */ |
*/ |
| |
|
|
Line 18
|
Line 18
|
| #include "zlib.h" |
#include "zlib.h" |
| |
|
| #if 0 |
#if 0 |
| #ifdef STDC | #if defined(STDC) && !defined(Z_SOLO) |
| # ifndef _WIN32_WCE | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) |
| # include <stddef.h> |
# include <stddef.h> |
| # endif |
# endif |
| # include <string.h> |
# include <string.h> |
| # include <stdlib.h> |
# include <stdlib.h> |
| #endif |
#endif |
| #ifdef NO_ERRNO_H |
|
| # ifdef _WIN32_WCE |
|
| /* The Microsoft C Run-Time Library for Windows CE doesn't have |
|
| * errno. We define it as a global variable to simplify porting. |
|
| * Its value is always 0 and should not be used. We rename it to |
|
| * avoid conflict with other libraries that use the same workaround. |
|
| */ |
|
| # define errno z_errno |
|
| # endif |
|
| extern int errno; |
|
| #else |
|
| # ifndef _WIN32_WCE |
|
| # include <errno.h> |
|
| # endif |
|
| #endif |
#endif |
| |
|
| |
#ifdef Z_SOLO |
| |
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ |
| #endif |
#endif |
| |
|
| #ifndef local |
#ifndef local |
|
Line 53 typedef unsigned short ush;
|
Line 42 typedef unsigned short ush;
|
| typedef ush FAR ushf; |
typedef ush FAR ushf; |
| typedef unsigned long ulg; |
typedef unsigned long ulg; |
| |
|
| extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ |
| /* (size given to avoid silly warnings with Visual C++) */ |
/* (size given to avoid silly warnings with Visual C++) */ |
| |
|
| #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] |
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] |
| |
|
| #define ERR_RETURN(strm,err) \ |
#define ERR_RETURN(strm,err) \ |
| return (strm->msg = (char*)ERR_MSG(err), (err)) | return (strm->msg = ERR_MSG(err), (err)) |
| /* To be used only when the state is known to be valid */ |
/* To be used only when the state is known to be valid */ |
| |
|
| /* common constants */ |
/* common constants */ |
|
Line 91 extern const char * const z_errmsg[10]; /* indexed by
|
Line 80 extern const char * const z_errmsg[10]; /* indexed by
|
| |
|
| #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) |
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) |
| # define OS_CODE 0x00 |
# define OS_CODE 0x00 |
| # if defined(__TURBOC__) || defined(__BORLANDC__) | # ifndef Z_SOLO |
| # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) | # if defined(__TURBOC__) || defined(__BORLANDC__) |
| /* Allow compilation with ANSI keywords only enabled */ | # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) |
| void _Cdecl farfree( void *block ); | /* Allow compilation with ANSI keywords only enabled */ |
| void *_Cdecl farmalloc( unsigned long nbytes ); | void _Cdecl farfree( void *block ); |
| # else | void *_Cdecl farmalloc( unsigned long nbytes ); |
| # include <alloc.h> | # endif |
| | # include <alloc.h> |
| | # endif |
| | # else /* MSC or DJGPP */ |
| | # include <malloc.h> |
| # endif |
# endif |
| # else /* MSC or DJGPP */ |
|
| # include <malloc.h> |
|
| # endif |
# endif |
| #endif |
#endif |
| |
|
|
Line 120 extern const char * const z_errmsg[10]; /* indexed by
|
Line 111 extern const char * const z_errmsg[10]; /* indexed by
|
| |
|
| #ifdef OS2 |
#ifdef OS2 |
| # define OS_CODE 0x06 |
# define OS_CODE 0x06 |
| # ifdef M_I86 | # if defined(M_I86) && !defined(Z_SOLO) |
| #include <malloc.h> | # include <malloc.h> |
| # endif |
# endif |
| #endif |
#endif |
| |
|
| #if defined(MACOS) || defined(TARGET_OS_MAC) |
#if defined(MACOS) || defined(TARGET_OS_MAC) |
| # define OS_CODE 0x07 |
# define OS_CODE 0x07 |
| # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os | # ifndef Z_SOLO |
| # include <unix.h> /* for fdopen */ | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os |
| # else | # include <unix.h> /* for fdopen */ |
| # ifndef fdopen | # else |
| # define fdopen(fd,mode) NULL /* No fdopen() */ | # endif |
| | # define fdopen(fd,mode) NULL /* No fdopen() */ |
| | # endif |
| # endif |
# endif |
| # endif |
# endif |
| #endif |
#endif |
|
Line 154 extern const char * const z_errmsg[10]; /* indexed by
|
Line 147 extern const char * const z_errmsg[10]; /* indexed by
|
| # define fdopen(fd,mode) NULL /* No fdopen() */ |
# define fdopen(fd,mode) NULL /* No fdopen() */ |
| #endif |
#endif |
| |
|
| #if (defined(_MSC_VER) && (_MSC_VER > 600)) | #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX |
| # if defined(_WIN32_WCE) |
# if defined(_WIN32_WCE) |
| # define fdopen(fd,mode) NULL /* No fdopen() */ |
# define fdopen(fd,mode) NULL /* No fdopen() */ |
| # ifndef _PTRDIFF_T_DEFINED |
# ifndef _PTRDIFF_T_DEFINED |
|
Line 166 extern const char * const z_errmsg[10]; /* indexed by
|
Line 159 extern const char * const z_errmsg[10]; /* indexed by
|
| # endif |
# endif |
| #endif |
#endif |
| |
|
| |
#if defined(__BORLANDC__) && !defined(MSDOS) |
| |
#pragma warn -8004 |
| |
#pragma warn -8008 |
| |
#pragma warn -8066 |
| |
#endif |
| |
|
| |
/* provide prototypes for these when building zlib without LFS */ |
| |
#if !defined(_WIN32) && \ |
| |
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) |
| |
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); |
| |
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); |
| |
#endif |
| |
|
| /* common defaults */ |
/* common defaults */ |
| |
|
| #ifndef OS_CODE |
#ifndef OS_CODE |
|
Line 178 extern const char * const z_errmsg[10]; /* indexed by
|
Line 184 extern const char * const z_errmsg[10]; /* indexed by
|
| |
|
| /* functions */ |
/* functions */ |
| |
|
| #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) | #if defined(pyr) || defined(Z_SOLO) |
| # ifndef HAVE_VSNPRINTF | |
| # define HAVE_VSNPRINTF | |
| # endif | |
| #endif | |
| #if defined(__CYGWIN__) | |
| # ifndef HAVE_VSNPRINTF | |
| # define HAVE_VSNPRINTF | |
| # endif | |
| #endif | |
| #ifndef HAVE_VSNPRINTF | |
| # ifdef MSDOS | |
| /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), | |
| but for now we just assume it doesn't. */ | |
| # define NO_vsnprintf | |
| # endif | |
| # ifdef __TURBOC__ | |
| # define NO_vsnprintf | |
| # endif | |
| # ifdef WIN32 | |
| /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ | |
| # if !defined(vsnprintf) && !defined(NO_vsnprintf) | |
| # define vsnprintf _vsnprintf | |
| # endif | |
| # endif | |
| # ifdef __SASC | |
| # define NO_vsnprintf | |
| # endif | |
| #endif | |
| #ifdef VMS | |
| # define NO_vsnprintf | |
| #endif | |
| |
| #if defined(pyr) | |
| # define NO_MEMCPY |
# define NO_MEMCPY |
| #endif |
#endif |
| #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) |
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) |
|
Line 235 extern const char * const z_errmsg[10]; /* indexed by
|
Line 208 extern const char * const z_errmsg[10]; /* indexed by
|
| # define zmemzero(dest, len) memset(dest, 0, len) |
# define zmemzero(dest, len) memset(dest, 0, len) |
| # endif |
# endif |
| #else |
#else |
| extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); | void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); |
| extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); | int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); |
| extern void zmemzero OF((Bytef* dest, uInt len)); | void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); |
| #endif |
#endif |
| |
|
| /* Diagnostic functions */ |
/* Diagnostic functions */ |
| #ifdef DEBUG |
#ifdef DEBUG |
| # include <stdio.h> |
# include <stdio.h> |
| extern int z_verbose; | extern int ZLIB_INTERNAL z_verbose; |
| extern void z_error OF((char *m)); | extern void ZLIB_INTERNAL z_error OF((char *m)); |
| # define Assert(cond,msg) {if(!(cond)) z_error(msg);} |
# define Assert(cond,msg) {if(!(cond)) z_error(msg);} |
| # define Trace(x) {if (z_verbose>=0) fprintf x ;} |
# define Trace(x) {if (z_verbose>=0) fprintf x ;} |
| # define Tracev(x) {if (z_verbose>0) fprintf x ;} |
# define Tracev(x) {if (z_verbose>0) fprintf x ;} |
|
Line 260 extern const char * const z_errmsg[10]; /* indexed by
|
Line 233 extern const char * const z_errmsg[10]; /* indexed by
|
| # define Tracecv(c,x) |
# define Tracecv(c,x) |
| #endif |
#endif |
| |
|
| |
#ifndef Z_SOLO |
| |
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, |
| |
unsigned size)); |
| |
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); |
| |
#endif |
| |
|
| voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); |
|
| void zcfree OF((voidpf opaque, voidpf ptr)); |
|
| |
|
| #define ZALLOC(strm, items, size) \ |
#define ZALLOC(strm, items, size) \ |
| (*((strm)->zalloc))((strm)->opaque, (items), (size)) |
(*((strm)->zalloc))((strm)->opaque, (items), (size)) |
| #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |
| #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} |
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} |
| |
|
| |
/* Reverse the bytes in a 32-bit value */ |
| |
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ |
| |
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) |
| |
|
| #endif /* ZUTIL_H */ |
#endif /* ZUTIL_H */ |