VirtualBox

source: vbox/trunk/src/libs/zlib-1.2.13/gzguts.h@ 98103

Last change on this file since 98103 was 97809, checked in by vboxsync, 2 years ago

libs/zlib: fixed incorrect change tagging. bugref:10261

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette