annotate src/zlib-1.2.7/gzguts.h @ 83:ae30d91d2ffe

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