os/ossrv/compressionlibs/ziplib/test/oldezlib/Zlib/zutil.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/* zutil.h -- internal interface and configuration of the compression library
sl@0
     2
 * Copyright (C) 1995-1998 Jean-loup Gailly.
sl@0
     3
 * For conditions of distribution and use, see copyright notice in zlib.h
sl@0
     4
 */
sl@0
     5
sl@0
     6
/* WARNING: this file should *not* be used by applications. It is
sl@0
     7
   part of the implementation of the compression library and is
sl@0
     8
   subject to change. Applications should only use zlib.h.
sl@0
     9
 */
sl@0
    10
sl@0
    11
/* @(#) $Id$ */
sl@0
    12
sl@0
    13
#ifndef _Z_UTIL_H
sl@0
    14
#define _Z_UTIL_H
sl@0
    15
sl@0
    16
#include "zlib.h"
sl@0
    17
sl@0
    18
#ifdef STDC
sl@0
    19
#  include <stddef.h>
sl@0
    20
#  include <string.h>
sl@0
    21
#  include <stdlib.h>
sl@0
    22
#endif
sl@0
    23
#ifdef NO_ERRNO_H
sl@0
    24
    extern int errno;
sl@0
    25
#else
sl@0
    26
#   include <errno.h>
sl@0
    27
#endif
sl@0
    28
sl@0
    29
#ifndef local
sl@0
    30
#  define local static
sl@0
    31
#endif
sl@0
    32
/* compile with -Dlocal if your debugger can't find static symbols */
sl@0
    33
sl@0
    34
typedef unsigned char  uch;
sl@0
    35
typedef uch FAR uchf;
sl@0
    36
typedef unsigned short ush;
sl@0
    37
typedef ush FAR ushf;
sl@0
    38
typedef unsigned long  ulg;
sl@0
    39
sl@0
    40
extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
sl@0
    41
/* (size given to avoid silly warnings with Visual C++) */
sl@0
    42
sl@0
    43
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
sl@0
    44
sl@0
    45
#define ERR_RETURN(strm,err) \
sl@0
    46
  return (strm->msg = (char*)ERR_MSG(err), (err))
sl@0
    47
/* To be used only when the state is known to be valid */
sl@0
    48
sl@0
    49
        /* common constants */
sl@0
    50
sl@0
    51
#ifndef DEF_WBITS
sl@0
    52
#  define DEF_WBITS MAX_WBITS
sl@0
    53
#endif
sl@0
    54
/* default windowBits for decompression. MAX_WBITS is for compression only */
sl@0
    55
sl@0
    56
#if MAX_MEM_LEVEL >= 8
sl@0
    57
#  define DEF_MEM_LEVEL 8
sl@0
    58
#else
sl@0
    59
#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
sl@0
    60
#endif
sl@0
    61
/* default memLevel */
sl@0
    62
sl@0
    63
#define STORED_BLOCK 0
sl@0
    64
#define STATIC_TREES 1
sl@0
    65
#define DYN_TREES    2
sl@0
    66
/* The three kinds of block type */
sl@0
    67
sl@0
    68
#define MIN_MATCH  3
sl@0
    69
#define MAX_MATCH  258
sl@0
    70
/* The minimum and maximum match lengths */
sl@0
    71
sl@0
    72
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
sl@0
    73
sl@0
    74
        /* target dependencies */
sl@0
    75
sl@0
    76
#ifdef MSDOS
sl@0
    77
#  define OS_CODE  0x00
sl@0
    78
#  if defined(__TURBOC__) || defined(__BORLANDC__)
sl@0
    79
#    if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
sl@0
    80
       /* Allow compilation with ANSI keywords only enabled */
sl@0
    81
       void _Cdecl farfree( void *block );
sl@0
    82
       void *_Cdecl farmalloc( unsigned long nbytes );
sl@0
    83
#    else
sl@0
    84
#     include <alloc.h>
sl@0
    85
#    endif
sl@0
    86
#  else /* MSC or DJGPP */
sl@0
    87
#    include <malloc.h>
sl@0
    88
#  endif
sl@0
    89
#endif
sl@0
    90
sl@0
    91
#ifdef OS2
sl@0
    92
#  define OS_CODE  0x06
sl@0
    93
#endif
sl@0
    94
sl@0
    95
#ifdef WIN32 /* Window 95 & Windows NT */
sl@0
    96
#  define OS_CODE  0x0b
sl@0
    97
#endif
sl@0
    98
sl@0
    99
#if defined(VAXC) || defined(VMS)
sl@0
   100
#  define OS_CODE  0x02
sl@0
   101
#  define F_OPEN(name, mode) \
sl@0
   102
     fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
sl@0
   103
#endif
sl@0
   104
sl@0
   105
#ifdef AMIGA
sl@0
   106
#  define OS_CODE  0x01
sl@0
   107
#endif
sl@0
   108
sl@0
   109
#if defined(ATARI) || defined(atarist)
sl@0
   110
#  define OS_CODE  0x05
sl@0
   111
#endif
sl@0
   112
sl@0
   113
#if defined(MACOS) || defined(TARGET_OS_MAC)
sl@0
   114
