summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Library
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2016-07-18 17:46:59 +0800
committerHao Wu <hao.a.wu@intel.com>2016-07-25 11:05:38 +0800
commit580a861a6bc2a68e46ce719ce7689746ab9cae95 (patch)
tree3aeafb5d3a94cb951f6f731be3ea2c6c639a5691 /ShellPkg/Library
parent1f22879ac2174d12180c1a0aaeb97080fec5f752 (diff)
downloadedk2-580a861a6bc2a68e46ce719ce7689746ab9cae95.tar.gz
edk2-580a861a6bc2a68e46ce719ce7689746ab9cae95.tar.bz2
edk2-580a861a6bc2a68e46ce719ce7689746ab9cae95.zip
ShellPkg: Add Shell[Get|Set]RawCmdLine to ShellCommandLib
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> (cherry picked from commit 0fcf8d4df85d861b6e721bd1d8abb449f05e15ed)
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index ac77111ef9..7fe908cb57 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -30,6 +30,7 @@ STATIC UINTN mProfileListSize;
STATIC UINTN mFsMaxCount = 0;
STATIC UINTN mBlkMaxCount = 0;
STATIC BUFFER_LIST mFileHandleList;
+STATIC CHAR16 *mRawCmdLine = NULL;
STATIC CONST CHAR8 Hex[] = {
'0',
@@ -1869,6 +1870,50 @@ ShellFileHandleEof(
}
/**
+ Function to get the original CmdLine string for current command.
+
+ @return A pointer to the buffer of the original command string.
+ It's the caller's responsibility to free the buffer.
+**/
+CHAR16*
+EFIAPI
+ShellGetRawCmdLine (
+ VOID
+ )
+{
+ if (mRawCmdLine == NULL) {
+ return NULL;
+ } else {
+ return AllocateCopyPool(StrSize(mRawCmdLine), mRawCmdLine);
+ }
+}
+
+/**
+ Function to store the raw command string.
+
+ The alias and variables have been replaced and spaces are trimmed.
+
+ @param[in] CmdLine the command line string to store.
+**/
+VOID
+EFIAPI
+ShellSetRawCmdLine (
+ IN CONST CHAR16 *CmdLine
+ )
+{
+ SHELL_FREE_NON_NULL(mRawCmdLine);
+
+ if (CmdLine != NULL) {
+ //
+ // The spaces in the beginning and end are trimmed.
+ //
+ ASSERT (*CmdLine != L' ');
+ ASSERT (CmdLine[StrLen (CmdLine) - 1] != L' ');
+ mRawCmdLine = AllocateCopyPool (StrSize(CmdLine), CmdLine);
+ }
+}
+
+/**
Frees any BUFFER_LIST defined type.
@param[in] List The BUFFER_LIST object to free.