]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/LzmaCompress/LzmaCompress.c
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / C / LzmaCompress / LzmaCompress.c
index aff0bed2c80830c118af1fc69ff8c5cbb99a5562..a3607f9b20844a95133124de1c1745870f7fa4da 100644 (file)
@@ -1,18 +1,12 @@
 /** @file\r
   LZMA Compress/Decompress tool (LzmaCompress)\r
 \r
-  Based on LZMA SDK 16.04:\r
+  Based on LZMA SDK 18.05:\r
     LzmaUtil.c -- Test application for LZMA compression\r
-    2016-10-04 : Igor Pavlov : Public domain\r
+    2018-04-30 : Igor Pavlov : Public domain\r
 \r
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -33,7 +27,7 @@
 #define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)\r
 \r
 typedef enum {\r
-  NoConverter, \r
+  NoConverter,\r
   X86Converter,\r
   MaxConverter\r
 } CONVERTER_TYPE;\r
@@ -50,7 +44,7 @@ static CONVERTER_TYPE mConType = NoConverter;
 #define UTILITY_MAJOR_VERSION 0\r
 #define UTILITY_MINOR_VERSION 2\r
 #define INTEL_COPYRIGHT \\r
-  "Copyright (c) 2009-2016, Intel Corporation. All rights reserved."\r
+  "Copyright (c) 2009-2018, Intel Corporation. All rights reserved."\r
 void PrintHelp(char *buffer)\r
 {\r
   strcat(buffer,\r
@@ -113,7 +107,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
   } else {\r
     return SZ_ERROR_INPUT_EOF;\r
   }\r
-  \r
+\r
   if (SeqInStream_Read(inStream, inBuffer, inSize) != SZ_OK) {\r
     res = SZ_ERROR_READ;\r
     goto Done;\r
@@ -126,7 +120,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
     res = SZ_ERROR_MEM;\r
     goto Done;\r
   }\r
-  \r
+\r
   {\r
     int i;\r
     for (i = 0; i < 8; i++)\r
@@ -141,7 +135,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
       goto Done;\r
     }\r
     memcpy(filteredStream, inBuffer, inSize);\r
-    \r
+\r
     if (mConType == X86Converter) {\r
       {\r
         UInt32 x86State;\r
@@ -154,12 +148,12 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
   {\r
     size_t outSizeProcessed = outSize - LZMA_HEADER_SIZE;\r
     size_t outPropsSize = LZMA_PROPS_SIZE;\r
-    \r
+\r
     res = LzmaEncode(outBuffer + LZMA_HEADER_SIZE, &outSizeProcessed,\r
         mConType != NoConverter ? filteredStream : inBuffer, inSize,\r
         &props, outBuffer, &outPropsSize, 0,\r
         NULL, &g_Alloc, &g_Alloc);\r
-    \r
+\r
     if (res != SZ_OK)\r
       goto Done;\r
 \r
@@ -190,13 +184,13 @@ static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 file
 \r
   int i;\r
 \r
-  if (inSize < LZMA_HEADER_SIZE) \r
+  if (inSize < LZMA_HEADER_SIZE)\r
     return SZ_ERROR_INPUT_EOF;\r
 \r
   inBuffer = (Byte *)MyAlloc(inSize);\r
   if (inBuffer == 0)\r
     return SZ_ERROR_MEM;\r
-  \r
+\r
   if (SeqInStream_Read(inStream, inBuffer, inSize) != SZ_OK) {\r
     res = SZ_ERROR_READ;\r
     goto Done;\r
@@ -329,8 +323,10 @@ int main2(int numArgs, const char *args[], char *rs)
   if (InFile_Open(&inStream.file, inputFile) != 0)\r
     return PrintError(rs, "Can not open input file");\r
 \r
-  if (OutFile_Open(&outStream.file, outputFile) != 0)\r
+  if (OutFile_Open(&outStream.file, outputFile) != 0) {\r
+    File_Close(&inStream.file);\r
     return PrintError(rs, "Can not open output file");\r
+  }\r
 \r
   File_GetLength(&inStream.file, &fileSize);\r
 \r
@@ -339,14 +335,14 @@ int main2(int numArgs, const char *args[], char *rs)
     if (!mQuietMode) {\r
       printf("Encoding\n");\r
     }\r
-    res = Encode(&outStream.s, &inStream.s, fileSize);\r
+    res = Encode(&outStream.vt, &inStream.vt, fileSize);\r
   }\r
   else\r
   {\r
     if (!mQuietMode) {\r
       printf("Decoding\n");\r
     }\r
-    res = Decode(&outStream.s, &inStream.s, fileSize);\r
+    res = Decode(&outStream.vt, &inStream.vt, fileSize);\r
   }\r
 \r
   File_Close(&outStream.file);\r