1592N/A/*
1592N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1592N/A *
1592N/A * This code is free software; you can redistribute it and/or modify it
1592N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
1592N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
1592N/A *
1592N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1592N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1592N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1592N/A * version 2 for more details (a copy is included in the LICENSE file that
1592N/A * accompanied this code).
1592N/A *
1592N/A * You should have received a copy of the GNU General Public License version
1592N/A * 2 along with this work; if not, write to the Free Software Foundation,
1592N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1592N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1592N/A */
1592N/A
1592N/A/* zutil.h -- internal interface and configuration of the compression library
1592N/A * Copyright (C) 1995-2005 Jean-loup Gailly.
1592N/A * For conditions of distribution and use, see copyright notice in zlib.h
1592N/A */
1592N/A
1592N/A/* WARNING: this file should *not* be used by applications. It is
1592N/A part of the implementation of the compression library and is
1592N/A subject to change. Applications should only use zlib.h.
1592N/A */
1592N/A
1592N/A/* @(#) $Id$ */
1592N/A
1592N/A#ifndef ZUTIL_H
1592N/A#define ZUTIL_H
1592N/A
1592N/A#define ZLIB_INTERNAL
1592N/A#include "zlib.h"
1592N/A
1592N/A#ifdef STDC
1592N/A# ifndef _WIN32_WCE
1592N/A# include <stddef.h>
1592N/A# endif
1592N/A# include <string.h>
1592N/A# include <stdlib.h>
1592N/A#endif
1592N/A#ifdef NO_ERRNO_H
1592N/A# ifdef _WIN32_WCE
1592N/A /* The Microsoft C Run-Time Library for Windows CE doesn't have
1592N/A * errno. We define it as a global variable to simplify porting.
1592N/A * Its value is always 0 and should not be used. We rename it to
1592N/A * avoid conflict with other libraries that use the same workaround.
1592N/A */
1592N/A# define errno z_errno
1592N/A# endif
1592N/A extern int errno;
1592N/A#else
1592N/A# ifndef _WIN32_WCE
1592N/A# include <errno.h>
1592N/A# endif
1592N/A#endif
1592N/A
1592N/A#ifndef local
1592N/A# define local static
1592N/A#endif
1592N/A/* compile with -Dlocal if your debugger can't find static symbols */
1592N/A
1592N/Atypedef unsigned char uch;
1592N/Atypedef uch FAR uchf;
1592N/Atypedef unsigned short ush;
1592N/Atypedef ush FAR ushf;
1592N/Atypedef unsigned long ulg;
1592N/A
1592N/Aextern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
1592N/A/* (size given to avoid silly warnings with Visual C++) */
1592N/A
1592N/A#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
1592N/A
1592N/A#define ERR_RETURN(strm,err) \
1592N/A return (strm->msg = (char*)ERR_MSG(err), (err))
1592N/A/* To be used only when the state is known to be valid */
1592N/A
1592N/A /* common constants */
1592N/A
1592N/A#ifndef DEF_WBITS
1592N/A# define DEF_WBITS MAX_WBITS
1592N/A#endif
1592N/A/* default windowBits for decompression. MAX_WBITS is for compression only */
1592N/A
1592N/A#if MAX_MEM_LEVEL >= 8
1592N/A# define DEF_MEM_LEVEL 8
1592N/A#else
1592N/A# define DEF_MEM_LEVEL MAX_MEM_LEVEL
1592N/A#endif
1592N/A/* default memLevel */
1592N/A
1592N/A#define STORED_BLOCK 0
1592N/A#define STATIC_TREES 1
1592N/A#define DYN_TREES 2
1592N/A/* The three kinds of block type */
1592N/A
1592N/A#define MIN_MATCH 3
1592N/A#define MAX_MATCH 258
1592N/A/* The minimum and maximum match lengths */
1592N/A
1592N/A#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
1592N/A
1592N/A /* target dependencies */
1592N/A
1592N/A#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
1592N/A# define OS_CODE 0x00
1592N/A# if defined(__TURBOC__) || defined(__BORLANDC__)
1592N/A# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
1592N/A /* Allow compilation with ANSI keywords only enabled */
1592N/A void _Cdecl farfree( void *block );
1592N/A void *_Cdecl farmalloc( unsigned long nbytes );
1592N/A# else
1592N/A# include <alloc.h>
1592N/A# endif
1592N/A# else /* MSC or DJGPP */
1592N/A# include <malloc.h>
1592N/A# endif
1592N/A#endif
1592N/A
1592N/A#ifdef AMIGA
1592N/A# define OS_CODE 0x01
1592N/A#endif
1592N/A
1592N/A#if defined(VAXC) || defined(VMS)
1592N/A# define OS_CODE 0x02
1592N/A# define F_OPEN(name, mode) \
1592N/A fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
1592N/A#endif
1592N/A
1592N/A#if defined(ATARI) || defined(atarist)
1592N/A# define OS_CODE 0x05
1592N/A#endif
1592N/A
1592N/A#ifdef OS2
1592N/A# define OS_CODE 0x06
1592N/A# ifdef M_I86
1592N/A #include <malloc.h>
1592N/A# endif
1592N/A#endif
1592N/A
1592N/A#if defined(MACOS) || defined(TARGET_OS_MAC)
1592N/A# define OS_CODE 0x07
1592N/A# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
1592N/A# include <unix.h> /* for fdopen */
1592N/A# else
1592N/A# ifndef fdopen
1592N/A# define fdopen(fd,mode) NULL /* No fdopen() */
1592N/A# endif
1592N/A# endif
1592N/A#endif
1592N/A
1592N/A#ifdef TOPS20
1592N/A# define OS_CODE 0x0a
1592N/A#endif
1592N/A
1592N/A#ifdef WIN32
1592N/A# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
1592N/A# define OS_CODE 0x0b
1592N/A# endif
1592N/A#endif
1592N/A
1592N/A#ifdef __50SERIES /* Prime/PRIMOS */
1592N/A# define OS_CODE 0x0f
1592N/A#endif
1592N/A
1592N/A#if defined(_BEOS_) || defined(RISCOS)
1592N/A# define fdopen(fd,mode) NULL /* No fdopen() */
1592N/A#endif
1592N/A
1592N/A#if (defined(_MSC_VER) && (_MSC_VER > 600))
1592N/A# if defined(_WIN32_WCE)
1592N/A# define fdopen(fd,mode) NULL /* No fdopen() */
1592N/A# ifndef _PTRDIFF_T_DEFINED
1592N/A typedef int ptrdiff_t;
1592N/A# define _PTRDIFF_T_DEFINED
1592N/A# endif
1592N/A# else
1592N/A# define fdopen(fd,type) _fdopen(fd,type)
1592N/A# endif
1592N/A#endif
1592N/A
1592N/A /* common defaults */
1592N/A
1592N/A#ifndef OS_CODE
1592N/A# define OS_CODE 0x03 /* assume Unix */
1592N/A#endif
1592N/A
1592N/A#ifndef F_OPEN
1592N/A# define F_OPEN(name, mode) fopen((name), (mode))
1592N/A#endif
1592N/A
1592N/A /* functions */
1592N/A
1592N/A#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
1592N/A# ifndef HAVE_VSNPRINTF
1592N/A# define HAVE_VSNPRINTF
1592N/A# endif
1592N/A#endif
1592N/A#if defined(__CYGWIN__)
1592N/A# ifndef HAVE_VSNPRINTF
1592N/A# define HAVE_VSNPRINTF
1592N/A# endif
1592N/A#endif
1592N/A#ifndef HAVE_VSNPRINTF
1592N/A# ifdef MSDOS
1592N/A /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
1592N/A but for now we just assume it doesn't. */
1592N/A# define NO_vsnprintf
1592N/A# endif
1592N/A# ifdef __TURBOC__
1592N/A# define NO_vsnprintf
1592N/A# endif
1592N/A# ifdef WIN32
1592N/A /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
2044N/A# if !defined(vsnprintf) && !defined(NO_vsnprintf) && (!defined(_MSC_VER) || (_MSC_VER < 1500))
2044N/A /* Only needed before Visual Studio 2008 */
1592N/A# define vsnprintf _vsnprintf
1592N/A# endif
1592N/A# endif
1592N/A# ifdef __SASC
1592N/A# define NO_vsnprintf
1592N/A# endif
1592N/A#endif
1592N/A#ifdef VMS
1592N/A# define NO_vsnprintf
1592N/A#endif
1592N/A
1592N/A#if defined(pyr)
1592N/A# define NO_MEMCPY
1592N/A#endif
1592N/A#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
1592N/A /* Use our own functions for small and medium model with MSC <= 5.0.
1592N/A * You may have to use the same strategy for Borland C (untested).
1592N/A * The __SC__ check is for Symantec.
1592N/A */
1592N/A# define NO_MEMCPY
1592N/A#endif
1592N/A#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
1592N/A# define HAVE_MEMCPY
1592N/A#endif
1592N/A#ifdef HAVE_MEMCPY
1592N/A# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
1592N/A# define zmemcpy _fmemcpy
1592N/A# define zmemcmp _fmemcmp
1592N/A# define zmemzero(dest, len) _fmemset(dest, 0, len)
1592N/A# else
1592N/A# define zmemcpy memcpy
1592N/A# define zmemcmp memcmp
1592N/A# define zmemzero(dest, len) memset(dest, 0, len)
1592N/A# endif
1592N/A#else
1592N/A extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
1592N/A extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
1592N/A extern void zmemzero OF((Bytef* dest, uInt len));
1592N/A#endif
1592N/A
1592N/A/* Diagnostic functions */
1592N/A#ifdef DEBUG
1592N/A# include <stdio.h>
1592N/A extern int z_verbose;
1592N/A extern void z_error OF((char *m));
1592N/A# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
1592N/A# define Trace(x) {if (z_verbose>=0) fprintf x ;}
1592N/A# define Tracev(x) {if (z_verbose>0) fprintf x ;}
1592N/A# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
1592N/A# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
1592N/A# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
1592N/A#else
1592N/A# define Assert(cond,msg)
1592N/A# define Trace(x)
1592N/A# define Tracev(x)
1592N/A# define Tracevv(x)
1592N/A# define Tracec(c,x)
1592N/A# define Tracecv(c,x)
1592N/A#endif
1592N/A
1592N/A
1592N/Avoidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
1592N/Avoid zcfree OF((voidpf opaque, voidpf ptr));
1592N/A
1592N/A#define ZALLOC(strm, items, size) \
1592N/A (*((strm)->zalloc))((strm)->opaque, (items), (size))
1592N/A#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
1592N/A#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
1592N/A
1592N/A#endif /* ZUTIL_H */