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