Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenuncompr.c
Go to the documentation of this file.
00001 /* uncompr.c -- decompress a memory buffer 00002 * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 00003 * For conditions of distribution and use, see copyright notice in zlib.h 00004 */ 00005 00006 /* @(#) $Id: uncompr.c 47691 2010-06-08 01:37:58Z tkreuzer $ */ 00007 00008 #define ZLIB_INTERNAL 00009 #include "zlib.h" 00010 00011 /* =========================================================================== 00012 Decompresses the source buffer into the destination buffer. sourceLen is 00013 the byte length of the source buffer. Upon entry, destLen is the total 00014 size of the destination buffer, which must be large enough to hold the 00015 entire uncompressed data. (The size of the uncompressed data must have 00016 been saved previously by the compressor and transmitted to the decompressor 00017 by some mechanism outside the scope of this compression library.) 00018 Upon exit, destLen is the actual size of the compressed buffer. 00019 00020 uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 00021 enough memory, Z_BUF_ERROR if there was not enough room in the output 00022 buffer, or Z_DATA_ERROR if the input data was corrupted. 00023 */ 00024 int ZEXPORT uncompress (dest, destLen, source, sourceLen) 00025 Bytef *dest; 00026 uLongf *destLen; 00027 const Bytef *source; 00028 uLong sourceLen; 00029 { 00030 z_stream stream; 00031 int err; 00032 00033 stream.next_in = (Bytef*)source; 00034 stream.avail_in = (uInt)sourceLen; 00035 /* Check for source > 64K on 16-bit machine: */ 00036 if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 00037 00038 stream.next_out = dest; 00039 stream.avail_out = (uInt)*destLen; 00040 if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 00041 00042 stream.zalloc = (alloc_func)0; 00043 stream.zfree = (free_func)0; 00044 00045 err = inflateInit(&stream); 00046 if (err != Z_OK) return err; 00047 00048 err = inflate(&stream, Z_FINISH); 00049 if (err != Z_STREAM_END) { 00050 inflateEnd(&stream); 00051 if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 00052 return Z_DATA_ERROR; 00053 return err; 00054 } 00055 *destLen = stream.total_out; 00056 00057 err = inflateEnd(&stream); 00058 return err; 00059 } Generated on Sat May 26 2012 04:34:50 for ReactOS by
1.7.6.1
|