kerneltest/e32test/misc/unzip.h
changeset 9 96e5fb8b040d
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test\misc\unzip.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __UNZIP_H__
       
    19 #define __UNZIP_H__
       
    20 #include <e32cmn.h>
       
    21 
       
    22 #ifdef __KERNEL_MODE__
       
    23 #define	MALLOC(x)				Kern::Alloc(x)
       
    24 #define	FREE(x)					Kern::Free(x)
       
    25 #define WAIT_FOR_ANY_REQUEST()	Kern::WaitForAnyRequest()
       
    26 #else
       
    27 #include <e32std.h>
       
    28 #define	MALLOC(x)				User::Alloc(x)
       
    29 #define	FREE(x)					User::Free(x)
       
    30 #define WAIT_FOR_ANY_REQUEST()	User::WaitForAnyRequest()
       
    31 #define	WAIT_FOR_REQUEST(x)		User::WaitForRequest(x)
       
    32 #define DELAY(x)				User::After(x)
       
    33 #endif
       
    34 
       
    35 const TInt KZipLocalHeaderLen=30;
       
    36 const TInt KZipExtHeaderLen=16;
       
    37 const TUint KZipSignature=0x04034b50u;
       
    38 const TInt KZipWindowSize=0x8000;
       
    39 
       
    40 class TZipInfo
       
    41 	{
       
    42 public:
       
    43 	TInt iFlags;
       
    44 	TInt iMethod;
       
    45 	TUint iCrc;
       
    46 	TInt iCompressedSize;
       
    47 	TInt iUncompressedSize;
       
    48 	TInt iFileNameLength;
       
    49 	TInt iExtraLength;
       
    50 	TInt iNameOffset;
       
    51 	TInt iDataOffset;
       
    52 	TBuf<128> iName;
       
    53 	TUint iInBufSize;				// must be a power of 2
       
    54 	volatile TUint iFileBufW;
       
    55 	volatile TUint iFileBufR;
       
    56 	TUint iFileBufSize;				// must be a power of 2 and a multiple of iInBufSize
       
    57 	TUint8* iFileBuf;
       
    58 	TRequestStatus iProcessedHeader;
       
    59 	volatile TInt iHeaderDone;
       
    60 	TUint8* iOutBuf;
       
    61 	TInt iRemain;
       
    62 	TInt iThreadHandle;
       
    63 	TRequestStatus iThreadStatus;
       
    64 	};
       
    65 
       
    66 GLREF_C void AcceptUnzippedBlock(TZipInfo& aInfo, TUint8*& aOutPtr, TInt aError);
       
    67 GLREF_C TInt InitInfo(TZipInfo& a);
       
    68 GLREF_C TInt UnzipThread(TAny* aInfo);
       
    69 GLREF_C TInt ReadBlockToBuffer(TZipInfo& a);
       
    70 GLREF_C TInt ReadInputData(TUint8* aDest, TInt& aLength);
       
    71 GLREF_C TInt UnzipComplete(TZipInfo& a, TUint8* aOutPtr, TInt aError);
       
    72 #endif