diff options
Diffstat (limited to 'utils/zenutils/libraries/zlib123/zlib/uncompr.c')
-rw-r--r--[-rwxr-xr-x] | utils/zenutils/libraries/zlib123/zlib/uncompr.c | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/utils/zenutils/libraries/zlib123/zlib/uncompr.c b/utils/zenutils/libraries/zlib123/zlib/uncompr.c index ad6db0a67c..b59e3d0def 100755..100644 --- a/utils/zenutils/libraries/zlib123/zlib/uncompr.c +++ b/utils/zenutils/libraries/zlib123/zlib/uncompr.c | |||
@@ -1,61 +1,61 @@ | |||
1 | /* uncompr.c -- decompress a memory buffer | 1 | /* uncompr.c -- decompress a memory buffer |
2 | * Copyright (C) 1995-2003 Jean-loup Gailly. | 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* @(#) $Id$ */ | 6 | /* @(#) $Id$ */ |
7 | 7 | ||
8 | #define ZLIB_INTERNAL | 8 | #define ZLIB_INTERNAL |
9 | #include "zlib.h" | 9 | #include "zlib.h" |
10 | 10 | ||
11 | /* =========================================================================== | 11 | /* =========================================================================== |
12 | Decompresses the source buffer into the destination buffer. sourceLen is | 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 | 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 | 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 | 15 | entire uncompressed data. (The size of the uncompressed data must have |
16 | been saved previously by the compressor and transmitted to the decompressor | 16 | been saved previously by the compressor and transmitted to the decompressor |
17 | by some mechanism outside the scope of this compression library.) | 17 | by some mechanism outside the scope of this compression library.) |
18 | Upon exit, destLen is the actual size of the compressed buffer. | 18 | Upon exit, destLen is the actual size of the compressed buffer. |
19 | This function can be used to decompress a whole file at once if the | 19 | This function can be used to decompress a whole file at once if the |
20 | input file is mmap'ed. | 20 | input file is mmap'ed. |
21 | 21 | ||
22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not | 22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not |
23 | enough memory, Z_BUF_ERROR if there was not enough room in the output | 23 | enough memory, Z_BUF_ERROR if there was not enough room in the output |
24 | buffer, or Z_DATA_ERROR if the input data was corrupted. | 24 | buffer, or Z_DATA_ERROR if the input data was corrupted. |
25 | */ | 25 | */ |
26 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) | 26 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) |
27 | Bytef *dest; | 27 | Bytef *dest; |
28 | uLongf *destLen; | 28 | uLongf *destLen; |
29 | const Bytef *source; | 29 | const Bytef *source; |
30 | uLong sourceLen; | 30 | uLong sourceLen; |
31 | { | 31 | { |
32 | z_stream stream; | 32 | z_stream stream; |
33 | int err; | 33 | int err; |
34 | 34 | ||
35 | stream.next_in = (Bytef*)source; | 35 | stream.next_in = (Bytef*)source; |
36 | stream.avail_in = (uInt)sourceLen; | 36 | stream.avail_in = (uInt)sourceLen; |
37 | /* Check for source > 64K on 16-bit machine: */ | 37 | /* Check for source > 64K on 16-bit machine: */ |
38 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; | 38 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; |
39 | 39 | ||
40 | stream.next_out = dest; | 40 | stream.next_out = dest; |
41 | stream.avail_out = (uInt)*destLen; | 41 | stream.avail_out = (uInt)*destLen; |
42 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; | 42 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; |
43 | 43 | ||
44 | stream.zalloc = (alloc_func)0; | 44 | stream.zalloc = (alloc_func)0; |
45 | stream.zfree = (free_func)0; | 45 | stream.zfree = (free_func)0; |
46 | 46 | ||
47 | err = inflateInit(&stream); | 47 | err = inflateInit(&stream); |
48 | if (err != Z_OK) return err; | 48 | if (err != Z_OK) return err; |
49 | 49 | ||
50 | err = inflate(&stream, Z_FINISH); | 50 | err = inflate(&stream, Z_FINISH); |
51 | if (err != Z_STREAM_END) { | 51 | if (err != Z_STREAM_END) { |
52 | inflateEnd(&stream); | 52 | inflateEnd(&stream); |
53 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) | 53 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) |
54 | return Z_DATA_ERROR; | 54 | return Z_DATA_ERROR; |
55 | return err; | 55 | return err; |
56 | } | 56 | } |
57 | *destLen = stream.total_out; | 57 | *destLen = stream.total_out; |
58 | 58 | ||
59 | err = inflateEnd(&stream); | 59 | err = inflateEnd(&stream); |
60 | return err; | 60 | return err; |
61 | } | 61 | } |