Biomedical Image Analysis Library
The Biomedical Image Analysis Library is a poweful tool for developers, physicians, researchers, engineers, and so on.
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
gzguts.h
Go to the documentation of this file.
1
/* gzguts.h -- zlib internal header definitions for gz* operations
2
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 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
#include <stdio.h>
22
#include <unistd.h>
23
#include "
zlib.h
"
24
#ifdef STDC
25
# include <string.h>
26
# include <stdlib.h>
27
# include <limits.h>
28
#endif
29
#include <fcntl.h>
30
31
#ifdef _WIN32
32
# include <stddef.h>
33
#endif
34
35
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
36
# include <io.h>
37
#endif
38
39
#ifdef WINAPI_FAMILY
40
# define open _open
41
# define read _read
42
# define write _write
43
# define close _close
44
#endif
45
46
#ifdef NO_DEFLATE
/* for compatibility with old definition */
47
# define NO_GZCOMPRESS
48
#endif
49
50
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
51
# ifndef HAVE_VSNPRINTF
52
# define HAVE_VSNPRINTF
53
# endif
54
#endif
55
56
#if defined(__CYGWIN__)
57
# ifndef HAVE_VSNPRINTF
58
# define HAVE_VSNPRINTF
59
# endif
60
#endif
61
62
#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
63
# ifndef HAVE_VSNPRINTF
64
# define HAVE_VSNPRINTF
65
# endif
66
#endif
67
68
#ifndef HAVE_VSNPRINTF
69
# ifdef MSDOS
70
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
71
but for now we just assume it doesn't. */
72
# define NO_vsnprintf
73
# endif
74
# ifdef __TURBOC__
75
# define NO_vsnprintf
76
# endif
77
# ifdef WIN32
78
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
79
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
80
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
81
# define vsnprintf _vsnprintf
82
# endif
83
# endif
84
# endif
85
# ifdef __SASC
86
# define NO_vsnprintf
87
# endif
88
# ifdef VMS
89
# define NO_vsnprintf
90
# endif
91
# ifdef __OS400__
92
# define NO_vsnprintf
93
# endif
94
# ifdef __MVS__
95
# define NO_vsnprintf
96
# endif
97
#endif
98
99
/* unlike snprintf (which is required in C99, yet still not supported by
100
Microsoft more than a decade later!), _snprintf does not guarantee null
101
termination of the result -- however this is only used in gzlib.c where
102
the result is assured to fit in the space provided */
103
#ifdef _MSC_VER
104
# define snprintf _snprintf
105
#endif
106
107
#ifndef local
108
# define local static
109
#endif
110
/* compile with -Dlocal if your debugger can't find static symbols */
111
112
/* gz* functions always use library allocation functions */
113
#ifndef STDC
114
extern
voidp
malloc
OF
((
uInt
size
));
115
extern
void
free
OF
((
voidpf
ptr));
116
#endif
117
118
/* get errno and strerror definition */
119
#if defined UNDER_CE
120
# include <windows.h>
121
# define zstrerror() gz_strwinerror((DWORD)GetLastError())
122
#else
123
# ifndef NO_STRERROR
124
# include <errno.h>
125
# define zstrerror() strerror(errno)
126
# else
127
# define zstrerror() "stdio error (consult errno)"
128
# endif
129
#endif
130
131
/* provide prototypes for these when building zlib without LFS */
132
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
133
ZEXTERN
gzFile
ZEXPORT
gzopen64
OF
((
const
char
*,
const
char
*));
134
ZEXTERN
z_off64_t
ZEXPORT
gzseek64
OF
((gzFile,
z_off64_t
,
int
));
135
ZEXTERN
z_off64_t
ZEXPORT
gztell64
OF
((gzFile));
136
ZEXTERN
z_off64_t
ZEXPORT
gzoffset64
OF
((gzFile));
137
#endif
138
139
/* default memLevel */
140
#if MAX_MEM_LEVEL >= 8
141
# define DEF_MEM_LEVEL 8
142
#else
143
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
144
#endif
145
146
/* default i/o buffer size -- double this for output when reading (this and
147
twice this must be able to fit in an unsigned type) */
148
#define GZBUFSIZE 8192
149
150
/* gzip modes, also provide a little integrity check on the passed structure */
151
#define GZ_NONE 0
152
#define GZ_READ 7247
153
#define GZ_WRITE 31153
154
#define GZ_APPEND 1
/* mode set to GZ_WRITE after the file is opened */
155
156
/* values for gz_state how */
157
#define LOOK 0
/* look for a gzip header */
158
#define COPY 1
/* copy input directly */
159
#define GZIP 2
/* decompress a gzip stream */
160
161
/* internal gzip file state data structure */
162
typedef
struct
{
163
/* exposed contents for gzgetc() macro */
164
struct
gzFile_s
x;
/* "x" for exposed */
165
/* x.have: number of bytes available at x.next */
166
/* x.next: next output data to deliver or write */
167
/* x.pos: current position in uncompressed data */
168
/* used for both reading and writing */
169
int
mode
;
/* see gzip modes above */
170
int
fd
;
/* file descriptor */
171
char
*
path
;
/* path or fd for error messages */
172
unsigned
size
;
/* buffer size, zero if not allocated yet */
173
unsigned
want
;
/* requested buffer size, default is GZBUFSIZE */
174
unsigned
char
*
in
;
/* input buffer */
175
unsigned
char
*
out
;
/* output buffer (double-sized when reading) */
176
int
direct
;
/* 0 if processing gzip, 1 if transparent */
177
/* just for reading */
178
int
how
;
/* 0: get header, 1: copy, 2: decompress */
179
z_off64_t
start
;
/* where the gzip data started, for rewinding */
180
int
eof
;
/* true if end of input file reached */
181
int
past
;
/* true if read requested past end */
182
/* just for writing */
183
int
level
;
/* compression level */
184
int
strategy
;
/* compression strategy */
185
/* seek request */
186
z_off64_t
skip
;
/* amount to skip (already rewound if backwards) */
187
int
seek
;
/* true if seek request pending */
188
/* error information */
189
int
err
;
/* error code */
190
char
*
msg
;
/* error message */
191
/* zlib inflate or deflate stream */
192
z_stream
strm
;
/* stream structure in-place (not a pointer) */
193
}
gz_state
;
194
typedef
gz_state
FAR
*
gz_statep
;
195
196
/* shared functions */
197
void
ZLIB_INTERNAL
gz_error
OF
((gz_statep,
int
,
const
char
*));
198
#if defined UNDER_CE
199
char
ZLIB_INTERNAL
*gz_strwinerror
OF
((DWORD
error
));
200
#endif
201
202
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
203
value -- needed when comparing unsigned to z_off64_t, which is signed
204
(possible z_off64_t types off_t, off64_t, and long are all signed) */
205
#ifdef INT_MAX
206
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
207
#else
208
unsigned
ZLIB_INTERNAL
gz_intmax
OF
((
void
));
209
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
210
#endif
OF
#define OF(args)
Definition:
zconf.h:269
gz_error
void gz_error()
gz_state::err
int err
Definition:
gzguts.h:189
gz_state::want
unsigned want
Definition:
gzguts.h:173
gzopen64
gzFile gzopen64()
gz_state
Definition:
gzguts.h:162
gz_state::past
int past
Definition:
gzguts.h:181
gzseek64
long gzseek64()
z_off64_t
#define z_off64_t
Definition:
zconf.h:490
gz_state::mode
int mode
Definition:
gzguts.h:169
voidpf
Byte * voidpf
Definition:
zconf.h:390
gz_state::in
unsigned char * in
Definition:
gzguts.h:174
gz_state::how
int how
Definition:
gzguts.h:178
free
void free()
gz_state::fd
int fd
Definition:
gzguts.h:170
size
static size_t size
Definition:
enough.c:173
gz_state::msg
char * msg
Definition:
gzguts.h:190
gz_intmax
unsigned gz_intmax()
Definition:
gzlib.c:622
gz_state::skip
long skip
Definition:
gzguts.h:186
gz_state::strm
z_stream strm
Definition:
gzguts.h:192
gz_state::level
int level
Definition:
gzguts.h:183
zlib.h
gz_state::path
char * path
Definition:
gzguts.h:171
gzoffset64
long gzoffset64()
error
void error(const char *msg)
Definition:
untgz.c:593
gzFile_s
Definition:
zlib.h:1670
z_stream
Definition:
zlib.h:85
gz_state::out
unsigned char * out
Definition:
gzguts.h:175
voidp
Byte * voidp
Definition:
zconf.h:391
gz_state::start
long start
Definition:
gzguts.h:179
ZEXTERN
#define ZEXTERN
Definition:
zconf.h:354
gz_statep
gz_state * gz_statep
Definition:
gzguts.h:194
ZLIB_INTERNAL
#define ZLIB_INTERNAL
Definition:
gzguts.h:18
gztell64
long gztell64()
FAR
#define FAR
Definition:
zconf.h:364
gz_state::seek
int seek
Definition:
gzguts.h:187
gz_state::direct
int direct
Definition:
gzguts.h:176
gz_state::size
unsigned size
Definition:
gzguts.h:172
ZEXPORT
#define ZEXPORT
Definition:
zconf.h:357
gz_state::eof
int eof
Definition:
gzguts.h:180
malloc
voidp malloc()
uInt
unsigned int uInt
Definition:
zconf.h:370
gz_state::strategy
int strategy
Definition:
gzguts.h:184
bial
zlib
gzguts.h
Generated by
1.8.11