]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | CompressHeader class.\r | |
3 | \r | |
4 | This class is to generate the compressed section header.\r | |
5 | \r | |
6 | Copyright (c) 2006, Intel Corporation\r | |
7 | All rights reserved. This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | package org.tianocore.framework.tasks;\r | |
18 | \r | |
19 | import org.apache.tools.ant.BuildException;\r | |
878ddf1f | 20 | /**\r |
21 | \r | |
22 | Internal class: This class is to generate the compressed section header.\r | |
23 | \r | |
24 | **/\r | |
25 | public class CompressHeader {\r | |
26 | \r | |
27 | /**\r | |
28 | CommonSectionHeader\r | |
29 | \r | |
30 | This class define the compressed header structor.\r | |
31 | \r | |
32 | **/\r | |
33 | public class CommonSectionHeader {\r | |
34 | byte[] Size = new byte[3];\r | |
35 | byte type;\r | |
36 | }\r | |
37 | \r | |
38 | ///\r | |
39 | /// Section header.\r | |
40 | ///\r | |
41 | public CommonSectionHeader SectionHeader = new CommonSectionHeader();\r | |
42 | \r | |
43 | ///\r | |
44 | /// Length of uncompress section in byte.\r | |
45 | ///\r | |
46 | public int UncompressLen;\r | |
47 | /// \r | |
48 | /// Compress type.\r | |
49 | ///\r | |
50 | public byte CompressType;\r | |
51 | \r | |
52 | ///\r | |
53 | /// The size of compress header in byte. \r | |
54 | ///\r | |
55 | public int GetSize (){\r | |
56 | return 9;\r | |
57 | }\r | |
58 | \r | |
59 | ///\r | |
60 | /// Write class member to buffer. \r | |
61 | ///\r | |
62 | public void StructToBuffer (byte[] Buffer){\r | |
63 | if (Buffer.length != GetSize()) {\r | |
64 | throw new BuildException ("CompressHeader Buffer size is not correct!");\r | |
65 | }\r | |
66 | for (int i = 0; i < 3; i++){\r | |
67 | Buffer[i] = SectionHeader.Size[i];\r | |
68 | }\r | |
69 | Buffer[3] = SectionHeader.type;\r | |
70 | Buffer[4] = (byte)(UncompressLen & 0xff);\r | |
71 | Buffer[5] = (byte)((UncompressLen & 0xff00)>>8);\r | |
72 | Buffer[6] = (byte)((UncompressLen & 0xff0000)>>16);\r | |
73 | Buffer[7] = (byte)((UncompressLen & 0xff000000)>>24);\r | |
74 | Buffer[8] = CompressType;\r | |
75 | }\r | |
76 | \r | |
77 | } |