source: svn/newcon3bcm2_21bu/dst/dlib/src/ZLIB/uncompr.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1/* uncompr.c -- decompress a memory buffer
2 * Copyright (C) 1995-1998 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
5
6/*
7 * $Id: //suprahd/releases/suprahd_163/suprahd_ztvapp640_163/drivers/graphics/ZLIB/uncompr.c#1 $
8 * $Revision: #1 $
9 * $DateTime: 2006/02/24 17:51:46 $
10 * $Change: 42566 $
11 * $Author: pryush.sharma $
12 */
13
14#include "zlib.h"
15
16/* ===========================================================================
17     Decompresses the source buffer into the destination buffer.  sourceLen is
18   the byte length of the source buffer. Upon entry, destLen is the total
19   size of the destination buffer, which must be large enough to hold the
20   entire uncompressed data. (The size of the uncompressed data must have
21   been saved previously by the compressor and transmitted to the decompressor
22   by some mechanism outside the scope of this compression library.)
23   Upon exit, destLen is the actual size of the compressed buffer.
24     This function can be used to decompress a whole file at once if the
25   input file is mmap'ed.
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*/
31int ZEXPORT uncompress (
32    Bytef *dest,
33    uLongf *destLen,
34    const Bytef *source,
35    uLong sourceLen)
36{
37    z_stream stream;
38    int err;
39
40    stream.next_in = (Bytef*)source;
41    stream.avail_in = (uInt)sourceLen;
42    /* Check for source > 64K on 16-bit machine: */
43    if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
44
45    stream.next_out = dest;
46    stream.avail_out = (uInt)*destLen;
47    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
48
49    stream.zalloc = (alloc_func)0;
50    stream.zfree = (free_func)0;
51
52    err = inflateInit(&stream);
53    if (err != Z_OK) return err;
54
55    err = inflate(&stream, Z_FINISH);
56    if (err != Z_STREAM_END) {
57        inflateEnd(&stream);
58        return err == Z_OK ? Z_BUF_ERROR : err;
59    }
60    *destLen = stream.total_out;
61
62    err = inflateEnd(&stream);
63    return err;
64}
Note: See TracBrowser for help on using the repository browser.