diff -r 000000000000 -r a41df078684a kerneltest/e32test/misc/unzip.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kerneltest/e32test/misc/unzip.cpp Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,161 @@ +// Copyright (c) 1998-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: +// e32test\misc\unzip.cpp +// +// + +#include "unzip.h" +#include "inflate.h" + +//#include +//GLREF_C RTest test; + +const TInt INBUFSIZE=0x2000; + +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); + } +} + +TInt ParseZipHeader(TZipInfo& a) + { + TInt avail=inbuf_end-inptr; + if (avail=(TInt)INBUFSIZE); + TInt req_len=Min(a.iRemain,INBUFSIZE); + TInt len=req_len; + TInt wix=(TInt)(a.iFileBufW & (a.iFileBufSize-1)); + TInt r=ReadInputData(a.iFileBuf+wix,len); + if (len>req_len) + len=req_len; + if (r==KErrNone) + { + a.iFileBufW+=len; + a.iRemain-=len; + } + return r; + } +