modules/zlib/src/gzguts.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/zlib/src/gzguts.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,209 @@
     1.4 +/* gzguts.h -- zlib internal header definitions for gz* operations
     1.5 + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
     1.6 + * For conditions of distribution and use, see copyright notice in zlib.h
     1.7 + */
     1.8 +
     1.9 +#ifdef _LARGEFILE64_SOURCE
    1.10 +#  ifndef _LARGEFILE_SOURCE
    1.11 +#    define _LARGEFILE_SOURCE 1
    1.12 +#  endif
    1.13 +#  ifdef _FILE_OFFSET_BITS
    1.14 +#    undef _FILE_OFFSET_BITS
    1.15 +#  endif
    1.16 +#endif
    1.17 +
    1.18 +#ifdef HAVE_HIDDEN
    1.19 +#  define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
    1.20 +#else
    1.21 +#  define ZLIB_INTERNAL
    1.22 +#endif
    1.23 +
    1.24 +#include <stdio.h>
    1.25 +#include "zlib.h"
    1.26 +#ifdef STDC
    1.27 +#  include <string.h>
    1.28 +#  include <stdlib.h>
    1.29 +#  include <limits.h>
    1.30 +#endif
    1.31 +#include <fcntl.h>
    1.32 +
    1.33 +#ifdef _WIN32
    1.34 +#  include <stddef.h>
    1.35 +#endif
    1.36 +
    1.37 +#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
    1.38 +#  include <io.h>
    1.39 +#endif
    1.40 +
    1.41 +#ifdef WINAPI_FAMILY
    1.42 +#  define open _open
    1.43 +#  define read _read
    1.44 +#  define write _write
    1.45 +#  define close _close
    1.46 +#endif
    1.47 +
    1.48 +#ifdef NO_DEFLATE       /* for compatibility with old definition */
    1.49 +#  define NO_GZCOMPRESS
    1.50 +#endif
    1.51 +
    1.52 +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
    1.53 +#  ifndef HAVE_VSNPRINTF
    1.54 +#    define HAVE_VSNPRINTF
    1.55 +#  endif
    1.56 +#endif
    1.57 +
    1.58 +#if defined(__CYGWIN__)
    1.59 +#  ifndef HAVE_VSNPRINTF
    1.60 +#    define HAVE_VSNPRINTF
    1.61 +#  endif
    1.62 +#endif
    1.63 +
    1.64 +#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
    1.65 +#  ifndef HAVE_VSNPRINTF
    1.66 +#    define HAVE_VSNPRINTF
    1.67 +#  endif
    1.68 +#endif
    1.69 +
    1.70 +#ifndef HAVE_VSNPRINTF
    1.71 +#  ifdef MSDOS
    1.72 +/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
    1.73 +   but for now we just assume it doesn't. */
    1.74 +#    define NO_vsnprintf
    1.75 +#  endif
    1.76 +#  ifdef __TURBOC__
    1.77 +#    define NO_vsnprintf
    1.78 +#  endif
    1.79 +#  ifdef WIN32
    1.80 +/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
    1.81 +#    if !defined(vsnprintf) && !defined(NO_vsnprintf)
    1.82 +#      if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
    1.83 +#         define vsnprintf _vsnprintf
    1.84 +#      endif
    1.85 +#    endif
    1.86 +#  endif
    1.87 +#  ifdef __SASC
    1.88 +#    define NO_vsnprintf
    1.89 +#  endif
    1.90 +#  ifdef VMS
    1.91 +#    define NO_vsnprintf
    1.92 +#  endif
    1.93 +#  ifdef __OS400__
    1.94 +#    define NO_vsnprintf
    1.95 +#  endif
    1.96 +#  ifdef __MVS__
    1.97 +#    define NO_vsnprintf
    1.98 +#  endif
    1.99 +#endif
   1.100 +
   1.101 +/* unlike snprintf (which is required in C99, yet still not supported by
   1.102 +   Microsoft more than a decade later!), _snprintf does not guarantee null
   1.103 +   termination of the result -- however this is only used in gzlib.c where
   1.104 +   the result is assured to fit in the space provided */
   1.105 +#ifdef _MSC_VER
   1.106 +#  define snprintf _snprintf
   1.107 +#endif
   1.108 +
   1.109 +#ifndef local
   1.110 +#  define local static
   1.111 +#endif
   1.112 +/* compile with -Dlocal if your debugger can't find static symbols */
   1.113 +
   1.114 +/* gz* functions always use library allocation functions */
   1.115 +#ifndef STDC
   1.116 +  extern voidp  malloc OF((uInt size));
   1.117 +  extern void   free   OF((voidpf ptr));
   1.118 +#endif
   1.119 +
   1.120 +/* get errno and strerror definition */
   1.121 +#if defined UNDER_CE
   1.122 +#  include <windows.h>
   1.123 +#  define zstrerror() gz_strwinerror((DWORD)GetLastError())
   1.124 +#else
   1.125 +#  ifndef NO_STRERROR
   1.126 +#    include <errno.h>
   1.127 +#    define zstrerror() strerror(errno)
   1.128 +#  else
   1.129 +#    define zstrerror() "stdio error (consult errno)"
   1.130 +#  endif
   1.131 +#endif
   1.132 +
   1.133 +/* provide prototypes for these when building zlib without LFS */
   1.134 +#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
   1.135 +    ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
   1.136 +    ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
   1.137 +    ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
   1.138 +    ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
   1.139 +#endif
   1.140 +
   1.141 +/* default memLevel */
   1.142 +#if MAX_MEM_LEVEL >= 8
   1.143 +#  define DEF_MEM_LEVEL 8
   1.144 +#else
   1.145 +#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
   1.146 +#endif
   1.147 +
   1.148 +/* default i/o buffer size -- double this for output when reading (this and
   1.149 +   twice this must be able to fit in an unsigned type) */
   1.150 +#define GZBUFSIZE 8192
   1.151 +
   1.152 +/* gzip modes, also provide a little integrity check on the passed structure */
   1.153 +#define GZ_NONE 0
   1.154 +#define GZ_READ 7247
   1.155 +#define GZ_WRITE 31153
   1.156 +#define GZ_APPEND 1     /* mode set to GZ_WRITE after the file is opened */
   1.157 +
   1.158 +/* values for gz_state how */
   1.159 +#define LOOK 0      /* look for a gzip header */
   1.160 +#define COPY 1      /* copy input directly */
   1.161 +#define GZIP 2      /* decompress a gzip stream */
   1.162 +
   1.163 +/* internal gzip file state data structure */
   1.164 +typedef struct {
   1.165 +        /* exposed contents for gzgetc() macro */
   1.166 +    struct gzFile_s x;      /* "x" for exposed */
   1.167 +                            /* x.have: number of bytes available at x.next */
   1.168 +                            /* x.next: next output data to deliver or write */
   1.169 +                            /* x.pos: current position in uncompressed data */
   1.170 +        /* used for both reading and writing */
   1.171 +    int mode;               /* see gzip modes above */
   1.172 +    int fd;                 /* file descriptor */
   1.173 +    char *path;             /* path or fd for error messages */
   1.174 +    unsigned size;          /* buffer size, zero if not allocated yet */
   1.175 +    unsigned want;          /* requested buffer size, default is GZBUFSIZE */
   1.176 +    unsigned char *in;      /* input buffer */
   1.177 +    unsigned char *out;     /* output buffer (double-sized when reading) */
   1.178 +    int direct;             /* 0 if processing gzip, 1 if transparent */
   1.179 +        /* just for reading */
   1.180 +    int how;                /* 0: get header, 1: copy, 2: decompress */
   1.181 +    z_off64_t start;        /* where the gzip data started, for rewinding */
   1.182 +    int eof;                /* true if end of input file reached */
   1.183 +    int past;               /* true if read requested past end */
   1.184 +        /* just for writing */
   1.185 +    int level;              /* compression level */
   1.186 +    int strategy;           /* compression strategy */
   1.187 +        /* seek request */
   1.188 +    z_off64_t skip;         /* amount to skip (already rewound if backwards) */
   1.189 +    int seek;               /* true if seek request pending */
   1.190 +        /* error information */
   1.191 +    int err;                /* error code */
   1.192 +    char *msg;              /* error message */
   1.193 +        /* zlib inflate or deflate stream */
   1.194 +    z_stream strm;          /* stream structure in-place (not a pointer) */
   1.195 +} gz_state;
   1.196 +typedef gz_state FAR *gz_statep;
   1.197 +
   1.198 +/* shared functions */
   1.199 +void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
   1.200 +#if defined UNDER_CE
   1.201 +char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
   1.202 +#endif
   1.203 +
   1.204 +/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
   1.205 +   value -- needed when comparing unsigned to z_off64_t, which is signed
   1.206 +   (possible z_off64_t types off_t, off64_t, and long are all signed) */
   1.207 +#ifdef INT_MAX
   1.208 +#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
   1.209 +#else
   1.210 +unsigned ZLIB_INTERNAL gz_intmax OF((void));
   1.211 +#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
   1.212 +#endif

mercurial