|
1 /* |
|
2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __DECMPSTREAM_H_ |
|
20 #define __DECMPSTREAM_H_ |
|
21 //------------------------------------------------------------------------------ |
|
22 |
|
23 #include <EZGzip.h> |
|
24 //------------------------------------------------------------------------------ |
|
25 |
|
26 class EZDecompressor; |
|
27 class StreamBufMgr; |
|
28 class RMemReadStream; |
|
29 //------------------------------------------------------------------------------ |
|
30 |
|
31 class TZlibHeader |
|
32 { |
|
33 public: |
|
34 // ctor & dtor |
|
35 TZlibHeader() : iCMF( 0 ), iFLG( 0 ) {} |
|
36 ~TZlibHeader() {} |
|
37 //---------------------------------------------------------------------- |
|
38 |
|
39 // data |
|
40 TUint8 iCMF; |
|
41 TUint8 iFLG; |
|
42 //---------------------------------------------------------------------- |
|
43 }; |
|
44 |
|
45 |
|
46 class CDecmpStream : public CBase |
|
47 { |
|
48 public: |
|
49 enum { EGzip=0, EZlib=1 }; |
|
50 enum { EBadZlibHeader = -1,EDictionaryNotSupported = -2 }; |
|
51 //-------------------------------------------------------------------------- |
|
52 |
|
53 // dtor & ctor |
|
54 static CDecmpStream* NewL( TPtrC8 in, TInt format = EGzip ); |
|
55 virtual ~CDecmpStream(); |
|
56 //-------------------------------------------------------------------------- |
|
57 |
|
58 // inflate the content |
|
59 TBool InflateL(); |
|
60 TPtrC8 GetOutput(); |
|
61 void ResetBuffer( TPtrC8 in ); |
|
62 TBool NeedInput() const; |
|
63 TBool NeedOutput() const; |
|
64 TBool Finalized() const; |
|
65 void ResetOutput(); |
|
66 //-------------------------------------------------------------------------- |
|
67 |
|
68 private: |
|
69 // ctor |
|
70 CDecmpStream( TInt format ); |
|
71 void ConstructL( TPtrC8 in ); |
|
72 //-------------------------------------------------------------------------- |
|
73 |
|
74 // helper functions |
|
75 void ReadHeaderL( TEZGZipHeader& header ); |
|
76 TBool ReadHeaderL( TZlibHeader& header ); |
|
77 void ReadTrailerL( TEZGZipTrailer& trailer ); |
|
78 void ReadStringIntoDescriptorL( RMemReadStream& aMem, HBufC8 **aDes ) const; |
|
79 //-------------------------------------------------------------------------- |
|
80 |
|
81 CEZDecompressor* iDecompressor; |
|
82 StreamBufMgr* iBufMgr; |
|
83 TInt iOffset; |
|
84 HBufC8* iAuxBuf; // auxillary buffer, used for the wrong deflate implmentation |
|
85 TUint32 iCheckSum; // CRC or Adler |
|
86 TInt iFormat; |
|
87 //-------------------------------------------------------------------------- |
|
88 |
|
89 // Gzip Magic numbers |
|
90 static const TUint8 ID1; |
|
91 static const TUint8 ID2; |
|
92 //-------------------------------------------------------------------------- |
|
93 }; |
|
94 |
|
95 //------------------------------------------------------------------------------ |
|
96 #endif // !__DECMPSTREAM_H_ |