File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / rsync / zlib / zutil.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Fri Feb 17 15:09:30 2012 UTC (12 years, 5 months ago) by misho
Branches: rsync, MAIN
CVS tags: rsync3_0_9p0, RSYNC3_0_9, HEAD
rsync

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>