diff options
author | David Walter Seikel | 2013-01-13 17:24:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:24:39 +1000 |
commit | 393b5cd1dc438872af89d334ef6e5fcc59f27d47 (patch) | |
tree | 6a14521219942a08a1b95cb2f5a923a9edd60f63 /libraries/irrlicht-1.8/source/Irrlicht/zlib/uncompr.c | |
parent | Add a note about rasters suggested start up code. (diff) | |
download | SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.zip SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.gz SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.bz2 SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.xz |
Added Irrlicht 1.8, but without all the Windows binaries.
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/zlib/uncompr.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/zlib/uncompr.c b/libraries/irrlicht-1.8/source/Irrlicht/zlib/uncompr.c new file mode 100644 index 0000000..f07773c --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/zlib/uncompr.c | |||
@@ -0,0 +1,59 @@ | |||
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 | } | ||