| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2006, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: $ |
|---|
| 11 | * $brcm_Revision: $ |
|---|
| 12 | * $brcm_Date: $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: $ |
|---|
| 19 | * |
|---|
| 20 | ***************************************************************************/ |
|---|
| 21 | #define BDISPATCH_BYPASS |
|---|
| 22 | #include "ministd.h" |
|---|
| 23 | #undef BDISPATCH_BYPASS |
|---|
| 24 | #include "zlib.h" |
|---|
| 25 | |
|---|
| 26 | /****************************************************************************** |
|---|
| 27 | * INPUTS: in_buf - pointer to the input buffer |
|---|
| 28 | * in_size - size of input buffer in bytes |
|---|
| 29 | * out_buf - pointer to the output buffer |
|---|
| 30 | * out_size - size of the output buffer |
|---|
| 31 | * OUTPUTS: none. |
|---|
| 32 | * RETURNS: number of bytes decompressed or < 0 on error. |
|---|
| 33 | * FUNCTION: Uncompress the zlib intput buffer to the output buffer |
|---|
| 34 | ******************************************************************************/ |
|---|
| 35 | int m_uncompress(unsigned char *in_buf, unsigned int in_size, |
|---|
| 36 | unsigned char * out_buf, unsigned int out_size) |
|---|
| 37 | { |
|---|
| 38 | z_stream strm; |
|---|
| 39 | int ret; |
|---|
| 40 | printf("%s-%d,0x%08x,%d,0x%08x,%d\n",__FUNCTION__,__LINE__,in_buf,in_size,out_buf,out_size); |
|---|
| 41 | memset(&strm,0,sizeof(strm)); |
|---|
| 42 | ret = inflateInit(&strm); |
|---|
| 43 | if (ret == Z_OK) |
|---|
| 44 | { |
|---|
| 45 | strm.avail_in = in_size; |
|---|
| 46 | strm.next_in = in_buf; |
|---|
| 47 | strm.avail_out = out_size; |
|---|
| 48 | strm.next_out = out_buf; |
|---|
| 49 | ret = inflate(&strm, Z_NO_FLUSH); |
|---|
| 50 | inflateEnd(&strm); |
|---|
| 51 | if ((ret == Z_STREAM_END) || (ret == Z_OK)) |
|---|
| 52 | { |
|---|
| 53 | return strm.total_out; |
|---|
| 54 | } |
|---|
| 55 | else if (ret > 0) |
|---|
| 56 | { |
|---|
| 57 | return -ret; |
|---|
| 58 | } |
|---|
| 59 | } |
|---|
| 60 | return ret; |
|---|
| 61 | } |
|---|
| 62 | |
|---|