summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2014-07-31 15:44:30 +0000
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>2014-07-31 15:44:30 +0000
commit94c2a04449a13ae76ad1f337b4e0db91cb6bd144 (patch)
treee6557baaec31ae84210c37621447d1b0cb8ffa46 /ShellPkg
parent3a8e175b3329b9a31f937a67e1394653d8d587c4 (diff)
downloadedk2-platforms-94c2a04449a13ae76ad1f337b4e0db91cb6bd144.tar.xz
ShellPkg: UpdateStdInStdOutStdErr(): extract WriteFileTag()
Drop TagBuffer in the process. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15724 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Application/Shell/ShellParametersProtocol.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c
index 7809a0e0d7..88453a231c 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -2,6 +2,7 @@
Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,
manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
+ Copyright (C) 2014, Red Hat, Inc.
Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
@@ -594,6 +595,36 @@ RemoveFileTag(
}
/**
+ Write the unicode file tag to the specified file.
+
+ It is the caller's responsibility to ensure that
+ ShellInfoObject.NewEfiShellProtocol has been initialized before calling this
+ function.
+
+ @param[in] FileHandle The file to write the unicode file tag to.
+
+ @return Status code from ShellInfoObject.NewEfiShellProtocol->WriteFile.
+**/
+STATIC
+EFI_STATUS
+WriteFileTag (
+ IN SHELL_FILE_HANDLE FileHandle
+ )
+{
+ CHAR16 FileTag;
+ UINTN Size;
+ EFI_STATUS Status;
+
+ FileTag = gUnicodeFileTag;
+ Size = sizeof FileTag;
+ Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (FileHandle, &Size,
+ &FileTag);
+ ASSERT (EFI_ERROR (Status) || Size == sizeof FileTag);
+ return Status;
+}
+
+
+/**
Funcion will replace the current StdIn and StdOut in the ShellParameters protocol
structure by parsing NewCommandLine. The current values are returned to the
user.
@@ -638,7 +669,6 @@ UpdateStdInStdOutStdErr(
BOOLEAN OutAppend;
BOOLEAN ErrAppend;
UINTN Size;
- CHAR16 TagBuffer[2];
SPLIT_LIST *Split;
CHAR16 *FirstLocation;
@@ -1050,13 +1080,7 @@ UpdateStdInStdOutStdErr(
}
Status = ShellOpenFileByName(StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE,0);
if (!ErrAppend && ErrUnicode && !EFI_ERROR(Status)) {
- //
- // Write out the gUnicodeFileTag
- //
- Size = sizeof(CHAR16);
- TagBuffer[0] = gUnicodeFileTag;
- TagBuffer[1] = CHAR_NULL;
- ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer);
+ Status = WriteFileTag (TempHandle);
}
if (!ErrUnicode && !EFI_ERROR(Status)) {
TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
@@ -1085,13 +1109,7 @@ UpdateStdInStdOutStdErr(
if (StrStr(StdOutFileName, L"NUL")==StdOutFileName) {
//no-op
} else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
- //
- // Write out the gUnicodeFileTag
- //
- Size = sizeof(CHAR16);
- TagBuffer[0] = gUnicodeFileTag;
- TagBuffer[1] = CHAR_NULL;
- ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer);
+ Status = WriteFileTag (TempHandle);
} else if (OutAppend) {
//
// Move to end of file