]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/ConsoleWrappers.c
ShellPkg: Update CWD and current mapping when commands return
[mirror_edk2.git] / ShellPkg / Application / Shell / ConsoleWrappers.c
index feea6ef3a22e58d89038398cbc7d88a3a2ab5171..e1846ec9cba6e151f3a355eb6dc896a9579d571a 100644 (file)
@@ -2,7 +2,7 @@
   Function definitions for shell simple text in and out on top of file handles.\r
 \r
   (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2015, 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
@@ -15,6 +15,8 @@
 \r
 #include "Shell.h"\r
 \r
+extern BOOLEAN AsciiRedirection;\r
+\r
 typedef struct {\r
   EFI_SIMPLE_TEXT_INPUT_PROTOCOL  SimpleTextIn;\r
   SHELL_FILE_HANDLE               FileHandle;\r
@@ -81,6 +83,7 @@ FileBasedSimpleTextInReadKeyStroke(
   )\r
 {\r
   UINTN Size;\r
+  UINTN CharSize;\r
 \r
   //\r
   // Verify the parameters\r
@@ -98,11 +101,16 @@ FileBasedSimpleTextInReadKeyStroke(
 \r
   Size = sizeof(CHAR16);\r
 \r
+  if(!AsciiRedirection) {\r
+    CharSize = sizeof(CHAR16);\r
+  } else {\r
+    CharSize = sizeof(CHAR8);\r
+  } \r
   //\r
   // Decrement the amount of free space by Size or set to zero (for odd length files)\r
   //\r
-  if (((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->RemainingBytesOfInputFile > Size) {\r
-    ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->RemainingBytesOfInputFile -= Size;\r
+  if (((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->RemainingBytesOfInputFile > CharSize) {\r
+    ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->RemainingBytesOfInputFile -= CharSize;\r
   } else {\r
     ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->RemainingBytesOfInputFile = 0;\r
   }\r
@@ -125,7 +133,6 @@ FileBasedSimpleTextInReadKeyStroke(
   @return                     A pointer to the allocated protocol structure;\r
 **/\r
 EFI_SIMPLE_TEXT_INPUT_PROTOCOL*\r
-EFIAPI\r
 CreateSimpleTextInOnFile(\r
   IN SHELL_FILE_HANDLE  FileHandleToUse,\r
   IN EFI_HANDLE         *HandleLocation\r
@@ -192,7 +199,6 @@ CreateSimpleTextInOnFile(
   @retval EFI_SUCCESS         The object was closed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 CloseSimpleTextInOnFile(\r
   IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL  *SimpleTextIn\r
   )\r
@@ -426,7 +432,6 @@ FileBasedSimpleTextOutOutputString (
   @return                     A pointer to the allocated protocol structure;\r
 **/\r
 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*\r
-EFIAPI\r
 CreateSimpleTextOutOnFile(\r
   IN SHELL_FILE_HANDLE               FileHandleToUse,\r
   IN EFI_HANDLE                      *HandleLocation,\r
@@ -476,7 +481,8 @@ CreateSimpleTextOutOnFile(
     *HandleLocation = ProtocolToReturn->TheHandle;\r
     return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)ProtocolToReturn);\r
   } else {\r
-    FreePool(ProtocolToReturn);\r
+    SHELL_FREE_NON_NULL(ProtocolToReturn->SimpleTextOut.Mode);\r
+    SHELL_FREE_NON_NULL(ProtocolToReturn);\r
     return (NULL);\r
   }\r
 }\r
@@ -490,7 +496,6 @@ CreateSimpleTextOutOnFile(
   @retval EFI_SUCCESS         The object was closed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 CloseSimpleTextOutOnFile(\r
   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *SimpleTextOut\r
   )\r
@@ -503,6 +508,7 @@ CloseSimpleTextOutOnFile(
     ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->TheHandle, \r
     &gEfiSimpleTextOutProtocolGuid, \r
     &(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->SimpleTextOut));\r
+  FreePool(SimpleTextOut->Mode);\r
   FreePool(SimpleTextOut);\r
   return (Status);\r
 }\r