#  define OS_CODE  0x07
sl@0
   115
#  if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
sl@0
   116
#    include <unix.h> /* for fdopen */
sl@0
   117
#  else
sl@0
   118
#    ifndef fdopen
sl@0
   119
#      define fdopen(fd,mode) NULL /* No fdopen() */
sl@0
   120
#    endif
sl@0
   121
#  endif
sl@0
   122
#endif
sl@0
   123
sl@0
   124
#ifdef __50SERIES /* Prime/PRIMOS */
sl@0
   125
#  define OS_CODE  0x0F
sl@0
   126
#endif
sl@0
   127
sl@0
   128
#ifdef TOPS20
sl@0
   129
#  define OS_CODE  0x0a
sl@0
   130
#endif
sl@0
   131
sl@0
   132
#if defined(_BEOS_) || defined(RISCOS)
sl@0
   133
#  define fdopen(fd,mode) NULL /* No fdopen() */
sl@0
   134
#endif
sl@0
   135
sl@0
   136
#if (defined(_MSC_VER) && (_MSC_VER > 600))
sl@0
   137
#  define fdopen(fd,type)  _fdopen(fd,type)
sl@0
   138
#endif
sl@0
   139
sl@0
   140
sl@0
   141
        /* Common defaults */
sl@0
   142
sl@0
   143
#ifndef OS_CODE
sl@0
   144
#  define OS_CODE  0x03  /* assume Unix */
sl@0
   145
#endif
sl@0
   146
sl@0
   147
#ifndef F_OPEN
sl@0
   148
#  define F_OPEN(name, mode) fopen((name), (mode))
sl@0
   149
#endif
sl@0
   150
sl@0
   151
         /* functions */
sl@0
   152
sl@0
   153
#ifdef HAVE_STRERROR
sl@0
   154
   extern char *strerror OF((int));
sl@0
   155
#  define zstrerror(errnum) strerror(errnum)
sl@0
   156
#else
sl@0
   157
#  define zstrerror(errnum) ""
sl@0
   158
#endif
sl@0
   159
sl@0
   160
#if defined(pyr)
sl@0
   161
#  define NO_MEMCPY
sl@0
   162
#endif
sl@0
   163
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
sl@0
   164
 /* Use our own functions for small and medium model with MSC <= 5.0.
sl@0
   165
  * You may have to use the same strategy for Borland C (untested).
sl@0
   166
  * The __SC__ check is for Symantec.
sl@0
   167
  */
sl@0
   168
#  define NO_MEMCPY
sl@0
   169
#endif
sl@0
   170
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
sl@0
   171
#  define HAVE_MEMCPY
sl@0
   172
#endif
sl@0
   173
#ifdef HAVE_MEMCPY
sl@0
   174
#  ifdef SMALL_MEDIUM /* MSDOS small or medium model */
sl@0
   175
#    define zmemcpy _fmemcpy
sl@0
   176
#    define zmemcmp _fmemcmp
sl@0
   177
#    define zmemzero(dest, len) _fmemset(dest, 0, len)
sl@0
   178
#  else
sl@0
   179
#    define zmemcpy memcpy
sl@0
   180
#    define zmemcmp memcmp
sl@0
   181
#    define zmemzero(dest, len) memset(dest, 0, len)
sl@0
   182
#  endif
sl@0
   183
#else
sl@0
   184
   extern void zmemcpy  OF((Bytef* dest, const Bytef* source, uInt len));
sl@0
   185
   extern int  zmemcmp  OF((const Bytef* s1, const Bytef* s2, uInt len));
sl@0
   186
   extern void zmemzero OF((Bytef* dest, uInt len));
sl@0
   187
#endif
sl@0
   188
sl@0
   189
/* Diagnostic functions */
sl@0
   190
#ifdef DEBUG
sl@0
   191
#  include <stdio.h>
sl@0
   192
   extern int z_verbose;
sl@0
   193
   extern void z_error    OF((char *m));
sl@0
   194
#  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
sl@0
   195
#  define Trace(x) {if (z_verbose>=0) fprintf x ;}
sl@0
   196
#  define Tracev(x) {if (z_verbose>0) fprintf x ;}
sl@0
   197
#  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
sl@0
   198
#  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
sl@0
   199
#  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
sl@0
   200
#else
sl@0
   201
#  define Assert(cond,msg)
sl@0
   202
#  define Trace(x)
sl@0
   203
#  define Tracev(x)
sl@0
   204
#  define Tracevv(x)
sl@0
   205
#  define Tracec(c,x)
sl@0
   206
#  define Tracecv(c,x)
sl@0
   207
#endif
sl@0
   208
sl@0
   209
sl@0
   210
typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
sl@0
   211
				       uInt len));
sl@0
   212
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
sl@0
   213
void   zcfree  OF((voidpf opaque, voidpf ptr));
sl@0
   214
sl@0
   215
#define ZALLOC(strm, items, size) \
sl@0
   216
           (*((strm)->zalloc))((strm)->opaque, (items), (size))
sl@0
   217
#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
sl@0
   218
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
sl@0
   219
sl@0
   220
#endif /* _Z_UTIL_H */