diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2021-12-05 14:54:13 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-12-07 17:24:28 +0000 |
commit | 47d20b54f9a65b08aa602a1866c1b59a69088dfc (patch) | |
tree | e3241dd169bda79544a36248e834a4bebe298418 /ShellPkg/Application/Shell/ShellParametersProtocol.c | |
parent | c411b485b63a671a1e276700cff025c73997233c (diff) | |
download | edk2-47d20b54f9a65b08aa602a1866c1b59a69088dfc.zip edk2-47d20b54f9a65b08aa602a1866c1b59a69088dfc.tar.gz edk2-47d20b54f9a65b08aa602a1866c1b59a69088dfc.tar.bz2 |
ShellPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737
Apply uncrustify changes to .c/.h files in the ShellPkg package
Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'ShellPkg/Application/Shell/ShellParametersProtocol.c')
-rw-r--r-- | ShellPkg/Application/Shell/ShellParametersProtocol.c | 1100 |
1 files changed, 595 insertions, 505 deletions
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c index 7e0c8ce..64d67d9 100644 --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c @@ -12,22 +12,22 @@ #include "Shell.h"
-BOOLEAN AsciiRedirection = FALSE;
+BOOLEAN AsciiRedirection = FALSE;
/**
Return the next parameter's end from a command line string.
@param[in] String the string to parse
**/
-CONST CHAR16*
-FindEndOfParameter(
- IN CONST CHAR16 *String
+CONST CHAR16 *
+FindEndOfParameter (
+ IN CONST CHAR16 *String
)
{
- CONST CHAR16 *First;
- CONST CHAR16 *CloseQuote;
+ CONST CHAR16 *First;
+ CONST CHAR16 *CloseQuote;
- First = FindFirstCharacter(String, L" \"", L'^');
+ First = FindFirstCharacter (String, L" \"", L'^');
//
// nothing, all one parameter remaining
@@ -79,51 +79,51 @@ FindEndOfParameter( @return EFI_NOT_FOUND A closing " could not be found on the specified string
**/
EFI_STATUS
-GetNextParameter(
+GetNextParameter (
IN OUT CHAR16 **Walker,
IN OUT CHAR16 **TempParameter,
IN CONST UINTN Length,
IN BOOLEAN StripQuotation
)
{
- CONST CHAR16 *NextDelim;
-
- if (Walker == NULL
- ||*Walker == NULL
- ||TempParameter == NULL
- ||*TempParameter == NULL
- ){
+ CONST CHAR16 *NextDelim;
+
+ if ( (Walker == NULL)
+ || (*Walker == NULL)
+ || (TempParameter == NULL)
+ || (*TempParameter == NULL)
+ )
+ {
return (EFI_INVALID_PARAMETER);
}
-
//
// make sure we dont have any leading spaces
//
while ((*Walker)[0] == L' ') {
- (*Walker)++;
+ (*Walker)++;
}
//
// make sure we still have some params now...
//
- if (StrLen(*Walker) == 0) {
-DEBUG_CODE_BEGIN();
- *Walker = NULL;
-DEBUG_CODE_END();
+ if (StrLen (*Walker) == 0) {
+ DEBUG_CODE_BEGIN ();
+ *Walker = NULL;
+ DEBUG_CODE_END ();
return (EFI_INVALID_PARAMETER);
}
- NextDelim = FindEndOfParameter(*Walker);
+ NextDelim = FindEndOfParameter (*Walker);
- if (NextDelim == NULL){
-DEBUG_CODE_BEGIN();
- *Walker = NULL;
-DEBUG_CODE_END();
+ if (NextDelim == NULL) {
+ DEBUG_CODE_BEGIN ();
+ *Walker = NULL;
+ DEBUG_CODE_END ();
return (EFI_NOT_FOUND);
}
- StrnCpyS(*TempParameter, Length / sizeof(CHAR16), (*Walker), NextDelim - *Walker);
+ StrnCpyS (*TempParameter, Length / sizeof (CHAR16), (*Walker), NextDelim - *Walker);
//
// Add a CHAR_NULL if we didn't get one via the copy
@@ -135,33 +135,32 @@ DEBUG_CODE_END(); //
// Update Walker for the next iteration through the function
//
- *Walker = (CHAR16*)NextDelim;
+ *Walker = (CHAR16 *)NextDelim;
//
// Remove any non-escaped quotes in the string
// Remove any remaining escape characters in the string
//
- for (NextDelim = FindFirstCharacter(*TempParameter, L"\"^", CHAR_NULL)
- ; *NextDelim != CHAR_NULL
- ; NextDelim = FindFirstCharacter(NextDelim, L"\"^", CHAR_NULL)
- ) {
+ for (NextDelim = FindFirstCharacter (*TempParameter, L"\"^", CHAR_NULL)
+ ; *NextDelim != CHAR_NULL
+ ; NextDelim = FindFirstCharacter (NextDelim, L"\"^", CHAR_NULL)
+ )
+ {
if (*NextDelim == L'^') {
-
//
// eliminate the escape ^
//
- CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
+ CopyMem ((CHAR16 *)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
NextDelim++;
} else if (*NextDelim == L'\"') {
-
//
// eliminate the unescaped quote
//
if (StripQuotation) {
- CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
- } else{
+ CopyMem ((CHAR16 *)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
+ } else {
NextDelim++;
- }
+ }
}
}
@@ -189,11 +188,11 @@ DEBUG_CODE_END(); @return EFI_OUT_OF_RESOURCES a memory allocation failed.
**/
EFI_STATUS
-ParseCommandLineToArgs(
- IN CONST CHAR16 *CommandLine,
- IN BOOLEAN StripQuotation,
- IN OUT CHAR16 ***Argv,
- IN OUT UINTN *Argc
+ParseCommandLineToArgs (
+ IN CONST CHAR16 *CommandLine,
+ IN BOOLEAN StripQuotation,
+ IN OUT CHAR16 ***Argv,
+ IN OUT UINTN *Argc
)
{
UINTN Count;
@@ -204,34 +203,35 @@ ParseCommandLineToArgs( UINTN Size;
EFI_STATUS Status;
- ASSERT(Argc != NULL);
- ASSERT(Argv != NULL);
+ ASSERT (Argc != NULL);
+ ASSERT (Argv != NULL);
- if (CommandLine == NULL || StrLen(CommandLine)==0) {
+ if ((CommandLine == NULL) || (StrLen (CommandLine) == 0)) {
(*Argc) = 0;
(*Argv) = NULL;
return (EFI_SUCCESS);
}
- NewCommandLine = AllocateCopyPool(StrSize(CommandLine), CommandLine);
- if (NewCommandLine == NULL){
+ NewCommandLine = AllocateCopyPool (StrSize (CommandLine), CommandLine);
+ if (NewCommandLine == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- TrimSpaces(&NewCommandLine);
- Size = StrSize(NewCommandLine);
- TempParameter = AllocateZeroPool(Size);
+ TrimSpaces (&NewCommandLine);
+ Size = StrSize (NewCommandLine);
+ TempParameter = AllocateZeroPool (Size);
if (TempParameter == NULL) {
- SHELL_FREE_NON_NULL(NewCommandLine);
+ SHELL_FREE_NON_NULL (NewCommandLine);
return (EFI_OUT_OF_RESOURCES);
}
- for ( Count = 0
- , Walker = (CHAR16*)NewCommandLine
- ; Walker != NULL && *Walker != CHAR_NULL
- ; Count++
- ) {
- if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size, TRUE))) {
+ for ( Count = 0,
+ Walker = (CHAR16 *)NewCommandLine
+ ; Walker != NULL && *Walker != CHAR_NULL
+ ; Count++
+ )
+ {
+ if (EFI_ERROR (GetNextParameter (&Walker, &TempParameter, Size, TRUE))) {
break;
}
}
@@ -239,35 +239,37 @@ ParseCommandLineToArgs( //
// lets allocate the pointer array
//
- (*Argv) = AllocateZeroPool((Count)*sizeof(CHAR16*));
+ (*Argv) = AllocateZeroPool ((Count)*sizeof (CHAR16 *));
if (*Argv == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
- *Argc = 0;
- Walker = (CHAR16*)NewCommandLine;
- while(Walker != NULL && *Walker != CHAR_NULL) {
- SetMem16(TempParameter, Size, CHAR_NULL);
- if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size, StripQuotation))) {
+ *Argc = 0;
+ Walker = (CHAR16 *)NewCommandLine;
+ while (Walker != NULL && *Walker != CHAR_NULL) {
+ SetMem16 (TempParameter, Size, CHAR_NULL);
+ if (EFI_ERROR (GetNextParameter (&Walker, &TempParameter, Size, StripQuotation))) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
- NewParam = AllocateCopyPool(StrSize(TempParameter), TempParameter);
- if (NewParam == NULL){
+ NewParam = AllocateCopyPool (StrSize (TempParameter), TempParameter);
+ if (NewParam == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
- ((CHAR16**)(*Argv))[(*Argc)] = NewParam;
+
+ ((CHAR16 **)(*Argv))[(*Argc)] = NewParam;
(*Argc)++;
}
- ASSERT(Count >= (*Argc));
+
+ ASSERT (Count >= (*Argc));
Status = EFI_SUCCESS;
Done:
- SHELL_FREE_NON_NULL(TempParameter);
- SHELL_FREE_NON_NULL(NewCommandLine);
+ SHELL_FREE_NON_NULL (TempParameter);
+ SHELL_FREE_NON_NULL (NewCommandLine);
return (Status);
}
@@ -293,32 +295,32 @@ CreatePopulateInstallShellParametersProtocol ( IN OUT BOOLEAN *RootShellInstance
)
{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- CHAR16 *FullCommandLine;
- UINTN Size;
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ CHAR16 *FullCommandLine;
+ UINTN Size;
- Size = 0;
+ Size = 0;
FullCommandLine = NULL;
- LoadedImage = NULL;
+ LoadedImage = NULL;
//
// Assert for valid parameters
//
- ASSERT(NewShellParameters != NULL);
- ASSERT(RootShellInstance != NULL);
+ ASSERT (NewShellParameters != NULL);
+ ASSERT (RootShellInstance != NULL);
//
// See if we have a shell parameters placed on us
//
Status = gBS->OpenProtocol (
- gImageHandle,
- &gEfiShellParametersProtocolGuid,
- (VOID **) &ShellInfoObject.OldShellParameters,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ gImageHandle,
+ &gEfiShellParametersProtocolGuid,
+ (VOID **)&ShellInfoObject.OldShellParameters,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
//
// if we don't then we must be the root shell (error is expected)
//
@@ -329,7 +331,7 @@ CreatePopulateInstallShellParametersProtocol ( //
// Allocate the new structure
//
- *NewShellParameters = AllocateZeroPool(sizeof(EFI_SHELL_PARAMETERS_PROTOCOL));
+ *NewShellParameters = AllocateZeroPool (sizeof (EFI_SHELL_PARAMETERS_PROTOCOL));
if ((*NewShellParameters) == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
@@ -338,52 +340,57 @@ CreatePopulateInstallShellParametersProtocol ( // get loaded image protocol
//
Status = gBS->OpenProtocol (
- gImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- ASSERT_EFI_ERROR(Status);
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ ASSERT_EFI_ERROR (Status);
//
// Build the full command line
//
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(L"ShellOpt", &Size, FullCommandLine);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (L"ShellOpt", &Size, FullCommandLine);
if (Status == EFI_BUFFER_TOO_SMALL) {
- FullCommandLine = AllocateZeroPool(Size + LoadedImage->LoadOptionsSize);
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(L"ShellOpt", &Size, FullCommandLine);
+ FullCommandLine = AllocateZeroPool (Size + LoadedImage->LoadOptionsSize);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (L"ShellOpt", &Size, FullCommandLine);
}
+
if (Status == EFI_NOT_FOUND) {
//
// no parameters via environment... ok
//
} else {
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return (Status);
}
}
- if (Size == 0 && LoadedImage->LoadOptionsSize != 0) {
- ASSERT(FullCommandLine == NULL);
+
+ if ((Size == 0) && (LoadedImage->LoadOptionsSize != 0)) {
+ ASSERT (FullCommandLine == NULL);
//
// Now we need to include a NULL terminator in the size.
//
- Size = LoadedImage->LoadOptionsSize + sizeof(FullCommandLine[0]);
- FullCommandLine = AllocateZeroPool(Size);
+ Size = LoadedImage->LoadOptionsSize + sizeof (FullCommandLine[0]);
+ FullCommandLine = AllocateZeroPool (Size);
}
+
if (FullCommandLine != NULL) {
CopyMem (FullCommandLine, LoadedImage->LoadOptions, LoadedImage->LoadOptionsSize);
//
// Populate Argc and Argv
//
- Status = ParseCommandLineToArgs(FullCommandLine,
- TRUE,
- &(*NewShellParameters)->Argv,
- &(*NewShellParameters)->Argc);
+ Status = ParseCommandLineToArgs (
+ FullCommandLine,
+ TRUE,
+ &(*NewShellParameters)->Argv,
+ &(*NewShellParameters)->Argc
+ );
- FreePool(FullCommandLine);
+ FreePool (FullCommandLine);
- ASSERT_EFI_ERROR(Status);
+ ASSERT_EFI_ERROR (Status);
} else {
(*NewShellParameters)->Argv = NULL;
(*NewShellParameters)->Argc = 0;
@@ -396,10 +403,12 @@ CreatePopulateInstallShellParametersProtocol ( (*NewShellParameters)->StdIn = &FileInterfaceStdIn;
(*NewShellParameters)->StdOut = &FileInterfaceStdOut;
(*NewShellParameters)->StdErr = &FileInterfaceStdErr;
- Status = gBS->InstallProtocolInterface(&gImageHandle,
+ Status = gBS->InstallProtocolInterface (
+ &gImageHandle,
&gEfiShellParametersProtocolGuid,
EFI_NATIVE_INTERFACE,
- (VOID*)(*NewShellParameters));
+ (VOID *)(*NewShellParameters)
+ );
} else {
//
// copy from the existing ones
@@ -407,10 +416,12 @@ CreatePopulateInstallShellParametersProtocol ( (*NewShellParameters)->StdIn = ShellInfoObject.OldShellParameters->StdIn;
(*NewShellParameters)->StdOut = ShellInfoObject.OldShellParameters->StdOut;
(*NewShellParameters)->StdErr = ShellInfoObject.OldShellParameters->StdErr;
- Status = gBS->ReinstallProtocolInterface(gImageHandle,
- &gEfiShellParametersProtocolGuid,
- (VOID*)ShellInfoObject.OldShellParameters,
- (VOID*)(*NewShellParameters));
+ Status = gBS->ReinstallProtocolInterface (
+ gImageHandle,
+ &gEfiShellParametersProtocolGuid,
+ (VOID *)ShellInfoObject.OldShellParameters,
+ (VOID *)(*NewShellParameters)
+ );
}
return (Status);
@@ -433,36 +444,46 @@ CleanUpShellParametersProtocol ( IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParameters
)
{
- EFI_STATUS Status;
- UINTN LoopCounter;
+ EFI_STATUS Status;
+ UINTN LoopCounter;
//
// If the old exists we need to restore it
//
if (ShellInfoObject.OldShellParameters != NULL) {
- Status = gBS->ReinstallProtocolInterface(gImageHandle,
- &gEfiShellParametersProtocolGuid,
- (VOID*)NewShellParameters,
- (VOID*)ShellInfoObject.OldShellParameters);
- DEBUG_CODE(ShellInfoObject.OldShellParameters = NULL;);
+ Status = gBS->ReinstallProtocolInterface (
+ gImageHandle,
+ &gEfiShellParametersProtocolGuid,
+ (VOID *)NewShellParameters,
+ (VOID *)ShellInfoObject.OldShellParameters
+ );
+ DEBUG_CODE (
+ ShellInfoObject.OldShellParameters = NULL;
+ );
} else {
//
// No old one, just uninstall us...
//
- Status = gBS->UninstallProtocolInterface(gImageHandle,
- &gEfiShellParametersProtocolGuid,
- (VOID*)NewShellParameters);
+ Status = gBS->UninstallProtocolInterface (
+ gImageHandle,
+ &gEfiShellParametersProtocolGuid,
+ (VOID *)NewShellParameters
+ );
}
+
if (NewShellParameters->Argv != NULL) {
for ( LoopCounter = 0
- ; LoopCounter < NewShellParameters->Argc
- ; LoopCounter++
- ){
- FreePool(NewShellParameters->Argv[LoopCounter]);
+ ; LoopCounter < NewShellParameters->Argc
+ ; LoopCounter++
+ )
+ {
+ FreePool (NewShellParameters->Argv[LoopCounter]);
}
- FreePool(NewShellParameters->Argv);
+
+ FreePool (NewShellParameters->Argv);
}
- FreePool(NewShellParameters);
+
+ FreePool (NewShellParameters);
return (Status);
}
@@ -475,29 +496,31 @@ CleanUpShellParametersProtocol ( @return An error upon failure.
**/
EFI_STATUS
-IsUnicodeFile(
- IN CONST CHAR16 *FileName
+IsUnicodeFile (
+ IN CONST CHAR16 *FileName
)
{
- SHELL_FILE_HANDLE Handle;
- EFI_STATUS Status;
- UINT64 OriginalFilePosition;
- UINTN CharSize;
- CHAR16 CharBuffer;
-
- Status = gEfiShellProtocol->OpenFileByName(FileName, &Handle, EFI_FILE_MODE_READ);
- if (EFI_ERROR(Status)) {
+ SHELL_FILE_HANDLE Handle;
+ EFI_STATUS Status;
+ UINT64 OriginalFilePosition;
+ UINTN CharSize;
+ CHAR16 CharBuffer;
+
+ Status = gEfiShellProtocol->OpenFileByName (FileName, &Handle, EFI_FILE_MODE_READ);
+ if (EFI_ERROR (Status)) {
return (Status);
}
- gEfiShellProtocol->GetFilePosition(Handle, &OriginalFilePosition);
- gEfiShellProtocol->SetFilePosition(Handle, 0);
- CharSize = sizeof(CHAR16);
- Status = gEfiShellProtocol->ReadFile(Handle, &CharSize, &CharBuffer);
- if (EFI_ERROR(Status) || CharBuffer != gUnicodeFileTag) {
+
+ gEfiShellProtocol->GetFilePosition (Handle, &OriginalFilePosition);
+ gEfiShellProtocol->SetFilePosition (Handle, 0);
+ CharSize = sizeof (CHAR16);
+ Status = gEfiShellProtocol->ReadFile (Handle, &CharSize, &CharBuffer);
+ if (EFI_ERROR (Status) || (CharBuffer != gUnicodeFileTag)) {
Status = EFI_BUFFER_TOO_SMALL;
}
- gEfiShellProtocol->SetFilePosition(Handle, OriginalFilePosition);
- gEfiShellProtocol->CloseFile(Handle);
+
+ gEfiShellProtocol->SetFilePosition (Handle, OriginalFilePosition);
+ gEfiShellProtocol->CloseFile (Handle);
return (Status);
}
@@ -510,16 +533,16 @@ IsUnicodeFile( **/
VOID
StripQuotes (
- IN OUT CHAR16 *TheString
+ IN OUT CHAR16 *TheString
)
{
- BOOLEAN RemoveNow;
+ BOOLEAN RemoveNow;
- for (RemoveNow = FALSE ; TheString != NULL && *TheString != CHAR_NULL ; TheString++) {
- if (*TheString == L'^' && *(TheString + 1) == L'\"') {
+ for (RemoveNow = FALSE; TheString != NULL && *TheString != CHAR_NULL; TheString++) {
+ if ((*TheString == L'^') && (*(TheString + 1) == L'\"')) {
TheString++;
} else if (*TheString == L'\"') {
- RemoveNow = (BOOLEAN)!RemoveNow;
+ RemoveNow = (BOOLEAN) !RemoveNow;
} else if (RemoveNow) {
*TheString = L' ';
}
@@ -535,10 +558,10 @@ StripQuotes ( **/
VOID
CalculateEfiHdrCrc (
- IN OUT EFI_TABLE_HEADER *Hdr
+ IN OUT EFI_TABLE_HEADER *Hdr
)
{
- UINT32 Crc;
+ UINT32 Crc;
Hdr->CRC32 = 0;
@@ -559,9 +582,9 @@ CalculateEfiHdrCrc ( @retval NULL FileName was invalid.
@return The modified FileName.
**/
-CHAR16*
+CHAR16 *
FixFileName (
- IN CHAR16 *FileName
+ IN CHAR16 *FileName
)
{
CHAR16 *Copy;
@@ -573,15 +596,16 @@ FixFileName ( if (FileName[0] == L'\"') {
Copy = FileName+1;
- if ((TempLocation = StrStr(Copy , L"\"")) != NULL) {
+ if ((TempLocation = StrStr (Copy, L"\"")) != NULL) {
TempLocation[0] = CHAR_NULL;
}
} else {
Copy = FileName;
- while(Copy[0] == L' ') {
+ while (Copy[0] == L' ') {
Copy++;
}
- if ((TempLocation = StrStr(Copy , L" ")) != NULL) {
+
+ if ((TempLocation = StrStr (Copy, L" ")) != NULL) {
TempLocation[0] = CHAR_NULL;
}
}
@@ -601,9 +625,9 @@ FixFileName ( @retval NULL FileName was invalid.
@return The modified FileName.
**/
-CHAR16*
+CHAR16 *
FixVarName (
- IN CHAR16 *FileName
+ IN CHAR16 *FileName
)
{
CHAR16 *Copy;
@@ -613,15 +637,14 @@ FixVarName ( if (FileName[0] == L'%') {
Copy = FileName+1;
- if ((TempLocation = StrStr(Copy , L"%")) != NULL) {
+ if ((TempLocation = StrStr (Copy, L"%")) != NULL) {
TempLocation[0] = CHAR_NULL;
}
}
- return (FixFileName(Copy));
+ return (FixFileName (Copy));
}
-
/**
Write the unicode file tag to the specified file.
@@ -635,22 +658,24 @@ FixVarName ( **/
EFI_STATUS
WriteFileTag (
- IN SHELL_FILE_HANDLE FileHandle
+ IN SHELL_FILE_HANDLE FileHandle
)
{
- CHAR16 FileTag;
- UINTN Size;
- EFI_STATUS Status;
+ CHAR16 FileTag;
+ UINTN Size;
+ EFI_STATUS Status;
FileTag = gUnicodeFileTag;
- Size = sizeof FileTag;
- Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (FileHandle, &Size,
- &FileTag);
+ Size = sizeof FileTag;
+ Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (
+ FileHandle,
+ &Size,
+ &FileTag
+ );
ASSERT (EFI_ERROR (Status) || Size == sizeof FileTag);
return Status;
}
-
/**
Function will replace the current StdIn and StdOut in the ShellParameters protocol
structure by parsing NewCommandLine. The current values are returned to the
@@ -669,7 +694,7 @@ WriteFileTag ( @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
**/
EFI_STATUS
-UpdateStdInStdOutStdErr(
+UpdateStdInStdOutStdErr (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CHAR16 *NewCommandLine,
OUT SHELL_FILE_HANDLE *OldStdIn,
@@ -678,323 +703,353 @@ UpdateStdInStdOutStdErr( OUT SYSTEM_TABLE_INFO *SystemTableInfo
)
{
- CHAR16 *CommandLineCopy;
- CHAR16 *CommandLineWalker;
- CHAR16 *StdErrFileName;
- CHAR16 *StdOutFileName;
- CHAR16 *StdInFileName;
- CHAR16 *StdInVarName;
- CHAR16 *StdOutVarName;
- CHAR16 *StdErrVarName;
- EFI_STATUS Status;
- SHELL_FILE_HANDLE TempHandle;
- UINT64 FileSize;
- BOOLEAN OutUnicode;
- BOOLEAN InUnicode;
- BOOLEAN ErrUnicode;
- BOOLEAN OutAppend;
- BOOLEAN ErrAppend;
- UINTN Size;
- SPLIT_LIST *Split;
- CHAR16 *FirstLocation;
- BOOLEAN Volatile;
-
- OutUnicode = TRUE;
- InUnicode = TRUE;
+ CHAR16 *CommandLineCopy;
+ CHAR16 *CommandLineWalker;
+ CHAR16 *StdErrFileName;
+ CHAR16 *StdOutFileName;
+ CHAR16 *StdInFileName;
+ CHAR16 *StdInVarName;
+ CHAR16 *StdOutVarName;
+ CHAR16 *StdErrVarName;
+ EFI_STATUS Status;
+ SHELL_FILE_HANDLE TempHandle;
+ UINT64 FileSize;
+ BOOLEAN OutUnicode;
+ BOOLEAN InUnicode;
+ BOOLEAN ErrUnicode;
+ BOOLEAN OutAppend;
+ BOOLEAN ErrAppend;
+ UINTN Size;
+ SPLIT_LIST *Split;
+ CHAR16 *FirstLocation;
+ BOOLEAN Volatile;
+
+ OutUnicode = TRUE;
+ InUnicode = TRUE;
AsciiRedirection = FALSE;
- ErrUnicode = TRUE;
- StdInVarName = NULL;
- StdOutVarName = NULL;
- StdErrVarName = NULL;
- StdErrFileName = NULL;
- StdInFileName = NULL;
- StdOutFileName = NULL;
- ErrAppend = FALSE;
- OutAppend = FALSE;
- CommandLineCopy = NULL;
- FirstLocation = NULL;
-
- if (ShellParameters == NULL || SystemTableInfo == NULL || OldStdIn == NULL || OldStdOut == NULL || OldStdErr == NULL) {
+ ErrUnicode = TRUE;
+ StdInVarName = NULL;
+ StdOutVarName = NULL;
+ StdErrVarName = NULL;
+ StdErrFileName = NULL;
+ StdInFileName = NULL;
+ StdOutFileName = NULL;
+ ErrAppend = FALSE;
+ OutAppend = FALSE;
+ CommandLineCopy = NULL;
+ FirstLocation = NULL;
+
+ if ((ShellParameters == NULL) || (SystemTableInfo == NULL) || (OldStdIn == NULL) || (OldStdOut == NULL) || (OldStdErr == NULL)) {
return (EFI_INVALID_PARAMETER);
}
- SystemTableInfo->ConIn = gST->ConIn;
- SystemTableInfo->ConInHandle = gST->ConsoleInHandle;
- SystemTableInfo->ConOut = gST->ConOut;
- SystemTableInfo->ConOutHandle = gST->ConsoleOutHandle;
- SystemTableInfo->ErrOut = gST->StdErr;
- SystemTableInfo->ErrOutHandle = gST->StandardErrorHandle;
- *OldStdIn = ShellParameters->StdIn;
- *OldStdOut = ShellParameters->StdOut;
- *OldStdErr = ShellParameters->StdErr;
+ SystemTableInfo->ConIn = gST->ConIn;
+ SystemTableInfo->ConInHandle = gST->ConsoleInHandle;
+ SystemTableInfo->ConOut = gST->ConOut;
+ SystemTableInfo->ConOutHandle = gST->ConsoleOutHandle;
+ SystemTableInfo->ErrOut = gST->StdErr;
+ SystemTableInfo->ErrOutHandle = gST->StandardErrorHandle;
+ *OldStdIn = ShellParameters->StdIn;
+ *OldStdOut = ShellParameters->StdOut;
+ *OldStdErr = ShellParameters->StdErr;
if (NewCommandLine == NULL) {
return (EFI_SUCCESS);
}
- CommandLineCopy = StrnCatGrow(&CommandLineCopy, NULL, NewCommandLine, 0);
+ CommandLineCopy = StrnCatGrow (&CommandLineCopy, NULL, NewCommandLine, 0);
if (CommandLineCopy == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- Status = EFI_SUCCESS;
- Split = NULL;
- FirstLocation = CommandLineCopy + StrLen(CommandLineCopy);
- StripQuotes(CommandLineCopy);
+ Status = EFI_SUCCESS;
+ Split = NULL;
+ FirstLocation = CommandLineCopy + StrLen (CommandLineCopy);
+
+ StripQuotes (CommandLineCopy);
- if (!IsListEmpty(&ShellInfoObject.SplitList.Link)) {
- Split = (SPLIT_LIST*)GetFirstNode(&ShellInfoObject.SplitList.Link);
- if (Split != NULL && Split->SplitStdIn != NULL) {
- ShellParameters->StdIn = Split->SplitStdIn;
+ if (!IsListEmpty (&ShellInfoObject.SplitList.Link)) {
+ Split = (SPLIT_LIST *)GetFirstNode (&ShellInfoObject.SplitList.Link);
+ if ((Split != NULL) && (Split->SplitStdIn != NULL)) {
+ ShellParameters->StdIn = Split->SplitStdIn;
}
- if (Split != NULL && Split->SplitStdOut != NULL) {
+
+ if ((Split != NULL) && (Split->SplitStdOut != NULL)) {
ShellParameters->StdOut = Split->SplitStdOut;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>>v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 12, L' ');
- StdErrVarName = CommandLineWalker += 6;
- ErrAppend = TRUE;
- if (StrStr(CommandLineWalker, L" 2>>v ") != NULL) {
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>>v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 12, L' ');
+ StdErrVarName = CommandLineWalker += 6;
+ ErrAppend = TRUE;
+ if (StrStr (CommandLineWalker, L" 2>>v ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 12, L' ');
- StdOutVarName = CommandLineWalker += 6;
- OutAppend = TRUE;
- if (StrStr(CommandLineWalker, L" 1>>v ") != NULL) {
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>>v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 12, L' ');
+ StdOutVarName = CommandLineWalker += 6;
+ OutAppend = TRUE;
+ if (StrStr (CommandLineWalker, L" 1>>v ") != NULL) {
Status = EFI_NOT_FOUND;
}
- } else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
- StdOutVarName = CommandLineWalker += 5;
- OutAppend = TRUE;
- if (StrStr(CommandLineWalker, L" >>v ") != NULL) {
+ } else if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >>v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
+ StdOutVarName = CommandLineWalker += 5;
+ OutAppend = TRUE;
+ if (StrStr (CommandLineWalker, L" >>v ") != NULL) {
Status = EFI_NOT_FOUND;
}
- } else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
- StdOutVarName = CommandLineWalker += 4;
- OutAppend = FALSE;
- if (StrStr(CommandLineWalker, L" >v ") != NULL) {
+ } else if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
+ StdOutVarName = CommandLineWalker += 4;
+ OutAppend = FALSE;
+ if (StrStr (CommandLineWalker, L" >v ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 12, L' ');
- StdOutFileName = CommandLineWalker += 6;
- OutAppend = TRUE;
- OutUnicode = FALSE;
- if (StrStr(CommandLineWalker, L" 1>>a ") != NULL) {
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>>a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 12, L' ');
+ StdOutFileName = CommandLineWalker += 6;
+ OutAppend = TRUE;
+ OutUnicode = FALSE;
+ if (StrStr (CommandLineWalker, L" 1>>a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>> ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>> ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 5;
- OutAppend = TRUE;
+ StdOutFileName = CommandLineWalker += 5;
+ OutAppend = TRUE;
}
- if (StrStr(CommandLineWalker, L" 1>> ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 1>> ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >> ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >> ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 4;
- OutAppend = TRUE;
+ StdOutFileName = CommandLineWalker += 4;
+ OutAppend = TRUE;
}
- if (StrStr(CommandLineWalker, L" >> ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" >> ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >>a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 5;
- OutAppend = TRUE;
- OutUnicode = FALSE;
+ StdOutFileName = CommandLineWalker += 5;
+ OutAppend = TRUE;
+ OutUnicode = FALSE;
}
- if (StrStr(CommandLineWalker, L" >>a ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" >>a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 5;
- OutAppend = FALSE;
- OutUnicode = FALSE;
+ StdOutFileName = CommandLineWalker += 5;
+ OutAppend = FALSE;
+ OutUnicode = FALSE;
}
- if (StrStr(CommandLineWalker, L" 1>a ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 1>a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 4;
- OutAppend = FALSE;
- OutUnicode = FALSE;
+ StdOutFileName = CommandLineWalker += 4;
+ OutAppend = FALSE;
+ OutUnicode = FALSE;
}
- if (StrStr(CommandLineWalker, L" >a ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" >a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>> ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>> ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdErrFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdErrFileName = CommandLineWalker += 5;
- ErrAppend = TRUE;
+ StdErrFileName = CommandLineWalker += 5;
+ ErrAppend = TRUE;
}
- if (StrStr(CommandLineWalker, L" 2>> ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 2>> ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdErrVarName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdErrVarName = CommandLineWalker += 5;
- ErrAppend = FALSE;
+ StdErrVarName = CommandLineWalker += 5;
+ ErrAppend = FALSE;
}
- if (StrStr(CommandLineWalker, L" 2>v ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 2>v ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdOutVarName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutVarName = CommandLineWalker += 5;
- OutAppend = FALSE;
+ StdOutVarName = CommandLineWalker += 5;
+ OutAppend = FALSE;
}
- if (StrStr(CommandLineWalker, L" 1>v ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 1>v ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdErrFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdErrFileName = CommandLineWalker += 5;
- ErrAppend = FALSE;
- ErrUnicode = FALSE;
+ StdErrFileName = CommandLineWalker += 5;
+ ErrAppend = FALSE;
+ ErrUnicode = FALSE;
}
- if (StrStr(CommandLineWalker, L" 2>a ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 2>a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2> ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2> ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdErrFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdErrFileName = CommandLineWalker += 4;
- ErrAppend = FALSE;
+ StdErrFileName = CommandLineWalker += 4;
+ ErrAppend = FALSE;
}
- if (StrStr(CommandLineWalker, L" 2> ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 2> ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1> ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1> ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 4;
- OutAppend = FALSE;
+ StdOutFileName = CommandLineWalker += 4;
+ OutAppend = FALSE;
}
- if (StrStr(CommandLineWalker, L" 1> ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 1> ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" > ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 6, L' ');
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" > ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 6, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 3;
- OutAppend = FALSE;
+ StdOutFileName = CommandLineWalker += 3;
+ OutAppend = FALSE;
}
- if (StrStr(CommandLineWalker, L" > ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" > ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" < ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 6, L' ');
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" < ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 6, L' ');
if (StdInFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdInFileName = CommandLineWalker += 3;
+ StdInFileName = CommandLineWalker += 3;
}
- if (StrStr(CommandLineWalker, L" < ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" < ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" <a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdInFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdInFileName = CommandLineWalker += 4;
- InUnicode = FALSE;
+ StdInFileName = CommandLineWalker += 4;
+ InUnicode = FALSE;
AsciiRedirection = TRUE;
}
- if (StrStr(CommandLineWalker, L" <a ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" <a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" <v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdInVarName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdInVarName = CommandLineWalker += 4;
+ StdInVarName = CommandLineWalker += 4;
}
- if (StrStr(CommandLineWalker, L" <v ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" <v ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
@@ -1002,43 +1057,48 @@ UpdateStdInStdOutStdErr( //
// re-populate the string to support any filenames that were in quotes.
//
- StrnCpyS(CommandLineCopy, StrSize(CommandLineCopy)/sizeof(CHAR16), NewCommandLine, StrLen(NewCommandLine));
+ StrnCpyS (CommandLineCopy, StrSize (CommandLineCopy)/sizeof (CHAR16), NewCommandLine, StrLen (NewCommandLine));
- if (FirstLocation != CommandLineCopy + StrLen(CommandLineCopy)
- && (((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof(CHAR16) < StrLen(NewCommandLine))
- ){
- *(NewCommandLine + ((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof(CHAR16)) = CHAR_NULL;
+ if ( (FirstLocation != CommandLineCopy + StrLen (CommandLineCopy))
+ && (((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof (CHAR16) < StrLen (NewCommandLine))
+ )
+ {
+ *(NewCommandLine + ((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof (CHAR16)) = CHAR_NULL;
}
- if (!EFI_ERROR(Status)) {
-
+ if (!EFI_ERROR (Status)) {
if (StdErrFileName != NULL) {
- if ((StdErrFileName = FixFileName(StdErrFileName)) == NULL) {
+ if ((StdErrFileName = FixFileName (StdErrFileName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
+
if (StdOutFileName != NULL) {
- if ((StdOutFileName = FixFileName(StdOutFileName)) == NULL) {
+ if ((StdOutFileName = FixFileName (StdOutFileName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
+
if (StdInFileName != NULL) {
- if ((StdInFileName = FixFileName(StdInFileName)) == NULL) {
+ if ((StdInFileName = FixFileName (StdInFileName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
+
if (StdErrVarName != NULL) {
- if ((StdErrVarName = FixVarName(StdErrVarName)) == NULL) {
+ if ((StdErrVarName = FixVarName (StdErrVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
+
if (StdOutVarName != NULL) {
- if ((StdOutVarName = FixVarName(StdOutVarName)) == NULL) {
+ if ((StdOutVarName = FixVarName (StdOutVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
+
if (StdInVarName != NULL) {
- if ((StdInVarName = FixVarName(StdInVarName)) == NULL) {
+ if ((StdInVarName = FixVarName (StdInVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
@@ -1047,52 +1107,53 @@ UpdateStdInStdOutStdErr( // Verify not the same and not duplicating something from a split
//
if (
- //
- // Check that no 2 filenames are the same
- //
- (StdErrFileName != NULL && StdOutFileName!= NULL && StringNoCaseCompare(&StdErrFileName, &StdOutFileName) == 0)
- ||(StdErrFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdErrFileName, &StdInFileName ) == 0)
- ||(StdOutFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdOutFileName, &StdInFileName ) == 0)
- //
- // Check that no 2 variable names are the same
- //
- ||(StdErrVarName != NULL && StdInVarName != NULL && StringNoCaseCompare(&StdErrVarName , &StdInVarName ) == 0)
- ||(StdOutVarName != NULL && StdInVarName != NULL && StringNoCaseCompare(&StdOutVarName , &StdInVarName ) == 0)
- ||(StdErrVarName != NULL && StdOutVarName != NULL && StringNoCaseCompare(&StdErrVarName , &StdOutVarName ) == 0)
- //
- // When a split (using | operator) is in place some are not allowed
- //
- ||(Split != NULL && Split->SplitStdIn != NULL && (StdInVarName != NULL || StdInFileName != NULL))
- ||(Split != NULL && Split->SplitStdOut != NULL && (StdOutVarName != NULL || StdOutFileName != NULL))
- //
- // Check that nothing is trying to be output to 2 locations.
- //
- ||(StdErrFileName != NULL && StdErrVarName != NULL)
- ||(StdOutFileName != NULL && StdOutVarName != NULL)
- ||(StdInFileName != NULL && StdInVarName != NULL)
- //
- // Check for no volatile environment variables
- //
- ||(StdErrVarName != NULL && !EFI_ERROR (IsVolatileEnv (StdErrVarName, &Volatile)) && !Volatile)
- ||(StdOutVarName != NULL && !EFI_ERROR (IsVolatileEnv (StdOutVarName, &Volatile)) && !Volatile)
- //
- // Cant redirect during a reconnect operation.
- //
- ||(StrStr(NewCommandLine, L"connect -r") != NULL
- && (StdOutVarName != NULL || StdOutFileName != NULL || StdErrFileName != NULL || StdErrVarName != NULL))
- //
- // Check that filetypes (Unicode/Ascii) do not change during an append
- //
- ||(StdOutFileName != NULL && OutUnicode && OutAppend && (!EFI_ERROR(ShellFileExists(StdOutFileName)) && EFI_ERROR(IsUnicodeFile(StdOutFileName))))
- ||(StdErrFileName != NULL && ErrUnicode && ErrAppend && (!EFI_ERROR(ShellFileExists(StdErrFileName)) && EFI_ERROR(IsUnicodeFile(StdErrFileName))))
- ||(StdOutFileName != NULL && !OutUnicode && OutAppend && (!EFI_ERROR(ShellFileExists(StdOutFileName)) && !EFI_ERROR(IsUnicodeFile(StdOutFileName))))
- ||(StdErrFileName != NULL && !ErrUnicode && ErrAppend && (!EFI_ERROR(ShellFileExists(StdErrFileName)) && !EFI_ERROR(IsUnicodeFile(StdErrFileName))))
- ){
- Status = EFI_INVALID_PARAMETER;
+ //
+ // Check that no 2 filenames are the same
+ //
+ ((StdErrFileName != NULL) && (StdOutFileName != NULL) && (StringNoCaseCompare (&StdErrFileName, &StdOutFileName) == 0))
+ || ((StdErrFileName != NULL) && (StdInFileName != NULL) && (StringNoCaseCompare (&StdErrFileName, &StdInFileName) == 0))
+ || ((StdOutFileName != NULL) && (StdInFileName != NULL) && (StringNoCaseCompare (&StdOutFileName, &StdInFileName) == 0))
+ //
+ // Check that no 2 variable names are the same
+ //
+ || ((StdErrVarName != NULL) && (StdInVarName != NULL) && (StringNoCaseCompare (&StdErrVarName, &StdInVarName) == 0))
+ || ((StdOutVarName != NULL) && (StdInVarName != NULL) && (StringNoCaseCompare (&StdOutVarName, &StdInVarName) == 0))
+ || ((StdErrVarName != NULL) && (StdOutVarName != NULL) && (StringNoCaseCompare (&StdErrVarName, &StdOutVarName) == 0))
+ //
+ // When a split (using | operator) is in place some are not allowed
+ //
+ || ((Split != NULL) && (Split->SplitStdIn != NULL) && ((StdInVarName != NULL) || (StdInFileName != NULL)))
+ || ((Split != NULL) && (Split->SplitStdOut != NULL) && ((StdOutVarName != NULL) || (StdOutFileName != NULL)))
+ //
+ // Check that nothing is trying to be output to 2 locations.
+ //
+ || ((StdErrFileName != NULL) && (StdErrVarName != NULL))
+ || ((StdOutFileName != NULL) && (StdOutVarName != NULL))
+ || ((StdInFileName != NULL) && (StdInVarName != NULL))
+ //
+ // Check for no volatile environment variables
+ //
+ || ((StdErrVarName != NULL) && !EFI_ERROR (IsVolatileEnv (StdErrVarName, &Volatile)) && !Volatile)
+ || ((StdOutVarName != NULL) && !EFI_ERROR (IsVolatileEnv (StdOutVarName, &Volatile)) && !Volatile)
+ //
+ // Cant redirect during a reconnect operation.
+ //
+ || ( (StrStr (NewCommandLine, L"connect -r") != NULL)
+ && ((StdOutVarName != NULL) || (StdOutFileName != NULL) || (StdErrFileName != NULL) || (StdErrVarName != NULL)))
+ //
+ // Check that filetypes (Unicode/Ascii) do not change during an append
+ //
+ || ((StdOutFileName != NULL) && OutUnicode && OutAppend && (!EFI_ERROR (ShellFileExists (StdOutFileName)) && EFI_ERROR (IsUnicodeFile (StdOutFileName))))
+ || ((StdErrFileName != NULL) && ErrUnicode && ErrAppend && (!EFI_ERROR (ShellFileExists (StdErrFileName)) && EFI_ERROR (IsUnicodeFile (StdErrFileName))))
+ || ((StdOutFileName != NULL) && !OutUnicode && OutAppend && (!EFI_ERROR (ShellFileExists (StdOutFileName)) && !EFI_ERROR (IsUnicodeFile (StdOutFileName))))
+ || ((StdErrFileName != NULL) && !ErrUnicode && ErrAppend && (!EFI_ERROR (ShellFileExists (StdErrFileName)) && !EFI_ERROR (IsUnicodeFile (StdErrFileName))))
+ )
+ {
+ Status = EFI_INVALID_PARAMETER;
ShellParameters->StdIn = *OldStdIn;
ShellParameters->StdOut = *OldStdOut;
ShellParameters->StdErr = *OldStdErr;
- } else if (!EFI_ERROR(Status)){
+ } else if (!EFI_ERROR (Status)) {
//
// Open the Std<Whatever> and we should not have conflicts here...
//
@@ -1105,62 +1166,69 @@ UpdateStdInStdOutStdErr( //
// delete existing file.
//
- ShellInfoObject.NewEfiShellProtocol->DeleteFileByName(StdErrFileName);
+ ShellInfoObject.NewEfiShellProtocol->DeleteFileByName (StdErrFileName);
}
- Status = ShellOpenFileByName(StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE,0);
- if (!ErrAppend && ErrUnicode && !EFI_ERROR(Status)) {
+
+ Status = ShellOpenFileByName (StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, 0);
+ if (!ErrAppend && ErrUnicode && !EFI_ERROR (Status)) {
Status = WriteFileTag (TempHandle);
}
- if (!ErrUnicode && !EFI_ERROR(Status)) {
- TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
- ASSERT(TempHandle != NULL);
+
+ if (!ErrUnicode && !EFI_ERROR (Status)) {
+ TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
+ ASSERT (TempHandle != NULL);
}
- if (!EFI_ERROR(Status)) {
+
+ if (!EFI_ERROR (Status)) {
ShellParameters->StdErr = TempHandle;
- gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle, gST->StdErr);
+ gST->StdErr = CreateSimpleTextOutOnFile (TempHandle, &gST->StandardErrorHandle, gST->StdErr);
}
}
//
// StdOut to a file
//
- if (!EFI_ERROR(Status) && StdOutFileName != NULL) {
+ if (!EFI_ERROR (Status) && (StdOutFileName != NULL)) {
if (!OutAppend) {
//
// delete existing file.
//
- ShellInfoObject.NewEfiShellProtocol->DeleteFileByName(StdOutFileName);
+ ShellInfoObject.NewEfiShellProtocol->DeleteFileByName (StdOutFileName);
}
- Status = ShellOpenFileByName(StdOutFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE,0);
+
+ Status = ShellOpenFileByName (StdOutFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, 0);
if (TempHandle == NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
if (gUnicodeCollation->MetaiMatch (gUnicodeCollation, StdOutFileName, L"NUL")) {
- //no-op
- } else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
+ // no-op
+ } else if (!OutAppend && OutUnicode && !EFI_ERROR (Status)) {
Status = WriteFileTag (TempHandle);
} else if (OutAppend) {
- Status = ShellInfoObject.NewEfiShellProtocol->GetFileSize(TempHandle, &FileSize);
- if (!EFI_ERROR(Status)) {
+ Status = ShellInfoObject.NewEfiShellProtocol->GetFileSize (TempHandle, &FileSize);
+ if (!EFI_ERROR (Status)) {
//
// When appending to a new unicode file, write the file tag.
// Otherwise (ie. when appending to a new ASCII file, or an
// existent file with any encoding), just seek to the end.
//
Status = (FileSize == 0 && OutUnicode) ?
- WriteFileTag (TempHandle) :
- ShellInfoObject.NewEfiShellProtocol->SetFilePosition (
- TempHandle,
- FileSize);
+ WriteFileTag (TempHandle) :
+ ShellInfoObject.NewEfiShellProtocol->SetFilePosition (
+ TempHandle,
+ FileSize
+ );
}
}
- if (!OutUnicode && !EFI_ERROR(Status)) {
- TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
- ASSERT(TempHandle != NULL);
+
+ if (!OutUnicode && !EFI_ERROR (Status)) {
+ TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
+ ASSERT (TempHandle != NULL);
}
- if (!EFI_ERROR(Status)) {
+
+ if (!EFI_ERROR (Status)) {
ShellParameters->StdOut = TempHandle;
- gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
+ gST->ConOut = CreateSimpleTextOutOnFile (TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
}
}
}
@@ -1168,52 +1236,55 @@ UpdateStdInStdOutStdErr( //
// StdOut to a var
//
- if (!EFI_ERROR(Status) && StdOutVarName != NULL) {
+ if (!EFI_ERROR (Status) && (StdOutVarName != NULL)) {
if (!OutAppend) {
//
// delete existing variable.
//
- SHELL_SET_ENVIRONMENT_VARIABLE_V(StdOutVarName, 0, L"");
+ SHELL_SET_ENVIRONMENT_VARIABLE_V (StdOutVarName, 0, L"");
}
- TempHandle = CreateFileInterfaceEnv(StdOutVarName);
- ASSERT(TempHandle != NULL);
+
+ TempHandle = CreateFileInterfaceEnv (StdOutVarName);
+ ASSERT (TempHandle != NULL);
ShellParameters->StdOut = TempHandle;
- gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
+ gST->ConOut = CreateSimpleTextOutOnFile (TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
}
//
// StdErr to a var
//
- if (!EFI_ERROR(Status) && StdErrVarName != NULL) {
+ if (!EFI_ERROR (Status) && (StdErrVarName != NULL)) {
if (!ErrAppend) {
//
// delete existing variable.
//
- SHELL_SET_ENVIRONMENT_VARIABLE_V(StdErrVarName, 0, L"");
+ SHELL_SET_ENVIRONMENT_VARIABLE_V (StdErrVarName, 0, L"");
}
- TempHandle = CreateFileInterfaceEnv(StdErrVarName);
- ASSERT(TempHandle != NULL);
+
+ TempHandle = CreateFileInterfaceEnv (StdErrVarName);
+ ASSERT (TempHandle != NULL);
ShellParameters->StdErr = TempHandle;
- gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle, gST->StdErr);
+ gST->StdErr = CreateSimpleTextOutOnFile (TempHandle, &gST->StandardErrorHandle, gST->StdErr);
}
//
// StdIn from a var
//
- if (!EFI_ERROR(Status) && StdInVarName != NULL) {
- TempHandle = CreateFileInterfaceEnv(StdInVarName);
+ if (!EFI_ERROR (Status) && (StdInVarName != NULL)) {
+ TempHandle = CreateFileInterfaceEnv (StdInVarName);
if (TempHandle == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
if (!InUnicode) {
- TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
+ TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
}
+
Size = 0;
- if (TempHandle == NULL || ((EFI_FILE_PROTOCOL*)TempHandle)->Read(TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL) {
+ if ((TempHandle == NULL) || (((EFI_FILE_PROTOCOL *)TempHandle)->Read (TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL)) {
Status = EFI_INVALID_PARAMETER;
} else {
ShellParameters->StdIn = TempHandle;
- gST->ConIn = CreateSimpleTextInOnFile(TempHandle, &gST->ConsoleInHandle);
+ gST->ConIn = CreateSimpleTextInOnFile (TempHandle, &gST->ConsoleInHandle);
}
}
}
@@ -1221,37 +1292,40 @@ UpdateStdInStdOutStdErr( //
// StdIn from a file
//
- if (!EFI_ERROR(Status) && StdInFileName != NULL) {
- Status = ShellOpenFileByName(
- StdInFileName,
- &TempHandle,
- EFI_FILE_MODE_READ,
- 0);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status) && (StdInFileName != NULL)) {
+ Status = ShellOpenFileByName (
+ StdInFileName,
+ &TempHandle,
+ EFI_FILE_MODE_READ,
+ 0
+ );
+ if (!EFI_ERROR (Status)) {
if (!InUnicode) {
//
// Create the ASCII->Unicode conversion layer
//
- TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
+ TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
}
+
ShellParameters->StdIn = TempHandle;
- gST->ConIn = CreateSimpleTextInOnFile(TempHandle, &gST->ConsoleInHandle);
+ gST->ConIn = CreateSimpleTextInOnFile (TempHandle, &gST->ConsoleInHandle);
}
}
}
}
- FreePool(CommandLineCopy);
- CalculateEfiHdrCrc(&gST->Hdr);
+ FreePool (CommandLineCopy);
+
+ CalculateEfiHdrCrc (&gST->Hdr);
- if (gST->ConIn == NULL ||gST->ConOut == NULL) {
+ if ((gST->ConIn == NULL) || (gST->ConOut == NULL)) {
Status = EFI_OUT_OF_RESOURCES;
}
if (Status == EFI_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_REDUNDA_REDIR), ShellInfoObject.HiiHandle);
- } else if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_REDIR), ShellInfoObject.HiiHandle);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_REDUNDA_REDIR), ShellInfoObject.HiiHandle);
+ } else if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_REDIR), ShellInfoObject.HiiHandle);
}
return (Status);
@@ -1276,57 +1350,67 @@ RestoreStdInStdOutStdErr ( IN SYSTEM_TABLE_INFO *SystemTableInfo
)
{
- SPLIT_LIST *Split;
-
- if (ShellParameters == NULL
- ||OldStdIn == NULL
- ||OldStdOut == NULL
- ||OldStdErr == NULL
- ||SystemTableInfo == NULL) {
+ SPLIT_LIST *Split;
+
+ if ( (ShellParameters == NULL)
+ || (OldStdIn == NULL)
+ || (OldStdOut == NULL)
+ || (OldStdErr == NULL)
+ || (SystemTableInfo == NULL))
+ {
return (EFI_INVALID_PARAMETER);
}
- if (!IsListEmpty(&ShellInfoObject.SplitList.Link)) {
- Split = (SPLIT_LIST*)GetFirstNode(&ShellInfoObject.SplitList.Link);
+
+ if (!IsListEmpty (&ShellInfoObject.SplitList.Link)) {
+ Split = (SPLIT_LIST *)GetFirstNode (&ShellInfoObject.SplitList.Link);
} else {
Split = NULL;
}
+
if (ShellParameters->StdIn != *OldStdIn) {
- if ((Split != NULL && Split->SplitStdIn != ShellParameters->StdIn) || Split == NULL) {
- gEfiShellProtocol->CloseFile(ShellParameters->StdIn);
+ if (((Split != NULL) && (Split->SplitStdIn != ShellParameters->StdIn)) || (Split == NULL)) {
+ gEfiShellProtocol->CloseFile (ShellParameters->StdIn);
}
+
ShellParameters->StdIn = *OldStdIn;
}
+
if (ShellParameters->StdOut != *OldStdOut) {
- if ((Split != NULL && Split->SplitStdOut != ShellParameters->StdOut) || Split == NULL) {
- gEfiShellProtocol->CloseFile(ShellParameters->StdOut);
+ if (((Split != NULL) && (Split->SplitStdOut != ShellParameters->StdOut)) || (Split == NULL)) {
+ gEfiShellProtocol->CloseFile (ShellParameters->StdOut);
}
+
ShellParameters->StdOut = *OldStdOut;
}
+
if (ShellParameters->StdErr != *OldStdErr) {
- gEfiShellProtocol->CloseFile(ShellParameters->StdErr);
+ gEfiShellProtocol->CloseFile (ShellParameters->StdErr);
ShellParameters->StdErr = *OldStdErr;
}
if (gST->ConIn != SystemTableInfo->ConIn) {
- CloseSimpleTextInOnFile(gST->ConIn);
- gST->ConIn = SystemTableInfo->ConIn;
- gST->ConsoleInHandle = SystemTableInfo->ConInHandle;
+ CloseSimpleTextInOnFile (gST->ConIn);
+ gST->ConIn = SystemTableInfo->ConIn;
+ gST->ConsoleInHandle = SystemTableInfo->ConInHandle;
}
+
if (gST->ConOut != SystemTableInfo->ConOut) {
- CloseSimpleTextOutOnFile(gST->ConOut);
- gST->ConOut = SystemTableInfo->ConOut;
- gST->ConsoleOutHandle = SystemTableInfo->ConOutHandle;
+ CloseSimpleTextOutOnFile (gST->ConOut);
+ gST->ConOut = SystemTableInfo->ConOut;
+ gST->ConsoleOutHandle = SystemTableInfo->ConOutHandle;
}
+
if (gST->StdErr != SystemTableInfo->ErrOut) {
- CloseSimpleTextOutOnFile(gST->StdErr);
- gST->StdErr = SystemTableInfo->ErrOut;
- gST->StandardErrorHandle = SystemTableInfo->ErrOutHandle;
+ CloseSimpleTextOutOnFile (gST->StdErr);
+ gST->StdErr = SystemTableInfo->ErrOut;
+ gST->StandardErrorHandle = SystemTableInfo->ErrOutHandle;
}
- CalculateEfiHdrCrc(&gST->Hdr);
+ CalculateEfiHdrCrc (&gST->Hdr);
return (EFI_SUCCESS);
}
+
/**
Function will replace the current Argc and Argv in the ShellParameters protocol
structure by parsing NewCommandLine. The current values are returned to the
@@ -1346,7 +1430,7 @@ RestoreStdInStdOutStdErr ( @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
**/
EFI_STATUS
-UpdateArgcArgv(
+UpdateArgcArgv (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CONST CHAR16 *NewCommandLine,
IN SHELL_OPERATION_TYPES Type,
@@ -1354,14 +1438,15 @@ UpdateArgcArgv( OUT UINTN *OldArgc OPTIONAL
)
{
- BOOLEAN StripParamQuotation;
+ BOOLEAN StripParamQuotation;
- ASSERT(ShellParameters != NULL);
+ ASSERT (ShellParameters != NULL);
StripParamQuotation = TRUE;
if (OldArgc != NULL) {
*OldArgc = ShellParameters->Argc;
}
+
if (OldArgc != NULL) {
*OldArgv = ShellParameters->Argv;
}
@@ -1370,11 +1455,12 @@ UpdateArgcArgv( StripParamQuotation = FALSE;
}
- return ParseCommandLineToArgs( NewCommandLine,
- StripParamQuotation,
- &(ShellParameters->Argv),
- &(ShellParameters->Argc)
- );
+ return ParseCommandLineToArgs (
+ NewCommandLine,
+ StripParamQuotation,
+ &(ShellParameters->Argv),
+ &(ShellParameters->Argc)
+ );
}
/**
@@ -1387,28 +1473,32 @@ UpdateArgcArgv( @param[in] OldArgc pointer to old number of items in Argv list
**/
VOID
-RestoreArgcArgv(
+RestoreArgcArgv (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CHAR16 ***OldArgv,
IN UINTN *OldArgc
)
{
- UINTN LoopCounter;
- ASSERT(ShellParameters != NULL);
- ASSERT(OldArgv != NULL);
- ASSERT(OldArgc != NULL);
+ UINTN LoopCounter;
+
+ ASSERT (ShellParameters != NULL);
+ ASSERT (OldArgv != NULL);
+ ASSERT (OldArgc != NULL);
if (ShellParameters->Argv != NULL) {
for ( LoopCounter = 0
- ; LoopCounter < ShellParameters->Argc
- ; LoopCounter++
- ){
- FreePool(ShellParameters->Argv[LoopCounter]);
+ ; LoopCounter < ShellParameters->Argc
+ ; LoopCounter++
+ )
+ {
+ FreePool (ShellParameters->Argv[LoopCounter]);
}
- FreePool(ShellParameters->Argv);
+
+ FreePool (ShellParameters->Argv);
}
+
ShellParameters->Argv = *OldArgv;
- *OldArgv = NULL;
+ *OldArgv = NULL;
ShellParameters->Argc = *OldArgc;
- *OldArgc = 0;
+ *OldArgc = 0;
}
|