annotate src/zlib-1.2.8/gzguts.h @ 56:af97cad61ff0

Add updated build of PortAudio for OSX
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 03 Jan 2017 15:10:52 +0000
parents 5ea0608b923f
children
rev   line source
Chris@43 1 /* gzguts.h -- zlib internal header definitions for gz* operations
Chris@43 2 * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
Chris@43 3 * For conditions of distribution and use, see copyright notice in zlib.h
Chris@43 4 */
Chris@43 5
Chris@43 6 #ifdef _LARGEFILE64_SOURCE
Chris@43 7 # ifndef _LARGEFILE_SOURCE
Chris@43 8 # define _LARGEFILE_SOURCE 1
Chris@43 9 # endif
Chris@43 10 # ifdef _FILE_OFFSET_BITS
Chris@43 11 # undef _FILE_OFFSET_BITS
Chris@43 12 # endif
Chris@43 13 #endif
Chris@43 14
Chris@43 15 #ifdef HAVE_HIDDEN
Chris@43 16 # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
Chris@43 17 #else
Chris@43 18 # define ZLIB_INTERNAL
Chris@43 19 #endif
Chris@43 20
Chris@43 21 #include <stdio.h>
Chris@43 22 #include "zlib.h"
Chris@43 23 #ifdef STDC
Chris@43 24 # include <string.h>
Chris@43 25 # include <stdlib.h>
Chris@43 26 # include <limits.h>
Chris@43 27 #endif
Chris@43 28 #include <fcntl.h>
Chris@43 29
Chris@43 30 #ifdef _WIN32
Chris@43 31 # include <stddef.h>
Chris@43 32 #endif
Chris@43 33
Chris@43 34 #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
Chris@43 35 # include <io.h>
Chris@43 36 #endif
Chris@43 37
Chris@43 38 #ifdef WINAPI_FAMILY
Chris@43 39 # define open _open
Chris@43 40 # define read _read
Chris@43 41 # define write _write
Chris@43 42 # define close _close
Chris@43 43 #endif
Chris@43 44
Chris@43 45 #ifdef NO_DEFLATE /* for compatibility with old definition */
Chris@43 46 # define NO_GZCOMPRESS
Chris@43 47 #endif
Chris@43 48
Chris@43 49 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
Chris@43 50 # ifndef HAVE_VSNPRINTF
Chris@43 51 # define HAVE_VSNPRINTF
Chris@43 52 # endif
Chris@43 53 #endif
Chris@43 54
Chris@43 55 #if defined(__CYGWIN__)
Chris@43 56 # ifndef HAVE_VSNPRINTF
Chris@43 57 # define HAVE_VSNPRINTF
Chris@43 58 # endif
Chris@43 59 #endif
Chris@43 60
Chris@43 61 #if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
Chris@43 62 # ifndef HAVE_VSNPRINTF
Chris@43 63 # define HAVE_VSNPRINTF
Chris@43 64 # endif
Chris@43 65 #endif
Chris@43 66
Chris@43 67 #ifndef HAVE_VSNPRINTF
Chris@43 68 # ifdef MSDOS
Chris@43 69 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
Chris@43 70 but for now we just assume it doesn't. */
Chris@43 71 # define NO_vsnprintf
Chris@43 72 # endif
Chris@43 73 # ifdef __TURBOC__
Chris@43 74 # define NO_vsnprintf
Chris@43 75 # endif
Chris@43 76 # ifdef WIN32
Chris@43 77 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
Chris@43 78 # if !defined(vsnprintf) && !defined(NO_vsnprintf)
Chris@43 79 # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
Chris@43 80 # define vsnprintf _vsnprintf
Chris@43 81 # endif
Chris@43 82 # endif
Chris@43 83 # endif
Chris@43 84 # ifdef __SASC
Chris@43 85 # define NO_vsnprintf
Chris@43 86 # endif
Chris@43 87 # ifdef VMS
Chris@43 88 # define NO_vsnprintf
Chris@43 89 # endif
Chris@43 90 # ifdef __OS400__
Chris@43 91 # define NO_vsnprintf
Chris@43 92 # endif
Chris@43 93 # ifdef __MVS__
Chris@43 94 # define NO_vsnprintf
Chris@43 95 # endif
Chris@43 96 #endif
Chris@43 97
Chris@43 98 /* unlike snprintf (which is required in C99, yet still not supported by
Chris@43 99 Microsoft more than a decade later!), _snprintf does not guarantee null
Chris@43 100 termination of the result -- however this is only used in gzlib.c where
Chris@43 101 the result is assured to fit in the space provided */
Chris@43 102 #ifdef _MSC_VER
Chris@43 103 # define snprintf _snprintf
Chris@43 104 #endif
Chris@43 105
Chris@43 106 #ifndef local
Chris@43 107 # define local static
Chris@43 108 #endif
Chris@43 109 /* compile with -Dlocal if your debugger can't find static symbols */
Chris@43 110
Chris@43 111 /* gz* functions always use library allocation functions */
Chris@43 112 #ifndef STDC
Chris@43 113 extern voidp malloc OF((uInt size));
Chris@43 114 extern void free OF((voidpf ptr));
Chris@43 115 #endif
Chris@43 116
Chris@43 117 /* get errno and strerror definition */
Chris@43 118 #if defined UNDER_CE
Chris@43 119 # include <windows.h>
Chris@43 120 # define zstrerror() gz_strwinerror((DWORD)GetLastError())
Chris@43 121 #else
Chris@43 122 # ifndef NO_STRERROR
Chris@43 123 # include <errno.h>
Chris@43 124 # define zstrerror() strerror(errno)
Chris@43 125 # else
Chris@43 126 # define zstrerror() "stdio error (consult errno)"
Chris@43 127 # endif
Chris@43 128 #endif
Chris@43 129
Chris@43 130 /* provide prototypes for these when building zlib without LFS */
Chris@43 131 #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
Chris@43 132 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
Chris@43 133 ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
Chris@43 134 ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
Chris@43 135 ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
Chris@43 136 #endif
Chris@43 137
Chris@43 138 /* default memLevel */
Chris@43 139 #if MAX_MEM_LEVEL >= 8
Chris@43 140 # define DEF_MEM_LEVEL 8
Chris@43 141 #else
Chris@43 142 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
Chris@43 143 #endif
Chris@43 144
Chris@43 145 /* default i/o buffer size -- double this for output when reading (this and
Chris@43 146 twice this must be able to fit in an unsigned type) */
Chris@43 147 #define GZBUFSIZE 8192
Chris@43 148
Chris@43 149 /* gzip modes, also provide a little integrity check on the passed structure */
Chris@43 150 #define GZ_NONE 0
Chris@43 151 #define GZ_READ 7247
Chris@43 152 #define GZ_WRITE 31153
Chris@43 153 #define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */
Chris@43 154
Chris@43 155 /* values for gz_state how */
Chris@43 156 #define LOOK 0 /* look for a gzip header */
Chris@43 157 #define COPY 1 /* copy input directly */
Chris@43 158 #define GZIP 2 /* decompress a gzip stream */
Chris@43 159
Chris@43 160 /* internal gzip file state data structure */
Chris@43 161 typedef struct {
Chris@43 162 /* exposed contents for gzgetc() macro */
Chris@43 163 struct gzFile_s x; /* "x" for exposed */
Chris@43 164 /* x.have: number of bytes available at x.next */
Chris@43 165 /* x.next: next output data to deliver or write */
Chris@43 166 /* x.pos: current position in uncompressed data */
Chris@43 167 /* used for both reading and writing */
Chris@43 168 int mode; /* see gzip modes above */
Chris@43 169 int fd; /* file descriptor */
Chris@43 170 char *path; /* path or fd for error messages */
Chris@43 171 unsigned size; /* buffer size, zero if not allocated yet */
Chris@43 172 unsigned want; /* requested buffer size, default is GZBUFSIZE */
Chris@43 173 unsigned char *in; /* input buffer */
Chris@43 174 unsigned char *out; /* output buffer (double-sized when reading) */
Chris@43 175 int direct; /* 0 if processing gzip, 1 if transparent */
Chris@43 176 /* just for reading */
Chris@43 177 int how; /* 0: get header, 1: copy, 2: decompress */
Chris@43 178 z_off64_t start; /* where the gzip data started, for rewinding */
Chris@43 179 int eof; /* true if end of input file reached */
Chris@43 180 int past; /* true if read requested past end */
Chris@43 181 /* just for writing */
Chris@43 182 int level; /* compression level */
Chris@43 183 int strategy; /* compression strategy */
Chris@43 184 /* seek request */
Chris@43 185 z_off64_t skip; /* amount to skip (already rewound if backwards) */
Chris@43 186 int seek; /* true if seek request pending */
Chris@43 187 /* error information */
Chris@43 188 int err; /* error code */
Chris@43 189 char *msg; /* error message */
Chris@43 190 /* zlib inflate or deflate stream */
Chris@43 191 z_stream strm; /* stream structure in-place (not a pointer) */
Chris@43 192 } gz_state;
Chris@43 193 typedef gz_state FAR *gz_statep;
Chris@43 194
Chris@43 195 /* shared functions */
Chris@43 196 void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
Chris@43 197 #if defined UNDER_CE
Chris@43 198 char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
Chris@43 199 #endif
Chris@43 200
Chris@43 201 /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
Chris@43 202 value -- needed when comparing unsigned to z_off64_t, which is signed
Chris@43 203 (possible z_off64_t types off_t, off64_t, and long are all signed) */
Chris@43 204 #ifdef INT_MAX
Chris@43 205 # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
Chris@43 206 #else
Chris@43 207 unsigned ZLIB_INTERNAL gz_intmax OF((void));
Chris@43 208 # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
Chris@43 209 #endif