annotate src/zlib-1.2.8/gzguts.h @ 169:223a55898ab9 tip default

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