zlib123/zutil.h
author Ryan C. Gordon <icculus@icculus.org>
Sat, 23 Jul 2005 22:02:32 +0000
branchstable-1.0
changeset 719 7b4677a8de6e
permissions -rw-r--r--
Moved to zlib 1.2.3 proper.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
719
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/* zutil.h -- internal interface and configuration of the compression library
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * Copyright (C) 1995-2005 Jean-loup Gailly.
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 * For conditions of distribution and use, see copyright notice in zlib.h
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
/* WARNING: this file should *not* be used by applications. It is
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
   part of the implementation of the compression library and is
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
   subject to change. Applications should only use zlib.h.
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
 */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
/* @(#) $Id$ */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
#ifndef ZUTIL_H
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
#define ZUTIL_H
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
#define ZLIB_INTERNAL
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
#include "zlib.h"
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
#ifdef STDC
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
#  ifndef _WIN32_WCE
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
#    include <stddef.h>
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
#  include <string.h>
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
#  include <stdlib.h>
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
#ifdef NO_ERRNO_H
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
#   ifdef _WIN32_WCE
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
      /* The Microsoft C Run-Time Library for Windows CE doesn't have
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
       * errno.  We define it as a global variable to simplify porting.
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
       * Its value is always 0 and should not be used.  We rename it to
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
       * avoid conflict with other libraries that use the same workaround.
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
       */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
#     define errno z_errno
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
#   endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
    extern int errno;
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
#else
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
#  ifndef _WIN32_WCE
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
#    include <errno.h>
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
#ifndef local
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
#  define local static
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
/* compile with -Dlocal if your debugger can't find static symbols */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
typedef unsigned char  uch;
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
typedef uch FAR uchf;
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
typedef unsigned short ush;
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
typedef ush FAR ushf;
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
typedef unsigned long  ulg;
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
/* (size given to avoid silly warnings with Visual C++) */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
#define ERR_RETURN(strm,err) \
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
  return (strm->msg = (char*)ERR_MSG(err), (err))
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
/* To be used only when the state is known to be valid */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
        /* common constants */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
#ifndef DEF_WBITS
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
#  define DEF_WBITS MAX_WBITS
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
/* default windowBits for decompression. MAX_WBITS is for compression only */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
#if MAX_MEM_LEVEL >= 8
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
#  define DEF_MEM_LEVEL 8
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
#else
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
/* default memLevel */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
#define STORED_BLOCK 0
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
#define STATIC_TREES 1
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
#define DYN_TREES    2
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
/* The three kinds of block type */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
#define MIN_MATCH  3
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
#define MAX_MATCH  258
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
/* The minimum and maximum match lengths */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
        /* target dependencies */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
#  define OS_CODE  0x00
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
#  if defined(__TURBOC__) || defined(__BORLANDC__)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
#    if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
       /* Allow compilation with ANSI keywords only enabled */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
       void _Cdecl farfree( void *block );
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
       void *_Cdecl farmalloc( unsigned long nbytes );
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
#    else
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
#      include <alloc.h>
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
#    endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
#  else /* MSC or DJGPP */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
#    include <malloc.h>
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
#ifdef AMIGA
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
#  define OS_CODE  0x01
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
#if defined(VAXC) || defined(VMS)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
#  define OS_CODE  0x02
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
#  define F_OPEN(name, mode) \
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
     fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
#if defined(ATARI) || defined(atarist)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
#  define OS_CODE  0x05
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
#ifdef OS2
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
#  define OS_CODE  0x06
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
#  ifdef M_I86
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
     #include <malloc.h>
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
#if defined(MACOS) || defined(TARGET_OS_MAC)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
#  define OS_CODE  0x07
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
#  if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
#    include <unix.h> /* for fdopen */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
#  else
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
#    ifndef fdopen
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
#      define fdopen(fd,mode) NULL /* No fdopen() */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
#    endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
#ifdef TOPS20
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
#  define OS_CODE  0x0a
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
#ifdef WIN32
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
#  ifndef __CYGWIN__  /* Cygwin is Unix, not Win32 */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
#    define OS_CODE  0x0b
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
#ifdef __50SERIES /* Prime/PRIMOS */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
#  define OS_CODE  0x0f
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
#if defined(_BEOS_) || defined(RISCOS)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   151
#  define fdopen(fd,mode) NULL /* No fdopen() */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
#if (defined(_MSC_VER) && (_MSC_VER > 600))
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
#  if defined(_WIN32_WCE)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
#    define fdopen(fd,mode) NULL /* No fdopen() */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
#    ifndef _PTRDIFF_T_DEFINED
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
       typedef int ptrdiff_t;
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
#      define _PTRDIFF_T_DEFINED
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
#    endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   161
#  else
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
#    define fdopen(fd,type)  _fdopen(fd,type)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
        /* common defaults */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
