TTKMusicPlayer  4.2.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
gzguts.h
Go to the documentation of this file.
1 /* gzguts.h -- zlib internal header definitions for gz* operations
2  * Copyright (C) 2004-2024 Mark Adler
3  * For conditions of distribution and use, see copyright notice in zlib.h
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 #ifdef __APPLE__
38 #include <unistd.h> /* close, read, write etc. */
39 #endif
40 
41 #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
42 # include <io.h>
43 #endif
44 
45 #if defined(_WIN32)
46 # define WIDECHAR
47 #endif
48 
49 #ifdef WINAPI_FAMILY
50 # define open _open
51 # define read _read
52 # define write _write
53 # define close _close
54 #endif
55 
56 #ifdef NO_DEFLATE /* for compatibility with old definition */
57 # define NO_GZCOMPRESS
58 #endif
59 
60 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
61 # ifndef HAVE_VSNPRINTF
62 # define HAVE_VSNPRINTF
63 # endif
64 #endif
65 
66 #if defined(__CYGWIN__)
67 # ifndef HAVE_VSNPRINTF
68 # define HAVE_VSNPRINTF
69 # endif
70 #endif
71 
72 #if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
73 # ifndef HAVE_VSNPRINTF
74 # define HAVE_VSNPRINTF
75 # endif
76 #endif
77 
78 #ifndef HAVE_VSNPRINTF
79 # ifdef MSDOS
80 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
81  but for now we just assume it doesn't. */
82 # define NO_vsnprintf
83 # endif
84 # ifdef __TURBOC__
85 # define NO_vsnprintf
86 # endif
87 # ifdef WIN32
88 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
89 # if !defined(vsnprintf) && !defined(NO_vsnprintf)
90 # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
91 # define vsnprintf _vsnprintf
92 # endif
93 # endif
94 # endif
95 # ifdef __SASC
96 # define NO_vsnprintf
97 # endif
98 # ifdef VMS
99 # define NO_vsnprintf
100 # endif
101 # ifdef __OS400__
102 # define NO_vsnprintf
103 # endif
104 # ifdef __MVS__
105 # define NO_vsnprintf
106 # endif
107 #endif
108 
109 /* unlike snprintf (which is required in C99), _snprintf does not guarantee
110  null termination of the result -- however this is only used in gzlib.c where
111  the result is assured to fit in the space provided */
112 #if defined(_MSC_VER) && _MSC_VER < 1900
113 # define snprintf _snprintf
114 #endif
115 
116 #ifndef local
117 # define local static
118 #endif
119 /* since "static" is used to mean two completely different things in C, we
120  define "local" for the non-static meaning of "static", for readability
121  (compile with -Dlocal if your debugger can't find static symbols) */
122 
123 /* gz* functions always use library allocation functions */
124 #ifndef STDC
125  extern voidp malloc(uInt size);
126  extern void free(voidpf ptr);
127 #endif
128 
129 /* get errno and strerror definition */
130 #if defined UNDER_CE
131 # include <windows.h>
132 # define zstrerror() gz_strwinerror((DWORD)GetLastError())
133 #else
134 # ifndef NO_STRERROR
135 # include <errno.h>
136 # define zstrerror() strerror(errno)
137 # else
138 # define zstrerror() "stdio error (consult errno)"
139 # endif
140 #endif
141 
142 /* provide prototypes for these when building zlib without LFS */
143 #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
144  ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
148 #endif
149 
150 /* default memLevel */
151 #if MAX_MEM_LEVEL >= 8
152 # define DEF_MEM_LEVEL 8
153 #else
154 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
155 #endif
156 
157 /* default i/o buffer size -- double this for output when reading (this and
158  twice this must be able to fit in an unsigned type) */
159 #define GZBUFSIZE 8192
160 
161 /* gzip modes, also provide a little integrity check on the passed structure */
162 #define GZ_NONE 0
163 #define GZ_READ 7247
164 #define GZ_WRITE 31153
165 #define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */
166 
167 /* values for gz_state how */
168 #define LOOK 0 /* look for a gzip header */
169 #define COPY 1 /* copy input directly */
170 #define GZIP 2 /* decompress a gzip stream */
171 
172 /* internal gzip file state data structure */
173 typedef struct {
174  /* exposed contents for gzgetc() macro */
175  struct gzFile_s x; /* "x" for exposed */
176  /* x.have: number of bytes available at x.next */
177  /* x.next: next output data to deliver or write */
178  /* x.pos: current position in uncompressed data */
179  /* used for both reading and writing */
180  int mode; /* see gzip modes above */
181  int fd; /* file descriptor */
182  char *path; /* path or fd for error messages */
183  unsigned size; /* buffer size, zero if not allocated yet */
184  unsigned want; /* requested buffer size, default is GZBUFSIZE */
185  unsigned char *in; /* input buffer (double-sized when writing) */
186  unsigned char *out; /* output buffer (double-sized when reading) */
187  int direct; /* 0 if processing gzip, 1 if transparent */
188  /* just for reading */
189  int how; /* 0: get header, 1: copy, 2: decompress */
190  z_off64_t start; /* where the gzip data started, for rewinding */
191  int eof; /* true if end of input file reached */
192  int past; /* true if read requested past end */
193  /* just for writing */
194  int level; /* compression level */
195  int strategy; /* compression strategy */
196  int reset; /* true if a reset is pending after a Z_FINISH */
197  /* seek request */
198  z_off64_t skip; /* amount to skip (already rewound if backwards) */
199  int seek; /* true if seek request pending */
200  /* error information */
201  int err; /* error code */
202  char *msg; /* error message */
203  /* zlib inflate or deflate stream */
204  z_stream strm; /* stream structure in-place (not a pointer) */
205 } gz_state;
207 
208 /* shared functions */
209 void ZLIB_INTERNAL gz_error(gz_statep, int, const char *);
210 #if defined UNDER_CE
211 char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
212 #endif
213 
214 /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
215  value -- needed when comparing unsigned to z_off64_t, which is signed
216  (possible z_off64_t types off_t, off64_t, and long are all signed) */
217 unsigned ZLIB_INTERNAL gz_intmax(void);
218 #define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
int err
Definition: gzguts.h:201
char * path
Definition: gzguts.h:182
#define z_off64_t
Definition: zconf.h:522
voidpf void uLong size
Definition: ioapi.h:136
int mode
Definition: gzguts.h:180
unsigned ZLIB_INTERNAL gz_intmax(void)
Definition: gzlib.c:570
z_stream strm
Definition: gzguts.h:204
int fd
Definition: gzguts.h:181
int eof
Definition: gzguts.h:191
z_off64_t skip
Definition: gzguts.h:198
unsigned char * in
Definition: gzguts.h:185
unsigned size
Definition: gzguts.h:183
char * msg
Definition: gzguts.h:202
unsigned want
Definition: gzguts.h:184
Byte * voidp
Definition: zconf.h:416
void ZLIB_INTERNAL gz_error(gz_statep, int, const char *)
Definition: gzlib.c:529
int seek
Definition: gzguts.h:199
ZEXTERN z_off64_t ZEXPORT gztell64(gzFile)
Definition: gzlib.c:420
z_off64_t start
Definition: gzguts.h:190
#define ZEXTERN
Definition: zconf.h:379
Byte FAR * voidpf
Definition: zconf.h:415
int strategy
Definition: gzguts.h:195
int past
Definition: gzguts.h:192
int level
Definition: gzguts.h:194
#define ZLIB_INTERNAL
Definition: gzguts.h:17
ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int)
Definition: gzlib.c:339
int reset
Definition: gzguts.h:196
void free(voidpf ptr)
gz_state FAR * gz_statep
Definition: gzguts.h:206
ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile)
Definition: gzlib.c:443
#define FAR
Definition: zconf.h:389
int direct
Definition: gzguts.h:187
voidp malloc(uInt size)
unsigned char * out
Definition: gzguts.h:186
int how
Definition: gzguts.h:189
#define ZEXPORT
Definition: zconf.h:382
unsigned int uInt
Definition: zconf.h:395
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *)
Definition: gzlib.c:265