| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#ifdef _LARGEFILE64_SOURCE |
| 7 |
# ifndef _LARGEFILE_SOURCE |
| 8 |
# define _LARGEFILE_SOURCE 1 |
| 9 |
# endif |
| 10 |
# undef _FILE_OFFSET_BITS |
| 11 |
# undef _TIME_BITS |
| 12 |
#endif |
| 13 |
|
| 14 |
#ifdef HAVE_HIDDEN |
| 15 |
# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) |
| 16 |
#else |
| 17 |
# define ZLIB_INTERNAL |
| 18 |
#endif |
| 19 |
|
| 20 |
#include <stdio.h> |
| 21 |
#include "zlib.h" |
| 22 |
#ifdef STDC |
| 23 |
# include <string.h> |
| 24 |
# include <stdlib.h> |
| 25 |
# include <limits.h> |
| 26 |
#endif |
| 27 |
|
| 28 |
#ifndef _POSIX_SOURCE |
| 29 |
# define _POSIX_SOURCE |
| 30 |
#endif |
| 31 |
#include <fcntl.h> |
| 32 |
|
| 33 |
#ifdef _WIN32 |
| 34 |
# include <stddef.h> |
| 35 |
#endif |
| 36 |
|
| 37 |
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) |
| 38 |
# include <io.h> |
| 39 |
#endif |
| 40 |
|
| 41 |
#if defined(_WIN32) |
| 42 |
# define WIDECHAR |
| 43 |
#endif |
| 44 |
|
| 45 |
#ifdef WINAPI_FAMILY |
| 46 |
# define open _open |
| 47 |
# define read _read |
| 48 |
# define write _write |
| 49 |
# define close _close |
| 50 |
#endif |
| 51 |
|
| 52 |
#ifdef NO_DEFLATE |
| 53 |
# define NO_GZCOMPRESS |
| 54 |
#endif |
| 55 |
|
| 56 |
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) |
| 57 |
# ifndef HAVE_VSNPRINTF |
| 58 |
# define HAVE_VSNPRINTF |
| 59 |
# endif |
| 60 |
#endif |
| 61 |
|
| 62 |
#if defined(__CYGWIN__) |
| 63 |
# ifndef HAVE_VSNPRINTF |
| 64 |
# define HAVE_VSNPRINTF |
| 65 |
# endif |
| 66 |
#endif |
| 67 |
|
| 68 |
#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) |
| 69 |
# ifndef HAVE_VSNPRINTF |
| 70 |
# define HAVE_VSNPRINTF |
| 71 |
# endif |
| 72 |
#endif |
| 73 |
|
| 74 |
#ifndef HAVE_VSNPRINTF |
| 75 |
# ifdef MSDOS |
| 76 |
|
| 77 |
|
| 78 |
# define NO_vsnprintf |
| 79 |
# endif |
| 80 |
# ifdef __TURBOC__ |
| 81 |
# define NO_vsnprintf |
| 82 |
# endif |
| 83 |
# ifdef WIN32 |
| 84 |
|
| 85 |
# if !defined(vsnprintf) && !defined(NO_vsnprintf) |
| 86 |
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) |
| 87 |
# define vsnprintf _vsnprintf |
| 88 |
# endif |
| 89 |
# endif |
| 90 |
# endif |
| 91 |
# ifdef __SASC |
| 92 |
# define NO_vsnprintf |
| 93 |
# endif |
| 94 |
# ifdef VMS |
| 95 |
# define NO_vsnprintf |
| 96 |
# endif |
| 97 |
# ifdef __OS400__ |
| 98 |
# define NO_vsnprintf |
| 99 |
# endif |
| 100 |
# ifdef __MVS__ |
| 101 |
# define NO_vsnprintf |
| 102 |
# endif |
| 103 |
#endif |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
#if defined(_MSC_VER) && _MSC_VER < 1900 |
| 109 |
# define snprintf _snprintf |
| 110 |
#endif |
| 111 |
|
| 112 |
#ifndef local |
| 113 |
# define local static |
| 114 |
#endif |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
#ifndef STDC |
| 121 |
extern voidp malloc(uInt size); |
| 122 |
extern void free(voidpf ptr); |
| 123 |
#endif |
| 124 |
|
| 125 |
|
| 126 |
#if defined UNDER_CE |
| 127 |
# include <windows.h> |
| 128 |
# define zstrerror() gz_strwinerror((DWORD)GetLastError()) |
| 129 |
#else |
| 130 |
# ifndef NO_STRERROR |
| 131 |
# include <errno.h> |
| 132 |
# define zstrerror() strerror(errno) |
| 133 |
# else |
| 134 |
# define zstrerror() "stdio error (consult errno)" |
| 135 |
# endif |
| 136 |
#endif |
| 137 |
|
| 138 |
|
| 139 |
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 |
| 140 |
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); |
| 141 |
ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); |
| 142 |
ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); |
| 143 |
ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); |
| 144 |
#endif |
| 145 |
|
| 146 |
|
| 147 |
#if MAX_MEM_LEVEL >= 8 |
| 148 |
# define DEF_MEM_LEVEL 8 |
| 149 |
#else |
| 150 |
# define DEF_MEM_LEVEL MAX_MEM_LEVEL |
| 151 |
#endif |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
#define GZBUFSIZE 8192 |
| 156 |
|
| 157 |
|
| 158 |
#define GZ_NONE 0 |
| 159 |
#define GZ_READ 7247 |
| 160 |
#define GZ_WRITE 31153 |
| 161 |
#define GZ_APPEND 1 |
| 162 |
|
| 163 |
|
| 164 |
#define LOOK 0 |
| 165 |
#define COPY 1 |
| 166 |
#define GZIP 2 |
| 167 |
|
| 168 |
|
| 169 |
typedef struct { |
| 170 |
|
| 171 |
struct gzFile_s x; |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
int mode; |
| 177 |
int fd; |
| 178 |
char *path; |
| 179 |
unsigned size; |
| 180 |
unsigned want; |
| 181 |
unsigned char *in; |
| 182 |
unsigned char *out; |
| 183 |
int direct; |
| 184 |
|
| 185 |
int how; |
| 186 |
z_off64_t start; |
| 187 |
int eof; |
| 188 |
int past; |
| 189 |
|
| 190 |
int level; |
| 191 |
int strategy; |
| 192 |
int reset; |
| 193 |
|
| 194 |
z_off64_t skip; |
| 195 |
int seek; |
| 196 |
|
| 197 |
int err; |
| 198 |
char *msg; |
| 199 |
|
| 200 |
z_stream strm; |
| 201 |
} gz_state; |
| 202 |
typedef gz_state FAR *gz_statep; |
| 203 |
|
| 204 |
|
| 205 |
void ZLIB_INTERNAL gz_error(gz_statep, int, const char *); |
| 206 |
#if defined UNDER_CE |
| 207 |
char ZLIB_INTERNAL *gz_strwinerror(DWORD error); |
| 208 |
#endif |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
unsigned ZLIB_INTERNAL gz_intmax(void); |
| 214 |
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) |