zenilib
0.5.3.0
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
uncompr.c
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$ */
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
(dest, destLen,
source
, sourceLen)
25
Bytef
*dest;
26
uLongf
*destLen;
27
const
Bytef
*
source
;
28
uLong
sourceLen;
29
{
30
z_stream
stream
;
31
int
err;
32
33
stream.
next_in
= (
Bytef
*)source;
34
stream.
avail_in
= (
uInt
)sourceLen;
35
/* Check for source > 64K on 16-bit machine: */
36
if
((
uLong
)stream.
avail_in
!= sourceLen)
return
Z_BUF_ERROR
;
37
38
stream.
next_out
= dest;
39
stream.
avail_out
= (
uInt
)*destLen;
40
if
((
uLong
)stream.
avail_out
!= *destLen)
return
Z_BUF_ERROR
;
41
42
stream.
zalloc
= (alloc_func)0;
43
stream.
zfree
= (free_func)0;
44
45
err =
inflateInit
(&stream);
46
if
(err !=
Z_OK
)
return
err;
47
48
err =
inflate
(&stream,
Z_FINISH
);
49
if
(err !=
Z_STREAM_END
) {
50
inflateEnd
(&stream);
51
if
(err ==
Z_NEED_DICT
|| (err ==
Z_BUF_ERROR
&& stream.
avail_in
== 0))
52
return
Z_DATA_ERROR
;
53
return
err;
54
}
55
*destLen = stream.
total_out
;
56
57
err =
inflateEnd
(&stream);
58
return
err;
59
}
uLong
unsigned long uLong
Definition:
zconf.h:222
uLongf
uLong FAR uLongf
Definition:
zconf.h:233
uncompress
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition:
uncompr.c:24
Bytef
Byte FAR Bytef
Definition:
zconf.h:228
inflateEnd
int ZEXPORT inflateEnd(z_streamp strm)
Definition:
inflate.c:1238
stream
GLuint GLuint stream
Definition:
glew.h:6573
z_stream_s::avail_in
uInt avail_in
Definition:
zlib.h:70
Z_DATA_ERROR
#define Z_DATA_ERROR
Definition:
zlib.h:137
ZEXPORT
#define ZEXPORT(x)
Definition:
zconf.h:202
uInt
unsigned int uInt
Definition:
zconf.h:221
Z_BUF_ERROR
#define Z_BUF_ERROR
Definition:
zlib.h:139
z_stream_s::zfree
free_func zfree
Definition:
zlib.h:81
Z_OK
#define Z_OK
Definition:
zlib.h:132
Z_FINISH
#define Z_FINISH
Definition:
zlib.h:129
Z_NEED_DICT
#define Z_NEED_DICT
Definition:
zlib.h:134
z_stream_s::zalloc
alloc_func zalloc
Definition:
zlib.h:80
inflate
int ZEXPORT inflate(z_streamp strm, int flush)
Definition:
inflate.c:589
z_stream_s::next_in
Bytef * next_in
Definition:
zlib.h:69
z_stream_s::total_out
uLong total_out
Definition:
zlib.h:75
Z_STREAM_END
#define Z_STREAM_END
Definition:
zlib.h:133
const
#define const
Definition:
zconf.h:91
inflateInit
#define inflateInit(strm)
Definition:
zlib.h:817
z_stream_s::avail_out
uInt avail_out
Definition:
zlib.h:74
zlib.h
z_stream_s::next_out
Bytef * next_out
Definition:
zlib.h:73
source
GLsizei GLsizei GLchar * source
Definition:
gl2ext.h:994
z_stream_s
Definition:
zlib.h:68
zenilib
jni
external
zlib
uncompr.c
Generated on Thu Oct 3 2013 19:56:51 for zenilib by
1.8.5