]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/CCode/Source/CompressDll/CompressDll.c
The main issue want to be resolve is that some tools need EfiCompress and other tools...
[mirror_edk2.git] / Tools / CCode / Source / CompressDll / CompressDll.c
CommitLineData
4cb22535 1/** @file\r
2 Compression DLL used by PCD Tools\r
3\r
4 Copyright (c) 2006, Intel Corporation All rights reserved.\r
5 This program and the accompanying materials are licensed and made available \r
6 under the terms and conditions of the BSD License which accompanies this \r
7 distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php \r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
8f7f05d5 14#if defined(__GNUC__)\r
15typedef long long __int64;/*For cygwin build*/\r
16#endif\r
878ddf1f 17#include "CompressDll.h"\r
30f80dd8 18#include "Compress.h"\r
878ddf1f 19\r
20extern\r
21EFI_STATUS\r
30f80dd8 22TianoCompress (\r
878ddf1f 23 IN UINT8 *SrcBuffer,\r
24 IN UINT32 SrcSize,\r
25 IN UINT8 *DstBuffer,\r
26 IN OUT UINT32 *DstSize\r
27 );\r
28 \r
29JNIEXPORT jbyteArray JNICALL Java_org_tianocore_framework_tasks_Compress_CallCompress \r
30(JNIEnv *env, jobject obj, jbyteArray SourceBuffer, jint SourceSize, jstring path)\r
31{\r
32 char* DestBuffer;\r
33 int DestSize; \r
34 int Result;\r
35 char *InputBuffer;\r
36 jbyteArray OutputBuffer;\r
37 jbyte *TempByte;\r
38 \r
39 DestSize = 0;\r
40 DestBuffer = NULL;\r
41 \r
42 TempByte = (*env)->GetByteArrayElements(env, SourceBuffer, 0);\r
43 InputBuffer = (char*) TempByte;\r
44\r
45 \r
46 //\r
47 // First call compress function and get need buffer size\r
48 //\r
49\r
30f80dd8 50 Result = TianoCompress (\r
ce53a8c3 51 (char*) InputBuffer, \r
52 SourceSize, \r
53 DestBuffer,\r
54 &DestSize\r
55 );\r
878ddf1f 56\r
57 if (Result = EFI_BUFFER_TOO_SMALL) {\r
ce53a8c3 58 DestBuffer = malloc (DestSize);\r
878ddf1f 59 }\r
60\r
61 //\r
62 // Second call compress and get the DestBuffer value\r
63 //\r
30f80dd8 64 Result = TianoCompress(\r
878ddf1f 65 (char*) InputBuffer, \r
ce53a8c3 66 SourceSize, \r
67 DestBuffer,\r
68 &DestSize \r
69 );\r
878ddf1f 70\r
71 //\r
72 // new a MV array to store the return compressed buffer\r
73 //\r
74 OutputBuffer = (*env)->NewByteArray(env, DestSize);\r
75 (*env)->SetByteArrayRegion(env, OutputBuffer,0, DestSize, (jbyte*) DestBuffer);\r
76\r
77 //\r
78 // Free Ouputbuffer.\r
79 //\r
80 free (DestBuffer);\r
81 \r
82\r
83 if (Result != 0) {\r
84 return NULL;\r
85 } else {\r
86 return OutputBuffer;\r
87 }\r
88}\r
89\r
90#ifdef _MSC_VER\r
91BOOLEAN \r
92__stdcall \r
93DllMainCRTStartup(\r
94 unsigned int hDllHandle, \r
95 unsigned int nReason, \r
96 void* Reserved \r
97)\r
98{\r
ce53a8c3 99 return TRUE;\r
878ddf1f 100}\r
101#else\r
102#ifdef __GNUC__\r
103#endif\r
104#endif\r
105\r