#ifndef OS_CODE
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
#  define OS_CODE  0x03  /* assume Unix */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
#ifndef F_OPEN
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
#  define F_OPEN(name, mode) fopen((name), (mode))
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
         /* functions */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   179
#  ifndef HAVE_VSNPRINTF
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   180
#    define HAVE_VSNPRINTF
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   181
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   183
#if defined(__CYGWIN__)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
#  ifndef HAVE_VSNPRINTF
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   185
#    define HAVE_VSNPRINTF
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
#ifndef HAVE_VSNPRINTF
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   189
#  ifdef MSDOS
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   190
     /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
        but for now we just assume it doesn't. */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   192
#    define NO_vsnprintf
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
#  ifdef __TURBOC__
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
#    define NO_vsnprintf
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
#  ifdef WIN32
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   198
     /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199
#    if !defined(vsnprintf) && !defined(NO_vsnprintf)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   200
#      define vsnprintf _vsnprintf
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
#    endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   202
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   203
#  ifdef __SASC
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   204
#    define NO_vsnprintf
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   205
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   206
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   207
#ifdef VMS
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   208
#  define NO_vsnprintf
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   209
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   210
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   211
#if defined(pyr)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
#  define NO_MEMCPY
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   213
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   214
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   215
 /* Use our own functions for small and medium model with MSC <= 5.0.
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   216
  * You may have to use the same strategy for Borland C (untested).
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   217
  * The __SC__ check is for Symantec.
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   218
  */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   219
#  define NO_MEMCPY
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   220
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
#  define HAVE_MEMCPY
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   224
#ifdef HAVE_MEMCPY
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
#  ifdef SMALL_MEDIUM /* MSDOS small or medium model */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
#    define zmemcpy _fmemcpy
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   227
#    define zmemcmp _fmemcmp
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   228
#    define zmemzero(dest, len) _fmemset(dest, 0, len)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   229
#  else
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   230
#    define zmemcpy memcpy
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   231
#    define zmemcmp memcmp
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   232
#    define zmemzero(dest, len) memset(dest, 0, len)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   233
#  endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   234
#else
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   235
   extern void zmemcpy  OF((Bytef* dest, const Bytef* source, uInt len));
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   236
   extern int  zmemcmp  OF((const Bytef* s1, const Bytef* s2, uInt len));
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
   extern void zmemzero OF((Bytef* dest, uInt len));
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   239
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   240
/* Diagnostic functions */
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
#ifdef DEBUG
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   242
#  include <stdio.h>
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
   extern int z_verbose;
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   244
   extern void z_error    OF((char *m));
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
#  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
#  define Trace(x) {if (z_verbose>=0) fprintf x ;}
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   247
#  define Tracev(x) {if (z_verbose>0) fprintf x ;}
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   248
#  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
#  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   250
#  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   251
#else
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   252
#  define Assert(cond,msg)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   253
#  define Trace(x)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   254
#  define Tracev(x)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   255
#  define Tracevv(x)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   256
#  define Tracec(c,x)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   257
#  define Tracecv(c,x)
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   258
#endif
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   259
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   261
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
void   zcfree  OF((voidpf opaque, voidpf ptr));
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   263
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   264
#define ZALLOC(strm, items, size) \
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
           (*((strm)->zalloc))((strm)->opaque, (items), (size))
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   267
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
7b4677a8de6e Moved to zlib 1.2.3 proper.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
#endif /* ZUTIL_H */