istereo2

annotate libs/zlib/uncompr.c @ 25:a9f2d30f7e8e

First hack at implementing banners on android. JNI interface to hide/show ads with the menu remains to be done.
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 05 Oct 2015 06:00:16 +0300
parents
children
rev   line source
nuclear@2 1 /* uncompr.c -- decompress a memory buffer
nuclear@2 2 * Copyright (C) 1995-2003 Jean-loup Gailly.
nuclear@2 3 * For conditions of distribution and use, see copyright notice in zlib.h
nuclear@2 4 */
nuclear@2 5
nuclear@2 6 /* @(#) $Id$ */
nuclear@2 7
nuclear@2 8 #define ZLIB_INTERNAL
nuclear@2 9 #include "zlib.h"
nuclear@2 10
nuclear@2 11 /* ===========================================================================
nuclear@2 12 Decompresses the source buffer into the destination buffer. sourceLen is
nuclear@2 13 the byte length of the source buffer. Upon entry, destLen is the total
nuclear@2 14 size of the destination buffer, which must be large enough to hold the
nuclear@2 15 entire uncompressed data. (The size of the uncompressed data must have
nuclear@2 16 been saved previously by the compressor and transmitted to the decompressor
nuclear@2 17 by some mechanism outside the scope of this compression library.)
nuclear@2 18 Upon exit, destLen is the actual size of the compressed buffer.
nuclear@2 19 This function can be used to decompress a whole file at once if the
nuclear@2 20 input file is mmap'ed.
nuclear@2 21
nuclear@2 22 uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
nuclear@2 23 enough memory, Z_BUF_ERROR if there was not enough room in the output
nuclear@2 24 buffer, or Z_DATA_ERROR if the input data was corrupted.
nuclear@2 25 */
nuclear@2 26 int ZEXPORT uncompress (dest, destLen, source, sourceLen)
nuclear@2 27 Bytef *dest;
nuclear@2 28 uLongf *destLen;
nuclear@2 29 const Bytef *source;
nuclear@2 30 uLong sourceLen;
nuclear@2 31 {
nuclear@2 32 z_stream stream;
nuclear@2 33 int err;
nuclear@2 34
nuclear@2 35 stream.next_in = (Bytef*)source;
nuclear@2 36 stream.avail_in = (uInt)sourceLen;
nuclear@2 37 /* Check for source > 64K on 16-bit machine: */
nuclear@2 38 if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
nuclear@2 39
nuclear@2 40 stream.next_out = dest;
nuclear@2 41 stream.avail_out = (uInt)*destLen;
nuclear@2 42 if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
nuclear@2 43
nuclear@2 44 stream.zalloc = (alloc_func)0;
nuclear@2 45 stream.zfree = (free_func)0;
nuclear@2 46
nuclear@2 47 err = inflateInit(&stream);
nuclear@2 48 if (err != Z_OK) return err;
nuclear@2 49
nuclear@2 50 err = inflate(&stream, Z_FINISH);
nuclear@2 51 if (err != Z_STREAM_END) {
nuclear@2 52 inflateEnd(&stream);
nuclear@2 53 if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
nuclear@2 54 return Z_DATA_ERROR;
nuclear@2 55 return err;
nuclear@2 56 }
nuclear@2 57 *destLen = stream.total_out;
nuclear@2 58
nuclear@2 59 err = inflateEnd(&stream);
nuclear@2 60 return err;
nuclear@2 61 }