sdk-world
v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Toggle main menu visibility
Loading...
Searching...
No Matches
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
10
#ifdef _LARGEFILE64_SOURCE
11
# ifndef _LARGEFILE_SOURCE
12
# define _LARGEFILE_SOURCE 1
13
# endif
14
# undef _FILE_OFFSET_BITS
15
# undef _TIME_BITS
16
#endif
17
18
#ifdef HAVE_HIDDEN
19
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
20
#else
21
# define ZLIB_INTERNAL
22
#endif
23
24
#include <stdio.h>
25
#include "zlib.h"
26
#ifdef STDC
27
# include <string.h>
28
# include <stdlib.h>
29
# include <limits.h>
30
#endif
31
32
#ifndef _POSIX_SOURCE
33
# define _POSIX_SOURCE
34
#endif
35
#include <fcntl.h>
36
37
#ifdef _WIN32
38
# include <stddef.h>
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
*);
145
ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t,
int
);
146
ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
147
ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
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
;
206
typedef
gz_state
FAR *gz_statep;
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())
gzFile_s
Definition
zlib.h:1869
gz_state
Definition
gzguts.h:173
zlib
src
gzguts.h
Generated by
1.18.0