Geant4_10
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
source
source
externals
zlib
src
uncompr.cc
Go to the documentation of this file.
1
/* uncompr.c -- decompress a memory buffer
2
* Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
3
* For conditions of distribution and use, see copyright notice in zlib.h
4
*/
5
6
/* @(#) $Id: uncompr.cc 69560 2013-05-08 12:23:51Z gcosmo $ */
7
8
#define ZLIB_INTERNAL
9
#include "
zlib.h
"
10
11
/* ===========================================================================
12
Decompresses the source buffer into the destination buffer. sourceLen is
13
the byte length of the source buffer. Upon entry, destLen is the total
14
size of the destination buffer, which must be large enough to hold the
15
entire uncompressed data. (The size of the uncompressed data must have
16
been saved previously by the compressor and transmitted to the decompressor
17
by some mechanism outside the scope of this compression library.)
18
Upon exit, destLen is the actual size of the compressed buffer.
19
20
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
21
enough memory, Z_BUF_ERROR if there was not enough room in the output
22
buffer, or Z_DATA_ERROR if the input data was corrupted.
23
*/
24
int
ZEXPORT
uncompress
(Bytef *dest, uLongf *destLen,
const
Bytef *source, uLong sourceLen)
25
{
26
z_stream
stream;
27
int
err;
28
29
stream.
next_in
= (Bytef*)source;
30
stream.
avail_in
= (uInt)sourceLen;
31
/* Check for source > 64K on 16-bit machine: */
32
if
((uLong)stream.
avail_in
!= sourceLen)
return
Z_BUF_ERROR
;
33
34
stream.
next_out
= dest;
35
stream.
avail_out
= (uInt)*destLen;
36
if
((uLong)stream.
avail_out
!= *destLen)
return
Z_BUF_ERROR
;
37
38
stream.
zalloc
= (alloc_func)0;
39
stream.
zfree
= (free_func)0;
40
41
err =
inflateInit
(&stream);
42
if
(err !=
Z_OK
)
return
err;
43
44
err =
inflate
(&stream,
Z_FINISH
);
45
if
(err !=
Z_STREAM_END
) {
46
inflateEnd
(&stream);
47
if
(err ==
Z_NEED_DICT
|| (err ==
Z_BUF_ERROR
&& stream.
avail_in
== 0))
48
return
Z_DATA_ERROR
;
49
return
err;
50
}
51
*destLen = stream.
total_out
;
52
53
err =
inflateEnd
(&stream);
54
return
err;
55
}
z_stream_s::avail_in
uInt avail_in
Definition:
zlib.h:87
Z_NEED_DICT
#define Z_NEED_DICT
Definition:
zlib.h:175
z_stream_s::zfree
free_func zfree
Definition:
zlib.h:98
zlib.h
Z_FINISH
#define Z_FINISH
Definition:
zlib.h:168
Z_DATA_ERROR
#define Z_DATA_ERROR
Definition:
zlib.h:178
Z_STREAM_END
#define Z_STREAM_END
Definition:
zlib.h:174
z_stream_s::zalloc
alloc_func zalloc
Definition:
zlib.h:97
z_stream_s::next_out
Bytef * next_out
Definition:
zlib.h:90
uncompress
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition:
uncompr.cc:24
z_stream_s::total_out
uLong total_out
Definition:
zlib.h:92
Z_BUF_ERROR
#define Z_BUF_ERROR
Definition:
zlib.h:180
inflateInit
#define inflateInit(strm)
Definition:
zlib.h:1632
z_stream_s::avail_out
uInt avail_out
Definition:
zlib.h:91
z_stream_s::next_in
z_const Bytef * next_in
Definition:
zlib.h:86
Z_OK
#define Z_OK
Definition:
zlib.h:173
inflateEnd
int ZEXPORT inflateEnd(z_streamp strm)
Definition:
inflate.cc:1234
inflate
int ZEXPORT inflate(z_streamp strm, int flush)
Definition:
inflate.cc:587
z_stream_s
Definition:
zlib.h:85
Generated on Sat Dec 14 2013 14:34:05 for Geant4_10 by
1.8.5