abc-master
Main Page
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
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
#include <stdio.h>
9
#include <stdlib.h>
10
#include <string.h>
11
#include "
misc/util/abc_global.h
"
12
13
#define ZLIB_INTERNAL
14
#include "
zlib.h
"
15
16
ABC_NAMESPACE_IMPL_START
17
18
/* ===========================================================================
19
Decompresses the source buffer into the destination buffer. sourceLen is
20
the byte length of the source buffer. Upon entry, destLen is the total
21
size of the destination buffer, which must be large enough to hold the
22
entire uncompressed data. (The size of the uncompressed data must have
23
been saved previously by the compressor and transmitted to the decompressor
24
by some mechanism outside the scope of this compression library.)
25
Upon exit, destLen is the actual size of the compressed buffer.
26
27
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
28
enough memory, Z_BUF_ERROR if there was not enough room in the output
29
buffer, or Z_DATA_ERROR if the input data was corrupted.
30
*/
31
int
ZEXPORT
uncompress
(
Bytef
*dest,
uLongf
*destLen,
const
Bytef
*source,
uLong
sourceLen)
32
{
33
z_stream
stream;
34
int
err;
35
36
stream.
next_in
= (
Bytef
*)source;
37
stream.
avail_in
= (
uInt
)sourceLen;
38
/* Check for source > 64K on 16-bit machine: */
39
if
((
uLong
)stream.
avail_in
!= sourceLen)
return
Z_BUF_ERROR
;
40
41
stream.
next_out
= dest;
42
stream.
avail_out
= (
uInt
)*destLen;
43
if
((
uLong
)stream.
avail_out
!= *destLen)
return
Z_BUF_ERROR
;
44
45
stream.
zalloc
= (alloc_func)0;
46
stream.
zfree
= (free_func)0;
47
48
err =
inflateInit
(&stream);
49
if
(err !=
Z_OK
)
return
err;
50
51
err =
inflate
(&stream,
Z_FINISH
);
52
if
(err !=
Z_STREAM_END
) {
53
inflateEnd
(&stream);
54
if
(err ==
Z_NEED_DICT
|| (err ==
Z_BUF_ERROR
&& stream.
avail_in
== 0))
55
return
Z_DATA_ERROR
;
56
return
err;
57
}
58
*destLen = stream.
total_out
;
59
60
err =
inflateEnd
(&stream);
61
return
err;
62
}
63
64
65
66
ABC_NAMESPACE_IMPL_END
67
z_stream_s::next_in
Bytef * next_in
Definition:
zlib.h:94
z_stream_s::avail_in
uInt avail_in
Definition:
zlib.h:95
Z_NEED_DICT
#define Z_NEED_DICT
Definition:
zlib.h:183
uLong
unsigned long uLong
Definition:
zconf.h:336
Bytef
Byte FAR Bytef
Definition:
zconf.h:342
z_stream_s::zfree
free_func zfree
Definition:
zlib.h:106
zlib.h
Z_FINISH
#define Z_FINISH
Definition:
zlib.h:176
Z_DATA_ERROR
#define Z_DATA_ERROR
Definition:
zlib.h:186
ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_END
Definition:
abc_global.h:108
Z_STREAM_END
#define Z_STREAM_END
Definition:
zlib.h:182
z_stream_s::zalloc
alloc_func zalloc
Definition:
zlib.h:105
z_stream_s::next_out
Bytef * next_out
Definition:
zlib.h:98
ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_START
Definition:
abc_global.h:107
z_stream_s::total_out
uLong total_out
Definition:
zlib.h:100
abc_global.h
uLongf
uLong FAR uLongf
Definition:
zconf.h:347
Z_BUF_ERROR
#define Z_BUF_ERROR
Definition:
zlib.h:188
inflateInit
#define inflateInit(strm)
Definition:
zlib.h:1556
z_stream_s::avail_out
uInt avail_out
Definition:
zlib.h:99
Z_OK
#define Z_OK
Definition:
zlib.h:181
inflate
int ZEXPORT inflate(z_streamp strm, int flush)
Definition:
inflate.c:580
uncompress
ABC_NAMESPACE_IMPL_START int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition:
uncompr.c:31
ZEXPORT
#define ZEXPORT
Definition:
zconf.h:322
inflateEnd
int ZEXPORT inflateEnd(z_streamp strm)
Definition:
inflate.c:1227
z_stream_s
Definition:
zlib.h:93
uInt
unsigned int uInt
Definition:
zconf.h:335
src
misc
zlib
uncompr.c
Generated on Thu Dec 18 2014 16:11:59 for abc-master by
1.8.6