/*************************************************************************** * Copyright (c) 2003-2006, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: * * Revision History: * * $brcm_Log: $ * ***************************************************************************/ #define BDISPATCH_BYPASS #include "ministd.h" #undef BDISPATCH_BYPASS #include "zlib.h" /****************************************************************************** * INPUTS: in_buf - pointer to the input buffer * in_size - size of input buffer in bytes * out_buf - pointer to the output buffer * out_size - size of the output buffer * OUTPUTS: none. * RETURNS: number of bytes decompressed or < 0 on error. * FUNCTION: Uncompress the zlib intput buffer to the output buffer ******************************************************************************/ int m_uncompress(unsigned char *in_buf, unsigned int in_size, unsigned char * out_buf, unsigned int out_size) { z_stream strm; int ret; printf("%s-%d,0x%08x,%d,0x%08x,%d\n",__FUNCTION__,__LINE__,in_buf,in_size,out_buf,out_size); memset(&strm,0,sizeof(strm)); ret = inflateInit(&strm); if (ret == Z_OK) { strm.avail_in = in_size; strm.next_in = in_buf; strm.avail_out = out_size; strm.next_out = out_buf; ret = inflate(&strm, Z_NO_FLUSH); inflateEnd(&strm); if ((ret == Z_STREAM_END) || (ret == Z_OK)) { return strm.total_out; } else if (ret > 0) { return -ret; } } return ret; }