diff -r 000000000000 -r a41df078684a brdbootldr/ubootldr/unzip.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/brdbootldr/ubootldr/unzip.cpp Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,181 @@ +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// ubootldr\unzip.cpp +// +// + +#define FILE_ID 0x555A4950 + +#include "bootldr.h" +#include "unzip.h" +#include "inflate.h" + +const TInt INBUFSIZE = 0x2000; +const TUint32 RETRY_WARNING_COUNT = 100; // if we get 100 retries, things must be really bad... + +TZipInfo* TheZipInfo; + +#define Z (*TheZipInfo) + +extern "C" { + +extern int inflate(); + +TUint8 inbuf[INBUFSIZE]; +TUint8* volatile inptr; /* index of next byte to be processed in inbuf */ +TUint8* volatile inbuf_end; /* pointer to last valid input byte + 1 */ +TUint8* volatile outptr; /* pointer to output data */ + +TAny* malloc(TUint aSize) + { + return MALLOC((TInt)aSize); + } + +void free(TAny* aPtr) + { + FREE(aPtr); + } + +TUint8 fill_inbuf() + { + WAIT_FOR_ANY_REQUEST(); // wait for a block from the file + TUint w=Z.iFileBufW; + TInt avail=(TInt)w-(TInt)Z.iFileBufR; + TInt amount=(avail>(TInt)INBUFSIZE)?INBUFSIZE:avail; + TInt rix=(TInt)(Z.iFileBufR & (Z.iFileBufSize-1)); + memcpy(inbuf,Z.iFileBuf+rix,amount); + Z.iFileBufR+=amount; + inptr=inbuf; + inbuf_end=inbuf+amount; + return *inptr++; + } + +void process_block(int error) + { + AcceptUnzippedBlock(Z, (TUint8*&)outptr, error); + } +} // extern "C" { + +const TUint KZipSpan=0x30304b50u; +TInt ParseZipHeader(TZipInfo& a) + { + TInt avail=inbuf_end-inptr; + if (availreq_len) + len=req_len; + if (r==KErrNone) + { + ImageReadProgress+=len; + a.iFileBufW+=len; + a.iRemain-=len; + } + return r; + } +