]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Add Shell[Get|Set]RawCmdLine to ShellCommandLib
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 18 Jul 2016 09:46:59 +0000 (17:46 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Wed, 20 Jul 2016 02:27:56 +0000 (10:27 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Include/Library/ShellCommandLib.h
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c

index 5c5e241f1525e03b0a8713cd0dc5a9a83508b15c..44eccc447cb269f669e9674d28ac5b3a12dc14c5 100644 (file)
@@ -670,6 +670,29 @@ ShellFileHandleEof(
   IN SHELL_FILE_HANDLE Handle\r
   );\r
 \r
+/**\r
+  Function to get the original CmdLine string for current command.\r
+\r
+  @return     A pointer to the buffer of the original command string.\r
+              It's the caller's responsibility to free the buffer.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+ShellGetRawCmdLine (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Function to store the orgignal command string into mOriginalCmdLine.\r
+\r
+  @param[in] CmdLine     the command line string to store.\r
+**/\r
+VOID\r
+EFIAPI\r
+ShellSetRawCmdLine (\r
+  IN CONST CHAR16     *CmdLine\r
+  );\r
+\r
 typedef struct {\r
   LIST_ENTRY    Link;\r
   void          *Buffer;\r
index ac77111ef93c6630e9d53214cd1c527f09e0d989..7fe908cb57cd556c1ef254a066665c75d97bcef9 100644 (file)
@@ -30,6 +30,7 @@ STATIC UINTN                              mProfileListSize;
 STATIC UINTN                              mFsMaxCount = 0;\r
 STATIC UINTN                              mBlkMaxCount = 0;\r
 STATIC BUFFER_LIST                        mFileHandleList;\r
+STATIC CHAR16                             *mRawCmdLine = NULL;\r
 \r
 STATIC CONST CHAR8 Hex[] = {\r
   '0',\r
@@ -1868,6 +1869,50 @@ ShellFileHandleEof(
   return (RetVal);\r
 }\r
 \r
+/**\r
+  Function to get the original CmdLine string for current command.\r
+\r
+  @return     A pointer to the buffer of the original command string.\r
+              It's the caller's responsibility to free the buffer.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+ShellGetRawCmdLine (\r
+  VOID\r
+  )\r
+{\r
+  if (mRawCmdLine == NULL) {\r
+    return NULL;\r
+  } else {\r
+    return AllocateCopyPool(StrSize(mRawCmdLine), mRawCmdLine);\r
+  }\r
+}\r
+\r
+/**\r
+  Function to store the raw command string.\r
+\r
+  The alias and variables have been replaced and spaces are trimmed.\r
+\r
+  @param[in] CmdLine     the command line string to store.\r
+**/\r
+VOID\r
+EFIAPI\r
+ShellSetRawCmdLine (\r
+  IN CONST CHAR16     *CmdLine\r
+  )\r
+{\r
+  SHELL_FREE_NON_NULL(mRawCmdLine);\r
+\r
+  if (CmdLine != NULL) {\r
+    //\r
+    // The spaces in the beginning and end are trimmed.\r
+    //\r
+    ASSERT (*CmdLine != L' ');\r
+    ASSERT (CmdLine[StrLen (CmdLine) - 1] != L' ');\r
+    mRawCmdLine = AllocateCopyPool (StrSize(CmdLine), CmdLine);\r
+  }\r
+}\r
+\r
 /**\r
   Frees any BUFFER_LIST defined type.\r
 \r