summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Library/UefiShellLevel2CommandsLib
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:13 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commit47d20b54f9a65b08aa602a1866c1b59a69088dfc (patch)
treee3241dd169bda79544a36248e834a4bebe298418 /ShellPkg/Library/UefiShellLevel2CommandsLib
parentc411b485b63a671a1e276700cff025c73997233c (diff)
downloadedk2-47d20b54f9a65b08aa602a1866c1b59a69088dfc.tar.gz
edk2-47d20b54f9a65b08aa602a1866c1b59a69088dfc.tar.bz2
edk2-47d20b54f9a65b08aa602a1866c1b59a69088dfc.zip
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/Library/UefiShellLevel2CommandsLib')
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Attrib.c216
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c158
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c573
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c171
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c577
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c1021
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c111
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c557
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c205
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c107
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c288
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Set.c96
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c590
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c177
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h39
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c271
16 files changed, 2725 insertions, 2432 deletions
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Attrib.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Attrib.c
index a5950b4e4b..724dc808ae 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Attrib.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Attrib.c
@@ -9,19 +9,19 @@
#include "UefiShellLevel2CommandsLib.h"
-STATIC CONST CHAR16 AllFiles[] = L"*";
-
-STATIC CONST SHELL_PARAM_ITEM AttribParamList[] = {
- {L"-a", TypeFlag},
- {L"+a", TypeFlag},
- {L"-s", TypeFlag},
- {L"+s", TypeFlag},
- {L"-h", TypeFlag},
- {L"+h", TypeFlag},
- {L"-r", TypeFlag},
- {L"+r", TypeFlag},
- {NULL, TypeMax}
- };
+STATIC CONST CHAR16 AllFiles[] = L"*";
+
+STATIC CONST SHELL_PARAM_ITEM AttribParamList[] = {
+ { L"-a", TypeFlag },
+ { L"+a", TypeFlag },
+ { L"-s", TypeFlag },
+ { L"+s", TypeFlag },
+ { L"-h", TypeFlag },
+ { L"+h", TypeFlag },
+ { L"-r", TypeFlag },
+ { L"+r", TypeFlag },
+ { NULL, TypeMax }
+};
/**
Function for 'attrib' command.
@@ -36,127 +36,137 @@ ShellCommandRunAttrib (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- UINT64 FileAttributesToAdd;
- UINT64 FileAttributesToRemove;
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN ParamNumberCount;
- CONST CHAR16 *FileName;
- EFI_SHELL_FILE_INFO *ListOfFiles;
- EFI_SHELL_FILE_INFO *FileNode;
- EFI_FILE_INFO *FileInfo;
-
- ListOfFiles = NULL;
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
+ UINT64 FileAttributesToAdd;
+ UINT64 FileAttributesToRemove;
+ EFI_STATUS Status;
+ LIST_ENTRY *Package;
+ CHAR16 *ProblemParam;
+ SHELL_STATUS ShellStatus;
+ UINTN ParamNumberCount;
+ CONST CHAR16 *FileName;
+ EFI_SHELL_FILE_INFO *ListOfFiles;
+ EFI_SHELL_FILE_INFO *FileNode;
+ EFI_FILE_INFO *FileInfo;
+
+ ListOfFiles = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ ProblemParam = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (AttribParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"attrib", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"attrib", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
-
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
} else {
- FileAttributesToAdd = 0;
+ FileAttributesToAdd = 0;
FileAttributesToRemove = 0;
//
// apply or remove each flag
//
- if (ShellCommandLineGetFlag(Package, L"+a")) {
+ if (ShellCommandLineGetFlag (Package, L"+a")) {
FileAttributesToAdd |= EFI_FILE_ARCHIVE;
}
- if (ShellCommandLineGetFlag(Package, L"-a")) {
+
+ if (ShellCommandLineGetFlag (Package, L"-a")) {
FileAttributesToRemove |= EFI_FILE_ARCHIVE;
}
- if (ShellCommandLineGetFlag(Package, L"+s")) {
+
+ if (ShellCommandLineGetFlag (Package, L"+s")) {
FileAttributesToAdd |= EFI_FILE_SYSTEM;
}
- if (ShellCommandLineGetFlag(Package, L"-s")) {
+
+ if (ShellCommandLineGetFlag (Package, L"-s")) {
FileAttributesToRemove |= EFI_FILE_SYSTEM;
}
- if (ShellCommandLineGetFlag(Package, L"+h")) {
+
+ if (ShellCommandLineGetFlag (Package, L"+h")) {
FileAttributesToAdd |= EFI_FILE_HIDDEN;
}
- if (ShellCommandLineGetFlag(Package, L"-h")) {
+
+ if (ShellCommandLineGetFlag (Package, L"-h")) {
FileAttributesToRemove |= EFI_FILE_HIDDEN;
}
- if (ShellCommandLineGetFlag(Package, L"+r")) {
+
+ if (ShellCommandLineGetFlag (Package, L"+r")) {
FileAttributesToAdd |= EFI_FILE_READ_ONLY;
}
- if (ShellCommandLineGetFlag(Package, L"-r")) {
+
+ if (ShellCommandLineGetFlag (Package, L"-r")) {
FileAttributesToRemove |= EFI_FILE_READ_ONLY;
}
- if (FileAttributesToRemove == 0 && FileAttributesToAdd == 0) {
+ if ((FileAttributesToRemove == 0) && (FileAttributesToAdd == 0)) {
//
// Do display as we have no attributes to change
//
for ( ParamNumberCount = 1
- ;
- ; ParamNumberCount++
- ){
- FileName = ShellCommandLineGetRawValue(Package, ParamNumberCount);
+ ;
+ ; ParamNumberCount++
+ )
+ {
+ FileName = ShellCommandLineGetRawValue (Package, ParamNumberCount);
// if we dont have anything left, move on...
- if (FileName == NULL && ParamNumberCount == 1) {
- FileName = (CHAR16*)AllFiles;
+ if ((FileName == NULL) && (ParamNumberCount == 1)) {
+ FileName = (CHAR16 *)AllFiles;
} else if (FileName == NULL) {
break;
}
- ASSERT(ListOfFiles == NULL);
- Status = ShellOpenFileMetaArg((CHAR16*)FileName, EFI_FILE_MODE_READ, &ListOfFiles);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
+
+ ASSERT (ListOfFiles == NULL);
+ Status = ShellOpenFileMetaArg ((CHAR16 *)FileName, EFI_FILE_MODE_READ, &ListOfFiles);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue (Package, ParamNumberCount));
ShellStatus = SHELL_NOT_FOUND;
} else {
- for (FileNode = (EFI_SHELL_FILE_INFO*)GetFirstNode(&ListOfFiles->Link)
- ; !IsNull(&ListOfFiles->Link, &FileNode->Link)
- ; FileNode = (EFI_SHELL_FILE_INFO*)GetNextNode(&ListOfFiles->Link, &FileNode->Link)
- ){
- ShellPrintHiiEx(
+ for (FileNode = (EFI_SHELL_FILE_INFO *)GetFirstNode (&ListOfFiles->Link)
+ ; !IsNull (&ListOfFiles->Link, &FileNode->Link)
+ ; FileNode = (EFI_SHELL_FILE_INFO *)GetNextNode (&ListOfFiles->Link, &FileNode->Link)
+ )
+ {
+ ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_ATTRIB_OUTPUT_LINE),
gShellLevel2HiiHandle,
- FileNode->Info->Attribute&EFI_FILE_DIRECTORY? L'D':L' ',
- FileNode->Info->Attribute&EFI_FILE_ARCHIVE? L'A':L' ',
- FileNode->Info->Attribute&EFI_FILE_SYSTEM? L'S':L' ',
- FileNode->Info->Attribute&EFI_FILE_HIDDEN? L'H':L' ',
- FileNode->Info->Attribute&EFI_FILE_READ_ONLY? L'R':L' ',
+ FileNode->Info->Attribute&EFI_FILE_DIRECTORY ? L'D' : L' ',
+ FileNode->Info->Attribute&EFI_FILE_ARCHIVE ? L'A' : L' ',
+ FileNode->Info->Attribute&EFI_FILE_SYSTEM ? L'S' : L' ',
+ FileNode->Info->Attribute&EFI_FILE_HIDDEN ? L'H' : L' ',
+ FileNode->Info->Attribute&EFI_FILE_READ_ONLY ? L'R' : L' ',
FileNode->FileName
- );
+ );
- if (ShellGetExecutionBreakFlag()) {
- ShellStatus = SHELL_ABORTED;
- break;
+ if (ShellGetExecutionBreakFlag ()) {
+ ShellStatus = SHELL_ABORTED;
+ break;
}
}
- Status = ShellCloseFileMetaArg(&ListOfFiles);
+
+ Status = ShellCloseFileMetaArg (&ListOfFiles);
ListOfFiles = NULL;
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_CLOSE_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_CLOSE_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue (Package, ParamNumberCount));
ShellStatus = SHELL_NOT_FOUND;
}
} // for loop for handling wildcard filenames
@@ -165,26 +175,28 @@ ShellCommandRunAttrib (
//
// fail as we have conflcting params.
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle, L"attrib");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle, L"attrib");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// enumerate through all the files/directories and apply the attributes
//
for ( ParamNumberCount = 1
- ;
- ; ParamNumberCount++
- ){
- FileName = ShellCommandLineGetRawValue(Package, ParamNumberCount);
+ ;
+ ; ParamNumberCount++
+ )
+ {
+ FileName = ShellCommandLineGetRawValue (Package, ParamNumberCount);
// if we dont have anything left, move on...
if (FileName == NULL) {
//
// make sure we are not failing on the first one we do... if yes that's an error...
//
if (ParamNumberCount == 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"attrib");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"attrib");
ShellStatus = SHELL_INVALID_PARAMETER;
}
+
break;
}
@@ -196,24 +208,25 @@ ShellCommandRunAttrib (
//
// Open the file(s)
//
- ASSERT(ListOfFiles == NULL);
- Status = ShellOpenFileMetaArg((CHAR16*)FileName, EFI_FILE_MODE_READ, &ListOfFiles);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
+ ASSERT (ListOfFiles == NULL);
+ Status = ShellOpenFileMetaArg ((CHAR16 *)FileName, EFI_FILE_MODE_READ, &ListOfFiles);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue (Package, ParamNumberCount));
ShellStatus = SHELL_NOT_FOUND;
} else {
- for (FileNode = (EFI_SHELL_FILE_INFO*)GetFirstNode(&ListOfFiles->Link)
- ; !IsNull(&ListOfFiles->Link, &FileNode->Link)
- ; FileNode = (EFI_SHELL_FILE_INFO*)GetNextNode(&ListOfFiles->Link, &FileNode->Link)
- ){
+ for (FileNode = (EFI_SHELL_FILE_INFO *)GetFirstNode (&ListOfFiles->Link)
+ ; !IsNull (&ListOfFiles->Link, &FileNode->Link)
+ ; FileNode = (EFI_SHELL_FILE_INFO *)GetNextNode (&ListOfFiles->Link, &FileNode->Link)
+ )
+ {
//
// skip the directory traversing stuff...
//
- if (StrCmp(FileNode->FileName, L".") == 0 || StrCmp(FileNode->FileName, L"..") == 0) {
+ if ((StrCmp (FileNode->FileName, L".") == 0) || (StrCmp (FileNode->FileName, L"..") == 0)) {
continue;
}
- FileInfo = gEfiShellProtocol->GetFileInfo(FileNode->Handle);
+ FileInfo = gEfiShellProtocol->GetFileInfo (FileNode->Handle);
//
// if we are removing Read-Only we need to do that alone
@@ -223,9 +236,9 @@ ShellCommandRunAttrib (
//
// SetFileInfo
//
- Status = ShellSetFileInfo(FileNode->Handle, FileInfo);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
+ Status = ShellSetFileInfo (FileNode->Handle, FileInfo);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue (Package, ParamNumberCount));
ShellStatus = SHELL_ACCESS_DENIED;
}
}
@@ -239,18 +252,19 @@ ShellCommandRunAttrib (
//
// SetFileInfo
//
- Status = ShellSetFileInfo(FileNode->Handle, FileInfo);
- if (EFI_ERROR(Status)) {;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
+ Status = ShellSetFileInfo (FileNode->Handle, FileInfo);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue (Package, ParamNumberCount));
ShellStatus = SHELL_ACCESS_DENIED;
}
- SHELL_FREE_NON_NULL(FileInfo);
+ SHELL_FREE_NON_NULL (FileInfo);
}
- Status = ShellCloseFileMetaArg(&ListOfFiles);
+
+ Status = ShellCloseFileMetaArg (&ListOfFiles);
ListOfFiles = NULL;
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_CLOSE_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue(Package, ParamNumberCount));
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_CLOSE_FAIL), gShellLevel2HiiHandle, L"attrib", ShellCommandLineGetRawValue (Package, ParamNumberCount));
ShellStatus = SHELL_NOT_FOUND;
}
} // for loop for handling wildcard filenames
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
index 30243da222..48ef988fb7 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
@@ -31,33 +31,33 @@ ReplaceDriveWithCwd (
IN CONST CHAR16 *Cwd
)
{
- CHAR16 *Splitter;
- CHAR16 *TempBuffer;
- UINTN TotalSize;
+ CHAR16 *Splitter;
+ CHAR16 *TempBuffer;
+ UINTN TotalSize;
Splitter = NULL;
TempBuffer = NULL;
TotalSize = 0;
- if (FullPath == NULL || *FullPath == NULL) {
+ if ((FullPath == NULL) || (*FullPath == NULL)) {
return EFI_SUCCESS;
}
Splitter = StrStr (*FullPath, L":");
- ASSERT(Splitter != *FullPath);
+ ASSERT (Splitter != *FullPath);
- if (Splitter != NULL && *(Splitter + 1) != L'\\' && *(Splitter + 1) != L'/') {
- TotalSize = StrSize (Cwd) + StrSize (Splitter + 1);
+ if ((Splitter != NULL) && (*(Splitter + 1) != L'\\') && (*(Splitter + 1) != L'/')) {
+ TotalSize = StrSize (Cwd) + StrSize (Splitter + 1);
TempBuffer = AllocateZeroPool (TotalSize);
if (TempBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- StrCpyS (TempBuffer, TotalSize / sizeof(CHAR16), Cwd);
- StrCatS (TempBuffer, TotalSize / sizeof(CHAR16), L"\\");
- StrCatS (TempBuffer, TotalSize / sizeof(CHAR16), Splitter + 1);
+ StrCpyS (TempBuffer, TotalSize / sizeof (CHAR16), Cwd);
+ StrCatS (TempBuffer, TotalSize / sizeof (CHAR16), L"\\");
+ StrCatS (TempBuffer, TotalSize / sizeof (CHAR16), Splitter + 1);
- FreePool(*FullPath);
+ FreePool (*FullPath);
*FullPath = TempBuffer;
}
@@ -75,17 +75,17 @@ ReplaceDriveWithCwd (
**/
BOOLEAN
IsCurrentFileSystem (
- IN CONST CHAR16 *FullPath,
- IN CONST CHAR16 *Cwd
+ IN CONST CHAR16 *FullPath,
+ IN CONST CHAR16 *Cwd
)
{
- CHAR16 *Splitter1;
- CHAR16 *Splitter2;
+ CHAR16 *Splitter1;
+ CHAR16 *Splitter2;
Splitter1 = NULL;
Splitter2 = NULL;
- ASSERT(FullPath != NULL);
+ ASSERT (FullPath != NULL);
Splitter1 = StrStr (FullPath, L":");
if (Splitter1 == NULL) {
@@ -94,10 +94,10 @@ IsCurrentFileSystem (
Splitter2 = StrStr (Cwd, L":");
- if (((UINTN) Splitter1 - (UINTN) FullPath) != ((UINTN) Splitter2 - (UINTN) Cwd)) {
+ if (((UINTN)Splitter1 - (UINTN)FullPath) != ((UINTN)Splitter2 - (UINTN)Cwd)) {
return FALSE;
} else {
- if (StrniCmp (FullPath, Cwd, ((UINTN) Splitter1 - (UINTN) FullPath) / sizeof (CHAR16)) == 0) {
+ if (StrniCmp (FullPath, Cwd, ((UINTN)Splitter1 - (UINTN)FullPath) / sizeof (CHAR16)) == 0) {
return TRUE;
} else {
return FALSE;
@@ -119,12 +119,12 @@ IsCurrentFileSystem (
**/
EFI_STATUS
ExtractDriveAndPath (
- IN CONST CHAR16 *FullPath,
- OUT CHAR16 **Drive,
- OUT CHAR16 **Path
+ IN CONST CHAR16 *FullPath,
+ OUT CHAR16 **Drive,
+ OUT CHAR16 **Path
)
{
- CHAR16 *Splitter;
+ CHAR16 *Splitter;
ASSERT (FullPath != NULL);
@@ -132,22 +132,23 @@ ExtractDriveAndPath (
if (Splitter == NULL) {
*Drive = NULL;
- *Path = AllocateCopyPool (StrSize (FullPath), FullPath);
+ *Path = AllocateCopyPool (StrSize (FullPath), FullPath);
if (*Path == NULL) {
return EFI_OUT_OF_RESOURCES;
}
} else {
if (*(Splitter + 1) == CHAR_NULL) {
*Drive = AllocateCopyPool (StrSize (FullPath), FullPath);
- *Path = NULL;
+ *Path = NULL;
if (*Drive == NULL) {
return EFI_OUT_OF_RESOURCES;
}
} else {
- *Drive = AllocateCopyPool ((Splitter - FullPath + 2) * sizeof(CHAR16), FullPath);
+ *Drive = AllocateCopyPool ((Splitter - FullPath + 2) * sizeof (CHAR16), FullPath);
if (*Drive == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
(*Drive)[Splitter - FullPath + 1] = CHAR_NULL;
*Path = AllocateCopyPool (StrSize (Splitter + 1), Splitter + 1);
@@ -174,59 +175,59 @@ ShellCommandRunCd (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CONST CHAR16 *Cwd;
- CHAR16 *Path;
- CHAR16 *Drive;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Param1;
- CHAR16 *Param1Copy;
- CHAR16 *Walker;
- CHAR16 *Splitter;
- CHAR16 *TempBuffer;
- UINTN TotalSize;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- Cwd = NULL;
- Path = NULL;
- Drive = NULL;
- Splitter = NULL;
- TempBuffer = NULL;
- TotalSize = 0;
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
+ EFI_STATUS Status;
+ LIST_ENTRY *Package;
+ CONST CHAR16 *Cwd;
+ CHAR16 *Path;
+ CHAR16 *Drive;
+ CHAR16 *ProblemParam;
+ SHELL_STATUS ShellStatus;
+ CONST CHAR16 *Param1;
+ CHAR16 *Param1Copy;
+ CHAR16 *Walker;
+ CHAR16 *Splitter;
+ CHAR16 *TempBuffer;
+ UINTN TotalSize;
+
+ ProblemParam = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ Cwd = NULL;
+ Path = NULL;
+ Drive = NULL;
+ Splitter = NULL;
+ TempBuffer = NULL;
+ TotalSize = 0;
+
+ Status = CommandInit ();
+ ASSERT_EFI_ERROR (Status);
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cd", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cd", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
}
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"cd");
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
+ } else if (ShellCommandLineGetRawValue (Package, 2) != NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"cd");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
@@ -237,7 +238,7 @@ ShellCommandRunCd (
//
Cwd = ShellGetCurrentDir (NULL);
if (Cwd == NULL) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd");
ShellStatus = SHELL_NOT_FOUND;
} else {
Param1 = ShellCommandLineGetRawValue (Package, 1);
@@ -245,17 +246,17 @@ ShellCommandRunCd (
//
// display the current directory
//
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_CD_PRINT), gShellLevel2HiiHandle, Cwd);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CD_PRINT), gShellLevel2HiiHandle, Cwd);
} else {
Param1Copy = CatSPrint (NULL, L"%s", Param1, NULL);
for (Walker = Param1Copy; Walker != NULL && *Walker != CHAR_NULL; Walker++) {
if (*Walker == L'\"') {
- CopyMem (Walker, Walker + 1, StrSize(Walker) - sizeof(Walker[0]));
+ CopyMem (Walker, Walker + 1, StrSize (Walker) - sizeof (Walker[0]));
}
}
- if (Param1Copy != NULL && IsCurrentFileSystem (Param1Copy, Cwd)) {
- Status = ReplaceDriveWithCwd (&Param1Copy,Cwd);
+ if ((Param1Copy != NULL) && IsCurrentFileSystem (Param1Copy, Cwd)) {
+ Status = ReplaceDriveWithCwd (&Param1Copy, Cwd);
} else {
//
// Can't use cd command to change filesystem.
@@ -264,27 +265,27 @@ ShellCommandRunCd (
Status = EFI_NOT_FOUND;
}
- if (!EFI_ERROR(Status) && Param1Copy != NULL) {
+ if (!EFI_ERROR (Status) && (Param1Copy != NULL)) {
Splitter = StrStr (Cwd, L":");
if (Param1Copy[0] == L'\\') {
//
// Absolute Path on current drive letter.
//
- TotalSize = ((Splitter - Cwd + 1) * sizeof(CHAR16)) + StrSize(Param1Copy);
+ TotalSize = ((Splitter - Cwd + 1) * sizeof (CHAR16)) + StrSize (Param1Copy);
TempBuffer = AllocateZeroPool (TotalSize);
if (TempBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
- StrnCpyS (TempBuffer, TotalSize / sizeof(CHAR16), Cwd, (Splitter - Cwd + 1));
- StrCatS (TempBuffer, TotalSize / sizeof(CHAR16), Param1Copy);
+ StrnCpyS (TempBuffer, TotalSize / sizeof (CHAR16), Cwd, (Splitter - Cwd + 1));
+ StrCatS (TempBuffer, TotalSize / sizeof (CHAR16), Param1Copy);
FreePool (Param1Copy);
Param1Copy = TempBuffer;
TempBuffer = NULL;
}
} else {
- if (StrStr (Param1Copy,L":") == NULL) {
- TotalSize = StrSize (Cwd) + StrSize (Param1Copy);
+ if (StrStr (Param1Copy, L":") == NULL) {
+ TotalSize = StrSize (Cwd) + StrSize (Param1Copy);
TempBuffer = AllocateZeroPool (TotalSize);
if (TempBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -301,19 +302,19 @@ ShellCommandRunCd (
}
}
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
Param1Copy = PathCleanUpDirectories (Param1Copy);
- Status = ExtractDriveAndPath (Param1Copy, &Drive, &Path);
+ Status = ExtractDriveAndPath (Param1Copy, &Drive, &Path);
}
- if (!EFI_ERROR (Status) && Drive != NULL && Path != NULL) {
- if (EFI_ERROR(ShellIsDirectory (Param1Copy))) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cd", Param1Copy);
+ if (!EFI_ERROR (Status) && (Drive != NULL) && (Path != NULL)) {
+ if (EFI_ERROR (ShellIsDirectory (Param1Copy))) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cd", Param1Copy);
ShellStatus = SHELL_NOT_FOUND;
} else {
Status = gEfiShellProtocol->SetCurDir (Drive, Path + 1);
if (EFI_ERROR (Status)) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cd", Param1Copy);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cd", Param1Copy);
ShellStatus = SHELL_NOT_FOUND;
}
}
@@ -342,4 +343,3 @@ ShellCommandRunCd (
//
return (ShellStatus);
}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
index 4a2c2cfe64..c3927ca35b 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
@@ -29,7 +29,7 @@
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed
**/
SHELL_STATUS
-ValidateAndCopyFiles(
+ValidateAndCopyFiles (
IN CONST EFI_SHELL_FILE_INFO *FileList,
IN CONST CHAR16 *DestDir,
IN BOOLEAN SilentMode,
@@ -51,12 +51,12 @@ ValidateAndCopyFiles(
@retval SHELL_SUCCESS The source file was copied to the destination
**/
SHELL_STATUS
-CopySingleFile(
- IN CONST CHAR16 *Source,
- IN CONST CHAR16 *Dest,
- OUT VOID **Resp,
- IN BOOLEAN SilentMode,
- IN CONST CHAR16 *CmdName
+CopySingleFile (
+ IN CONST CHAR16 *Source,
+ IN CONST CHAR16 *Dest,
+ OUT VOID **Resp,
+ IN BOOLEAN SilentMode,
+ IN CONST CHAR16 *CmdName
)
{
VOID *Response;
@@ -75,28 +75,29 @@ CopySingleFile(
EFI_FILE_SYSTEM_INFO *DestVolumeInfo;
UINTN DestVolumeInfoSize;
- ASSERT(Resp != NULL);
+ ASSERT (Resp != NULL);
- SourceHandle = NULL;
- DestHandle = NULL;
- Response = *Resp;
- List = NULL;
- DestVolumeInfo = NULL;
- ShellStatus = SHELL_SUCCESS;
+ SourceHandle = NULL;
+ DestHandle = NULL;
+ Response = *Resp;
+ List = NULL;
+ DestVolumeInfo = NULL;
+ ShellStatus = SHELL_SUCCESS;
- ReadSize = PcdGet32(PcdShellFileOperationSize);
+ ReadSize = PcdGet32 (PcdShellFileOperationSize);
// Why bother copying a file to itself
- if (StrCmp(Source, Dest) == 0) {
+ if (StrCmp (Source, Dest) == 0) {
return (SHELL_SUCCESS);
}
//
// if the destination file existed check response and possibly prompt user
//
- if (ShellFileExists(Dest) == EFI_SUCCESS) {
- if (Response == NULL && !SilentMode) {
- Status = ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
+ if (ShellFileExists (Dest) == EFI_SUCCESS) {
+ if ((Response == NULL) && !SilentMode) {
+ Status = ShellPromptForResponseHii (ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
}
+
//
// possibly return based on response
//
@@ -104,7 +105,8 @@ CopySingleFile(
if (Response == NULL) {
return SHELL_ABORTED;
}
- switch (*(SHELL_PROMPT_RESPONSE*)Response) {
+
+ switch (*(SHELL_PROMPT_RESPONSE *)Response) {
case ShellPromptResponseNo:
//
// return success here so we dont stop the process
@@ -126,39 +128,39 @@ CopySingleFile(
}
}
- if (ShellIsDirectory(Source) == EFI_SUCCESS) {
- Status = ShellCreateDirectory(Dest, &DestHandle);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_DIR_FAIL), gShellLevel2HiiHandle, CmdName, Dest);
+ if (ShellIsDirectory (Source) == EFI_SUCCESS) {
+ Status = ShellCreateDirectory (Dest, &DestHandle);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_DIR_FAIL), gShellLevel2HiiHandle, CmdName, Dest);
return (SHELL_ACCESS_DENIED);
}
//
// Now copy all the files under the directory...
//
- TempName = NULL;
- Size = 0;
- StrnCatGrow(&TempName, &Size, Source, 0);
- StrnCatGrow(&TempName, &Size, L"\\*", 0);
+ TempName = NULL;
+ Size = 0;
+ StrnCatGrow (&TempName, &Size, Source, 0);
+ StrnCatGrow (&TempName, &Size, L"\\*", 0);
if (TempName != NULL) {
- ShellOpenFileMetaArg((CHAR16*)TempName, EFI_FILE_MODE_READ, &List);
+ ShellOpenFileMetaArg ((CHAR16 *)TempName, EFI_FILE_MODE_READ, &List);
*TempName = CHAR_NULL;
- StrnCatGrow(&TempName, &Size, Dest, 0);
- StrnCatGrow(&TempName, &Size, L"\\", 0);
- ShellStatus = ValidateAndCopyFiles(List, TempName, SilentMode, TRUE, Resp);
- ShellCloseFileMetaArg(&List);
- SHELL_FREE_NON_NULL(TempName);
+ StrnCatGrow (&TempName, &Size, Dest, 0);
+ StrnCatGrow (&TempName, &Size, L"\\", 0);
+ ShellStatus = ValidateAndCopyFiles (List, TempName, SilentMode, TRUE, Resp);
+ ShellCloseFileMetaArg (&List);
+ SHELL_FREE_NON_NULL (TempName);
Size = 0;
}
} else {
- Status = ShellDeleteFileByName(Dest);
+ Status = ShellDeleteFileByName (Dest);
//
// open file with create enabled
//
- Status = ShellOpenFileByName(Dest, &DestHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_OPEN_FAIL), gShellLevel2HiiHandle, CmdName, Dest);
+ Status = ShellOpenFileByName (Dest, &DestHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_OPEN_FAIL), gShellLevel2HiiHandle, CmdName, Dest);
return (SHELL_ACCESS_DENIED);
}
@@ -172,90 +174,93 @@ CopySingleFile(
}
//
- //get file size of source file and freespace available on destination volume
+ // get file size of source file and freespace available on destination volume
//
- ShellGetFileSize(SourceHandle, &SourceFileSize);
- ShellGetFileSize(DestHandle, &DestFileSize);
+ ShellGetFileSize (SourceHandle, &SourceFileSize);
+ ShellGetFileSize (DestHandle, &DestFileSize);
//
- //if the destination file already exists then it will be replaced, meaning the sourcefile effectively needs less storage space
+ // if the destination file already exists then it will be replaced, meaning the sourcefile effectively needs less storage space
//
- if(DestFileSize < SourceFileSize){
+ if (DestFileSize < SourceFileSize) {
SourceFileSize -= DestFileSize;
} else {
SourceFileSize = 0;
}
//
- //get the system volume info to check the free space
+ // get the system volume info to check the free space
//
- DestVolumeFP = ConvertShellHandleToEfiFileProtocol(DestHandle);
- DestVolumeInfo = NULL;
+ DestVolumeFP = ConvertShellHandleToEfiFileProtocol (DestHandle);
+ DestVolumeInfo = NULL;
DestVolumeInfoSize = 0;
- Status = DestVolumeFP->GetInfo(
- DestVolumeFP,
- &gEfiFileSystemInfoGuid,
- &DestVolumeInfoSize,
- DestVolumeInfo
- );
+ Status = DestVolumeFP->GetInfo (
+ DestVolumeFP,
+ &gEfiFileSystemInfoGuid,
+ &DestVolumeInfoSize,
+ DestVolumeInfo
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- DestVolumeInfo = AllocateZeroPool(DestVolumeInfoSize);
- Status = DestVolumeFP->GetInfo(
- DestVolumeFP,
- &gEfiFileSystemInfoGuid,
- &DestVolumeInfoSize,
- DestVolumeInfo
- );
+ DestVolumeInfo = AllocateZeroPool (DestVolumeInfoSize);
+ Status = DestVolumeFP->GetInfo (
+ DestVolumeFP,
+ &gEfiFileSystemInfoGuid,
+ &DestVolumeInfoSize,
+ DestVolumeInfo
+ );
}
//
- //check if enough space available on destination drive to complete copy
+ // check if enough space available on destination drive to complete copy
//
- if (DestVolumeInfo!= NULL && (DestVolumeInfo->FreeSpace < SourceFileSize)) {
+ if ((DestVolumeInfo != NULL) && (DestVolumeInfo->FreeSpace < SourceFileSize)) {
//
- //not enough space on destination directory to copy file
+ // not enough space on destination directory to copy file
//
- SHELL_FREE_NON_NULL(DestVolumeInfo);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_FAIL), gShellLevel2HiiHandle, CmdName);
- return(SHELL_VOLUME_FULL);
+ SHELL_FREE_NON_NULL (DestVolumeInfo);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_FAIL), gShellLevel2HiiHandle, CmdName);
+ return (SHELL_VOLUME_FULL);
} else {
//
// copy data between files
//
- Buffer = AllocateZeroPool(ReadSize);
+ Buffer = AllocateZeroPool (ReadSize);
if (Buffer == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, CmdName);
return SHELL_OUT_OF_RESOURCES;
}
- while (ReadSize == PcdGet32(PcdShellFileOperationSize) && !EFI_ERROR(Status)) {
- Status = ShellReadFile(SourceHandle, &ReadSize, Buffer);
- if (!EFI_ERROR(Status)) {
- Status = ShellWriteFile(DestHandle, &ReadSize, Buffer);
- if (EFI_ERROR(Status)) {
- ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT));
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_WRITE_ERROR), gShellLevel2HiiHandle, CmdName, Dest);
+
+ while (ReadSize == PcdGet32 (PcdShellFileOperationSize) && !EFI_ERROR (Status)) {
+ Status = ShellReadFile (SourceHandle, &ReadSize, Buffer);
+ if (!EFI_ERROR (Status)) {
+ Status = ShellWriteFile (DestHandle, &ReadSize, Buffer);
+ if (EFI_ERROR (Status)) {
+ ShellStatus = (SHELL_STATUS)(Status & (~MAX_BIT));
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_WRITE_ERROR), gShellLevel2HiiHandle, CmdName, Dest);
break;
}
} else {
- ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT));
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_READ_ERROR), gShellLevel2HiiHandle, CmdName, Source);
+ ShellStatus = (SHELL_STATUS)(Status & (~MAX_BIT));
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_READ_ERROR), gShellLevel2HiiHandle, CmdName, Source);
break;
}
}
}
- SHELL_FREE_NON_NULL(DestVolumeInfo);
+
+ SHELL_FREE_NON_NULL (DestVolumeInfo);
}
//
// close files
//
if (DestHandle != NULL) {
- ShellCloseFile(&DestHandle);
- DestHandle = NULL;
+ ShellCloseFile (&DestHandle);
+ DestHandle = NULL;
}
+
if (SourceHandle != NULL) {
- ShellCloseFile(&SourceHandle);
+ ShellCloseFile (&SourceHandle);
SourceHandle = NULL;
}
@@ -286,7 +291,7 @@ CopySingleFile(
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed
**/
SHELL_STATUS
-ValidateAndCopyFiles(
+ValidateAndCopyFiles (
IN CONST EFI_SHELL_FILE_INFO *FileList,
IN CONST CHAR16 *DestDir,
IN BOOLEAN SilentMode,
@@ -294,17 +299,17 @@ ValidateAndCopyFiles(
IN VOID **Resp
)
{
- CHAR16 *HiiOutput;
- CHAR16 *HiiResultOk;
- CONST EFI_SHELL_FILE_INFO *Node;
- SHELL_STATUS ShellStatus;
- EFI_STATUS Status;
- CHAR16 *DestPath;
- VOID *Response;
- UINTN PathSize;
- CONST CHAR16 *Cwd;
- UINTN NewSize;
- CHAR16 *CleanFilePathStr;
+ CHAR16 *HiiOutput;
+ CHAR16 *HiiResultOk;
+ CONST EFI_SHELL_FILE_INFO *Node;
+ SHELL_STATUS ShellStatus;
+ EFI_STATUS Status;
+ CHAR16 *DestPath;
+ VOID *Response;
+ UINTN PathSize;
+ CONST CHAR16 *Cwd;
+ UINTN NewSize;
+ CHAR16 *CleanFilePathStr;
if (Resp == NULL) {
Response = NULL;
@@ -315,12 +320,11 @@ ValidateAndCopyFiles(
DestPath = NULL;
ShellStatus = SHELL_SUCCESS;
PathSize = 0;
- Cwd = ShellGetCurrentDir(NULL);
+ Cwd = ShellGetCurrentDir (NULL);
CleanFilePathStr = NULL;
- ASSERT(FileList != NULL);
- ASSERT(DestDir != NULL);
-
+ ASSERT (FileList != NULL);
+ ASSERT (DestDir != NULL);
Status = ShellLevel2StripQuotes (DestDir, &CleanFilePathStr);
if (EFI_ERROR (Status)) {
@@ -336,28 +340,30 @@ ValidateAndCopyFiles(
//
// If we are trying to copy multiple files... make sure we got a directory for the target...
//
- if (EFI_ERROR(ShellIsDirectory(CleanFilePathStr)) && FileList->Link.ForwardLink != FileList->Link.BackLink) {
+ if (EFI_ERROR (ShellIsDirectory (CleanFilePathStr)) && (FileList->Link.ForwardLink != FileList->Link.BackLink)) {
//
// Error for destination not a directory
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
FreePool (CleanFilePathStr);
return (SHELL_INVALID_PARAMETER);
}
- for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
- ){
+
+ for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link)
+ ; !IsNull (&FileList->Link, &Node->Link)
+ ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &Node->Link)
+ )
+ {
//
// skip the directory traversing stuff...
//
- if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
+ if ((StrCmp (Node->FileName, L".") == 0) || (StrCmp (Node->FileName, L"..") == 0)) {
continue;
}
- NewSize = StrSize(CleanFilePathStr);
- NewSize += StrSize(Node->FullName);
- NewSize += (Cwd == NULL)? 0 : (StrSize(Cwd) + sizeof(CHAR16));
+ NewSize = StrSize (CleanFilePathStr);
+ NewSize += StrSize (Node->FullName);
+ NewSize += (Cwd == NULL) ? 0 : (StrSize (Cwd) + sizeof (CHAR16));
if (NewSize > PathSize) {
PathSize = NewSize;
}
@@ -365,8 +371,8 @@ ValidateAndCopyFiles(
//
// Make sure got -r if required
//
- if (!RecursiveMode && !EFI_ERROR(ShellIsDirectory(Node->FullName))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_REQ), gShellLevel2HiiHandle, L"cp");
+ if (!RecursiveMode && !EFI_ERROR (ShellIsDirectory (Node->FullName))) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_REQ), gShellLevel2HiiHandle, L"cp");
FreePool (CleanFilePathStr);
return (SHELL_INVALID_PARAMETER);
}
@@ -374,11 +380,11 @@ ValidateAndCopyFiles(
//
// make sure got dest as dir if needed
//
- if (!EFI_ERROR(ShellIsDirectory(Node->FullName)) && EFI_ERROR(ShellIsDirectory(CleanFilePathStr))) {
+ if (!EFI_ERROR (ShellIsDirectory (Node->FullName)) && EFI_ERROR (ShellIsDirectory (CleanFilePathStr))) {
//
// Error for destination not a directory
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
FreePool (CleanFilePathStr);
return (SHELL_INVALID_PARAMETER);
}
@@ -386,12 +392,12 @@ ValidateAndCopyFiles(
HiiOutput = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_CP_OUTPUT), NULL);
HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
- DestPath = AllocateZeroPool(PathSize);
+ DestPath = AllocateZeroPool (PathSize);
- if (DestPath == NULL || HiiOutput == NULL || HiiResultOk == NULL) {
- SHELL_FREE_NON_NULL(DestPath);
- SHELL_FREE_NON_NULL(HiiOutput);
- SHELL_FREE_NON_NULL(HiiResultOk);
+ if ((DestPath == NULL) || (HiiOutput == NULL) || (HiiResultOk == NULL)) {
+ SHELL_FREE_NON_NULL (DestPath);
+ SHELL_FREE_NON_NULL (HiiOutput);
+ SHELL_FREE_NON_NULL (HiiResultOk);
FreePool (CleanFilePathStr);
return (SHELL_OUT_OF_RESOURCES);
}
@@ -399,46 +405,51 @@ ValidateAndCopyFiles(
//
// Go through the list of files to copy...
//
- for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
- ){
- if (ShellGetExecutionBreakFlag()) {
+ for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link)
+ ; !IsNull (&FileList->Link, &Node->Link)
+ ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &Node->Link)
+ )
+ {
+ if (ShellGetExecutionBreakFlag ()) {
break;
}
- ASSERT(Node->FileName != NULL);
- ASSERT(Node->FullName != NULL);
+
+ ASSERT (Node->FileName != NULL);
+ ASSERT (Node->FullName != NULL);
//
// skip the directory traversing stuff...
//
- if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
+ if ((StrCmp (Node->FileName, L".") == 0) || (StrCmp (Node->FileName, L"..") == 0)) {
continue;
}
- if (FileList->Link.ForwardLink == FileList->Link.BackLink // 1 item
- && EFI_ERROR(ShellIsDirectory(CleanFilePathStr)) // not an existing directory
- ) {
- if (StrStr(CleanFilePathStr, L":") == NULL) {
+ if ( (FileList->Link.ForwardLink == FileList->Link.BackLink) // 1 item
+ && EFI_ERROR (ShellIsDirectory (CleanFilePathStr)) // not an existing directory
+ )
+ {
+ if (StrStr (CleanFilePathStr, L":") == NULL) {
//
// simple copy of a single file
//
if (Cwd != NULL) {
- StrCpyS(DestPath, PathSize / sizeof(CHAR16), Cwd);
- StrCatS(DestPath, PathSize / sizeof(CHAR16), L"\\");
+ StrCpyS (DestPath, PathSize / sizeof (CHAR16), Cwd);
+ StrCatS (DestPath, PathSize / sizeof (CHAR16), L"\\");
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
FreePool (CleanFilePathStr);
return (SHELL_INVALID_PARAMETER);
}
- if (DestPath[StrLen(DestPath)-1] != L'\\' && CleanFilePathStr[0] != L'\\') {
- StrCatS(DestPath, PathSize / sizeof(CHAR16), L"\\");
- } else if (DestPath[StrLen(DestPath)-1] == L'\\' && CleanFilePathStr[0] == L'\\') {
- ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
+
+ if ((DestPath[StrLen (DestPath)-1] != L'\\') && (CleanFilePathStr[0] != L'\\')) {
+ StrCatS (DestPath, PathSize / sizeof (CHAR16), L"\\");
+ } else if ((DestPath[StrLen (DestPath)-1] == L'\\') && (CleanFilePathStr[0] == L'\\')) {
+ ((CHAR16 *)DestPath)[StrLen (DestPath)-1] = CHAR_NULL;
}
- StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr);
+
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), CleanFilePathStr);
} else {
- StrCpyS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr);
+ StrCpyS (DestPath, PathSize/sizeof (CHAR16), CleanFilePathStr);
}
} else {
//
@@ -449,112 +460,121 @@ ValidateAndCopyFiles(
// Check for leading slash
//
if (CleanFilePathStr[0] == L'\\') {
- //
- // Copy to the root of CWD
- //
+ //
+ // Copy to the root of CWD
+ //
if (Cwd != NULL) {
- StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);
- StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
+ StrCpyS (DestPath, PathSize/sizeof (CHAR16), Cwd);
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), L"\\");
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
- FreePool(CleanFilePathStr);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
+ FreePool (CleanFilePathStr);
return (SHELL_INVALID_PARAMETER);
}
- while (PathRemoveLastItem(DestPath));
- StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr+1);
- StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName);
- } else if (StrStr(CleanFilePathStr, L":") == NULL) {
+
+ while (PathRemoveLastItem (DestPath)) {
+ }
+
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), CleanFilePathStr+1);
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), Node->FileName);
+ } else if (StrStr (CleanFilePathStr, L":") == NULL) {
if (Cwd != NULL) {
- StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);
- StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
+ StrCpyS (DestPath, PathSize/sizeof (CHAR16), Cwd);
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), L"\\");
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
- FreePool(CleanFilePathStr);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
+ FreePool (CleanFilePathStr);
return (SHELL_INVALID_PARAMETER);
}
- if (DestPath[StrLen(DestPath)-1] != L'\\' && CleanFilePathStr[0] != L'\\') {
- StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
- } else if (DestPath[StrLen(DestPath)-1] == L'\\' && CleanFilePathStr[0] == L'\\') {
- ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
+
+ if ((DestPath[StrLen (DestPath)-1] != L'\\') && (CleanFilePathStr[0] != L'\\')) {
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), L"\\");
+ } else if ((DestPath[StrLen (DestPath)-1] == L'\\') && (CleanFilePathStr[0] == L'\\')) {
+ ((CHAR16 *)DestPath)[StrLen (DestPath)-1] = CHAR_NULL;
}
- StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr);
- if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] != L'\\' && Node->FileName[0] != L'\\') {
- StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
- } else if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] == L'\\' && Node->FileName[0] == L'\\') {
- ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
+
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), CleanFilePathStr);
+ if ((CleanFilePathStr[StrLen (CleanFilePathStr)-1] != L'\\') && (Node->FileName[0] != L'\\')) {
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), L"\\");
+ } else if ((CleanFilePathStr[StrLen (CleanFilePathStr)-1] == L'\\') && (Node->FileName[0] == L'\\')) {
+ ((CHAR16 *)DestPath)[StrLen (DestPath)-1] = CHAR_NULL;
}
- StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName);
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), Node->FileName);
} else {
- StrCpyS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr);
- if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] != L'\\' && Node->FileName[0] != L'\\') {
- StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");
- } else if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] == L'\\' && Node->FileName[0] == L'\\') {
- ((CHAR16*)CleanFilePathStr)[StrLen(CleanFilePathStr)-1] = CHAR_NULL;
+ StrCpyS (DestPath, PathSize/sizeof (CHAR16), CleanFilePathStr);
+ if ((CleanFilePathStr[StrLen (CleanFilePathStr)-1] != L'\\') && (Node->FileName[0] != L'\\')) {
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), L"\\");
+ } else if ((CleanFilePathStr[StrLen (CleanFilePathStr)-1] == L'\\') && (Node->FileName[0] == L'\\')) {
+ ((CHAR16 *)CleanFilePathStr)[StrLen (CleanFilePathStr)-1] = CHAR_NULL;
}
- StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName);
+
+ StrCatS (DestPath, PathSize/sizeof (CHAR16), Node->FileName);
}
}
//
// Make sure the path exists
//
- if (EFI_ERROR(VerifyIntermediateDirectories(DestPath))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_WNF), gShellLevel2HiiHandle, L"cp", DestPath);
+ if (EFI_ERROR (VerifyIntermediateDirectories (DestPath))) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_WNF), gShellLevel2HiiHandle, L"cp", DestPath);
ShellStatus = SHELL_DEVICE_ERROR;
break;
}
- if ( !EFI_ERROR(ShellIsDirectory(Node->FullName))
- && !EFI_ERROR(ShellIsDirectory(DestPath))
- && StrniCmp(Node->FullName, DestPath, StrLen(DestPath)) == 0
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_PARENT), gShellLevel2HiiHandle, L"cp");
+ if ( !EFI_ERROR (ShellIsDirectory (Node->FullName))
+ && !EFI_ERROR (ShellIsDirectory (DestPath))
+ && (StrniCmp (Node->FullName, DestPath, StrLen (DestPath)) == 0)
+ )
+ {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_SD_PARENT), gShellLevel2HiiHandle, L"cp");
ShellStatus = SHELL_INVALID_PARAMETER;
break;
}
- if (StringNoCaseCompare(&Node->FullName, &DestPath) == 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp");
+
+ if (StringNoCaseCompare (&Node->FullName, &DestPath) == 0) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp");
ShellStatus = SHELL_INVALID_PARAMETER;
break;
}
- if ((StrniCmp(Node->FullName, DestPath, StrLen(Node->FullName)) == 0)
- && (DestPath[StrLen(Node->FullName)] == CHAR_NULL || DestPath[StrLen(Node->FullName)] == L'\\')
- ) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp");
+ if ( (StrniCmp (Node->FullName, DestPath, StrLen (Node->FullName)) == 0)
+ && ((DestPath[StrLen (Node->FullName)] == CHAR_NULL) || (DestPath[StrLen (Node->FullName)] == L'\\'))
+ )
+ {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp");
ShellStatus = SHELL_INVALID_PARAMETER;
break;
}
- PathCleanUpDirectories(DestPath);
+ PathCleanUpDirectories (DestPath);
if (!SilentMode) {
- ShellPrintEx(-1, -1, HiiOutput, Node->FullName, DestPath);
+ ShellPrintEx (-1, -1, HiiOutput, Node->FullName, DestPath);
}
//
// copy single file...
//
- ShellStatus = CopySingleFile(Node->FullName, DestPath, &Response, SilentMode, L"cp");
+ ShellStatus = CopySingleFile (Node->FullName, DestPath, &Response, SilentMode, L"cp");
if (ShellStatus != SHELL_SUCCESS) {
break;
}
}
- if (ShellStatus == SHELL_SUCCESS && Resp == NULL) {
- ShellPrintEx(-1, -1, L"%s", HiiResultOk);
+
+ if ((ShellStatus == SHELL_SUCCESS) && (Resp == NULL)) {
+ ShellPrintEx (-1, -1, L"%s", HiiResultOk);
}
- SHELL_FREE_NON_NULL(DestPath);
- SHELL_FREE_NON_NULL(HiiOutput);
- SHELL_FREE_NON_NULL(HiiResultOk);
- SHELL_FREE_NON_NULL(CleanFilePathStr);
+ SHELL_FREE_NON_NULL (DestPath);
+ SHELL_FREE_NON_NULL (HiiOutput);
+ SHELL_FREE_NON_NULL (HiiResultOk);
+ SHELL_FREE_NON_NULL (CleanFilePathStr);
if (Resp == NULL) {
- SHELL_FREE_NON_NULL(Response);
+ SHELL_FREE_NON_NULL (Response);
}
return (ShellStatus);
-
}
/**
@@ -570,55 +590,55 @@ ValidateAndCopyFiles(
@retval SHELL_SUCCESS The operation was successful.
**/
SHELL_STATUS
-ProcessValidateAndCopyFiles(
+ProcessValidateAndCopyFiles (
IN EFI_SHELL_FILE_INFO *FileList,
IN CONST CHAR16 *DestDir,
IN BOOLEAN SilentMode,
IN BOOLEAN RecursiveMode
)
{
- SHELL_STATUS ShellStatus;
- EFI_SHELL_FILE_INFO *List;
- EFI_FILE_INFO *FileInfo;
- CHAR16 *FullName;
-
- List = NULL;
- FullName = NULL;
- FileInfo = NULL;
-
- ShellOpenFileMetaArg((CHAR16*)DestDir, EFI_FILE_MODE_READ, &List);
- if (List != NULL && List->Link.ForwardLink != List->Link.BackLink) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"cp", DestDir);
+ SHELL_STATUS ShellStatus;
+ EFI_SHELL_FILE_INFO *List;
+ EFI_FILE_INFO *FileInfo;
+ CHAR16 *FullName;
+
+ List = NULL;
+ FullName = NULL;
+ FileInfo = NULL;
+
+ ShellOpenFileMetaArg ((CHAR16 *)DestDir, EFI_FILE_MODE_READ, &List);
+ if ((List != NULL) && (List->Link.ForwardLink != List->Link.BackLink)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"cp", DestDir);
ShellStatus = SHELL_INVALID_PARAMETER;
- ShellCloseFileMetaArg(&List);
+ ShellCloseFileMetaArg (&List);
} else if (List != NULL) {
- ASSERT(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink) != NULL);
- ASSERT(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName != NULL);
- FileInfo = gEfiShellProtocol->GetFileInfo(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->Handle);
- ASSERT(FileInfo != NULL);
- StrnCatGrow(&FullName, NULL, ((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName, 0);
- ShellCloseFileMetaArg(&List);
+ ASSERT (((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink) != NULL);
+ ASSERT (((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName != NULL);
+ FileInfo = gEfiShellProtocol->GetFileInfo (((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->Handle);
+ ASSERT (FileInfo != NULL);
+ StrnCatGrow (&FullName, NULL, ((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName, 0);
+ ShellCloseFileMetaArg (&List);
if ((FileInfo->Attribute & EFI_FILE_READ_ONLY) == 0) {
- ShellStatus = ValidateAndCopyFiles(FileList, FullName, SilentMode, RecursiveMode, NULL);
+ ShellStatus = ValidateAndCopyFiles (FileList, FullName, SilentMode, RecursiveMode, NULL);
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_ERROR), gShellLevel2HiiHandle, L"cp");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_ERROR), gShellLevel2HiiHandle, L"cp");
ShellStatus = SHELL_ACCESS_DENIED;
}
} else {
- ShellCloseFileMetaArg(&List);
- ShellStatus = ValidateAndCopyFiles(FileList, DestDir, SilentMode, RecursiveMode, NULL);
+ ShellCloseFileMetaArg (&List);
+ ShellStatus = ValidateAndCopyFiles (FileList, DestDir, SilentMode, RecursiveMode, NULL);
}
- SHELL_FREE_NON_NULL(FileInfo);
- SHELL_FREE_NON_NULL(FullName);
+ SHELL_FREE_NON_NULL (FileInfo);
+ SHELL_FREE_NON_NULL (FullName);
return (ShellStatus);
}
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-r", TypeFlag},
- {L"-q", TypeFlag},
- {NULL, TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+ { L"-r", TypeFlag },
+ { L"-q", TypeFlag },
+ { NULL, TypeMax }
+};
/**
Function for 'cp' command.
@@ -633,86 +653,87 @@ ShellCommandRunCp (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- UINTN LoopCounter;
- EFI_SHELL_FILE_INFO *FileList;
- BOOLEAN SilentMode;
- BOOLEAN RecursiveMode;
- CONST CHAR16 *Cwd;
- CHAR16 *FullCwd;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- ParamCount = 0;
- FileList = NULL;
+ EFI_STATUS Status;
+ LIST_ENTRY *Package;
+ CHAR16 *ProblemParam;
+ SHELL_STATUS ShellStatus;
+ UINTN ParamCount;
+ UINTN LoopCounter;
+ EFI_SHELL_FILE_INFO *FileList;
+ BOOLEAN SilentMode;
+ BOOLEAN RecursiveMode;
+ CONST CHAR16 *Cwd;
+ CHAR16 *FullCwd;
+
+ ProblemParam = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ ParamCount = 0;
+ FileList = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
+ Status = CommandInit ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cp", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cp", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
}
//
// Initialize SilentMode and RecursiveMode
//
- if (gEfiShellProtocol->BatchIsActive()) {
+ if (gEfiShellProtocol->BatchIsActive ()) {
SilentMode = TRUE;
} else {
- SilentMode = ShellCommandLineGetFlag(Package, L"-q");
+ SilentMode = ShellCommandLineGetFlag (Package, L"-q");
}
- RecursiveMode = ShellCommandLineGetFlag(Package, L"-r");
- switch (ParamCount = ShellCommandLineGetCount(Package)) {
+ RecursiveMode = ShellCommandLineGetFlag (Package, L"-r");
+
+ switch (ParamCount = ShellCommandLineGetCount (Package)) {
case 0:
case 1:
//
// we have insufficient parameters
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"cp");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"cp");
ShellStatus = SHELL_INVALID_PARAMETER;
break;
case 2:
//
// must have valid CWD for single parameter...
//
- Cwd = ShellGetCurrentDir(NULL);
- if (Cwd == NULL){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cp");
+ Cwd = ShellGetCurrentDir (NULL);
+ if (Cwd == NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cp");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, 1));
+ Status = ShellOpenFileMetaArg ((CHAR16 *)ShellCommandLineGetRawValue (Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
+ if ((FileList == NULL) || IsListEmpty (&FileList->Link) || EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue (Package, 1));
ShellStatus = SHELL_NOT_FOUND;
- } else {
- FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));
+ } else {
+ FullCwd = AllocateZeroPool (StrSize (Cwd) + sizeof (CHAR16));
if (FullCwd == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"cp");
ShellStatus = SHELL_OUT_OF_RESOURCES;
@@ -729,36 +750,39 @@ ShellCommandRunCp (
//
// Make a big list of all the files...
//
- for (ParamCount--, LoopCounter = 1 ; LoopCounter < ParamCount && ShellStatus == SHELL_SUCCESS ; LoopCounter++) {
- if (ShellGetExecutionBreakFlag()) {
+ for (ParamCount--, LoopCounter = 1; LoopCounter < ParamCount && ShellStatus == SHELL_SUCCESS; LoopCounter++) {
+ if (ShellGetExecutionBreakFlag ()) {
break;
}
- Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (EFI_ERROR(Status) || FileList == NULL || IsListEmpty(&FileList->Link)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, LoopCounter));
+
+ Status = ShellOpenFileMetaArg ((CHAR16 *)ShellCommandLineGetRawValue (Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
+ if (EFI_ERROR (Status) || (FileList == NULL) || IsListEmpty (&FileList->Link)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue (Package, LoopCounter));
ShellStatus = SHELL_NOT_FOUND;
}
}
+
if (ShellStatus != SHELL_SUCCESS) {
- Status = ShellCloseFileMetaArg(&FileList);
+ Status = ShellCloseFileMetaArg (&FileList);
} else {
//
// now copy them all...
//
- if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
- ShellStatus = ProcessValidateAndCopyFiles(FileList, PathCleanUpDirectories((CHAR16*)ShellCommandLineGetRawValue(Package, ParamCount)), SilentMode, RecursiveMode);
- Status = ShellCloseFileMetaArg(&FileList);
- if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, ParamCount), ShellStatus|MAX_BIT);
+ if ((FileList != NULL) && !IsListEmpty (&FileList->Link)) {
+ ShellStatus = ProcessValidateAndCopyFiles (FileList, PathCleanUpDirectories ((CHAR16 *)ShellCommandLineGetRawValue (Package, ParamCount)), SilentMode, RecursiveMode);
+ Status = ShellCloseFileMetaArg (&FileList);
+ if (EFI_ERROR (Status) && (ShellStatus == SHELL_SUCCESS)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue (Package, ParamCount), ShellStatus|MAX_BIT);
ShellStatus = SHELL_ACCESS_DENIED;
}
}
}
+
break;
} // switch on parameter count
if (FileList != NULL) {
- ShellCloseFileMetaArg(&FileList);
+ ShellCloseFileMetaArg (&FileList);
}
//
@@ -767,10 +791,9 @@ ShellCommandRunCp (
ShellCommandLineFreeVarList (Package);
}
- if (ShellGetExecutionBreakFlag()) {
+ if (ShellGetExecutionBreakFlag ()) {
return (SHELL_ABORTED);
}
return (ShellStatus);
}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
index b6e7c952fa..f92cfa502d 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
@@ -12,6 +12,7 @@
// This function was from from the BdsLib implementation in
// IntelFrameworkModulePkg\Library\GenericBdsLib\BdsConnect.c
// function name: BdsLibConnectAllEfi
+
/**
This function will connect all current system handles recursively. The
connection will finish until every handle's child handle created if it have.
@@ -37,7 +38,7 @@ ConnectAllEfi (
NULL,
&HandleCount,
&HandleBuffer
- );
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -67,51 +68,52 @@ ConnectAllEfi (
@retval EFI_OUT_OF_RESOURCES there was insufficient memory
**/
EFI_STATUS
-LoadDriver(
+LoadDriver (
IN CONST CHAR16 *FileName,
IN CONST BOOLEAN Connect
)
{
- EFI_HANDLE LoadedDriverHandle;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *FilePath;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedDriverImage;
+ EFI_HANDLE LoadedDriverHandle;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *FilePath;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedDriverImage;
- LoadedDriverImage = NULL;
- FilePath = NULL;
- LoadedDriverHandle = NULL;
- Status = EFI_SUCCESS;
+ LoadedDriverImage = NULL;
+ FilePath = NULL;
+ LoadedDriverHandle = NULL;
+ Status = EFI_SUCCESS;
ASSERT (FileName != NULL);
//
// Fix local copies of the protocol pointers
//
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
+ Status = CommandInit ();
+ ASSERT_EFI_ERROR (Status);
//
// Convert to DEVICE_PATH
//
- FilePath = gEfiShellProtocol->GetDevicePathFromFilePath(FileName);
+ FilePath = gEfiShellProtocol->GetDevicePathFromFilePath (FileName);
if (FilePath == NULL) {
- ASSERT(FALSE);
+ ASSERT (FALSE);
return (EFI_INVALID_PARAMETER);
}
//
// Use LoadImage to get it into memory
//
- Status = gBS->LoadImage(
- FALSE,
- gImageHandle,
- FilePath,
- NULL,
- 0,
- &LoadedDriverHandle);
-
- if (EFI_ERROR(Status)) {
+ Status = gBS->LoadImage (
+ FALSE,
+ gImageHandle,
+ FilePath,
+ NULL,
+ 0,
+ &LoadedDriverHandle
+ );
+
+ if (EFI_ERROR (Status)) {
//
// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
// with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
@@ -121,62 +123,64 @@ LoadDriver(
if (Status == EFI_SECURITY_VIOLATION) {
gBS->UnloadImage (LoadedDriverHandle);
}
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_NOT_IMAGE), gShellLevel2HiiHandle, FileName, Status);
+
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LOAD_NOT_IMAGE), gShellLevel2HiiHandle, FileName, Status);
} else {
//
// Make sure it is a driver image
//
- Status = gBS->HandleProtocol (LoadedDriverHandle, &gEfiLoadedImageProtocolGuid, (VOID *) &LoadedDriverImage);
+ Status = gBS->HandleProtocol (LoadedDriverHandle, &gEfiLoadedImageProtocolGuid, (VOID *)&LoadedDriverImage);
ASSERT (LoadedDriverImage != NULL);
- if ( EFI_ERROR(Status)
- || ( LoadedDriverImage->ImageCodeType != EfiBootServicesCode
- && LoadedDriverImage->ImageCodeType != EfiRuntimeServicesCode)
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_NOT_DRIVER), gShellLevel2HiiHandle, FileName);
+ if ( EFI_ERROR (Status)
+ || ( (LoadedDriverImage->ImageCodeType != EfiBootServicesCode)
+ && (LoadedDriverImage->ImageCodeType != EfiRuntimeServicesCode))
+ )
+ {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LOAD_NOT_DRIVER), gShellLevel2HiiHandle, FileName);
//
// Exit and unload the non-driver image
//
- gBS->Exit(LoadedDriverHandle, EFI_INVALID_PARAMETER, 0, NULL);
+ gBS->Exit (LoadedDriverHandle, EFI_INVALID_PARAMETER, 0, NULL);
Status = EFI_INVALID_PARAMETER;
}
}
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
//
// Start the image
//
- Status = gBS->StartImage(LoadedDriverHandle, NULL, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_ERROR), gShellLevel2HiiHandle, FileName, Status);
+ Status = gBS->StartImage (LoadedDriverHandle, NULL, NULL);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LOAD_ERROR), gShellLevel2HiiHandle, FileName, Status);
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_LOADED), gShellLevel2HiiHandle, FileName, LoadedDriverImage->ImageBase, Status);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LOAD_LOADED), gShellLevel2HiiHandle, FileName, LoadedDriverImage->ImageBase, Status);
}
}
- if (!EFI_ERROR(Status) && Connect) {
+ if (!EFI_ERROR (Status) && Connect) {
//
// Connect it...
//
- Status = ConnectAllEfi();
+ Status = ConnectAllEfi ();
}
//
// clean up memory...
//
if (FilePath != NULL) {
- FreePool(FilePath);
+ FreePool (FilePath);
}
return (Status);
}
-STATIC CONST SHELL_PARAM_ITEM LoadParamList[] = {
- {L"-nc", TypeFlag},
- {NULL, TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM LoadParamList[] = {
+ { L"-nc", TypeFlag },
+ { NULL, TypeMax }
+};
/**
Function for 'load' command.
@@ -191,78 +195,81 @@ ShellCommandRunLoad (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- EFI_SHELL_FILE_INFO *ListHead;
- EFI_SHELL_FILE_INFO *Node;
-
- ListHead = NULL;
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
+ EFI_STATUS Status;
+ LIST_ENTRY *Package;
+ CHAR16 *ProblemParam;
+ SHELL_STATUS ShellStatus;
+ UINTN ParamCount;
+ EFI_SHELL_FILE_INFO *ListHead;
+ EFI_SHELL_FILE_INFO *Node;
+
+ ListHead = NULL;
+ ProblemParam = NULL;
+ ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (LoadParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"load", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"load", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
+ } else if (ShellCommandLineGetRawValue (Package, 1) == NULL) {
//
// we didnt get a single file to load parameter
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"load");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"load");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
for ( ParamCount = 1
- ; ShellCommandLineGetRawValue(Package, ParamCount) != NULL
- ; ParamCount++
- ){
- Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, ParamCount), EFI_FILE_MODE_READ, &ListHead);
- if (!EFI_ERROR(Status)) {
- for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link)
- ; !IsNull(&ListHead->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)
- ){
+ ; ShellCommandLineGetRawValue (Package, ParamCount) != NULL
+ ; ParamCount++
+ )
+ {
+ Status = ShellOpenFileMetaArg ((CHAR16 *)ShellCommandLineGetRawValue (Package, ParamCount), EFI_FILE_MODE_READ, &ListHead);
+ if (!EFI_ERROR (Status)) {
+ for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&ListHead->Link)
+ ; !IsNull (&ListHead->Link, &Node->Link)
+ ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&ListHead->Link, &Node->Link)
+ )
+ {
//
// once we have an error preserve that value, but finish the loop.
//
- if (EFI_ERROR(Status)) {
- LoadDriver(Node->FullName, (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-nc")==FALSE));
+ if (EFI_ERROR (Status)) {
+ LoadDriver (Node->FullName, (BOOLEAN)(ShellCommandLineGetFlag (Package, L"-nc") == FALSE));
} else {
- Status = LoadDriver(Node->FullName, (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-nc")==FALSE));
+ Status = LoadDriver (Node->FullName, (BOOLEAN)(ShellCommandLineGetFlag (Package, L"-nc") == FALSE));
}
} // for loop for multi-open
- if (EFI_ERROR(Status)) {
- ShellCloseFileMetaArg(&ListHead);
+
+ if (EFI_ERROR (Status)) {
+ ShellCloseFileMetaArg (&ListHead);
} else {
- Status = ShellCloseFileMetaArg(&ListHead);;
+ Status = ShellCloseFileMetaArg (&ListHead);
}
} else {
//
// no files found.
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"load", (CHAR16*)ShellCommandLineGetRawValue(Package, ParamCount));
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"load", (CHAR16 *)ShellCommandLineGetRawValue (Package, ParamCount));
ShellStatus = SHELL_NOT_FOUND;
}
} // for loop for params
@@ -274,7 +281,7 @@ ShellCommandRunLoad (
ShellCommandLineFreeVarList (Package);
}
- if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {
+ if (EFI_ERROR (Status) && (ShellStatus == SHELL_SUCCESS)) {
ShellStatus = SHELL_DEVICE_ERROR;
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
index 8b97926d7f..6f9d035a1a 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
@@ -10,7 +10,7 @@
#include "UefiShellLevel2CommandsLib.h"
#include <Guid/FileSystemInfo.h>
-UINTN mDayOfMonth[] = {31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30};
+UINTN mDayOfMonth[] = { 31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30 };
/**
print out the standard format output volume entry.
@@ -18,8 +18,8 @@ UINTN mDayOfMonth[] = {31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30};
@param[in] TheList a list of files from the volume.
**/
EFI_STATUS
-PrintSfoVolumeInfoTableEntry(
- IN CONST EFI_SHELL_FILE_INFO *TheList
+PrintSfoVolumeInfoTableEntry (
+ IN CONST EFI_SHELL_FILE_INFO *TheList
)
{
EFI_STATUS Status;
@@ -33,77 +33,79 @@ PrintSfoVolumeInfoTableEntry(
//
// Get the first valid handle (directories)
//
- for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&TheList->Link)
- ; !IsNull(&TheList->Link, &Node->Link) && Node->Handle == NULL
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&TheList->Link, &Node->Link)
- );
+ for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&TheList->Link)
+ ; !IsNull (&TheList->Link, &Node->Link) && Node->Handle == NULL
+ ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&TheList->Link, &Node->Link)
+ )
+ {
+ }
if (Node->Handle == NULL) {
- DirectoryName = GetFullyQualifiedPath(((EFI_SHELL_FILE_INFO *)GetFirstNode(&TheList->Link))->FullName);
+ DirectoryName = GetFullyQualifiedPath (((EFI_SHELL_FILE_INFO *)GetFirstNode (&TheList->Link))->FullName);
//
// We need to open something up to get system information
//
- Status = gEfiShellProtocol->OpenFileByName(
- DirectoryName,
- &ShellFileHandle,
- EFI_FILE_MODE_READ
- );
+ Status = gEfiShellProtocol->OpenFileByName (
+ DirectoryName,
+ &ShellFileHandle,
+ EFI_FILE_MODE_READ
+ );
- ASSERT_EFI_ERROR(Status);
- FreePool(DirectoryName);
+ ASSERT_EFI_ERROR (Status);
+ FreePool (DirectoryName);
//
// Get the Volume Info from ShellFileHandle
//
SysInfo = NULL;
SysInfoSize = 0;
- EfiFpHandle = ConvertShellHandleToEfiFileProtocol(ShellFileHandle);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo
- );
+ EfiFpHandle = ConvertShellHandleToEfiFileProtocol (ShellFileHandle);
+ Status = EfiFpHandle->GetInfo (
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ &SysInfoSize,
+ SysInfo
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- SysInfo = AllocateZeroPool(SysInfoSize);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo
- );
+ SysInfo = AllocateZeroPool (SysInfoSize);
+ Status = EfiFpHandle->GetInfo (
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ &SysInfoSize,
+ SysInfo
+ );
}
- ASSERT_EFI_ERROR(Status);
+ ASSERT_EFI_ERROR (Status);
- gEfiShellProtocol->CloseFile(ShellFileHandle);
+ gEfiShellProtocol->CloseFile (ShellFileHandle);
} else {
//
// Get the Volume Info from Node->Handle
//
- SysInfo = NULL;
+ SysInfo = NULL;
SysInfoSize = 0;
- EfiFpHandle = ConvertShellHandleToEfiFileProtocol(Node->Handle);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo
- );
+ EfiFpHandle = ConvertShellHandleToEfiFileProtocol (Node->Handle);
+ Status = EfiFpHandle->GetInfo (
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ &SysInfoSize,
+ SysInfo
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- SysInfo = AllocateZeroPool(SysInfoSize);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo
- );
+ SysInfo = AllocateZeroPool (SysInfoSize);
+ Status = EfiFpHandle->GetInfo (
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ &SysInfoSize,
+ SysInfo
+ );
}
- ASSERT_EFI_ERROR(Status);
+ ASSERT_EFI_ERROR (Status);
}
ShellPrintHiiEx (
@@ -117,7 +119,7 @@ PrintSfoVolumeInfoTableEntry(
//
// print VolumeInfo table
//
- ASSERT(SysInfo != NULL);
+ ASSERT (SysInfo != NULL);
ShellPrintHiiEx (
0,
gST->ConOut->Mode->CursorRow,
@@ -126,12 +128,12 @@ PrintSfoVolumeInfoTableEntry(
gShellLevel2HiiHandle,
SysInfo->VolumeLabel,
SysInfo->VolumeSize,
- SysInfo->ReadOnly?L"TRUE":L"FALSE",
+ SysInfo->ReadOnly ? L"TRUE" : L"FALSE",
SysInfo->FreeSpace,
SysInfo->BlockSize
);
- SHELL_FREE_NON_NULL(SysInfo);
+ SHELL_FREE_NON_NULL (SysInfo);
return (Status);
}
@@ -147,7 +149,7 @@ PrintSfoVolumeInfoTableEntry(
**/
VOID
-PrintFileInformation(
+PrintFileInformation (
IN CONST BOOLEAN Sfo,
IN CONST EFI_SHELL_FILE_INFO *TheNode,
IN UINT64 *Files,
@@ -155,10 +157,10 @@ PrintFileInformation(
IN UINT64 *Dirs
)
{
- ASSERT(Files != NULL);
- ASSERT(Size != NULL);
- ASSERT(Dirs != NULL);
- ASSERT(TheNode != NULL);
+ ASSERT (Files != NULL);
+ ASSERT (Size != NULL);
+ ASSERT (Dirs != NULL);
+ ASSERT (TheNode != NULL);
if (Sfo) {
//
@@ -173,11 +175,11 @@ PrintFileInformation(
TheNode->FullName,
TheNode->Info->FileSize,
TheNode->Info->PhysicalSize,
- (TheNode->Info->Attribute & EFI_FILE_ARCHIVE) != 0?L"a":L"",
- (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) != 0?L"d":L"",
- (TheNode->Info->Attribute & EFI_FILE_HIDDEN) != 0?L"h":L"",
- (TheNode->Info->Attribute & EFI_FILE_READ_ONLY) != 0?L"r":L"",
- (TheNode->Info->Attribute & EFI_FILE_SYSTEM) != 0?L"s":L"",
+ (TheNode->Info->Attribute & EFI_FILE_ARCHIVE) != 0 ? L"a" : L"",
+ (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) != 0 ? L"d" : L"",
+ (TheNode->Info->Attribute & EFI_FILE_HIDDEN) != 0 ? L"h" : L"",
+ (TheNode->Info->Attribute & EFI_FILE_READ_ONLY) != 0 ? L"r" : L"",
+ (TheNode->Info->Attribute & EFI_FILE_SYSTEM) != 0 ? L"s" : L"",
TheNode->Info->CreateTime.Hour,
TheNode->Info->CreateTime.Minute,
TheNode->Info->CreateTime.Second,
@@ -209,8 +211,8 @@ PrintFileInformation(
STRING_TOKEN (STR_LS_LINE_START_ALL),
gShellLevel2HiiHandle,
&TheNode->Info->ModificationTime,
- (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) != 0?L"<DIR>":L"",
- (TheNode->Info->Attribute & EFI_FILE_READ_ONLY) != 0?L'r':L' ',
+ (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) != 0 ? L"<DIR>" : L"",
+ (TheNode->Info->Attribute & EFI_FILE_READ_ONLY) != 0 ? L'r' : L' ',
TheNode->Info->FileSize
);
if (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) {
@@ -226,9 +228,10 @@ PrintFileInformation(
} else {
(*Files)++;
(*Size) += TheNode->Info->FileSize;
- if ( (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)L".nsh", (CHAR16*)&(TheNode->FileName[StrLen (TheNode->FileName) - 4])) == 0)
- || (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)L".efi", (CHAR16*)&(TheNode->FileName[StrLen (TheNode->FileName) - 4])) == 0)
- ){
+ if ( (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)L".nsh", (CHAR16 *)&(TheNode->FileName[StrLen (TheNode->FileName) - 4])) == 0)
+ || (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)L".efi", (CHAR16 *)&(TheNode->FileName[StrLen (TheNode->FileName) - 4])) == 0)
+ )
+ {
ShellPrintHiiEx (
-1,
-1,
@@ -257,16 +260,16 @@ PrintFileInformation(
@param[in] Path String with starting path.
**/
VOID
-PrintNonSfoHeader(
- IN CONST CHAR16 *Path
+PrintNonSfoHeader (
+ IN CONST CHAR16 *Path
)
{
- CHAR16 *DirectoryName;
+ CHAR16 *DirectoryName;
//
// get directory name from path...
//
- DirectoryName = GetFullyQualifiedPath(Path);
+ DirectoryName = GetFullyQualifiedPath (Path);
if (DirectoryName != NULL) {
//
@@ -281,7 +284,7 @@ PrintNonSfoHeader(
DirectoryName
);
- SHELL_FREE_NON_NULL(DirectoryName);
+ SHELL_FREE_NON_NULL (DirectoryName);
}
}
@@ -293,10 +296,10 @@ PrintNonSfoHeader(
@param[in] Dirs The number of directories.
**/
VOID
-PrintNonSfoFooter(
- IN UINT64 Files,
- IN UINT64 Size,
- IN UINT64 Dirs
+PrintNonSfoFooter (
+ IN UINT64 Files,
+ IN UINT64 Size,
+ IN UINT64 Dirs
)
{
//
@@ -311,7 +314,7 @@ PrintNonSfoFooter(
Files,
Size,
Dirs
- );
+ );
}
/**
@@ -322,33 +325,33 @@ PrintNonSfoFooter(
**/
VOID
FileTimeToLocalTime (
- IN EFI_TIME *Time,
- IN INT16 LocalTimeZone
+ IN EFI_TIME *Time,
+ IN INT16 LocalTimeZone
)
{
- INTN MinuteDiff;
- INTN TempMinute;
- INTN HourNumberOfTempMinute;
- INTN TempHour;
- INTN DayNumberOfTempHour;
- INTN TempDay;
- INTN MonthNumberOfTempDay;
- INTN TempMonth;
- INTN YearNumberOfTempMonth;
- INTN MonthRecord;
-
- ASSERT ((Time->TimeZone >= -1440) && (Time->TimeZone <=1440));
- ASSERT ((LocalTimeZone >= -1440) && (LocalTimeZone <=1440));
+ INTN MinuteDiff;
+ INTN TempMinute;
+ INTN HourNumberOfTempMinute;
+ INTN TempHour;
+ INTN DayNumberOfTempHour;
+ INTN TempDay;
+ INTN MonthNumberOfTempDay;
+ INTN TempMonth;
+ INTN YearNumberOfTempMonth;
+ INTN MonthRecord;
+
+ ASSERT ((Time->TimeZone >= -1440) && (Time->TimeZone <= 1440));
+ ASSERT ((LocalTimeZone >= -1440) && (LocalTimeZone <= 1440));
ASSERT ((Time->Month >= 1) && (Time->Month <= 12));
- if(Time->TimeZone == LocalTimeZone) {
+ if (Time->TimeZone == LocalTimeZone) {
//
- //if the file timezone is equal to the local timezone, there is no need to adjust the file time.
+ // if the file timezone is equal to the local timezone, there is no need to adjust the file time.
//
return;
}
- if((Time->Year % 4 == 0 && Time->Year / 100 != 0)||(Time->Year % 400 == 0)) {
+ if (((Time->Year % 4 == 0) && (Time->Year / 100 != 0)) || (Time->Year % 400 == 0)) {
//
// Day in February of leap year is 29.
//
@@ -363,21 +366,23 @@ FileTimeToLocalTime (
// TempHour will be used to calculate Time->Hour
//
HourNumberOfTempMinute = TempMinute / 60;
- if(TempMinute < 0) {
- HourNumberOfTempMinute --;
+ if (TempMinute < 0) {
+ HourNumberOfTempMinute--;
}
- TempHour = Time->Hour + HourNumberOfTempMinute;
+
+ TempHour = Time->Hour + HourNumberOfTempMinute;
Time->Minute = (UINT8)(TempMinute - 60 * HourNumberOfTempMinute);
//
// Calculate Time->Hour
// TempDay will be used to calculate Time->Day
//
- DayNumberOfTempHour = TempHour / 24 ;
- if(TempHour < 0){
+ DayNumberOfTempHour = TempHour / 24;
+ if (TempHour < 0) {
DayNumberOfTempHour--;
}
- TempDay = Time->Day + DayNumberOfTempHour;
+
+ TempDay = Time->Day + DayNumberOfTempHour;
Time->Hour = (UINT8)(TempHour - 24 * DayNumberOfTempHour);
//
@@ -385,11 +390,12 @@ FileTimeToLocalTime (
// TempMonth will be used to calculate Time->Month
//
MonthNumberOfTempDay = (TempDay - 1) / (INTN)mDayOfMonth[Time->Month - 1];
- MonthRecord = (INTN)(Time->Month) ;
- if(TempDay - 1 < 0){
- MonthNumberOfTempDay -- ;
- MonthRecord -- ;
+ MonthRecord = (INTN)(Time->Month);
+ if (TempDay - 1 < 0) {
+ MonthNumberOfTempDay--;
+ MonthRecord--;
}
+
TempMonth = Time->Month + MonthNumberOfTempDay;
Time->Day = (UINT8)(TempDay - (INTN)mDayOfMonth[(MonthRecord - 1 + 12) % 12] * MonthNumberOfTempDay);
@@ -397,11 +403,12 @@ FileTimeToLocalTime (
// Calculate Time->Month, Time->Year
//
YearNumberOfTempMonth = (TempMonth - 1) / 12;
- if(TempMonth - 1 < 0){
- YearNumberOfTempMonth --;
+ if (TempMonth - 1 < 0) {
+ YearNumberOfTempMonth--;
}
+
Time->Month = (UINT8)(TempMonth - 12 * (YearNumberOfTempMonth));
- Time->Year = (UINT16)(Time->Year + YearNumberOfTempMonth);
+ Time->Year = (UINT16)(Time->Year + YearNumberOfTempMonth);
}
/**
@@ -423,30 +430,30 @@ FileTimeToLocalTime (
@retval SHELL_SUCCESS the printing was sucessful.
**/
SHELL_STATUS
-PrintLsOutput(
- IN CONST BOOLEAN Rec,
- IN CONST UINT64 Attribs,
- IN CONST BOOLEAN Sfo,
- IN CONST CHAR16 *RootPath,
- IN CONST CHAR16 *SearchString,
- IN BOOLEAN *Found,
- IN CONST UINTN Count,
- IN CONST INT16 TimeZone,
- IN CONST BOOLEAN ListUnfiltered
+PrintLsOutput (
+ IN CONST BOOLEAN Rec,
+ IN CONST UINT64 Attribs,
+ IN CONST BOOLEAN Sfo,
+ IN CONST CHAR16 *RootPath,
+ IN CONST CHAR16 *SearchString,
+ IN BOOLEAN *Found,
+ IN CONST UINTN Count,
+ IN CONST INT16 TimeZone,
+ IN CONST BOOLEAN ListUnfiltered
)
{
- EFI_STATUS Status;
- EFI_SHELL_FILE_INFO *ListHead;
- EFI_SHELL_FILE_INFO *Node;
- SHELL_STATUS ShellStatus;
- UINT64 FileCount;
- UINT64 DirCount;
- UINT64 FileSize;
- UINTN LongestPath;
- CHAR16 *CorrectedPath;
- BOOLEAN FoundOne;
- BOOLEAN HeaderPrinted;
- EFI_TIME LocalTime;
+ EFI_STATUS Status;
+ EFI_SHELL_FILE_INFO *ListHead;
+ EFI_SHELL_FILE_INFO *Node;
+ SHELL_STATUS ShellStatus;
+ UINT64 FileCount;
+ UINT64 DirCount;
+ UINT64 FileSize;
+ UINTN LongestPath;
+ CHAR16 *CorrectedPath;
+ BOOLEAN FoundOne;
+ BOOLEAN HeaderPrinted;
+ EFI_TIME LocalTime;
HeaderPrinted = FALSE;
FileCount = 0;
@@ -463,30 +470,33 @@ PrintLsOutput(
FoundOne = FALSE;
}
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, RootPath, 0);
+ CorrectedPath = StrnCatGrow (&CorrectedPath, &LongestPath, RootPath, 0);
if (CorrectedPath == NULL) {
return SHELL_OUT_OF_RESOURCES;
}
- if (CorrectedPath[StrLen(CorrectedPath)-1] != L'\\'
- &&CorrectedPath[StrLen(CorrectedPath)-1] != L'/') {
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"\\", 0);
+
+ if ( (CorrectedPath[StrLen (CorrectedPath)-1] != L'\\')
+ && (CorrectedPath[StrLen (CorrectedPath)-1] != L'/'))
+ {
+ CorrectedPath = StrnCatGrow (&CorrectedPath, &LongestPath, L"\\", 0);
}
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, SearchString, 0);
+
+ CorrectedPath = StrnCatGrow (&CorrectedPath, &LongestPath, SearchString, 0);
if (CorrectedPath == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
- PathCleanUpDirectories(CorrectedPath);
+ PathCleanUpDirectories (CorrectedPath);
- Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
- if (!EFI_ERROR(Status)) {
- if (ListHead == NULL || IsListEmpty(&ListHead->Link)) {
- SHELL_FREE_NON_NULL(CorrectedPath);
+ Status = ShellOpenFileMetaArg ((CHAR16 *)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
+ if (!EFI_ERROR (Status)) {
+ if ((ListHead == NULL) || IsListEmpty (&ListHead->Link)) {
+ SHELL_FREE_NON_NULL (CorrectedPath);
return (SHELL_SUCCESS);
}
- if (Sfo && Found == NULL) {
- PrintSfoVolumeInfoTableEntry(ListHead);
+ if (Sfo && (Found == NULL)) {
+ PrintSfoVolumeInfoTableEntry (ListHead);
}
if (!Sfo) {
@@ -503,54 +513,64 @@ PrintLsOutput(
);
}
- for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link), LongestPath = 0
- ; !IsNull(&ListHead->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)
- ){
+ for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&ListHead->Link), LongestPath = 0
+ ; !IsNull (&ListHead->Link, &Node->Link)
+ ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&ListHead->Link, &Node->Link)
+ )
+ {
if (ShellGetExecutionBreakFlag ()) {
ShellStatus = SHELL_ABORTED;
break;
}
- ASSERT(Node != NULL);
+
+ ASSERT (Node != NULL);
//
// Change the file time to local time.
//
- Status = gRT->GetTime(&LocalTime, NULL);
+ Status = gRT->GetTime (&LocalTime, NULL);
if (!EFI_ERROR (Status) && (LocalTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE)) {
if ((Node->Info->CreateTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) &&
- (Node->Info->CreateTime.Month >= 1 && Node->Info->CreateTime.Month <= 12)) {
+ ((Node->Info->CreateTime.Month >= 1) && (Node->Info->CreateTime.Month <= 12)))
+ {
//
// FileTimeToLocalTime () requires Month is in a valid range, other buffer out-of-band access happens.
//
FileTimeToLocalTime (&Node->Info->CreateTime, LocalTime.TimeZone);
}
+
if ((Node->Info->LastAccessTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) &&
- (Node->Info->LastAccessTime.Month >= 1 && Node->Info->LastAccessTime.Month <= 12)) {
+ ((Node->Info->LastAccessTime.Month >= 1) && (Node->Info->LastAccessTime.Month <= 12)))
+ {
FileTimeToLocalTime (&Node->Info->LastAccessTime, LocalTime.TimeZone);
}
+
if ((Node->Info->ModificationTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) &&
- (Node->Info->ModificationTime.Month >= 1 && Node->Info->ModificationTime.Month <= 12)) {
+ ((Node->Info->ModificationTime.Month >= 1) && (Node->Info->ModificationTime.Month <= 12)))
+ {
FileTimeToLocalTime (&Node->Info->ModificationTime, LocalTime.TimeZone);
}
}
- if (LongestPath < StrSize(Node->FullName)) {
- LongestPath = StrSize(Node->FullName);
+ if (LongestPath < StrSize (Node->FullName)) {
+ LongestPath = StrSize (Node->FullName);
}
- ASSERT(Node->Info != NULL);
- ASSERT((Node->Info->Attribute & EFI_FILE_VALID_ATTR) == Node->Info->Attribute);
+
+ ASSERT (Node->Info != NULL);
+ ASSERT ((Node->Info->Attribute & EFI_FILE_VALID_ATTR) == Node->Info->Attribute);
if (Attribs == 0) {
//
// NOT system & NOT hidden
//
- if ( (Node->Info->Attribute & EFI_FILE_SYSTEM)
- || (Node->Info->Attribute & EFI_FILE_HIDDEN)
- ){
+ if ( (Node->Info->Attribute & EFI_FILE_SYSTEM)
+ || (Node->Info->Attribute & EFI_FILE_HIDDEN)
+ )
+ {
continue;
}
} else if ((Attribs != EFI_FILE_VALID_ATTR) ||
- (Count == 5)) {
+ (Count == 5))
+ {
//
// Only matches the bits which "Attribs" contains, not
// all files/directories with any of the bits.
@@ -558,47 +578,52 @@ PrintLsOutput(
// specifying all bits (EX: -arhsda) and just specifying
// -a (means display all files with any attribute).
//
- if ( (Node->Info->Attribute & Attribs) != Attribs) {
+ if ((Node->Info->Attribute & Attribs) != Attribs) {
continue;
}
}
if (!Sfo && !HeaderPrinted) {
PathRemoveLastItem (CorrectedPath);
- PrintNonSfoHeader(CorrectedPath);
+ PrintNonSfoHeader (CorrectedPath);
}
- PrintFileInformation(Sfo, Node, &FileCount, &FileSize, &DirCount);
- FoundOne = TRUE;
+
+ PrintFileInformation (Sfo, Node, &FileCount, &FileSize, &DirCount);
+ FoundOne = TRUE;
HeaderPrinted = TRUE;
}
- if (!Sfo && ShellStatus != SHELL_ABORTED && HeaderPrinted) {
- PrintNonSfoFooter(FileCount, FileSize, DirCount);
+ if (!Sfo && (ShellStatus != SHELL_ABORTED) && HeaderPrinted) {
+ PrintNonSfoFooter (FileCount, FileSize, DirCount);
}
}
- if (Rec && ShellStatus != SHELL_ABORTED) {
+ if (Rec && (ShellStatus != SHELL_ABORTED)) {
//
// Re-Open all the files under the starting path for directories that didnt necessarily match our file filter
//
- ShellCloseFileMetaArg(&ListHead);
+ ShellCloseFileMetaArg (&ListHead);
CorrectedPath[0] = CHAR_NULL;
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, RootPath, 0);
+ CorrectedPath = StrnCatGrow (&CorrectedPath, &LongestPath, RootPath, 0);
if (CorrectedPath == NULL) {
return SHELL_OUT_OF_RESOURCES;
}
- if (CorrectedPath[StrLen(CorrectedPath)-1] != L'\\'
- &&CorrectedPath[StrLen(CorrectedPath)-1] != L'/') {
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"\\", 0);
+
+ if ( (CorrectedPath[StrLen (CorrectedPath)-1] != L'\\')
+ && (CorrectedPath[StrLen (CorrectedPath)-1] != L'/'))
+ {
+ CorrectedPath = StrnCatGrow (&CorrectedPath, &LongestPath, L"\\", 0);
}
- CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"*", 0);
- Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
-
- if (!EFI_ERROR(Status)) {
- for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link)
- ; !IsNull(&ListHead->Link, &Node->Link) && ShellStatus == SHELL_SUCCESS
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)
- ){
+
+ CorrectedPath = StrnCatGrow (&CorrectedPath, &LongestPath, L"*", 0);
+ Status = ShellOpenFileMetaArg ((CHAR16 *)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
+
+ if (!EFI_ERROR (Status)) {
+ for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&ListHead->Link)
+ ; !IsNull (&ListHead->Link, &Node->Link) && ShellStatus == SHELL_SUCCESS
+ ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&ListHead->Link, &Node->Link)
+ )
+ {
if (ShellGetExecutionBreakFlag ()) {
ShellStatus = SHELL_ABORTED;
break;
@@ -607,20 +632,22 @@ PrintLsOutput(
//
// recurse on any directory except the traversing ones...
//
- if (((Node->Info->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY)
- && StrCmp(Node->FileName, L".") != 0
- && StrCmp(Node->FileName, L"..") != 0
- ){
- ShellStatus = PrintLsOutput(
- Rec,
- Attribs,
- Sfo,
- Node->FullName,
- SearchString,
- &FoundOne,
- Count,
- TimeZone,
- FALSE);
+ if ( ((Node->Info->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY)
+ && (StrCmp (Node->FileName, L".") != 0)
+ && (StrCmp (Node->FileName, L"..") != 0)
+ )
+ {
+ ShellStatus = PrintLsOutput (
+ Rec,
+ Attribs,
+ Sfo,
+ Node->FullName,
+ SearchString,
+ &FoundOne,
+ Count,
+ TimeZone,
+ FALSE
+ );
//
// Since it's running recursively, we have to break immediately when returned SHELL_ABORTED
@@ -633,10 +660,10 @@ PrintLsOutput(
}
}
- SHELL_FREE_NON_NULL(CorrectedPath);
- ShellCloseFileMetaArg(&ListHead);
+ SHELL_FREE_NON_NULL (CorrectedPath);
+ ShellCloseFileMetaArg (&ListHead);
- if (Found == NULL && !FoundOne) {
+ if ((Found == NULL) && !FoundOne) {
if (ListUnfiltered) {
//
// When running "ls" without any filtering request, avoid outputing
@@ -661,12 +688,12 @@ PrintLsOutput(
return (ShellStatus);
}
-STATIC CONST SHELL_PARAM_ITEM LsParamList[] = {
- {L"-r", TypeFlag},
- {L"-a", TypeStart},
- {L"-sfo", TypeFlag},
- {NULL, TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM LsParamList[] = {
+ { L"-r", TypeFlag },
+ { L"-a", TypeStart },
+ { L"-sfo", TypeFlag },
+ { NULL, TypeMax }
+};
/**
Function for 'ls' command.
@@ -696,62 +723,63 @@ ShellCommandRunLs (
CHAR16 *SearchString;
BOOLEAN ListUnfiltered;
- Size = 0;
- FullPath = NULL;
- ProblemParam = NULL;
- Attribs = NULL;
- ShellStatus = SHELL_SUCCESS;
- RequiredAttributes = 0;
- PathName = NULL;
- SearchString = NULL;
- CurDir = NULL;
- Count = 0;
- ListUnfiltered = FALSE;
+ Size = 0;
+ FullPath = NULL;
+ ProblemParam = NULL;
+ Attribs = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ RequiredAttributes = 0;
+ PathName = NULL;
+ SearchString = NULL;
+ CurDir = NULL;
+ Count = 0;
+ ListUnfiltered = FALSE;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// Fix local copies of the protocol pointers
//
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
+ Status = CommandInit ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (LsParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"ls", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"ls", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
}
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"ls");
+ if (ShellCommandLineGetCount (Package) > 2) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"ls");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// check for -a
//
- if (ShellCommandLineGetFlag(Package, L"-a")) {
- for ( Attribs = ShellCommandLineGetValue(Package, L"-a")
- ; Attribs != NULL && *Attribs != CHAR_NULL && ShellStatus == SHELL_SUCCESS
- ; Attribs++
- ){
+ if (ShellCommandLineGetFlag (Package, L"-a")) {
+ for ( Attribs = ShellCommandLineGetValue (Package, L"-a")
+ ; Attribs != NULL && *Attribs != CHAR_NULL && ShellStatus == SHELL_SUCCESS
+ ; Attribs++
+ )
+ {
switch (*Attribs) {
case L'a':
case L'A':
@@ -779,11 +807,12 @@ ShellCommandRunLs (
Count++;
continue;
default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ATTRIBUTE), gShellLevel2HiiHandle, L"ls", ShellCommandLineGetValue(Package, L"-a"));
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ATTRIBUTE), gShellLevel2HiiHandle, L"ls", ShellCommandLineGetValue (Package, L"-a"));
ShellStatus = SHELL_INVALID_PARAMETER;
break;
} // switch
} // for loop
+
//
// if nothing is specified all are specified
//
@@ -791,103 +820,109 @@ ShellCommandRunLs (
RequiredAttributes = EFI_FILE_VALID_ATTR;
}
} // if -a present
+
if (ShellStatus == SHELL_SUCCESS) {
- PathName = ShellCommandLineGetRawValue(Package, 1);
+ PathName = ShellCommandLineGetRawValue (Package, 1);
if (PathName == NULL) {
//
// Nothing specified... must start from current directory
//
- CurDir = gEfiShellProtocol->GetCurDir(NULL);
+ CurDir = gEfiShellProtocol->GetCurDir (NULL);
if (CurDir == NULL) {
ShellStatus = SHELL_NOT_FOUND;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"ls");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"ls");
}
+
ListUnfiltered = TRUE;
//
// Copy to the 2 strings for starting path and file search string
//
- ASSERT(SearchString == NULL);
- ASSERT(FullPath == NULL);
- StrnCatGrow(&SearchString, NULL, L"*", 0);
- StrnCatGrow(&FullPath, NULL, CurDir, 0);
- Size = FullPath != NULL? StrSize(FullPath) : 0;
- StrnCatGrow(&FullPath, &Size, L"\\", 0);
+ ASSERT (SearchString == NULL);
+ ASSERT (FullPath == NULL);
+ StrnCatGrow (&SearchString, NULL, L"*", 0);
+ StrnCatGrow (&FullPath, NULL, CurDir, 0);
+ Size = FullPath != NULL ? StrSize (FullPath) : 0;
+ StrnCatGrow (&FullPath, &Size, L"\\", 0);
} else {
- if (StrStr(PathName, L":") == NULL && gEfiShellProtocol->GetCurDir(NULL) == NULL) {
+ if ((StrStr (PathName, L":") == NULL) && (gEfiShellProtocol->GetCurDir (NULL) == NULL)) {
//
// If we got something and it doesnt have a fully qualified path, then we needed to have a CWD.
//
ShellStatus = SHELL_NOT_FOUND;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"ls");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"ls");
} else {
//
// We got a valid fully qualified path or we have a CWD
//
- ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL));
- if (StrStr(PathName, L":") == NULL) {
- StrnCatGrow(&FullPath, &Size, gEfiShellProtocol->GetCurDir(NULL), 0);
+ ASSERT ((FullPath == NULL && Size == 0) || (FullPath != NULL));
+ if (StrStr (PathName, L":") == NULL) {
+ StrnCatGrow (&FullPath, &Size, gEfiShellProtocol->GetCurDir (NULL), 0);
if (FullPath == NULL) {
ShellCommandLineFreeVarList (Package);
return SHELL_OUT_OF_RESOURCES;
}
- Size = FullPath != NULL? StrSize(FullPath) : 0;
- StrnCatGrow(&FullPath, &Size, L"\\", 0);
+
+ Size = FullPath != NULL ? StrSize (FullPath) : 0;
+ StrnCatGrow (&FullPath, &Size, L"\\", 0);
}
- StrnCatGrow(&FullPath, &Size, PathName, 0);
+
+ StrnCatGrow (&FullPath, &Size, PathName, 0);
if (FullPath == NULL) {
- ShellCommandLineFreeVarList (Package);
- return SHELL_OUT_OF_RESOURCES;
+ ShellCommandLineFreeVarList (Package);
+ return SHELL_OUT_OF_RESOURCES;
}
- if (ShellIsDirectory(PathName) == EFI_SUCCESS) {
+ if (ShellIsDirectory (PathName) == EFI_SUCCESS) {
//
// is listing ends with a directory, then we list all files in that directory
//
ListUnfiltered = TRUE;
- StrnCatGrow(&SearchString, NULL, L"*", 0);
+ StrnCatGrow (&SearchString, NULL, L"*", 0);
} else {
//
// must split off the search part that applies to files from the end of the directory part
//
- StrnCatGrow(&SearchString, NULL, FullPath, 0);
+ StrnCatGrow (&SearchString, NULL, FullPath, 0);
if (SearchString == NULL) {
FreePool (FullPath);
ShellCommandLineFreeVarList (Package);
return SHELL_OUT_OF_RESOURCES;
}
+
PathRemoveLastItem (FullPath);
CopyMem (SearchString, SearchString + StrLen (FullPath), StrSize (SearchString + StrLen (FullPath)));
}
}
}
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"ls", L"gRT->GetTime", Status);
+
+ Status = gRT->GetTime (&TheTime, NULL);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"ls", L"gRT->GetTime", Status);
TheTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
}
if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = PrintLsOutput(
- ShellCommandLineGetFlag(Package, L"-r"),
- RequiredAttributes,
- ShellCommandLineGetFlag(Package, L"-sfo"),
- FullPath,
- SearchString,
- NULL,
- Count,
- TheTime.TimeZone,
- ListUnfiltered
- );
+ ShellStatus = PrintLsOutput (
+ ShellCommandLineGetFlag (Package, L"-r"),
+ RequiredAttributes,
+ ShellCommandLineGetFlag (Package, L"-sfo"),
+ FullPath,
+ SearchString,
+ NULL,
+ Count,
+ TheTime.TimeZone,
+ ListUnfiltered
+ );
if (ShellStatus == SHELL_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LS_FILE_NOT_FOUND), gShellLevel2HiiHandle, L"ls", FullPath);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_LS_FILE_NOT_FOUND), gShellLevel2HiiHandle, L"ls", FullPath);
} else if (ShellStatus == SHELL_INVALID_PARAMETER) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"ls", FullPath);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"ls", FullPath);
} else if (ShellStatus == SHELL_ABORTED) {
//
// Ignore aborting.
//
} else if (ShellStatus != SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"ls", FullPath);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"ls", FullPath);
}
}
}
@@ -897,8 +932,8 @@ ShellCommandRunLs (
//
// Free memory allocated
//
- SHELL_FREE_NON_NULL(SearchString);
- SHELL_FREE_NON_NULL(FullPath);
+ SHELL_FREE_NON_NULL (SearchString);
+ SHELL_FREE_NON_NULL (FullPath);
ShellCommandLineFreeVarList (Package);
return (ShellStatus);
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
index c5968226be..f3c888edd4 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
@@ -28,20 +28,23 @@
@retval FALSE String has at least one other character.
**/
BOOLEAN
-IsNumberLetterOnly(
- IN CONST CHAR16 *String,
- IN CONST UINTN Len
+IsNumberLetterOnly (
+ IN CONST CHAR16 *String,
+ IN CONST UINTN Len
)
{
- UINTN Count;
- for (Count = 0 ; Count < Len && String != NULL && *String != CHAR_NULL ; String++,Count++) {
- if (! ((*String >= L'a' && *String <= L'z') ||
- (*String >= L'A' && *String <= L'Z') ||
- (*String >= L'0' && *String <= L'9'))
- ){
+ UINTN Count;
+
+ for (Count = 0; Count < Len && String != NULL && *String != CHAR_NULL; String++, Count++) {
+ if (!(((*String >= L'a') && (*String <= L'z')) ||
+ ((*String >= L'A') && (*String <= L'Z')) ||
+ ((*String >= L'0') && (*String <= L'9')))
+ )
+ {
return (FALSE);
}
}
+
return (TRUE);
}
@@ -58,7 +61,7 @@ IsNumberLetterOnly(
items (";" normally).
**/
BOOLEAN
-SearchList(
+SearchList (
IN CONST CHAR16 *List,
IN CONST CHAR16 *MetaTarget,
OUT CHAR16 **FullName OPTIONAL,
@@ -73,39 +76,44 @@ SearchList(
BOOLEAN Result;
CHAR16 *TempSpot;
- for (ListWalker = List , TempList = NULL
- ; ListWalker != NULL && *ListWalker != CHAR_NULL
- ;
- ) {
- TempList = StrnCatGrow(&TempList, NULL, ListWalker, 0);
- ASSERT(TempList != NULL);
- TempSpot = StrStr(TempList, Target);
+ for (ListWalker = List, TempList = NULL
+ ; ListWalker != NULL && *ListWalker != CHAR_NULL
+ ;
+ )
+ {
+ TempList = StrnCatGrow (&TempList, NULL, ListWalker, 0);
+ ASSERT (TempList != NULL);
+ TempSpot = StrStr (TempList, Target);
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
- while (SkipTrailingNumbers && (ShellIsDecimalDigitCharacter(TempList[StrLen(TempList)-1]) || TempList[StrLen(TempList)-1] == L':')) {
- TempList[StrLen(TempList)-1] = CHAR_NULL;
+ while (SkipTrailingNumbers && (ShellIsDecimalDigitCharacter (TempList[StrLen (TempList)-1]) || TempList[StrLen (TempList)-1] == L':')) {
+ TempList[StrLen (TempList)-1] = CHAR_NULL;
}
- ListWalker = StrStr(ListWalker, Target);
- while(ListWalker != NULL && *ListWalker == *Target) {
+ ListWalker = StrStr (ListWalker, Target);
+ while (ListWalker != NULL && *ListWalker == *Target) {
ListWalker++;
}
+
if (Meta) {
- Result = gUnicodeCollation->MetaiMatch(gUnicodeCollation, (CHAR16*)TempList, (CHAR16*)MetaTarget);
+ Result = gUnicodeCollation->MetaiMatch (gUnicodeCollation, (CHAR16 *)TempList, (CHAR16 *)MetaTarget);
} else {
- Result = (BOOLEAN)(StrCmp(TempList, MetaTarget)==0);
+ Result = (BOOLEAN)(StrCmp (TempList, MetaTarget) == 0);
}
+
if (Result) {
if (FullName != NULL) {
*FullName = TempList;
} else {
- FreePool(TempList);
+ FreePool (TempList);
}
+
return (TRUE);
}
- FreePool(TempList);
+
+ FreePool (TempList);
TempList = NULL;
}
@@ -124,9 +132,9 @@ SearchList(
@retval STR_MAP_MEDIA_CDROM The media is a CD ROM.
@retval STR_MAP_MEDIA_FLOPPY The media is a floppy drive.
**/
-CHAR16*
+CHAR16 *
GetDeviceMediaType (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
ACPI_HID_DEVICE_PATH *Acpi;
@@ -139,26 +147,26 @@ GetDeviceMediaType (
// Acpi.HID = 0X0604 -> Floppy
//
if (NULL == DevicePath) {
- return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_UNKNOWN), NULL);
+ return HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MAP_MEDIA_UNKNOWN), NULL);
}
- for (;!IsDevicePathEndType (DevicePath) ;DevicePath = NextDevicePathNode (DevicePath)) {
+ for ( ; !IsDevicePathEndType (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) {
switch (DevicePathSubType (DevicePath)) {
- case MEDIA_HARDDRIVE_DP:
- return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_HARDDISK), NULL);
- case MEDIA_CDROM_DP:
- return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_CDROM), NULL);
+ case MEDIA_HARDDRIVE_DP:
+ return HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MAP_MEDIA_HARDDISK), NULL);
+ case MEDIA_CDROM_DP:
+ return HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MAP_MEDIA_CDROM), NULL);
}
} else if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH) {
- Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;
+ Acpi = (ACPI_HID_DEVICE_PATH *)DevicePath;
if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {
- return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_FLOPPY), NULL);
+ return HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MAP_MEDIA_FLOPPY), NULL);
}
}
}
- return HiiGetString(gShellLevel2HiiHandle, STRING_TOKEN(STR_MAP_MEDIA_UNKNOWN), NULL);
+ return HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MAP_MEDIA_UNKNOWN), NULL);
}
/**
@@ -171,7 +179,7 @@ GetDeviceMediaType (
**/
BOOLEAN
IsRemoveableDevice (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
if (NULL == DevicePath) {
@@ -181,15 +189,17 @@ IsRemoveableDevice (
while (!IsDevicePathEndType (DevicePath)) {
if (DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) {
switch (DevicePathSubType (DevicePath)) {
- case MSG_USB_DP:
- case MSG_SCSI_DP:
- return TRUE;
- default:
- return FALSE;
+ case MSG_USB_DP:
+ case MSG_SCSI_DP:
+ return TRUE;
+ default:
+ return FALSE;
}
}
+
DevicePath = NextDevicePathNode (DevicePath);
}
+
return FALSE;
}
@@ -206,68 +216,73 @@ IsRemoveableDevice (
@retval FALSE The map should not be displayed.
**/
BOOLEAN
-MappingListHasType(
- IN CONST CHAR16 *MapList,
- IN CONST CHAR16 *Specific,
- IN CONST CHAR16 *TypeString,
- IN CONST BOOLEAN Normal,
- IN CONST BOOLEAN Consist
+MappingListHasType (
+ IN CONST CHAR16 *MapList,
+ IN CONST CHAR16 *Specific,
+ IN CONST CHAR16 *TypeString,
+ IN CONST BOOLEAN Normal,
+ IN CONST BOOLEAN Consist
)
{
- CHAR16 *NewSpecific;
- RETURN_STATUS Status;
- UINTN Length;
+ CHAR16 *NewSpecific;
+ RETURN_STATUS Status;
+ UINTN Length;
//
// specific has priority
//
if (Specific != NULL) {
- Length = StrLen (Specific);
+ Length = StrLen (Specific);
//
// Allocate enough buffer for Specific and potential ":"
//
- NewSpecific = AllocatePool ((Length + 2) * sizeof(CHAR16));
- if (NewSpecific == NULL){
+ NewSpecific = AllocatePool ((Length + 2) * sizeof (CHAR16));
+ if (NewSpecific == NULL) {
return FALSE;
}
+
StrCpyS (NewSpecific, Length + 2, Specific);
if (Specific[Length - 1] != L':') {
- Status = StrnCatS(NewSpecific, Length + 2, L":", StrLen(L":"));
+ Status = StrnCatS (NewSpecific, Length + 2, L":", StrLen (L":"));
if (EFI_ERROR (Status)) {
- FreePool(NewSpecific);
+ FreePool (NewSpecific);
return FALSE;
}
}
- if (SearchList(MapList, NewSpecific, NULL, TRUE, FALSE, L";")) {
- FreePool(NewSpecific);
+ if (SearchList (MapList, NewSpecific, NULL, TRUE, FALSE, L";")) {
+ FreePool (NewSpecific);
return (TRUE);
}
- FreePool(NewSpecific);
+
+ FreePool (NewSpecific);
}
+
if ( Consist
- && Specific == NULL
- && (SearchList(MapList, L"HD*", NULL, TRUE, TRUE, L";")
- ||SearchList(MapList, L"CD*", NULL, TRUE, TRUE, L";")
- ||SearchList(MapList, L"F*", NULL, TRUE, TRUE, L";")
- ||SearchList(MapList, L"FP*", NULL, TRUE, TRUE, L";"))){
+ && (Specific == NULL)
+ && ( SearchList (MapList, L"HD*", NULL, TRUE, TRUE, L";")
+ || SearchList (MapList, L"CD*", NULL, TRUE, TRUE, L";")
+ || SearchList (MapList, L"F*", NULL, TRUE, TRUE, L";")
+ || SearchList (MapList, L"FP*", NULL, TRUE, TRUE, L";")))
+ {
return (TRUE);
}
if ( Normal
- && Specific == NULL
- && (SearchList(MapList, L"FS", NULL, FALSE, TRUE, L";")
- ||SearchList(MapList, L"BLK", NULL, FALSE, TRUE, L";"))){
+ && (Specific == NULL)
+ && ( SearchList (MapList, L"FS", NULL, FALSE, TRUE, L";")
+ || SearchList (MapList, L"BLK", NULL, FALSE, TRUE, L";")))
+ {
return (TRUE);
}
- if (TypeString != NULL && SearchList(MapList, TypeString, NULL, TRUE, TRUE, L";")) {
+ if ((TypeString != NULL) && SearchList (MapList, TypeString, NULL, TRUE, TRUE, L";")) {
return (TRUE);
}
+
return (FALSE);
}
-
/**
Display a single map line for device Handle if conditions are met.
@@ -282,14 +297,14 @@ MappingListHasType(
@retval EFI_SUCCESS The mapping was displayed.
**/
EFI_STATUS
-PerformSingleMappingDisplay(
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Consist,
- IN CONST BOOLEAN Normal,
- IN CONST CHAR16 *TypeString,
- IN CONST BOOLEAN SFO,
- IN CONST CHAR16 *Specific OPTIONAL,
- IN CONST EFI_HANDLE Handle
+PerformSingleMappingDisplay (
+ IN CONST BOOLEAN Verbose,
+ IN CONST BOOLEAN Consist,
+ IN CONST BOOLEAN Normal,
+ IN CONST CHAR16 *TypeString,
+ IN CONST BOOLEAN SFO,
+ IN CONST CHAR16 *Specific OPTIONAL,
+ IN CONST EFI_HANDLE Handle
)
{
EFI_DEVICE_PATH_PROTOCOL *DevPath;
@@ -307,14 +322,14 @@ PerformSingleMappingDisplay(
Alias = NULL;
TempSpot2 = NULL;
CurrentName = NULL;
- DevPath = DevicePathFromHandle(Handle);
+ DevPath = DevicePathFromHandle (Handle);
DevPathCopy = DevPath;
- MapList = gEfiShellProtocol->GetMapFromDevicePath(&DevPathCopy);
+ MapList = gEfiShellProtocol->GetMapFromDevicePath (&DevPathCopy);
if (MapList == NULL) {
return EFI_NOT_FOUND;
}
- if (!MappingListHasType(MapList, Specific, TypeString, Normal, Consist)){
+ if (!MappingListHasType (MapList, Specific, TypeString, Normal, Consist)) {
return EFI_NOT_FOUND;
}
@@ -327,7 +342,7 @@ PerformSingleMappingDisplay(
// Allocate a name
//
CurrentName = NULL;
- CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
+ CurrentName = StrnCatGrow (&CurrentName, 0, MapList, 0);
if (CurrentName == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
@@ -336,7 +351,7 @@ PerformSingleMappingDisplay(
// Chop off the other names that become "Alias(s)"
// leaving just the normal name
//
- TempSpot = StrStr(CurrentName, L";");
+ TempSpot = StrStr (CurrentName, L";");
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
@@ -346,54 +361,62 @@ PerformSingleMappingDisplay(
//
// Skip the first name. This is the standard name.
//
- TempSpot = StrStr(MapList, L";");
+ TempSpot = StrStr (MapList, L";");
if (TempSpot != NULL) {
TempSpot++;
}
- SearchList(TempSpot, L"HD*", &CurrentName, TRUE, FALSE, L";");
+
+ SearchList (TempSpot, L"HD*", &CurrentName, TRUE, FALSE, L";");
if (CurrentName == NULL) {
- SearchList(TempSpot, L"CD*", &CurrentName, TRUE, FALSE, L";");
+ SearchList (TempSpot, L"CD*", &CurrentName, TRUE, FALSE, L";");
}
+
if (CurrentName == NULL) {
- SearchList(TempSpot, L"FP*", &CurrentName, TRUE, FALSE, L";");
+ SearchList (TempSpot, L"FP*", &CurrentName, TRUE, FALSE, L";");
}
+
if (CurrentName == NULL) {
- SearchList(TempSpot, L"F*", &CurrentName, TRUE, FALSE, L";");
+ SearchList (TempSpot, L"F*", &CurrentName, TRUE, FALSE, L";");
}
+
if (CurrentName == NULL) {
//
// We didnt find anything, so just the first one in the list...
//
- CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
+ CurrentName = StrnCatGrow (&CurrentName, 0, MapList, 0);
if (CurrentName == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- TempSpot = StrStr(CurrentName, L";");
+
+ TempSpot = StrStr (CurrentName, L";");
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
} else {
- Alias = StrnCatGrow(&Alias, 0, MapList, 0);
+ Alias = StrnCatGrow (&Alias, 0, MapList, 0);
if (Alias == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- TempSpot = StrStr(Alias, CurrentName);
+
+ TempSpot = StrStr (Alias, CurrentName);
if (TempSpot != NULL) {
- TempSpot2 = StrStr(TempSpot, L";");
+ TempSpot2 = StrStr (TempSpot, L";");
if (TempSpot2 != NULL) {
TempSpot2++; // Move past ";" from CurrentName
- CopyMem(TempSpot, TempSpot2, StrSize(TempSpot2));
+ CopyMem (TempSpot, TempSpot2, StrSize (TempSpot2));
} else {
*TempSpot = CHAR_NULL;
}
}
- if (Alias[StrLen(Alias)-1] == L';') {
- Alias[StrLen(Alias)-1] = CHAR_NULL;
+
+ if (Alias[StrLen (Alias)-1] == L';') {
+ Alias[StrLen (Alias)-1] = CHAR_NULL;
}
}
}
- DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);
- TempLen = StrLen(CurrentName);
+
+ DevPathString = ConvertDevicePathToText (DevPath, TRUE, FALSE);
+ TempLen = StrLen (CurrentName);
if (!SFO) {
ShellPrintHiiEx (
-1,
@@ -402,30 +425,31 @@ PerformSingleMappingDisplay(
STRING_TOKEN (STR_MAP_ENTRY),
gShellLevel2HiiHandle,
CurrentName,
- Alias!=NULL?Alias:(TempLen < StrLen(MapList)?MapList + TempLen+1:L""),
+ Alias != NULL ? Alias : (TempLen < StrLen (MapList) ? MapList + TempLen+1 : L""),
DevPathString
- );
+ );
if (Verbose) {
//
// also print handle, media type, removable (y/n), and current directory
//
- MediaType = GetDeviceMediaType(DevPath);
- if ((TypeString != NULL &&MediaType != NULL && StrStr(TypeString, MediaType) != NULL) || TypeString == NULL) {
- Removable = IsRemoveableDevice(DevPath);
- TempSpot2 = ShellGetCurrentDir(CurrentName);
+ MediaType = GetDeviceMediaType (DevPath);
+ if (((TypeString != NULL) && (MediaType != NULL) && (StrStr (TypeString, MediaType) != NULL)) || (TypeString == NULL)) {
+ Removable = IsRemoveableDevice (DevPath);
+ TempSpot2 = ShellGetCurrentDir (CurrentName);
ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_MAP_ENTRY_VERBOSE),
gShellLevel2HiiHandle,
- ConvertHandleToHandleIndex(Handle),
+ ConvertHandleToHandleIndex (Handle),
MediaType,
- Removable?L"Yes":L"No",
+ Removable ? L"Yes" : L"No",
TempSpot2
- );
+ );
}
- SHELL_FREE_NON_NULL(MediaType);
+
+ SHELL_FREE_NON_NULL (MediaType);
}
} else {
ShellPrintHiiEx (
@@ -436,12 +460,13 @@ PerformSingleMappingDisplay(
gShellLevel2HiiHandle,
CurrentName,
DevPathString,
- Consist?L"":(TempLen < StrLen(MapList)?MapList + TempLen+1:L"")
- );
+ Consist ? L"" : (TempLen < StrLen (MapList) ? MapList + TempLen+1 : L"")
+ );
}
- SHELL_FREE_NON_NULL(DevPathString);
- SHELL_FREE_NON_NULL(CurrentName);
- SHELL_FREE_NON_NULL(Alias);
+
+ SHELL_FREE_NON_NULL (DevPathString);
+ SHELL_FREE_NON_NULL (CurrentName);
+ SHELL_FREE_NON_NULL (Alias);
return EFI_SUCCESS;
}
@@ -455,9 +480,9 @@ PerformSingleMappingDisplay(
@retval EFI_NOT_FOUND Name was not a map on Handle.
**/
EFI_STATUS
-PerformSingleMappingDelete(
- IN CONST CHAR16 *Specific,
- IN CONST EFI_HANDLE Handle
+PerformSingleMappingDelete (
+ IN CONST CHAR16 *Specific,
+ IN CONST EFI_HANDLE Handle
)
{
EFI_DEVICE_PATH_PROTOCOL *DevPath;
@@ -465,27 +490,30 @@ PerformSingleMappingDelete(
CONST CHAR16 *MapList;
CHAR16 *CurrentName;
- DevPath = DevicePathFromHandle(Handle);
+ DevPath = DevicePathFromHandle (Handle);
DevPathCopy = DevPath;
- MapList = gEfiShellProtocol->GetMapFromDevicePath(&DevPathCopy);
+ MapList = gEfiShellProtocol->GetMapFromDevicePath (&DevPathCopy);
CurrentName = NULL;
if (MapList == NULL) {
return (EFI_NOT_FOUND);
}
+
//
// if there is a specific and its not on the list...
//
- if (!SearchList(MapList, Specific, &CurrentName, TRUE, FALSE, L";")) {
+ if (!SearchList (MapList, Specific, &CurrentName, TRUE, FALSE, L";")) {
return (EFI_NOT_FOUND);
}
- return (gEfiShellProtocol->SetMap(NULL, CurrentName));
+
+ return (gEfiShellProtocol->SetMap (NULL, CurrentName));
}
-CONST CHAR16 Cd[] = L"cd*";
-CONST CHAR16 Hd[] = L"hd*";
-CONST CHAR16 Fp[] = L"fp*";
-CONST CHAR16 AnyF[] = L"F*";
+CONST CHAR16 Cd[] = L"cd*";
+CONST CHAR16 Hd[] = L"hd*";
+CONST CHAR16 Fp[] = L"fp*";
+CONST CHAR16 AnyF[] = L"F*";
+
/**
Function to display mapping information to the user.
@@ -505,40 +533,40 @@ CONST CHAR16 AnyF[] = L"F*";
**/
SHELL_STATUS
-PerformMappingDisplay(
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Consist,
- IN CONST BOOLEAN Normal,
- IN CONST CHAR16 *TypeString,
- IN CONST BOOLEAN SFO,
- IN CONST CHAR16 *Specific OPTIONAL,
- IN CONST BOOLEAN Header
+PerformMappingDisplay (
+ IN CONST BOOLEAN Verbose,
+ IN CONST BOOLEAN Consist,
+ IN CONST BOOLEAN Normal,
+ IN CONST CHAR16 *TypeString,
+ IN CONST BOOLEAN SFO,
+ IN CONST CHAR16 *Specific OPTIONAL,
+ IN CONST BOOLEAN Header
)
{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN BufferSize;
- UINTN LoopVar;
- CHAR16 *Test;
- BOOLEAN Found;
-
- if (!Consist && !Normal && Specific == NULL && TypeString == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"map");
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN BufferSize;
+ UINTN LoopVar;
+ CHAR16 *Test;
+ BOOLEAN Found;
+
+ if (!Consist && !Normal && (Specific == NULL) && (TypeString == NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"map");
return (SHELL_INVALID_PARAMETER);
}
if (TypeString != NULL) {
- Test = (CHAR16*)Cd;
- if (StrnCmp(TypeString, Test, StrLen(Test)-1) != 0) {
- Test = (CHAR16*)Hd;
- if (StrnCmp(TypeString, Test, StrLen(Test)-1) != 0) {
- Test = (CHAR16*)Fp;
- if (StrnCmp(TypeString, Test, StrLen(Test)-1) != 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", TypeString);
+ Test = (CHAR16 *)Cd;
+ if (StrnCmp (TypeString, Test, StrLen (Test)-1) != 0) {
+ Test = (CHAR16 *)Hd;
+ if (StrnCmp (TypeString, Test, StrLen (Test)-1) != 0) {
+ Test = (CHAR16 *)Fp;
+ if (StrnCmp (TypeString, Test, StrLen (Test)-1) != 0) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", TypeString);
return (SHELL_INVALID_PARAMETER);
}
} else if (Test == NULL) {
- Test = (CHAR16*)AnyF;
+ Test = (CHAR16 *)AnyF;
}
}
} else {
@@ -550,53 +578,58 @@ PerformMappingDisplay(
// Print the header
//
if (!SFO) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_HEADER), gShellLevel2HiiHandle);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MAP_HEADER), gShellLevel2HiiHandle);
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellLevel2HiiHandle, L"map");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellLevel2HiiHandle, L"map");
}
}
- BufferSize = 0;
- HandleBuffer = NULL;
+ BufferSize = 0;
+ HandleBuffer = NULL;
//
// Look up all SimpleFileSystems in the platform
//
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiSimpleFileSystemProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiSimpleFileSystemProtocolGuid,
+ NULL,
+ &BufferSize,
+ HandleBuffer
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleBuffer = AllocateZeroPool(BufferSize);
+ HandleBuffer = AllocateZeroPool (BufferSize);
if (HandleBuffer == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiSimpleFileSystemProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
+
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiSimpleFileSystemProtocolGuid,
+ NULL,
+ &BufferSize,
+ HandleBuffer
+ );
}
//
// Get the map name(s) for each one.
//
for ( LoopVar = 0, Found = FALSE
- ; LoopVar < (BufferSize / sizeof(EFI_HANDLE)) && HandleBuffer != NULL
- ; LoopVar ++
- ){
- Status = PerformSingleMappingDisplay(
- Verbose,
- Consist,
- Normal,
- Test,
- SFO,
- Specific,
- HandleBuffer[LoopVar]);
- if (!EFI_ERROR(Status)) {
+ ; LoopVar < (BufferSize / sizeof (EFI_HANDLE)) && HandleBuffer != NULL
+ ; LoopVar++
+ )
+ {
+ Status = PerformSingleMappingDisplay (
+ Verbose,
+ Consist,
+ Normal,
+ Test,
+ SFO,
+ Specific,
+ HandleBuffer[LoopVar]
+ );
+ if (!EFI_ERROR (Status)) {
Found = TRUE;
}
}
@@ -604,66 +637,78 @@ PerformMappingDisplay(
//
// Look up all BlockIo in the platform
//
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiBlockIoProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiBlockIoProtocolGuid,
+ NULL,
+ &BufferSize,
+ HandleBuffer
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- SHELL_FREE_NON_NULL(HandleBuffer);
- HandleBuffer = AllocateZeroPool(BufferSize);
+ SHELL_FREE_NON_NULL (HandleBuffer);
+ HandleBuffer = AllocateZeroPool (BufferSize);
if (HandleBuffer == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiBlockIoProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
+
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiBlockIoProtocolGuid,
+ NULL,
+ &BufferSize,
+ HandleBuffer
+ );
}
- if (!EFI_ERROR(Status) && HandleBuffer != NULL) {
+
+ if (!EFI_ERROR (Status) && (HandleBuffer != NULL)) {
//
// Get the map name(s) for each one.
//
for ( LoopVar = 0
- ; LoopVar < BufferSize / sizeof(EFI_HANDLE)
- ; LoopVar ++
- ){
+ ; LoopVar < BufferSize / sizeof (EFI_HANDLE)
+ ; LoopVar++
+ )
+ {
//
// Skip any that were already done...
//
- if (gBS->OpenProtocol(
- HandleBuffer[LoopVar],
- &gEfiSimpleFileSystemProtocolGuid,
- NULL,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {
- continue;
+ if (gBS->OpenProtocol (
+ HandleBuffer[LoopVar],
+ &gEfiSimpleFileSystemProtocolGuid,
+ NULL,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ ) == EFI_SUCCESS)
+ {
+ continue;
}
- Status = PerformSingleMappingDisplay(
- Verbose,
- Consist,
- Normal,
- Test,
- SFO,
- Specific,
- HandleBuffer[LoopVar]);
- if (!EFI_ERROR(Status)) {
+
+ Status = PerformSingleMappingDisplay (
+ Verbose,
+ Consist,
+ Normal,
+ Test,
+ SFO,
+ Specific,
+ HandleBuffer[LoopVar]
+ );
+ if (!EFI_ERROR (Status)) {
Found = TRUE;
}
}
- FreePool(HandleBuffer);
+
+ FreePool (HandleBuffer);
}
+
if (!Found) {
if (Specific != NULL) {
- ShellPrintHiiEx(gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, L"map", Specific);
+ ShellPrintHiiEx (gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, L"map", Specific);
} else {
- ShellPrintHiiEx(gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"map");
+ ShellPrintHiiEx (gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"map");
}
}
+
return (SHELL_SUCCESS);
}
@@ -682,41 +727,43 @@ PerformMappingDisplay(
@sa PerformMappingDisplay
**/
SHELL_STATUS
-PerformMappingDisplay2(
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Consist,
- IN CONST BOOLEAN Normal,
- IN CONST CHAR16 *TypeString,
- IN CONST BOOLEAN SFO,
- IN CONST CHAR16 *Specific OPTIONAL
+PerformMappingDisplay2 (
+ IN CONST BOOLEAN Verbose,
+ IN CONST BOOLEAN Consist,
+ IN CONST BOOLEAN Normal,
+ IN CONST CHAR16 *TypeString,
+ IN CONST BOOLEAN SFO,
+ IN CONST CHAR16 *Specific OPTIONAL
)
{
CONST CHAR16 *TypeWalker;
SHELL_STATUS ShellStatus;
CHAR16 *Comma;
-
if (TypeString == NULL) {
- return (PerformMappingDisplay(Verbose, Consist, Normal, NULL, SFO, Specific, TRUE));
+ return (PerformMappingDisplay (Verbose, Consist, Normal, NULL, SFO, Specific, TRUE));
}
+
ShellStatus = SHELL_SUCCESS;
- for (TypeWalker = TypeString ; TypeWalker != NULL && *TypeWalker != CHAR_NULL ;) {
- Comma = StrStr(TypeWalker, L",");
+ for (TypeWalker = TypeString; TypeWalker != NULL && *TypeWalker != CHAR_NULL;) {
+ Comma = StrStr (TypeWalker, L",");
if (Comma == NULL) {
if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
+ ShellStatus = PerformMappingDisplay (Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
} else {
- PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
+ PerformMappingDisplay (Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
}
+
break;
} else {
*Comma = CHAR_NULL;
if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
+ ShellStatus = PerformMappingDisplay (Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
} else {
- PerformMappingDisplay(Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
+ PerformMappingDisplay (Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
}
- *Comma = L',';
+
+ *Comma = L',';
TypeWalker = Comma + 1;
}
}
@@ -734,47 +781,51 @@ PerformMappingDisplay2(
@retval EFI_NOT_FOUND Specific could not be found.
**/
EFI_STATUS
-PerformMappingDelete(
+PerformMappingDelete (
IN CONST CHAR16 *Specific
)
{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN BufferSize;
- UINTN LoopVar;
- BOOLEAN Deleted;
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN BufferSize;
+ UINTN LoopVar;
+ BOOLEAN Deleted;
if (Specific == NULL) {
return (EFI_INVALID_PARAMETER);
}
- BufferSize = 0;
- HandleBuffer = NULL;
- Deleted = FALSE;
+ BufferSize = 0;
+ HandleBuffer = NULL;
+ Deleted = FALSE;
//
// Look up all SimpleFileSystems in the platform
//
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiDevicePathProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiDevicePathProtocolGuid,
+ NULL,
+ &BufferSize,
+ HandleBuffer
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleBuffer = AllocateZeroPool(BufferSize);
+ HandleBuffer = AllocateZeroPool (BufferSize);
if (HandleBuffer == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiDevicePathProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
+
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiDevicePathProtocolGuid,
+ NULL,
+ &BufferSize,
+ HandleBuffer
+ );
}
- if (EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL(HandleBuffer);
+
+ if (EFI_ERROR (Status)) {
+ SHELL_FREE_NON_NULL (HandleBuffer);
return (Status);
}
@@ -783,38 +834,44 @@ PerformMappingDelete(
// Get the map name(s) for each one.
//
for ( LoopVar = 0
- ; LoopVar < BufferSize / sizeof(EFI_HANDLE)
- ; LoopVar ++
- ){
- if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
- Deleted = TRUE;
+ ; LoopVar < BufferSize / sizeof (EFI_HANDLE)
+ ; LoopVar++
+ )
+ {
+ if (PerformSingleMappingDelete (Specific, HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
+ Deleted = TRUE;
}
}
}
+
//
// Look up all BlockIo in the platform
//
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiBlockIoProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiBlockIoProtocolGuid,
+ NULL,
+ &BufferSize,
+ HandleBuffer
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- FreePool(HandleBuffer);
- HandleBuffer = AllocateZeroPool(BufferSize);
+ FreePool (HandleBuffer);
+ HandleBuffer = AllocateZeroPool (BufferSize);
if (HandleBuffer == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiBlockIoProtocolGuid,
- NULL,
- &BufferSize,
- HandleBuffer);
+
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiBlockIoProtocolGuid,
+ NULL,
+ &BufferSize,
+ HandleBuffer
+ );
}
- if (EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL(HandleBuffer);
+
+ if (EFI_ERROR (Status)) {
+ SHELL_FREE_NON_NULL (HandleBuffer);
return (Status);
}
@@ -823,30 +880,36 @@ PerformMappingDelete(
// Get the map name(s) for each one.
//
for ( LoopVar = 0
- ; LoopVar < BufferSize / sizeof(EFI_HANDLE)
- ; LoopVar ++
- ){
+ ; LoopVar < BufferSize / sizeof (EFI_HANDLE)
+ ; LoopVar++
+ )
+ {
//
// Skip any that were already done...
//
- if (gBS->OpenProtocol(
- HandleBuffer[LoopVar],
- &gEfiDevicePathProtocolGuid,
- NULL,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {
- continue;
+ if (gBS->OpenProtocol (
+ HandleBuffer[LoopVar],
+ &gEfiDevicePathProtocolGuid,
+ NULL,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ ) == EFI_SUCCESS)
+ {
+ continue;
}
- if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
- Deleted = TRUE;
+
+ if (PerformSingleMappingDelete (Specific, HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
+ Deleted = TRUE;
}
}
}
- SHELL_FREE_NON_NULL(HandleBuffer);
+
+ SHELL_FREE_NON_NULL (HandleBuffer);
if (!Deleted) {
return (EFI_NOT_FOUND);
}
+
return (EFI_SUCCESS);
}
@@ -864,9 +927,9 @@ PerformMappingDelete(
**/
SHELL_STATUS
-AddMappingFromMapping(
- IN CONST CHAR16 *Map,
- IN CONST CHAR16 *SName
+AddMappingFromMapping (
+ IN CONST CHAR16 *Map,
+ IN CONST CHAR16 *SName
)
{
CONST EFI_DEVICE_PATH_PROTOCOL *DevPath;
@@ -874,34 +937,36 @@ AddMappingFromMapping(
CHAR16 *NewSName;
RETURN_STATUS StrRetStatus;
- NewSName = AllocateCopyPool(StrSize(SName) + sizeof(CHAR16), SName);
+ NewSName = AllocateCopyPool (StrSize (SName) + sizeof (CHAR16), SName);
if (NewSName == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
- if (NewSName[StrLen(NewSName)-1] != L':') {
- StrRetStatus = StrnCatS(NewSName, (StrSize(SName) + sizeof(CHAR16))/sizeof(CHAR16), L":", StrLen(L":"));
- if (EFI_ERROR(StrRetStatus)) {
- FreePool(NewSName);
- return ((SHELL_STATUS) (StrRetStatus & (~MAX_BIT)));
+
+ if (NewSName[StrLen (NewSName)-1] != L':') {
+ StrRetStatus = StrnCatS (NewSName, (StrSize (SName) + sizeof (CHAR16))/sizeof (CHAR16), L":", StrLen (L":"));
+ if (EFI_ERROR (StrRetStatus)) {
+ FreePool (NewSName);
+ return ((SHELL_STATUS)(StrRetStatus & (~MAX_BIT)));
}
}
- if (!IsNumberLetterOnly(NewSName, StrLen(NewSName)-1)) {
- FreePool(NewSName);
+ if (!IsNumberLetterOnly (NewSName, StrLen (NewSName)-1)) {
+ FreePool (NewSName);
return (SHELL_INVALID_PARAMETER);
}
- DevPath = gEfiShellProtocol->GetDevicePathFromMap(Map);
+ DevPath = gEfiShellProtocol->GetDevicePathFromMap (Map);
if (DevPath == NULL) {
- FreePool(NewSName);
+ FreePool (NewSName);
return (SHELL_INVALID_PARAMETER);
}
- Status = gEfiShellProtocol->SetMap(DevPath, NewSName);
- FreePool(NewSName);
- if (EFI_ERROR(Status)) {
+ Status = gEfiShellProtocol->SetMap (DevPath, NewSName);
+ FreePool (NewSName);
+ if (EFI_ERROR (Status)) {
return (SHELL_DEVICE_ERROR);
}
+
return (SHELL_SUCCESS);
}
@@ -920,9 +985,9 @@ AddMappingFromMapping(
**/
SHELL_STATUS
-AddMappingFromHandle(
- IN CONST EFI_HANDLE Handle,
- IN CONST CHAR16 *SName
+AddMappingFromHandle (
+ IN CONST EFI_HANDLE Handle,
+ IN CONST CHAR16 *SName
)
{
EFI_DEVICE_PATH_PROTOCOL *DevPath;
@@ -930,54 +995,57 @@ AddMappingFromHandle(
CHAR16 *NewSName;
RETURN_STATUS StrRetStatus;
- NewSName = AllocateCopyPool(StrSize(SName) + sizeof(CHAR16), SName);
+ NewSName = AllocateCopyPool (StrSize (SName) + sizeof (CHAR16), SName);
if (NewSName == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
- if (NewSName[StrLen(NewSName)-1] != L':') {
- StrRetStatus = StrnCatS(NewSName, (StrSize(SName) + sizeof(CHAR16))/sizeof(CHAR16), L":", StrLen(L":"));
- if (EFI_ERROR(StrRetStatus)) {
- FreePool(NewSName);
- return ((SHELL_STATUS) (StrRetStatus & (~MAX_BIT)));
+
+ if (NewSName[StrLen (NewSName)-1] != L':') {
+ StrRetStatus = StrnCatS (NewSName, (StrSize (SName) + sizeof (CHAR16))/sizeof (CHAR16), L":", StrLen (L":"));
+ if (EFI_ERROR (StrRetStatus)) {
+ FreePool (NewSName);
+ return ((SHELL_STATUS)(StrRetStatus & (~MAX_BIT)));
}
}
- if (!IsNumberLetterOnly(NewSName, StrLen(NewSName)-1)) {
- FreePool(NewSName);
+ if (!IsNumberLetterOnly (NewSName, StrLen (NewSName)-1)) {
+ FreePool (NewSName);
return (SHELL_INVALID_PARAMETER);
}
- Status = gBS->OpenProtocol(
- Handle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&DevPath,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR(Status)) {
- FreePool(NewSName);
+ Status = gBS->OpenProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevPath,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ FreePool (NewSName);
return (SHELL_DEVICE_ERROR);
}
- Status = gEfiShellProtocol->SetMap(DevPath, NewSName);
- FreePool(NewSName);
- if (EFI_ERROR(Status)) {
+
+ Status = gEfiShellProtocol->SetMap (DevPath, NewSName);
+ FreePool (NewSName);
+ if (EFI_ERROR (Status)) {
return (SHELL_DEVICE_ERROR);
}
+
return (SHELL_SUCCESS);
}
-STATIC CONST SHELL_PARAM_ITEM MapParamList[] = {
- {L"-d", TypeValue},
- {L"-r", TypeFlag},
- {L"-v", TypeFlag},
- {L"-c", TypeFlag},
- {L"-f", TypeFlag},
- {L"-u", TypeFlag},
- {L"-t", TypeValue},
- {L"-sfo", TypeValue},
- {NULL, TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM MapParamList[] = {
+ { L"-d", TypeValue },
+ { L"-r", TypeFlag },
+ { L"-v", TypeFlag },
+ { L"-c", TypeFlag },
+ { L"-f", TypeFlag },
+ { L"-u", TypeFlag },
+ { L"-t", TypeValue },
+ { L"-sfo", TypeValue },
+ { NULL, TypeMax }
+};
/**
The routine issues dummy read for every physical block device to cause
@@ -988,11 +1056,11 @@ ProbeForMediaChange (
VOID
)
{
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *Handles;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- UINTN Index;
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ UINTN Index;
gBS->LocateHandleBuffer (
ByProtocol,
@@ -1008,7 +1076,7 @@ ProbeForMediaChange (
Status = gBS->HandleProtocol (
Handles[Index],
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo
+ (VOID **)&BlockIo
);
if (!EFI_ERROR (Status)) {
if (!BlockIo->Media->LogicalPartition) {
@@ -1057,227 +1125,235 @@ ShellCommandRunMap (
CONST CHAR16 *TypeString;
UINTN TempStringLength;
- ProblemParam = NULL;
- Mapping = NULL;
- SName = NULL;
- ShellStatus = SHELL_SUCCESS;
- MapAsHandle = NULL;
+ ProblemParam = NULL;
+ Mapping = NULL;
+ SName = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ MapAsHandle = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
+ Status = CommandInit ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (MapParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"map", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"map", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
- ConstMode = ShellCommandLineGetFlag(Package, L"-c");
- NormlMode = ShellCommandLineGetFlag(Package, L"-f");
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 3) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"map");
+ SfoMode = ShellCommandLineGetFlag (Package, L"-sfo");
+ ConstMode = ShellCommandLineGetFlag (Package, L"-c");
+ NormlMode = ShellCommandLineGetFlag (Package, L"-f");
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
+ } else if (ShellCommandLineGetRawValue (Package, 3) != NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"map");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// Deleting a map name...
//
- if (ShellCommandLineGetFlag(Package, L"-d")) {
- if ( ShellCommandLineGetFlag(Package, L"-r")
- || ShellCommandLineGetFlag(Package, L"-v")
- || ConstMode
- || NormlMode
- || ShellCommandLineGetFlag(Package, L"-u")
- || ShellCommandLineGetFlag(Package, L"-t")
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle, L"map");
+ if (ShellCommandLineGetFlag (Package, L"-d")) {
+ if ( ShellCommandLineGetFlag (Package, L"-r")
+ || ShellCommandLineGetFlag (Package, L"-v")
+ || ConstMode
+ || NormlMode
+ || ShellCommandLineGetFlag (Package, L"-u")
+ || ShellCommandLineGetFlag (Package, L"-t")
+ )
+ {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle, L"map");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- SName = ShellCommandLineGetValue(Package, L"-d");
+ SName = ShellCommandLineGetValue (Package, L"-d");
if (SName != NULL) {
- Status = PerformMappingDelete(SName);
- if (EFI_ERROR(Status)) {
+ Status = PerformMappingDelete (SName);
+ if (EFI_ERROR (Status)) {
if (Status == EFI_ACCESS_DENIED) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
ShellStatus = SHELL_ACCESS_DENIED;
} else if (Status == EFI_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, L"map", SName);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, L"map", SName);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
ShellStatus = SHELL_UNSUPPORTED;
}
}
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"map");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"map");
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
- } else if ( ShellCommandLineGetFlag(Package, L"-r")
-// || ShellCommandLineGetFlag(Package, L"-v")
- || ConstMode
- || NormlMode
- || ShellCommandLineGetFlag(Package, L"-u")
- || ShellCommandLineGetFlag(Package, L"-t")
- ){
+ } else if ( ShellCommandLineGetFlag (Package, L"-r")
+ // || ShellCommandLineGetFlag(Package, L"-v")
+ || ConstMode
+ || NormlMode
+ || ShellCommandLineGetFlag (Package, L"-u")
+ || ShellCommandLineGetFlag (Package, L"-t")
+ )
+ {
ProbeForMediaChange ();
- if ( ShellCommandLineGetFlag(Package, L"-r")) {
+ if ( ShellCommandLineGetFlag (Package, L"-r")) {
//
// Do the reset
//
- Status = ShellCommandCreateInitialMappingsAndPaths();
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
+ Status = ShellCommandCreateInitialMappingsAndPaths ();
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
ShellStatus = SHELL_UNSUPPORTED;
}
}
- if ( ShellStatus == SHELL_SUCCESS && ShellCommandLineGetFlag(Package, L"-u")) {
+
+ if ((ShellStatus == SHELL_SUCCESS) && ShellCommandLineGetFlag (Package, L"-u")) {
//
// Do the Update
//
Status = ShellCommandUpdateMapping ();
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
ShellStatus = SHELL_UNSUPPORTED;
}
}
+
if (ShellStatus == SHELL_SUCCESS) {
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- TypeString = ShellCommandLineGetValue(Package, L"-t");
- if (!ConstMode
- &&!NormlMode
- &&TypeString == NULL
- ) {
+ Param1 = ShellCommandLineGetRawValue (Package, 1);
+ TypeString = ShellCommandLineGetValue (Package, L"-t");
+ if ( !ConstMode
+ && !NormlMode
+ && (TypeString == NULL)
+ )
+ {
//
// now do the display...
//
- ShellStatus = PerformMappingDisplay(
- ShellCommandLineGetFlag(Package, L"-v"),
- TRUE,
- TRUE,
- NULL,
- SfoMode,
- Param1,
- TRUE
- );
+ ShellStatus = PerformMappingDisplay (
+ ShellCommandLineGetFlag (Package, L"-v"),
+ TRUE,
+ TRUE,
+ NULL,
+ SfoMode,
+ Param1,
+ TRUE
+ );
} else {
//
// now do the display...
//
- ShellStatus = PerformMappingDisplay2(
- ShellCommandLineGetFlag(Package, L"-v"),
- ConstMode,
- NormlMode,
- TypeString,
- SfoMode,
- Param1
- );
+ ShellStatus = PerformMappingDisplay2 (
+ ShellCommandLineGetFlag (Package, L"-v"),
+ ConstMode,
+ NormlMode,
+ TypeString,
+ SfoMode,
+ Param1
+ );
}
}
} else {
//
// adding or displaying (there were no flags)
//
- SName = ShellCommandLineGetRawValue(Package, 1);
- Mapping = ShellCommandLineGetRawValue(Package, 2);
- if ( SName == NULL
- && Mapping == NULL
- ){
+ SName = ShellCommandLineGetRawValue (Package, 1);
+ Mapping = ShellCommandLineGetRawValue (Package, 2);
+ if ( (SName == NULL)
+ && (Mapping == NULL)
+ )
+ {
//
// display only since no flags
//
- ShellStatus = PerformMappingDisplay(
- ShellCommandLineGetFlag(Package, L"-v"),
- TRUE,
- TRUE,
- NULL,
- SfoMode,
- NULL,
- TRUE
- );
- } else if ( SName == NULL
- || Mapping == NULL
- ){
- //
- // Display only the one specified
- //
- ShellStatus = PerformMappingDisplay(
- FALSE,
- FALSE,
- FALSE,
- NULL,
- SfoMode,
- SName, // note the variable here...
- TRUE
- );
+ ShellStatus = PerformMappingDisplay (
+ ShellCommandLineGetFlag (Package, L"-v"),
+ TRUE,
+ TRUE,
+ NULL,
+ SfoMode,
+ NULL,
+ TRUE
+ );
+ } else if ( (SName == NULL)
+ || (Mapping == NULL)
+ )
+ {
+ //
+ // Display only the one specified
+ //
+ ShellStatus = PerformMappingDisplay (
+ FALSE,
+ FALSE,
+ FALSE,
+ NULL,
+ SfoMode,
+ SName, // note the variable here...
+ TRUE
+ );
} else {
- if (ShellIsHexOrDecimalNumber(Mapping, TRUE, FALSE)) {
- MapAsHandle = ConvertHandleIndexToHandle(ShellStrToUintn(Mapping));
+ if (ShellIsHexOrDecimalNumber (Mapping, TRUE, FALSE)) {
+ MapAsHandle = ConvertHandleIndexToHandle (ShellStrToUintn (Mapping));
} else {
MapAsHandle = NULL;
}
- if (MapAsHandle == NULL && Mapping[StrLen(Mapping)-1] != L':') {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
+
+ if ((MapAsHandle == NULL) && (Mapping[StrLen (Mapping)-1] != L':')) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- TempStringLength = StrLen(SName);
- if (!IsNumberLetterOnly(SName, TempStringLength-(SName[TempStringLength-1]==L':'?1:0))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", SName);
+ TempStringLength = StrLen (SName);
+ if (!IsNumberLetterOnly (SName, TempStringLength-((SName[TempStringLength-1] == L':') ? 1 : 0))) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", SName);
ShellStatus = SHELL_INVALID_PARAMETER;
}
if (ShellStatus == SHELL_SUCCESS) {
if (MapAsHandle != NULL) {
- ShellStatus = AddMappingFromHandle(MapAsHandle, SName);
+ ShellStatus = AddMappingFromHandle (MapAsHandle, SName);
} else {
- ShellStatus = AddMappingFromMapping(Mapping, SName);
+ ShellStatus = AddMappingFromMapping (Mapping, SName);
}
if (ShellStatus != SHELL_SUCCESS) {
switch (ShellStatus) {
case SHELL_ACCESS_DENIED:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
break;
case SHELL_INVALID_PARAMETER:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
break;
case SHELL_DEVICE_ERROR:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NOF), gShellLevel2HiiHandle, L"map", Mapping);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MAP_NOF), gShellLevel2HiiHandle, L"map", Mapping);
break;
default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", ShellStatus|MAX_BIT);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", ShellStatus|MAX_BIT);
}
} else {
//
// now do the display...
//
- ShellStatus = PerformMappingDisplay(
- FALSE,
- FALSE,
- FALSE,
- NULL,
- SfoMode,
- SName,
- TRUE
- );
+ ShellStatus = PerformMappingDisplay (
+ FALSE,
+ FALSE,
+ FALSE,
+ NULL,
+ SfoMode,
+ SName,
+ TRUE
+ );
} // we were sucessful so do an output
}
} // got a valid map target
@@ -1293,4 +1369,3 @@ ShellCommandRunMap (
return (ShellStatus);
}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c
index e3d7aaa1ac..bdc6a0d08d 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c
@@ -22,129 +22,139 @@ ShellCommandRunMkDir (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- CONST CHAR16 *NewDirName;
- CHAR16 *NewDirNameCopy;
- CHAR16 *SplitName;
- CHAR16 SaveSplitChar;
- UINTN DirCreateCount;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_FILE_HANDLE FileHandle;
- SHELL_STATUS ShellStatus;
-
- ShellStatus = SHELL_SUCCESS;
- NewDirNameCopy = NULL;
- SplitName = NULL;
- SaveSplitChar = CHAR_NULL;
+ EFI_STATUS Status;
+ CONST CHAR16 *NewDirName;
+ CHAR16 *NewDirNameCopy;
+ CHAR16 *SplitName;
+ CHAR16 SaveSplitChar;
+ UINTN DirCreateCount;
+ LIST_ENTRY *Package;
+ CHAR16 *ProblemParam;
+ SHELL_FILE_HANDLE FileHandle;
+ SHELL_STATUS ShellStatus;
+
+ ShellStatus = SHELL_SUCCESS;
+ NewDirNameCopy = NULL;
+ SplitName = NULL;
+ SaveSplitChar = CHAR_NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mkdir", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mkdir", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
}
//
// create a set of directories
//
- if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
+ if (ShellCommandLineGetRawValue (Package, 1) == NULL) {
//
// we didnt get a single parameter
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mkdir");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mkdir");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
for ( DirCreateCount = 1
- ;
- ; DirCreateCount++
- ){
+ ;
+ ; DirCreateCount++
+ )
+ {
//
// loop through each directory specified
//
- NewDirName = ShellCommandLineGetRawValue(Package, DirCreateCount);
+ NewDirName = ShellCommandLineGetRawValue (Package, DirCreateCount);
if (NewDirName == NULL) {
break;
}
+
//
// check if that already exists... if yes fail
//
FileHandle = NULL;
- Status = ShellOpenFileByName(NewDirName,
- &FileHandle,
- EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE,
- EFI_FILE_DIRECTORY
- );
- if (!EFI_ERROR(Status)) {
- ShellCloseFile(&FileHandle);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MKDIR_ALREADY), gShellLevel2HiiHandle, NewDirName);
+ Status = ShellOpenFileByName (
+ NewDirName,
+ &FileHandle,
+ EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE,
+ EFI_FILE_DIRECTORY
+ );
+ if (!EFI_ERROR (Status)) {
+ ShellCloseFile (&FileHandle);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MKDIR_ALREADY), gShellLevel2HiiHandle, NewDirName);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FileHandle == NULL);
+ ASSERT (FileHandle == NULL);
//
// create the nested directory from parent to child.
// if NewDirName = test1\test2\test3, first create "test1\" directory, then "test1\test2\", finally "test1\test2\test3".
//
- NewDirNameCopy = AllocateCopyPool (StrSize(NewDirName), NewDirName);
+ NewDirNameCopy = AllocateCopyPool (StrSize (NewDirName), NewDirName);
NewDirNameCopy = PathCleanUpDirectories (NewDirNameCopy);
- if(NewDirNameCopy == NULL) {
+ if (NewDirNameCopy == NULL) {
ShellStatus = SHELL_OUT_OF_RESOURCES;
break;
}
+
SplitName = NewDirNameCopy;
while (SplitName != NULL) {
SplitName = StrStr (SplitName + 1, L"\\");
if (SplitName != NULL) {
- SaveSplitChar = *(SplitName + 1);
+ SaveSplitChar = *(SplitName + 1);
*(SplitName + 1) = '\0';
}
+
//
// check if current nested directory already exists... continue to create the child directory.
//
- Status = ShellOpenFileByName (NewDirNameCopy,
- &FileHandle,
- EFI_FILE_MODE_READ,
- EFI_FILE_DIRECTORY
- );
- if (!EFI_ERROR(Status)) {
+ Status = ShellOpenFileByName (
+ NewDirNameCopy,
+ &FileHandle,
+ EFI_FILE_MODE_READ,
+ EFI_FILE_DIRECTORY
+ );
+ if (!EFI_ERROR (Status)) {
ShellCloseFile (&FileHandle);
} else {
Status = ShellCreateDirectory (NewDirNameCopy, &FileHandle);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
break;
}
+
if (FileHandle != NULL) {
gEfiShellProtocol->CloseFile (FileHandle);
}
}
+
if (SplitName != NULL) {
*(SplitName + 1) = SaveSplitChar;
}
}
- if (EFI_ERROR(Status)) {
+
+ if (EFI_ERROR (Status)) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MKDIR_CREATEFAIL), gShellLevel2HiiHandle, NewDirName);
ShellStatus = SHELL_ACCESS_DENIED;
break;
}
+
SHELL_FREE_NON_NULL (NewDirNameCopy);
}
}
@@ -158,4 +168,3 @@ ShellCommandRunMkDir (
return (ShellStatus);
}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
index f50c1e4c20..58cdeca7cb 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
@@ -20,34 +20,37 @@
@retval FALSE The move is within a file system.
**/
BOOLEAN
-IsBetweenFileSystem(
- IN CONST CHAR16 *FullName,
- IN CONST CHAR16 *Cwd,
- IN CONST CHAR16 *DestPath
+IsBetweenFileSystem (
+ IN CONST CHAR16 *FullName,
+ IN CONST CHAR16 *Cwd,
+ IN CONST CHAR16 *DestPath
)
{
CHAR16 *Test;
CHAR16 *Test1;
UINTN Result;
- Test = StrStr(FullName, L":");
- if (Test == NULL && Cwd != NULL) {
- Test = StrStr(Cwd, L":");
+ Test = StrStr (FullName, L":");
+ if ((Test == NULL) && (Cwd != NULL)) {
+ Test = StrStr (Cwd, L":");
}
- Test1 = StrStr(DestPath, L":");
- if (Test1 == NULL && Cwd != NULL) {
- Test1 = StrStr(Cwd, L":");
+
+ Test1 = StrStr (DestPath, L":");
+ if ((Test1 == NULL) && (Cwd != NULL)) {
+ Test1 = StrStr (Cwd, L":");
}
- if (Test1 != NULL && Test != NULL) {
- *Test = CHAR_NULL;
+
+ if ((Test1 != NULL) && (Test != NULL)) {
+ *Test = CHAR_NULL;
*Test1 = CHAR_NULL;
- Result = StringNoCaseCompare(&FullName, &DestPath);
- *Test = L':';
+ Result = StringNoCaseCompare (&FullName, &DestPath);
+ *Test = L':';
*Test1 = L':';
if (Result != 0) {
return (TRUE);
}
}
+
return (FALSE);
}
@@ -67,14 +70,14 @@ IsBetweenFileSystem(
@retval FALSE The source path is invalid.
**/
BOOLEAN
-IsSoucePathValid(
- IN CONST CHAR16* SrcPath,
- IN CONST CHAR16* CwdPath
+IsSoucePathValid (
+ IN CONST CHAR16 *SrcPath,
+ IN CONST CHAR16 *CwdPath
)
{
- CHAR16* SrcPathBuffer;
- CHAR16* CwdPathBuffer;
- BOOLEAN Ret;
+ CHAR16 *SrcPathBuffer;
+ CHAR16 *CwdPathBuffer;
+ BOOLEAN Ret;
ASSERT (CwdPath != NULL);
if (SrcPath == NULL) {
@@ -90,14 +93,14 @@ IsSoucePathValid(
CwdPathBuffer = AllocateCopyPool (StrSize (CwdPath), CwdPath);
if (CwdPathBuffer == NULL) {
- FreePool(SrcPathBuffer);
+ FreePool (SrcPathBuffer);
return FALSE;
}
gUnicodeCollation->StrUpr (gUnicodeCollation, SrcPathBuffer);
gUnicodeCollation->StrUpr (gUnicodeCollation, CwdPathBuffer);
- if (SrcPathBuffer[StrLen (SrcPathBuffer) -1 ] == L'\\') {
+ if (SrcPathBuffer[StrLen (SrcPathBuffer) -1] == L'\\') {
SrcPathBuffer[StrLen (SrcPathBuffer) - 1] = CHAR_NULL;
}
@@ -105,10 +108,11 @@ IsSoucePathValid(
CwdPathBuffer[StrLen (CwdPathBuffer) - 1] = CHAR_NULL;
}
- if (StrCmp (CwdPathBuffer, SrcPathBuffer) == 0 ||
+ if ((StrCmp (CwdPathBuffer, SrcPathBuffer) == 0) ||
((StrStr (CwdPathBuffer, SrcPathBuffer) == CwdPathBuffer) &&
(CwdPathBuffer[StrLen (SrcPathBuffer)] == L'\\'))
- ) {
+ )
+ {
Ret = FALSE;
}
@@ -139,13 +143,13 @@ IsSoucePathValid(
@retval FALSE The move is not
**/
BOOLEAN
-IsValidMove(
- IN CONST CHAR16 *SourcePath,
- IN CONST CHAR16 *Cwd,
- IN CONST CHAR16 *DestPath,
- IN CONST UINT64 Attribute,
- IN CONST UINT64 DestAttr,
- IN CONST EFI_STATUS FileStatus
+IsValidMove (
+ IN CONST CHAR16 *SourcePath,
+ IN CONST CHAR16 *Cwd,
+ IN CONST CHAR16 *DestPath,
+ IN CONST UINT64 Attribute,
+ IN CONST UINT64 DestAttr,
+ IN CONST EFI_STATUS FileStatus
)
{
CHAR16 *DestPathCopy;
@@ -156,7 +160,7 @@ IsValidMove(
//
// Invalid move
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_MV_INV_CWD), gShellLevel2HiiHandle);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MV_INV_CWD), gShellLevel2HiiHandle);
return FALSE;
}
}
@@ -164,41 +168,45 @@ IsValidMove(
//
// invalid to move read only or move to a read only destination
//
- if (((Attribute & EFI_FILE_READ_ONLY) != 0)
- || (FileStatus == EFI_WRITE_PROTECTED)
- || ((DestAttr & EFI_FILE_READ_ONLY) != 0)
- ) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_RO), gShellLevel2HiiHandle, SourcePath);
+ if ( ((Attribute & EFI_FILE_READ_ONLY) != 0)
+ || (FileStatus == EFI_WRITE_PROTECTED)
+ || ((DestAttr & EFI_FILE_READ_ONLY) != 0)
+ )
+ {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MV_INV_RO), gShellLevel2HiiHandle, SourcePath);
return (FALSE);
}
- DestPathCopy = AllocateCopyPool(StrSize(DestPath), DestPath);
+ DestPathCopy = AllocateCopyPool (StrSize (DestPath), DestPath);
if (DestPathCopy == NULL) {
return (FALSE);
}
- for (DestPathWalker = DestPathCopy; *DestPathWalker == L'\\'; DestPathWalker++) ;
+ for (DestPathWalker = DestPathCopy; *DestPathWalker == L'\\'; DestPathWalker++) {
+ }
- while(DestPathWalker != NULL && DestPathWalker[StrLen(DestPathWalker)-1] == L'\\') {
- DestPathWalker[StrLen(DestPathWalker)-1] = CHAR_NULL;
+ while (DestPathWalker != NULL && DestPathWalker[StrLen (DestPathWalker)-1] == L'\\') {
+ DestPathWalker[StrLen (DestPathWalker)-1] = CHAR_NULL;
}
- ASSERT(DestPathWalker != NULL);
- ASSERT(SourcePath != NULL);
+ ASSERT (DestPathWalker != NULL);
+ ASSERT (SourcePath != NULL);
//
// If they're the same, or if source is "above" dest on file path tree
//
- if ( StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0 ||
- ((StrStr(DestPathWalker, SourcePath) == DestPathWalker) &&
- (DestPathWalker[StrLen(SourcePath)] == '\\')
- )
- ) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);
- FreePool(DestPathCopy);
+ if ((StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0) ||
+ ((StrStr (DestPathWalker, SourcePath) == DestPathWalker) &&
+ (DestPathWalker[StrLen (SourcePath)] == '\\')
+ )
+ )
+ {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);
+ FreePool (DestPathCopy);
return (FALSE);
}
- FreePool(DestPathCopy);
+
+ FreePool (DestPathCopy);
return (TRUE);
}
@@ -222,116 +230,124 @@ IsValidMove(
@retval SHELL_SUCCESS The operation was sucessful.
**/
SHELL_STATUS
-GetDestinationLocation(
- IN CONST CHAR16 *DestParameter,
- IN OUT CHAR16 **DestPathPointer,
- IN CONST CHAR16 *Cwd,
- IN CONST BOOLEAN SingleSource,
- IN OUT UINT64 *DestAttr
+GetDestinationLocation (
+ IN CONST CHAR16 *DestParameter,
+ IN OUT CHAR16 **DestPathPointer,
+ IN CONST CHAR16 *Cwd,
+ IN CONST BOOLEAN SingleSource,
+ IN OUT UINT64 *DestAttr
)
{
- EFI_SHELL_FILE_INFO *DestList;
- EFI_SHELL_FILE_INFO *Node;
- CHAR16 *DestPath;
- UINTN NewSize;
- UINTN CurrentSize;
+ EFI_SHELL_FILE_INFO *DestList;
+ EFI_SHELL_FILE_INFO *Node;
+ CHAR16 *DestPath;
+ UINTN NewSize;
+ UINTN CurrentSize;
DestList = NULL;
DestPath = NULL;
- ASSERT(DestAttr != NULL);
+ ASSERT (DestAttr != NULL);
- if (StrStr(DestParameter, L"\\") == DestParameter) {
+ if (StrStr (DestParameter, L"\\") == DestParameter) {
if (Cwd == NULL) {
return SHELL_INVALID_PARAMETER;
}
- DestPath = AllocateZeroPool(StrSize(Cwd));
+
+ DestPath = AllocateZeroPool (StrSize (Cwd));
if (DestPath == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
- StrCpyS(DestPath, StrSize(Cwd) / sizeof(CHAR16), Cwd);
- while (PathRemoveLastItem(DestPath)) ;
+
+ StrCpyS (DestPath, StrSize (Cwd) / sizeof (CHAR16), Cwd);
+ while (PathRemoveLastItem (DestPath)) {
+ }
//
// Append DestParameter beyond '\' which may be present
//
- CurrentSize = StrSize(DestPath);
- StrnCatGrow(&DestPath, &CurrentSize, &DestParameter[1], 0);
+ CurrentSize = StrSize (DestPath);
+ StrnCatGrow (&DestPath, &CurrentSize, &DestParameter[1], 0);
*DestPathPointer = DestPath;
return (SHELL_SUCCESS);
}
+
//
// get the destination path
//
- ShellOpenFileMetaArg((CHAR16*)DestParameter, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, &DestList);
- if (DestList == NULL || IsListEmpty(&DestList->Link)) {
+ ShellOpenFileMetaArg ((CHAR16 *)DestParameter, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, &DestList);
+ if ((DestList == NULL) || IsListEmpty (&DestList->Link)) {
//
// Not existing... must be renaming
//
- if (StrStr(DestParameter, L":") == NULL) {
+ if (StrStr (DestParameter, L":") == NULL) {
if (Cwd == NULL) {
- ShellCloseFileMetaArg(&DestList);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);
+ ShellCloseFileMetaArg (&DestList);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);
return (SHELL_INVALID_PARAMETER);
}
- NewSize = StrSize(Cwd);
- NewSize += StrSize(DestParameter);
- DestPath = AllocateZeroPool(NewSize);
+
+ NewSize = StrSize (Cwd);
+ NewSize += StrSize (DestParameter);
+ DestPath = AllocateZeroPool (NewSize);
if (DestPath == NULL) {
- ShellCloseFileMetaArg(&DestList);
+ ShellCloseFileMetaArg (&DestList);
return (SHELL_OUT_OF_RESOURCES);
}
- StrCpyS(DestPath, NewSize / sizeof(CHAR16), Cwd);
- if (DestPath[StrLen(DestPath)-1] != L'\\' && DestParameter[0] != L'\\') {
- StrCatS(DestPath, NewSize / sizeof(CHAR16), L"\\");
- } else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestParameter[0] == L'\\') {
- ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;
+
+ StrCpyS (DestPath, NewSize / sizeof (CHAR16), Cwd);
+ if ((DestPath[StrLen (DestPath)-1] != L'\\') && (DestParameter[0] != L'\\')) {
+ StrCatS (DestPath, NewSize / sizeof (CHAR16), L"\\");
+ } else if ((DestPath[StrLen (DestPath)-1] == L'\\') && (DestParameter[0] == L'\\')) {
+ ((CHAR16 *)DestPath)[StrLen (DestPath)-1] = CHAR_NULL;
}
- StrCatS(DestPath, NewSize / sizeof(CHAR16), DestParameter);
+
+ StrCatS (DestPath, NewSize / sizeof (CHAR16), DestParameter);
} else {
- ASSERT(DestPath == NULL);
- DestPath = StrnCatGrow(&DestPath, NULL, DestParameter, 0);
+ ASSERT (DestPath == NULL);
+ DestPath = StrnCatGrow (&DestPath, NULL, DestParameter, 0);
if (DestPath == NULL) {
- ShellCloseFileMetaArg(&DestList);
+ ShellCloseFileMetaArg (&DestList);
return (SHELL_OUT_OF_RESOURCES);
}
}
} else {
- Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&DestList->Link);
+ Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&DestList->Link);
*DestAttr = Node->Info->Attribute;
//
// Make sure there is only 1 node in the list.
//
- if (!IsNodeAtEnd(&DestList->Link, &Node->Link)) {
- ShellCloseFileMetaArg(&DestList);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
+ if (!IsNodeAtEnd (&DestList->Link, &Node->Link)) {
+ ShellCloseFileMetaArg (&DestList);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
return (SHELL_INVALID_PARAMETER);
}
//
// If we are a directory or a single file, then one node is fine.
//
- if (ShellIsDirectory(Node->FullName)==EFI_SUCCESS || SingleSource) {
- DestPath = AllocateZeroPool(StrSize(Node->FullName)+sizeof(CHAR16));
+ if ((ShellIsDirectory (Node->FullName) == EFI_SUCCESS) || SingleSource) {
+ DestPath = AllocateZeroPool (StrSize (Node->FullName)+sizeof (CHAR16));
if (DestPath == NULL) {
- ShellCloseFileMetaArg(&DestList);
+ ShellCloseFileMetaArg (&DestList);
return (SHELL_OUT_OF_RESOURCES);
}
- StrCpyS(DestPath, (StrSize(Node->FullName)+sizeof(CHAR16)) / sizeof(CHAR16), Node->FullName);
- StrCatS(DestPath, (StrSize(Node->FullName)+sizeof(CHAR16)) / sizeof(CHAR16), L"\\");
+
+ StrCpyS (DestPath, (StrSize (Node->FullName)+sizeof (CHAR16)) / sizeof (CHAR16), Node->FullName);
+ StrCatS (DestPath, (StrSize (Node->FullName)+sizeof (CHAR16)) / sizeof (CHAR16), L"\\");
} else {
//
// cant move multiple files onto a single file.
//
- ShellCloseFileMetaArg(&DestList);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
+ ShellCloseFileMetaArg (&DestList);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);
return (SHELL_INVALID_PARAMETER);
}
}
*DestPathPointer = DestPath;
- ShellCloseFileMetaArg(&DestList);
+ ShellCloseFileMetaArg (&DestList);
return (SHELL_SUCCESS);
}
@@ -346,13 +362,13 @@ GetDestinationLocation(
@retval SHELL_SUCCESS The source file was moved to the destination.
**/
EFI_STATUS
-MoveBetweenFileSystems(
+MoveBetweenFileSystems (
IN EFI_SHELL_FILE_INFO *Node,
IN CONST CHAR16 *DestPath,
OUT VOID **Resp
)
{
- SHELL_STATUS ShellStatus;
+ SHELL_STATUS ShellStatus;
//
// First we copy the file
@@ -366,7 +382,7 @@ MoveBetweenFileSystems(
//
// The copy was successful. delete the source file.
//
- CascadeDelete(Node, TRUE);
+ CascadeDelete (Node, TRUE);
Node->Handle = NULL;
} else if (ShellStatus == SHELL_ABORTED) {
return EFI_ABORTED;
@@ -393,29 +409,31 @@ MoveBetweenFileSystems(
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed
**/
EFI_STATUS
-CreateFullDestPath(
- IN CONST CHAR16 **DestPath,
- OUT CHAR16 **FullDestPath,
- IN CONST CHAR16 *FileName
+CreateFullDestPath (
+ IN CONST CHAR16 **DestPath,
+ OUT CHAR16 **FullDestPath,
+ IN CONST CHAR16 *FileName
)
{
- UINTN Size;
- if (FullDestPath == NULL || FileName == NULL || DestPath == NULL || *DestPath == NULL){
+ UINTN Size;
+
+ if ((FullDestPath == NULL) || (FileName == NULL) || (DestPath == NULL) || (*DestPath == NULL)) {
return (EFI_INVALID_PARAMETER);
}
- Size = StrSize(*DestPath) + StrSize(FileName);
+ Size = StrSize (*DestPath) + StrSize (FileName);
- *FullDestPath = AllocateZeroPool(Size);
- if (*FullDestPath == NULL){
+ *FullDestPath = AllocateZeroPool (Size);
+ if (*FullDestPath == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- StrCpyS(*FullDestPath, Size / sizeof(CHAR16), *DestPath);
- if ((*FullDestPath)[StrLen(*FullDestPath)-1] != L'\\' && FileName[0] != L'\\') {
- StrCatS(*FullDestPath, Size / sizeof(CHAR16), L"\\");
+ StrCpyS (*FullDestPath, Size / sizeof (CHAR16), *DestPath);
+ if (((*FullDestPath)[StrLen (*FullDestPath)-1] != L'\\') && (FileName[0] != L'\\')) {
+ StrCatS (*FullDestPath, Size / sizeof (CHAR16), L"\\");
}
- StrCatS(*FullDestPath, Size / sizeof(CHAR16), FileName);
+
+ StrCatS (*FullDestPath, Size / sizeof (CHAR16), FileName);
return (EFI_SUCCESS);
}
@@ -431,46 +449,48 @@ CreateFullDestPath(
@retval SHELL_OUT_OF_RESOURCES A memory allocation failed.
**/
EFI_STATUS
-MoveWithinFileSystems(
+MoveWithinFileSystems (
IN EFI_SHELL_FILE_INFO *Node,
IN CHAR16 *DestPath,
OUT VOID **Resp
)
{
- EFI_FILE_INFO *NewFileInfo;
- CHAR16 *TempLocation;
- UINTN NewSize;
- UINTN Length;
- EFI_STATUS Status;
+ EFI_FILE_INFO *NewFileInfo;
+ CHAR16 *TempLocation;
+ UINTN NewSize;
+ UINTN Length;
+ EFI_STATUS Status;
//
// Chop off map info from DestPath
//
- if ((TempLocation = StrStr(DestPath, L":")) != NULL) {
- CopyMem(DestPath, TempLocation+1, StrSize(TempLocation+1));
+ if ((TempLocation = StrStr (DestPath, L":")) != NULL) {
+ CopyMem (DestPath, TempLocation+1, StrSize (TempLocation+1));
}
//
// construct the new file info block
//
- NewSize = StrSize(DestPath);
- NewSize += StrSize(Node->FileName) + SIZE_OF_EFI_FILE_INFO + sizeof(CHAR16);
- NewFileInfo = AllocateZeroPool(NewSize);
+ NewSize = StrSize (DestPath);
+ NewSize += StrSize (Node->FileName) + SIZE_OF_EFI_FILE_INFO + sizeof (CHAR16);
+ NewFileInfo = AllocateZeroPool (NewSize);
if (NewFileInfo == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
Status = EFI_OUT_OF_RESOURCES;
} else {
- CopyMem(NewFileInfo, Node->Info, SIZE_OF_EFI_FILE_INFO);
+ CopyMem (NewFileInfo, Node->Info, SIZE_OF_EFI_FILE_INFO);
if (DestPath[0] != L'\\') {
- StrCpyS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), L"\\");
- StrCatS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), DestPath);
+ StrCpyS (NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof (CHAR16), L"\\");
+ StrCatS (NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof (CHAR16), DestPath);
} else {
- StrCpyS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), DestPath);
+ StrCpyS (NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof (CHAR16), DestPath);
}
- Length = StrLen(NewFileInfo->FileName);
+
+ Length = StrLen (NewFileInfo->FileName);
if (Length > 0) {
Length--;
}
+
if (NewFileInfo->FileName[Length] == L'\\') {
if (Node->FileName[0] == L'\\') {
//
@@ -478,23 +498,26 @@ MoveWithinFileSystems(
//
NewFileInfo->FileName[Length] = CHAR_NULL;
}
- StrCatS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), Node->FileName);
+
+ StrCatS (NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof (CHAR16), Node->FileName);
}
- NewFileInfo->Size = SIZE_OF_EFI_FILE_INFO + StrSize(NewFileInfo->FileName);
+
+ NewFileInfo->Size = SIZE_OF_EFI_FILE_INFO + StrSize (NewFileInfo->FileName);
//
// Perform the move operation
//
- Status = ShellSetFileInfo(Node->Handle, NewFileInfo);
+ Status = ShellSetFileInfo (Node->Handle, NewFileInfo);
//
// Free the info object we used...
//
- FreePool(NewFileInfo);
+ FreePool (NewFileInfo);
}
return (Status);
}
+
/**
function to take a list of files to move and a destination location and do
the verification and moving of those files to that location. This function
@@ -511,49 +534,49 @@ MoveWithinFileSystems(
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed
**/
SHELL_STATUS
-ValidateAndMoveFiles(
- IN EFI_SHELL_FILE_INFO *FileList,
- OUT VOID **Resp,
- IN CONST CHAR16 *DestParameter
+ValidateAndMoveFiles (
+ IN EFI_SHELL_FILE_INFO *FileList,
+ OUT VOID **Resp,
+ IN CONST CHAR16 *DestParameter
)
{
- EFI_STATUS Status;
- CHAR16 *HiiOutput;
- CHAR16 *HiiResultOk;
- CHAR16 *DestPath;
- CHAR16 *FullDestPath;
- CONST CHAR16 *Cwd;
- CHAR16 *FullCwd;
- SHELL_STATUS ShellStatus;
- EFI_SHELL_FILE_INFO *Node;
- VOID *Response;
- UINT64 Attr;
- CHAR16 *CleanFilePathStr;
-
- ASSERT(FileList != NULL);
- ASSERT(DestParameter != NULL);
-
- DestPath = NULL;
- FullDestPath = NULL;
- Cwd = ShellGetCurrentDir(NULL);
- Response = *Resp;
- Attr = 0;
- CleanFilePathStr = NULL;
- FullCwd = NULL;
+ EFI_STATUS Status;
+ CHAR16 *HiiOutput;
+ CHAR16 *HiiResultOk;
+ CHAR16 *DestPath;
+ CHAR16 *FullDestPath;
+ CONST CHAR16 *Cwd;
+ CHAR16 *FullCwd;
+ SHELL_STATUS ShellStatus;
+ EFI_SHELL_FILE_INFO *Node;
+ VOID *Response;
+ UINT64 Attr;
+ CHAR16 *CleanFilePathStr;
+
+ ASSERT (FileList != NULL);
+ ASSERT (DestParameter != NULL);
+
+ DestPath = NULL;
+ FullDestPath = NULL;
+ Cwd = ShellGetCurrentDir (NULL);
+ Response = *Resp;
+ Attr = 0;
+ CleanFilePathStr = NULL;
+ FullCwd = NULL;
if (Cwd != NULL) {
- FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));
+ FullCwd = AllocateZeroPool (StrSize (Cwd) + sizeof (CHAR16));
if (FullCwd == NULL) {
return SHELL_OUT_OF_RESOURCES;
} else {
- StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);
- StrCatS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, L"\\");
+ StrCpyS (FullCwd, StrSize (Cwd)/sizeof (CHAR16)+1, Cwd);
+ StrCatS (FullCwd, StrSize (Cwd)/sizeof (CHAR16)+1, L"\\");
}
}
Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr);
if (EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL(FullCwd);
+ SHELL_FREE_NON_NULL (FullCwd);
if (Status == EFI_OUT_OF_RESOURCES) {
return SHELL_OUT_OF_RESOURCES;
} else {
@@ -566,14 +589,15 @@ ValidateAndMoveFiles(
//
// Get and validate the destination location
//
- ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, FullCwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);
+ ShellStatus = GetDestinationLocation (CleanFilePathStr, &DestPath, FullCwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);
FreePool (CleanFilePathStr);
if (ShellStatus != SHELL_SUCCESS) {
SHELL_FREE_NON_NULL (FullCwd);
return (ShellStatus);
}
- DestPath = PathCleanUpDirectories(DestPath);
+
+ DestPath = PathCleanUpDirectories (DestPath);
if (DestPath == NULL) {
FreePool (FullCwd);
return (SHELL_OUT_OF_RESOURCES);
@@ -581,68 +605,71 @@ ValidateAndMoveFiles(
HiiOutput = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MV_OUTPUT), NULL);
HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
- if (HiiOutput == NULL || HiiResultOk == NULL) {
- SHELL_FREE_NON_NULL(DestPath);
- SHELL_FREE_NON_NULL(HiiOutput);
- SHELL_FREE_NON_NULL(HiiResultOk);
- SHELL_FREE_NON_NULL(FullCwd);
+ if ((HiiOutput == NULL) || (HiiResultOk == NULL)) {
+ SHELL_FREE_NON_NULL (DestPath);
+ SHELL_FREE_NON_NULL (HiiOutput);
+ SHELL_FREE_NON_NULL (HiiResultOk);
+ SHELL_FREE_NON_NULL (FullCwd);
return (SHELL_OUT_OF_RESOURCES);
}
//
// Go through the list of files and directories to move...
//
- for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link)
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
- ){
- if (ShellGetExecutionBreakFlag()) {
+ for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link)
+ ; !IsNull (&FileList->Link, &Node->Link)
+ ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &Node->Link)
+ )
+ {
+ if (ShellGetExecutionBreakFlag ()) {
break;
}
//
// These should never be NULL
//
- ASSERT(Node->FileName != NULL);
- ASSERT(Node->FullName != NULL);
- ASSERT(Node->Info != NULL);
+ ASSERT (Node->FileName != NULL);
+ ASSERT (Node->FullName != NULL);
+ ASSERT (Node->Info != NULL);
//
// skip the directory traversing stuff...
//
- if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
+ if ((StrCmp (Node->FileName, L".") == 0) || (StrCmp (Node->FileName, L"..") == 0)) {
continue;
}
- SHELL_FREE_NON_NULL(FullDestPath);
+ SHELL_FREE_NON_NULL (FullDestPath);
FullDestPath = NULL;
- if (ShellIsDirectory(DestPath)==EFI_SUCCESS) {
- CreateFullDestPath((CONST CHAR16 **)&DestPath, &FullDestPath, Node->FileName);
+ if (ShellIsDirectory (DestPath) == EFI_SUCCESS) {
+ CreateFullDestPath ((CONST CHAR16 **)&DestPath, &FullDestPath, Node->FileName);
}
//
// Validate that the move is valid
//
- if (!IsValidMove(Node->FullName, FullCwd, FullDestPath!=NULL? FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {
+ if (!IsValidMove (Node->FullName, FullCwd, (FullDestPath != NULL) ? FullDestPath : DestPath, Node->Info->Attribute, Attr, Node->Status)) {
ShellStatus = SHELL_INVALID_PARAMETER;
continue;
}
- ShellPrintEx(-1, -1, HiiOutput, Node->FullName, FullDestPath!=NULL? FullDestPath:DestPath);
+ ShellPrintEx (-1, -1, HiiOutput, Node->FullName, FullDestPath != NULL ? FullDestPath : DestPath);
//
// See if destination exists
//
- if (!EFI_ERROR(ShellFileExists(FullDestPath!=NULL? FullDestPath:DestPath))) {
+ if (!EFI_ERROR (ShellFileExists ((FullDestPath != NULL) ? FullDestPath : DestPath))) {
if (Response == NULL) {
- ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
+ ShellPromptForResponseHii (ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
}
+
if (Response == NULL) {
return SHELL_ABORTED;
}
- switch (*(SHELL_PROMPT_RESPONSE*)Response) {
+
+ switch (*(SHELL_PROMPT_RESPONSE *)Response) {
case ShellPromptResponseNo:
- FreePool(Response);
+ FreePool (Response);
Response = NULL;
continue;
case ShellPromptResponseCancel:
@@ -650,42 +677,44 @@ ValidateAndMoveFiles(
//
// indicate to stop everything
//
- SHELL_FREE_NON_NULL(FullCwd);
+ SHELL_FREE_NON_NULL (FullCwd);
return (SHELL_ABORTED);
case ShellPromptResponseAll:
*Resp = Response;
break;
case ShellPromptResponseYes:
- FreePool(Response);
+ FreePool (Response);
Response = NULL;
break;
default:
- FreePool(Response);
- SHELL_FREE_NON_NULL(FullCwd);
+ FreePool (Response);
+ SHELL_FREE_NON_NULL (FullCwd);
return SHELL_ABORTED;
}
- Status = ShellDeleteFileByName(FullDestPath!=NULL? FullDestPath:DestPath);
+
+ Status = ShellDeleteFileByName (FullDestPath != NULL ? FullDestPath : DestPath);
}
- if (IsBetweenFileSystem(Node->FullName, FullCwd, DestPath)) {
- while (FullDestPath == NULL && DestPath != NULL && DestPath[0] != CHAR_NULL && DestPath[StrLen(DestPath) - 1] == L'\\') {
- DestPath[StrLen(DestPath) - 1] = CHAR_NULL;
+ if (IsBetweenFileSystem (Node->FullName, FullCwd, DestPath)) {
+ while (FullDestPath == NULL && DestPath != NULL && DestPath[0] != CHAR_NULL && DestPath[StrLen (DestPath) - 1] == L'\\') {
+ DestPath[StrLen (DestPath) - 1] = CHAR_NULL;
}
- Status = MoveBetweenFileSystems(Node, FullDestPath!=NULL? FullDestPath:DestPath, &Response);
+
+ Status = MoveBetweenFileSystems (Node, FullDestPath != NULL ? FullDestPath : DestPath, &Response);
} else {
- Status = MoveWithinFileSystems(Node, DestPath, &Response);
+ Status = MoveWithinFileSystems (Node, DestPath, &Response);
//
// Display error status
//
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"mv", Status);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"mv", Status);
}
}
//
// Check our result
//
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
ShellStatus = SHELL_INVALID_PARAMETER;
if (Status == EFI_SECURITY_VIOLATION) {
ShellStatus = SHELL_SECURITY_VIOLATION;
@@ -699,16 +728,15 @@ ValidateAndMoveFiles(
ShellStatus = SHELL_ACCESS_DENIED;
}
} else {
- ShellPrintEx(-1, -1, L"%s", HiiResultOk);
+ ShellPrintEx (-1, -1, L"%s", HiiResultOk);
}
-
} // main for loop
- SHELL_FREE_NON_NULL(FullDestPath);
- SHELL_FREE_NON_NULL(DestPath);
- SHELL_FREE_NON_NULL(HiiOutput);
- SHELL_FREE_NON_NULL(HiiResultOk);
- SHELL_FREE_NON_NULL(FullCwd);
+ SHELL_FREE_NON_NULL (FullDestPath);
+ SHELL_FREE_NON_NULL (DestPath);
+ SHELL_FREE_NON_NULL (HiiOutput);
+ SHELL_FREE_NON_NULL (HiiResultOk);
+ SHELL_FREE_NON_NULL (FullCwd);
return (ShellStatus);
}
@@ -725,76 +753,76 @@ ShellCommandRunMv (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CHAR16 *Cwd;
- UINTN CwdSize;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- UINTN LoopCounter;
- EFI_SHELL_FILE_INFO *FileList;
- VOID *Response;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- ParamCount = 0;
- FileList = NULL;
- Response = NULL;
+ EFI_STATUS Status;
+ LIST_ENTRY *Package;
+ CHAR16 *ProblemParam;
+ CHAR16 *Cwd;
+ UINTN CwdSize;
+ SHELL_STATUS ShellStatus;
+ UINTN ParamCount;
+ UINTN LoopCounter;
+ EFI_SHELL_FILE_INFO *FileList;
+ VOID *Response;
+
+ ProblemParam = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ ParamCount = 0;
+ FileList = NULL;
+ Response = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mv", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mv", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
}
- switch (ParamCount = ShellCommandLineGetCount(Package)) {
+ switch (ParamCount = ShellCommandLineGetCount (Package)) {
case 0:
case 1:
//
// we have insufficient parameters
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mv");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mv");
ShellStatus = SHELL_INVALID_PARAMETER;
break;
case 2:
//
// must have valid CWD for single parameter...
//
- if (ShellGetCurrentDir(NULL) == NULL){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"mv");
+ if (ShellGetCurrentDir (NULL) == NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"mv");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1));
+ Status = ShellOpenFileMetaArg ((CHAR16 *)ShellCommandLineGetRawValue (Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
+ if ((FileList == NULL) || IsListEmpty (&FileList->Link) || EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue (Package, 1));
ShellStatus = SHELL_NOT_FOUND;
- } else {
+ } else {
//
// ValidateAndMoveFiles will report errors to the screen itself
//
- CwdSize = StrSize(ShellGetCurrentDir(NULL)) + sizeof(CHAR16);
- Cwd = AllocateZeroPool(CwdSize);
+ CwdSize = StrSize (ShellGetCurrentDir (NULL)) + sizeof (CHAR16);
+ Cwd = AllocateZeroPool (CwdSize);
if (Cwd == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"mv");
ShellStatus = SHELL_OUT_OF_RESOURCES;
@@ -809,39 +837,42 @@ ShellCommandRunMv (
break;
default:
- ///@todo make sure this works with error half way through and continues...
- for (ParamCount--, LoopCounter = 1 ; LoopCounter < ParamCount ; LoopCounter++) {
- if (ShellGetExecutionBreakFlag()) {
+ /// @todo make sure this works with error half way through and continues...
+ for (ParamCount--, LoopCounter = 1; LoopCounter < ParamCount; LoopCounter++) {
+ if (ShellGetExecutionBreakFlag ()) {
break;
}
- Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, LoopCounter));
+
+ Status = ShellOpenFileMetaArg ((CHAR16 *)ShellCommandLineGetRawValue (Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
+ if ((FileList == NULL) || IsListEmpty (&FileList->Link) || EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue (Package, LoopCounter));
ShellStatus = SHELL_NOT_FOUND;
- } else {
+ } else {
//
// ValidateAndMoveFiles will report errors to the screen itself
// Only change ShellStatus if it's sucessful
//
if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellCommandLineGetRawValue(Package, ParamCount));
+ ShellStatus = ValidateAndMoveFiles (FileList, &Response, ShellCommandLineGetRawValue (Package, ParamCount));
} else {
- ValidateAndMoveFiles(FileList, &Response, ShellCommandLineGetRawValue(Package, ParamCount));
+ ValidateAndMoveFiles (FileList, &Response, ShellCommandLineGetRawValue (Package, ParamCount));
}
}
- if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
- Status = ShellCloseFileMetaArg(&FileList);
- if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {
+
+ if ((FileList != NULL) && !IsListEmpty (&FileList->Link)) {
+ Status = ShellCloseFileMetaArg (&FileList);
+ if (EFI_ERROR (Status) && (ShellStatus == SHELL_SUCCESS)) {
ShellStatus = SHELL_ACCESS_DENIED;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1), ShellStatus|MAX_BIT);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue (Package, 1), ShellStatus|MAX_BIT);
}
}
}
+
break;
} // switch on parameter count
if (FileList != NULL) {
- ShellCloseFileMetaArg(&FileList);
+ ShellCloseFileMetaArg (&FileList);
}
//
@@ -850,9 +881,9 @@ ShellCommandRunMv (
ShellCommandLineFreeVarList (Package);
}
- SHELL_FREE_NON_NULL(Response);
+ SHELL_FREE_NON_NULL (Response);
- if (ShellGetExecutionBreakFlag()) {
+ if (ShellGetExecutionBreakFlag ()) {
return (SHELL_ABORTED);
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c
index 47cb33252f..955e082a93 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Parse.c
@@ -22,24 +22,25 @@ IsStdInDataAvailable (
VOID
)
{
- SHELL_FILE_HANDLE FileHandle;
- EFI_STATUS Status;
- CHAR16 CharBuffer;
- UINTN CharSize;
- UINT64 OriginalFilePosition;
+ SHELL_FILE_HANDLE FileHandle;
+ EFI_STATUS Status;
+ CHAR16 CharBuffer;
+ UINTN CharSize;
+ UINT64 OriginalFilePosition;
Status = EFI_SUCCESS;
FileHandle = NULL;
OriginalFilePosition = 0;
if (ShellOpenFileByName (L">i", &FileHandle, EFI_FILE_MODE_READ, 0) == EFI_SUCCESS) {
- CharSize = sizeof(CHAR16);
+ CharSize = sizeof (CHAR16);
gEfiShellProtocol->GetFilePosition (FileHandle, &OriginalFilePosition);
Status = gEfiShellProtocol->ReadFile (FileHandle, &CharSize, &CharBuffer);
- if (EFI_ERROR (Status) || (CharSize != sizeof(CHAR16))) {
+ if (EFI_ERROR (Status) || (CharSize != sizeof (CHAR16))) {
return FALSE;
}
- gEfiShellProtocol->SetFilePosition(FileHandle, OriginalFilePosition);
+
+ gEfiShellProtocol->SetFilePosition (FileHandle, OriginalFilePosition);
}
if (FileHandle == NULL) {
@@ -78,15 +79,17 @@ HandleStringWithEscapeCharForParse (
if (NewStr == NULL) {
return NULL;
}
+
ReturnStr = NewStr;
StrWalker = String;
while (*StrWalker != CHAR_NULL) {
- if (*StrWalker == L'^' && (*(StrWalker + 1) == L'^' || *(StrWalker + 1) == L'"')) {
+ if ((*StrWalker == L'^') && ((*(StrWalker + 1) == L'^') || (*(StrWalker + 1) == L'"'))) {
*NewStr = *(StrWalker + 1);
StrWalker++;
} else {
*NewStr = *StrWalker;
}
+
StrWalker++;
NewStr++;
}
@@ -94,7 +97,6 @@ HandleStringWithEscapeCharForParse (
return ReturnStr;
}
-
/**
Do the actual parsing of the file. the file should be SFO output from a
shell command or a similar format.
@@ -110,44 +112,44 @@ HandleStringWithEscapeCharForParse (
@retval SHELL_SUCCESS The operation was successful.
**/
SHELL_STATUS
-PerformParsing(
- IN CONST CHAR16 *FileName,
- IN CONST CHAR16 *TableName,
- IN CONST UINTN ColumnIndex,
- IN CONST UINTN TableNameInstance,
- IN CONST UINTN ShellCommandInstance,
- IN BOOLEAN StreamingUnicode
+PerformParsing (
+ IN CONST CHAR16 *FileName,
+ IN CONST CHAR16 *TableName,
+ IN CONST UINTN ColumnIndex,
+ IN CONST UINTN TableNameInstance,
+ IN CONST UINTN ShellCommandInstance,
+ IN BOOLEAN StreamingUnicode
)
{
- SHELL_FILE_HANDLE FileHandle;
- EFI_STATUS Status;
- BOOLEAN Ascii;
- UINTN LoopVariable;
- UINTN ColumnLoop;
- CHAR16 *TempLine;
- CHAR16 *ColumnPointer;
- SHELL_STATUS ShellStatus;
- CHAR16 *TempSpot;
- CHAR16 *SfoString;
-
- ASSERT(FileName != NULL);
- ASSERT(TableName != NULL);
-
- ShellStatus = SHELL_SUCCESS;
-
- Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"parse", FileName);
+ SHELL_FILE_HANDLE FileHandle;
+ EFI_STATUS Status;
+ BOOLEAN Ascii;
+ UINTN LoopVariable;
+ UINTN ColumnLoop;
+ CHAR16 *TempLine;
+ CHAR16 *ColumnPointer;
+ SHELL_STATUS ShellStatus;
+ CHAR16 *TempSpot;
+ CHAR16 *SfoString;
+
+ ASSERT (FileName != NULL);
+ ASSERT (TableName != NULL);
+
+ ShellStatus = SHELL_SUCCESS;
+
+ Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"parse", FileName);
ShellStatus = SHELL_NOT_FOUND;
} else if (!EFI_ERROR (FileHandleIsDirectory (FileHandle))) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_FILE), gShellLevel2HiiHandle, L"parse", FileName);
ShellStatus = SHELL_NOT_FOUND;
} else {
- for (LoopVariable = 0 ; LoopVariable < ShellCommandInstance && !ShellFileHandleEof(FileHandle);) {
- TempLine = ShellFileHandleReturnLine (FileHandle, &Ascii);
+ for (LoopVariable = 0; LoopVariable < ShellCommandInstance && !ShellFileHandleEof (FileHandle);) {
+ TempLine = ShellFileHandleReturnLine (FileHandle, &Ascii);
- if ((TempLine == NULL) || (*TempLine == CHAR_NULL && StreamingUnicode)) {
- break;
+ if ((TempLine == NULL) || ((*TempLine == CHAR_NULL) && StreamingUnicode)) {
+ break;
}
//
@@ -158,46 +160,56 @@ PerformParsing(
if (StrStr (TempLine, L"ShellCommand,") == TempLine) {
LoopVariable++;
}
- SHELL_FREE_NON_NULL(TempLine);
+
+ SHELL_FREE_NON_NULL (TempLine);
}
+
if (LoopVariable == ShellCommandInstance) {
LoopVariable = 0;
- while(1) {
+ while (1) {
TempLine = ShellFileHandleReturnLine (FileHandle, &Ascii);
- if (TempLine == NULL
- || *TempLine == CHAR_NULL
- || StrStr (TempLine, L"ShellCommand,") == TempLine) {
- SHELL_FREE_NON_NULL(TempLine);
+ if ( (TempLine == NULL)
+ || (*TempLine == CHAR_NULL)
+ || (StrStr (TempLine, L"ShellCommand,") == TempLine))
+ {
+ SHELL_FREE_NON_NULL (TempLine);
break;
}
+
if (StrStr (TempLine, TableName) == TempLine) {
LoopVariable++;
- if (LoopVariable == TableNameInstance
- || (TableNameInstance == (UINTN)-1)) {
+ if ( (LoopVariable == TableNameInstance)
+ || (TableNameInstance == (UINTN)-1))
+ {
for (ColumnLoop = 1, ColumnPointer = TempLine; ColumnLoop < ColumnIndex && ColumnPointer != NULL && *ColumnPointer != CHAR_NULL; ColumnLoop++) {
ColumnPointer = StrStr (ColumnPointer, L",\"");
- if (ColumnPointer != NULL && *ColumnPointer != CHAR_NULL){
+ if ((ColumnPointer != NULL) && (*ColumnPointer != CHAR_NULL)) {
ColumnPointer++;
}
}
+
if (ColumnLoop == ColumnIndex) {
if (ColumnPointer == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"parse", L"Column Index");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"parse", L"Column Index");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
TempSpot = StrStr (ColumnPointer, L",\"");
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
- while (ColumnPointer != NULL && *ColumnPointer != CHAR_NULL && ColumnPointer[0] == L' '){
+
+ while (ColumnPointer != NULL && *ColumnPointer != CHAR_NULL && ColumnPointer[0] == L' ') {
ColumnPointer++;
}
- if (ColumnPointer != NULL && *ColumnPointer != CHAR_NULL && ColumnPointer[0] == L'\"'){
+
+ if ((ColumnPointer != NULL) && (*ColumnPointer != CHAR_NULL) && (ColumnPointer[0] == L'\"')) {
ColumnPointer++;
}
- if (ColumnPointer != NULL && *ColumnPointer != CHAR_NULL && ColumnPointer[StrLen (ColumnPointer) - 1] == L'\"'){
+
+ if ((ColumnPointer != NULL) && (*ColumnPointer != CHAR_NULL) && (ColumnPointer[StrLen (ColumnPointer) - 1] == L'\"')) {
ColumnPointer[StrLen (ColumnPointer) - 1] = CHAR_NULL;
}
+
SfoString = HandleStringWithEscapeCharForParse (ColumnPointer);
if (SfoString != NULL) {
ShellPrintEx (-1, -1, L"%s\r\n", SfoString);
@@ -207,18 +219,20 @@ PerformParsing(
}
}
}
- SHELL_FREE_NON_NULL(TempLine);
+
+ SHELL_FREE_NON_NULL (TempLine);
}
}
}
+
return (ShellStatus);
}
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-i", TypeValue},
- {L"-s", TypeValue},
- {NULL, TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+ { L"-i", TypeValue },
+ { L"-s", TypeValue },
+ { NULL, TypeMax }
+};
/**
Function for 'parse' command.
@@ -233,16 +247,16 @@ ShellCommandRunParse (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CONST CHAR16 *FileName;
- CONST CHAR16 *TableName;
- CONST CHAR16 *ColumnString;
- SHELL_STATUS ShellStatus;
- UINTN ShellCommandInstance;
- UINTN TableNameInstance;
- BOOLEAN StreamingUnicode;
+ EFI_STATUS Status;
+ LIST_ENTRY *Package;
+ CHAR16 *ProblemParam;
+ CONST CHAR16 *FileName;
+ CONST CHAR16 *TableName;
+ CONST CHAR16 *ColumnString;
+ SHELL_STATUS ShellStatus;
+ UINTN ShellCommandInstance;
+ UINTN TableNameInstance;
+ BOOLEAN StreamingUnicode;
ShellStatus = SHELL_SUCCESS;
ProblemParam = NULL;
@@ -251,53 +265,57 @@ ShellCommandRunParse (
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParseEx (ParamList, &Package, &ProblemParam, TRUE, FALSE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"parse", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"parse", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
StreamingUnicode = IsStdInDataAvailable ();
- if ((!StreamingUnicode && (ShellCommandLineGetCount(Package) < 4)) ||
- (ShellCommandLineGetCount(Package) < 3)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"parse");
+ if ((!StreamingUnicode && (ShellCommandLineGetCount (Package) < 4)) ||
+ (ShellCommandLineGetCount (Package) < 3))
+ {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"parse");
ShellStatus = SHELL_INVALID_PARAMETER;
- } else if ((StreamingUnicode && (ShellCommandLineGetCount(Package) > 3)) ||
- (ShellCommandLineGetCount(Package) > 4)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"parse");
+ } else if ((StreamingUnicode && (ShellCommandLineGetCount (Package) > 3)) ||
+ (ShellCommandLineGetCount (Package) > 4))
+ {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"parse");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (StreamingUnicode) {
- FileName = L">i";
- TableName = ShellCommandLineGetRawValue(Package, 1);
- ColumnString = ShellCommandLineGetRawValue(Package, 2);
+ FileName = L">i";
+ TableName = ShellCommandLineGetRawValue (Package, 1);
+ ColumnString = ShellCommandLineGetRawValue (Package, 2);
} else {
- FileName = ShellCommandLineGetRawValue(Package, 1);
- TableName = ShellCommandLineGetRawValue(Package, 2);
- ColumnString = ShellCommandLineGetRawValue(Package, 3);
+ FileName = ShellCommandLineGetRawValue (Package, 1);
+ TableName = ShellCommandLineGetRawValue (Package, 2);
+ ColumnString = ShellCommandLineGetRawValue (Package, 3);
}
- if (ShellCommandLineGetValue(Package, L"-i") == NULL) {
+
+ if (ShellCommandLineGetValue (Package, L"-i") == NULL) {
TableNameInstance = (UINTN)-1;
} else {
- TableNameInstance = ShellStrToUintn(ShellCommandLineGetValue(Package, L"-i"));
+ TableNameInstance = ShellStrToUintn (ShellCommandLineGetValue (Package, L"-i"));
}
- if (ShellCommandLineGetValue(Package, L"-s") == NULL) {
+
+ if (ShellCommandLineGetValue (Package, L"-s") == NULL) {
ShellCommandInstance = 1;
} else {
- ShellCommandInstance = ShellStrToUintn(ShellCommandLineGetValue(Package, L"-s"));
+ ShellCommandInstance = ShellStrToUintn (ShellCommandLineGetValue (Package, L"-s"));
}
- ShellStatus = PerformParsing(FileName, TableName, ShellStrToUintn(ColumnString), TableNameInstance, ShellCommandInstance, StreamingUnicode);
+ ShellStatus = PerformParsing (FileName, TableName, ShellStrToUintn (ColumnString), TableNameInstance, ShellCommandInstance, StreamingUnicode);
}
}
@@ -308,4 +326,3 @@ ShellCommandRunParse (
return (ShellStatus);
}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c
index 8412af721e..57ba3c90f3 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c
@@ -9,13 +9,13 @@
#include "UefiShellLevel2CommandsLib.h"
-STATIC CONST SHELL_PARAM_ITEM ResetParamList[] = {
- {L"-w", TypeValue},
- {L"-s", TypeValue},
- {L"-c", TypeValue},
- {L"-fwui", TypeFlag },
- {NULL, TypeMax }
- };
+STATIC CONST SHELL_PARAM_ITEM ResetParamList[] = {
+ { L"-w", TypeValue },
+ { L"-s", TypeValue },
+ { L"-c", TypeValue },
+ { L"-fwui", TypeFlag },
+ { NULL, TypeMax }
+};
/**
Function for 'reset' command.
@@ -39,64 +39,72 @@ ShellCommandRunReset (
UINT32 Attr;
UINTN DataSize;
- ShellStatus = SHELL_SUCCESS;
+ ShellStatus = SHELL_SUCCESS;
ProblemParam = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ResetParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"reset", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"reset", ProblemParam);
+ FreePool (ProblemParam);
return (SHELL_INVALID_PARAMETER);
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset");
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
+ } else if (ShellCommandLineGetRawValue (Package, 1) != NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
-
if (ShellCommandLineGetFlag (Package, L"-fwui")) {
-
- DataSize = sizeof (OsIndications);
- Status = gRT->GetVariable (
- EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME, &gEfiGlobalVariableGuid,
- &Attr, &DataSize, &OsIndications
- );
+ DataSize = sizeof (OsIndications);
+ Status = gRT->GetVariable (
+ EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ &Attr,
+ &DataSize,
+ &OsIndications
+ );
if (!EFI_ERROR (Status)) {
if ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0) {
DataSize = sizeof (OsIndications);
- Status = gRT->GetVariable (
- EFI_OS_INDICATIONS_VARIABLE_NAME, &gEfiGlobalVariableGuid,
- &Attr, &DataSize, &OsIndications
- );
+ Status = gRT->GetVariable (
+ EFI_OS_INDICATIONS_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ &Attr,
+ &DataSize,
+ &OsIndications
+ );
if (!EFI_ERROR (Status)) {
OsIndications |= EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
} else {
OsIndications = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
}
+
Status = gRT->SetVariable (
- EFI_OS_INDICATIONS_VARIABLE_NAME, &gEfiGlobalVariableGuid,
+ EFI_OS_INDICATIONS_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- sizeof (OsIndications), &OsIndications
+ sizeof (OsIndications),
+ &OsIndications
);
}
}
+
if (EFI_ERROR (Status)) {
ShellStatus = SHELL_UNSUPPORTED;
goto Error;
@@ -106,40 +114,42 @@ ShellCommandRunReset (
//
// check for warm reset flag, then shutdown reset flag, then cold (default) reset flag
//
- if (ShellCommandLineGetFlag(Package, L"-w")) {
- if (ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-c")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset");
+ if (ShellCommandLineGetFlag (Package, L"-w")) {
+ if (ShellCommandLineGetFlag (Package, L"-s") || ShellCommandLineGetFlag (Package, L"-c")) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- String = ShellCommandLineGetValue(Package, L"-w");
+ String = ShellCommandLineGetValue (Package, L"-w");
if (String != NULL) {
- gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, StrSize(String), (VOID*)String);
+ gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, StrSize (String), (VOID *)String);
} else {
- gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL);
+ gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
}
}
- } else if (ShellCommandLineGetFlag(Package, L"-s")) {
- if (ShellCommandLineGetFlag(Package, L"-c")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset");
+ } else if (ShellCommandLineGetFlag (Package, L"-s")) {
+ if (ShellCommandLineGetFlag (Package, L"-c")) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- String = ShellCommandLineGetValue(Package, L"-s");
- DEBUG_CODE(ShellPrintEx(-1,-1,L"Reset with %s (%d bytes)", String, String!=NULL?StrSize(String):0););
+ String = ShellCommandLineGetValue (Package, L"-s");
+ DEBUG_CODE (
+ ShellPrintEx (-1, -1, L"Reset with %s (%d bytes)", String, String != NULL ? StrSize (String) : 0);
+ );
if (String != NULL) {
- gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, StrSize(String), (VOID*)String);
+ gRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, StrSize (String), (VOID *)String);
} else {
- gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
+ gRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
}
}
} else {
//
// this is default so dont worry about flag...
//
- String = ShellCommandLineGetValue(Package, L"-c");
+ String = ShellCommandLineGetValue (Package, L"-c");
if (String != NULL) {
- gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, StrSize(String), (VOID*)String);
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, StrSize (String), (VOID *)String);
} else {
- gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
}
}
}
@@ -161,4 +171,3 @@ Error:
//
return (ShellStatus);
}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
index bc85039588..2354cd0620 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
@@ -9,10 +9,10 @@
#include "UefiShellLevel2CommandsLib.h"
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-q", TypeFlag},
- {NULL, TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+ { L"-q", TypeFlag },
+ { NULL, TypeMax }
+};
/**
Determine if a directory has no files in it.
@@ -24,27 +24,30 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
**/
BOOLEAN
IsDirectoryEmpty (
- IN SHELL_FILE_HANDLE FileHandle
+ IN SHELL_FILE_HANDLE FileHandle
)
{
- EFI_STATUS Status;
- EFI_FILE_INFO *FileInfo;
- BOOLEAN NoFile;
- BOOLEAN RetVal;
+ EFI_STATUS Status;
+ EFI_FILE_INFO *FileInfo;
+ BOOLEAN NoFile;
+ BOOLEAN RetVal;
- RetVal = TRUE;
- NoFile = FALSE;
+ RetVal = TRUE;
+ NoFile = FALSE;
FileInfo = NULL;
- for (Status = FileHandleFindFirstFile(FileHandle, &FileInfo)
- ; !NoFile && !EFI_ERROR (Status)
- ; FileHandleFindNextFile(FileHandle, FileInfo, &NoFile)
- ){
- if (StrStr(FileInfo->FileName, L".") != FileInfo->FileName
- &&StrStr(FileInfo->FileName, L"..") != FileInfo->FileName) {
+ for (Status = FileHandleFindFirstFile (FileHandle, &FileInfo)
+ ; !NoFile && !EFI_ERROR (Status)
+ ; FileHandleFindNextFile (FileHandle, FileInfo, &NoFile)
+ )
+ {
+ if ( (StrStr (FileInfo->FileName, L".") != FileInfo->FileName)
+ && (StrStr (FileInfo->FileName, L"..") != FileInfo->FileName))
+ {
RetVal = FALSE;
}
}
+
return (RetVal);
}
@@ -60,75 +63,81 @@ IsDirectoryEmpty (
@retval SHELL_DEVICE_ERROR A device error occurred reading this Node.
**/
SHELL_STATUS
-CascadeDelete(
+CascadeDelete (
IN EFI_SHELL_FILE_INFO *Node,
IN CONST BOOLEAN Quiet
)
{
- SHELL_STATUS ShellStatus;
- EFI_SHELL_FILE_INFO *List;
- EFI_SHELL_FILE_INFO *Node2;
- EFI_STATUS Status;
- SHELL_PROMPT_RESPONSE *Resp;
- CHAR16 *TempName;
- UINTN NewSize;
-
- Resp = NULL;
- ShellStatus = SHELL_SUCCESS;
- List = NULL;
- Status = EFI_SUCCESS;
+ SHELL_STATUS ShellStatus;
+ EFI_SHELL_FILE_INFO *List;
+ EFI_SHELL_FILE_INFO *Node2;
+ EFI_STATUS Status;
+ SHELL_PROMPT_RESPONSE *Resp;
+ CHAR16 *TempName;
+ UINTN NewSize;
+
+ Resp = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ List = NULL;
+ Status = EFI_SUCCESS;
if ((Node->Info->Attribute & EFI_FILE_READ_ONLY) == EFI_FILE_READ_ONLY) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DETELE_RO), gShellLevel2HiiHandle, L"rm", Node->FullName);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DETELE_RO), gShellLevel2HiiHandle, L"rm", Node->FullName);
return (SHELL_ACCESS_DENIED);
}
if ((Node->Info->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) {
- if (!IsDirectoryEmpty(Node->Handle)) {
+ if (!IsDirectoryEmpty (Node->Handle)) {
if (!Quiet) {
- Status = ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_RM_LOG_DELETE_CONF), gShellLevel2HiiHandle, Node->FullName);
- Status = ShellPromptForResponse(ShellPromptResponseTypeYesNo, NULL, (VOID**)&Resp);
- ASSERT(Resp != NULL);
- if (EFI_ERROR(Status) || *Resp != ShellPromptResponseYes) {
- SHELL_FREE_NON_NULL(Resp);
+ Status = ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_CONF), gShellLevel2HiiHandle, Node->FullName);
+ Status = ShellPromptForResponse (ShellPromptResponseTypeYesNo, NULL, (VOID **)&Resp);
+ ASSERT (Resp != NULL);
+ if (EFI_ERROR (Status) || (*Resp != ShellPromptResponseYes)) {
+ SHELL_FREE_NON_NULL (Resp);
return (SHELL_ABORTED);
}
- SHELL_FREE_NON_NULL(Resp);
+
+ SHELL_FREE_NON_NULL (Resp);
}
+
//
// empty out the directory
//
- Status = gEfiShellProtocol->FindFilesInDir(Node->Handle, &List);
- if (EFI_ERROR(Status)) {
- if (List!=NULL) {
- gEfiShellProtocol->FreeFileList(&List);
+ Status = gEfiShellProtocol->FindFilesInDir (Node->Handle, &List);
+ if (EFI_ERROR (Status)) {
+ if (List != NULL) {
+ gEfiShellProtocol->FreeFileList (&List);
}
+
return (SHELL_DEVICE_ERROR);
}
- for (Node2 = (EFI_SHELL_FILE_INFO *)GetFirstNode(&List->Link)
- ; !IsNull(&List->Link, &Node2->Link)
- ; Node2 = (EFI_SHELL_FILE_INFO *)GetNextNode(&List->Link, &Node2->Link)
- ){
+
+ for (Node2 = (EFI_SHELL_FILE_INFO *)GetFirstNode (&List->Link)
+ ; !IsNull (&List->Link, &Node2->Link)
+ ; Node2 = (EFI_SHELL_FILE_INFO *)GetNextNode (&List->Link, &Node2->Link)
+ )
+ {
//
// skip the directory traversing stuff...
//
- if (StrCmp(Node2->FileName, L".") == 0 || StrCmp(Node2->FileName, L"..") == 0) {
+ if ((StrCmp (Node2->FileName, L".") == 0) || (StrCmp (Node2->FileName, L"..") == 0)) {
continue;
}
+
Node2->Status = gEfiShellProtocol->OpenFileByName (Node2->FullName, &Node2->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);
- if (EFI_ERROR(Node2->Status) && StrStr(Node2->FileName, L":") == NULL) {
+ if (EFI_ERROR (Node2->Status) && (StrStr (Node2->FileName, L":") == NULL)) {
//
// Update the node filename to have full path with file system identifier
//
- NewSize = StrSize(Node->FullName) + StrSize(Node2->FullName);
- TempName = AllocateZeroPool(NewSize);
+ NewSize = StrSize (Node->FullName) + StrSize (Node2->FullName);
+ TempName = AllocateZeroPool (NewSize);
if (TempName == NULL) {
ShellStatus = SHELL_OUT_OF_RESOURCES;
} else {
- StrCpyS(TempName, NewSize/sizeof(CHAR16), Node->FullName);
- TempName[StrStr(TempName, L":")+1-TempName] = CHAR_NULL;
- StrCatS(TempName, NewSize/sizeof(CHAR16), Node2->FullName);
- FreePool((VOID*)Node2->FullName);
+ StrCpyS (TempName, NewSize/sizeof (CHAR16), Node->FullName);
+ TempName[StrStr (TempName, L":")+1-TempName] = CHAR_NULL;
+ StrCatS (TempName, NewSize/sizeof (CHAR16), Node2->FullName);
+ FreePool ((VOID *)Node2->FullName);
Node2->FullName = TempName;
//
@@ -137,45 +146,51 @@ CascadeDelete(
Node2->Status = gEfiShellProtocol->OpenFileByName (Node2->FullName, &Node2->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);
}
}
- if (!EFI_ERROR(Node2->Status)) {
- ShellStatus = CascadeDelete(Node2, Quiet);
+
+ if (!EFI_ERROR (Node2->Status)) {
+ ShellStatus = CascadeDelete (Node2, Quiet);
} else if (ShellStatus == SHELL_SUCCESS) {
ShellStatus = (SHELL_STATUS)(Node2->Status&(~0x80000000));
}
+
if (ShellStatus != SHELL_SUCCESS) {
- if (List!=NULL) {
- gEfiShellProtocol->FreeFileList(&List);
+ if (List != NULL) {
+ gEfiShellProtocol->FreeFileList (&List);
}
+
return (ShellStatus);
}
}
- if (List!=NULL) {
- gEfiShellProtocol->FreeFileList(&List);
+
+ if (List != NULL) {
+ gEfiShellProtocol->FreeFileList (&List);
}
}
}
- if (!(StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0)) {
+ if (!((StrCmp (Node->FileName, L".") == 0) || (StrCmp (Node->FileName, L"..") == 0))) {
//
// now delete the current node...
//
if (!Quiet) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE), gShellLevel2HiiHandle, Node->FullName);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE), gShellLevel2HiiHandle, Node->FullName);
}
- Status = gEfiShellProtocol->DeleteFile(Node->Handle);
+
+ Status = gEfiShellProtocol->DeleteFile (Node->Handle);
Node->Handle = NULL;
}
//
// We cant allow for the warning here! (Dont use EFI_ERROR Macro).
//
- if (Status != EFI_SUCCESS){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR), gShellLevel2HiiHandle, Status);
+ if (Status != EFI_SUCCESS) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR), gShellLevel2HiiHandle, Status);
return (SHELL_ACCESS_DENIED);
} else {
if (!Quiet) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_COMP), gShellLevel2HiiHandle);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_COMP), gShellLevel2HiiHandle);
}
+
return (SHELL_SUCCESS);
}
}
@@ -188,31 +203,31 @@ CascadeDelete(
@param[in] Package RESERVED. Not used.
**/
BOOLEAN
-IsValidDeleteTarget(
+IsValidDeleteTarget (
IN CONST EFI_SHELL_FILE_INFO *List,
IN CONST EFI_SHELL_FILE_INFO *Node,
IN CONST LIST_ENTRY *Package
)
{
- CONST CHAR16 *TempLocation;
- BOOLEAN RetVal;
- CHAR16 *SearchString;
- CHAR16 *Pattern;
- UINTN Size;
+ CONST CHAR16 *TempLocation;
+ BOOLEAN RetVal;
+ CHAR16 *SearchString;
+ CHAR16 *Pattern;
+ UINTN Size;
- if (Node == NULL || Node->FullName == NULL) {
+ if ((Node == NULL) || (Node->FullName == NULL)) {
return (FALSE);
}
- TempLocation = StrStr(Node->FullName, L":");
- if (StrLen(TempLocation) <= 2) {
+ TempLocation = StrStr (Node->FullName, L":");
+ if (StrLen (TempLocation) <= 2) {
//
// Deleting the root directory is invalid.
//
return (FALSE);
}
- TempLocation = ShellGetCurrentDir(NULL);
+ TempLocation = ShellGetCurrentDir (NULL);
if (TempLocation == NULL) {
//
// No working directory is specified so whatever is left is ok.
@@ -220,29 +235,29 @@ IsValidDeleteTarget(
return (TRUE);
}
- Pattern = NULL;
- SearchString = NULL;
- Size = 0;
- Pattern = StrnCatGrow(&Pattern, &Size, TempLocation , 0);
- Pattern = StrnCatGrow(&Pattern, &Size, L"\\" , 0);
- Size = 0;
- SearchString = StrnCatGrow(&SearchString, &Size, Node->FullName, 0);
- if (!EFI_ERROR(ShellIsDirectory(SearchString))) {
- SearchString = StrnCatGrow(&SearchString, &Size, L"\\", 0);
- SearchString = StrnCatGrow(&SearchString, &Size, L"*", 0);
+ Pattern = NULL;
+ SearchString = NULL;
+ Size = 0;
+ Pattern = StrnCatGrow (&Pattern, &Size, TempLocation, 0);
+ Pattern = StrnCatGrow (&Pattern, &Size, L"\\", 0);
+ Size = 0;
+ SearchString = StrnCatGrow (&SearchString, &Size, Node->FullName, 0);
+ if (!EFI_ERROR (ShellIsDirectory (SearchString))) {
+ SearchString = StrnCatGrow (&SearchString, &Size, L"\\", 0);
+ SearchString = StrnCatGrow (&SearchString, &Size, L"*", 0);
}
- if (Pattern == NULL || SearchString == NULL) {
+ if ((Pattern == NULL) || (SearchString == NULL)) {
RetVal = FALSE;
} else {
RetVal = TRUE;
- if (gUnicodeCollation->MetaiMatch(gUnicodeCollation, Pattern, SearchString)) {
+ if (gUnicodeCollation->MetaiMatch (gUnicodeCollation, Pattern, SearchString)) {
RetVal = FALSE;
}
}
- SHELL_FREE_NON_NULL(Pattern );
- SHELL_FREE_NON_NULL(SearchString);
+ SHELL_FREE_NON_NULL (Pattern);
+ SHELL_FREE_NON_NULL (SearchString);
return (RetVal);
}
@@ -260,106 +275,112 @@ ShellCommandRunRm (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- CONST CHAR16 *Param;
- SHELL_STATUS ShellStatus;
- UINTN ParamCount;
- EFI_SHELL_FILE_INFO *FileList;
- EFI_SHELL_FILE_INFO *Node;
-
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- ParamCount = 0;
- FileList = NULL;
+ EFI_STATUS Status;
+ LIST_ENTRY *Package;
+ CHAR16 *ProblemParam;
+ CONST CHAR16 *Param;
+ SHELL_STATUS ShellStatus;
+ UINTN ParamCount;
+ EFI_SHELL_FILE_INFO *FileList;
+ EFI_SHELL_FILE_INFO *Node;
+
+ ProblemParam = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ ParamCount = 0;
+ FileList = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"rm", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"rm", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
}
- if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
+
+ if (ShellCommandLineGetRawValue (Package, 1) == NULL) {
//
// we insufficient parameters
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"rm");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"rm");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// get a list with each file specified by parameters
// if parameter is a directory then add all the files below it to the list
//
- for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)
- ; Param != NULL
- ; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)
- ){
- Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
- if (EFI_ERROR(Status) || FileList == NULL || IsListEmpty(&FileList->Link)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"rm", (CHAR16*)Param);
+ for ( ParamCount = 1, Param = ShellCommandLineGetRawValue (Package, ParamCount)
+ ; Param != NULL
+ ; ParamCount++, Param = ShellCommandLineGetRawValue (Package, ParamCount)
+ )
+ {
+ Status = ShellOpenFileMetaArg ((CHAR16 *)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
+ if (EFI_ERROR (Status) || (FileList == NULL) || IsListEmpty (&FileList->Link)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"rm", (CHAR16 *)Param);
ShellStatus = SHELL_NOT_FOUND;
break;
}
}
- if (ShellStatus == SHELL_SUCCESS){
+ if (ShellStatus == SHELL_SUCCESS) {
//
// loop through the list and make sure we are not aborting...
//
- for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)
- ; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
- ; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
- ){
+ for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link)
+ ; !IsNull (&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag ()
+ ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &Node->Link)
+ )
+ {
//
// skip the directory traversing stuff...
//
- if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
+ if ((StrCmp (Node->FileName, L".") == 0) || (StrCmp (Node->FileName, L"..") == 0)) {
continue;
}
//
// do the deleting of nodes
//
- if (EFI_ERROR(Node->Status)){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR2), gShellLevel2HiiHandle, Node->Status);
+ if (EFI_ERROR (Node->Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR2), gShellLevel2HiiHandle, Node->Status);
ShellStatus = SHELL_ACCESS_DENIED;
break;
}
- if (!IsValidDeleteTarget(FileList, Node, Package)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR3), gShellLevel2HiiHandle, Node->FullName);
+
+ if (!IsValidDeleteTarget (FileList, Node, Package)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_RM_LOG_DELETE_ERR3), gShellLevel2HiiHandle, Node->FullName);
ShellStatus = SHELL_INVALID_PARAMETER;
break;
}
- ShellStatus = CascadeDelete(Node, ShellCommandLineGetFlag(Package, L"-q"));
+ ShellStatus = CascadeDelete (Node, ShellCommandLineGetFlag (Package, L"-q"));
}
}
+
//
// Free the fileList
//
if (FileList != NULL) {
- Status = ShellCloseFileMetaArg(&FileList);
+ Status = ShellCloseFileMetaArg (&FileList);
}
+
FileList = NULL;
}
@@ -371,4 +392,3 @@ ShellCommandRunRm (
return (ShellStatus);
}
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Set.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Set.c
index 6f9c1ec45c..c9082eb76c 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Set.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Set.c
@@ -18,31 +18,32 @@
@return any return code from GetNextVariableName except EFI_NOT_FOUND
**/
SHELL_STATUS
-PrintAllShellEnvVars(
+PrintAllShellEnvVars (
VOID
)
{
- CONST CHAR16 *Value;
- CONST CHAR16 *ConstEnvNameList;
+ CONST CHAR16 *Value;
+ CONST CHAR16 *ConstEnvNameList;
- ConstEnvNameList = gEfiShellProtocol->GetEnv(NULL);
+ ConstEnvNameList = gEfiShellProtocol->GetEnv (NULL);
if (ConstEnvNameList == NULL) {
return (SHELL_SUCCESS);
}
- while (*ConstEnvNameList != CHAR_NULL){
- Value = gEfiShellProtocol->GetEnv(ConstEnvNameList);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_DISP), gShellLevel2HiiHandle, ConstEnvNameList, Value);
- ConstEnvNameList += StrLen(ConstEnvNameList)+1;
+
+ while (*ConstEnvNameList != CHAR_NULL) {
+ Value = gEfiShellProtocol->GetEnv (ConstEnvNameList);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SET_DISP), gShellLevel2HiiHandle, ConstEnvNameList, Value);
+ ConstEnvNameList += StrLen (ConstEnvNameList)+1;
}
return (SHELL_SUCCESS);
}
-STATIC CONST SHELL_PARAM_ITEM SetParamList[] = {
- {L"-d", TypeValue},
- {L"-v", TypeFlag},
- {NULL, TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM SetParamList[] = {
+ { L"-d", TypeValue },
+ { L"-v", TypeFlag },
+ { NULL, TypeMax }
+};
/**
Function for 'set' command.
@@ -70,90 +71,89 @@ ShellCommandRunSet (
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// Make sure globals are good...
//
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
+ Status = CommandInit ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (SetParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"set", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"set", ProblemParam);
+ FreePool (ProblemParam);
return (SHELL_INVALID_PARAMETER);
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 3) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"set");
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
+ } else if (ShellCommandLineGetRawValue (Package, 3) != NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"set");
ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetRawValue(Package, 1) != NULL && ShellCommandLineGetFlag(Package, L"-d")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"set");
+ } else if ((ShellCommandLineGetRawValue (Package, 1) != NULL) && ShellCommandLineGetFlag (Package, L"-d")) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"set");
ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-d")) {
+ } else if (ShellCommandLineGetFlag (Package, L"-d")) {
//
// delete a environment variable
//
- KeyName = ShellCommandLineGetValue(Package, L"-d");
+ KeyName = ShellCommandLineGetValue (Package, L"-d");
if (KeyName == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"set", L"-d");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"set", L"-d");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- Status = ShellSetEnvironmentVariable(KeyName, L"", ShellCommandLineGetFlag(Package, L"-v"));
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_ND), gShellLevel2HiiHandle, L"set", KeyName);
+ Status = ShellSetEnvironmentVariable (KeyName, L"", ShellCommandLineGetFlag (Package, L"-v"));
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SET_ND), gShellLevel2HiiHandle, L"set", KeyName);
ShellStatus = SHELL_DEVICE_ERROR;
}
}
- } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
+ } else if (ShellCommandLineGetRawValue (Package, 1) == NULL) {
//
// print out all current environment variables
//
- return(PrintAllShellEnvVars());
+ return (PrintAllShellEnvVars ());
} else {
//
// we are either printing one or assigning one
//
- KeyName = ShellCommandLineGetRawValue(Package, 1);
- Value = ShellCommandLineGetRawValue(Package, 2);
- if (KeyName != NULL && Value != NULL) {
+ KeyName = ShellCommandLineGetRawValue (Package, 1);
+ Value = ShellCommandLineGetRawValue (Package, 2);
+ if ((KeyName != NULL) && (Value != NULL)) {
//
// assigning one
//
- Status = ShellSetEnvironmentVariable(KeyName, Value, ShellCommandLineGetFlag(Package, L"-v"));
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_ERROR_SET), gShellLevel2HiiHandle, L"set", KeyName);
- ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT));
+ Status = ShellSetEnvironmentVariable (KeyName, Value, ShellCommandLineGetFlag (Package, L"-v"));
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SET_ERROR_SET), gShellLevel2HiiHandle, L"set", KeyName);
+ ShellStatus = (SHELL_STATUS)(Status & (~MAX_BIT));
}
-
} else {
if (KeyName != NULL) {
//
// print out value for this one only.
//
- Value = ShellGetEnvironmentVariable(KeyName);
+ Value = ShellGetEnvironmentVariable (KeyName);
if (Value == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_NF), gShellLevel2HiiHandle, L"set", KeyName);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SET_NF), gShellLevel2HiiHandle, L"set", KeyName);
ShellStatus = SHELL_SUCCESS;
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_DISP), gShellLevel2HiiHandle, KeyName, Value);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SET_DISP), gShellLevel2HiiHandle, KeyName, Value);
ShellStatus = SHELL_SUCCESS;
}
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
}
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
index be8e952546..f01f4e450b 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
@@ -30,7 +30,8 @@ InternalIsTimeLikeString (
IN CONST BOOLEAN MinusOk
)
{
- UINTN Count;
+ UINTN Count;
+
Count = 0;
if (MinusOk) {
@@ -45,27 +46,32 @@ InternalIsTimeLikeString (
//
// the first char must be numeric.
//
- if (!ShellIsDecimalDigitCharacter(*String)) {
+ if (!ShellIsDecimalDigitCharacter (*String)) {
return (FALSE);
}
+
//
// loop through the characters and use the lib function
//
- for ( ; String != NULL && *String != CHAR_NULL ; String++){
+ for ( ; String != NULL && *String != CHAR_NULL; String++) {
if (*String == Char) {
Count++;
if (Count > Max) {
return (FALSE);
}
+
continue;
}
- if (!ShellIsDecimalDigitCharacter(*String)) {
+
+ if (!ShellIsDecimalDigitCharacter (*String)) {
return (FALSE);
}
}
+
if (Count < Min) {
return (FALSE);
}
+
return (TRUE);
}
@@ -81,38 +87,39 @@ InternalIsTimeLikeString (
**/
SHELL_STATUS
CheckAndSetDate (
- IN CONST CHAR16 *DateString
+ IN CONST CHAR16 *DateString
)
{
- EFI_TIME TheTime;
- EFI_STATUS Status;
- CHAR16 *DateStringCopy;
- CHAR16 *Walker;
- CHAR16 *Walker1;
+ EFI_TIME TheTime;
+ EFI_STATUS Status;
+ CHAR16 *DateStringCopy;
+ CHAR16 *Walker;
+ CHAR16 *Walker1;
- if (!InternalIsTimeLikeString(DateString, L'/', 2, 2, FALSE)) {
+ if (!InternalIsTimeLikeString (DateString, L'/', 2, 2, FALSE)) {
return (SHELL_INVALID_PARAMETER);
}
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"date", L"gRT->GetTime", Status);
+ Status = gRT->GetTime (&TheTime, NULL);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"date", L"gRT->GetTime", Status);
return (SHELL_DEVICE_ERROR);
}
DateStringCopy = NULL;
- DateStringCopy = StrnCatGrow(&DateStringCopy, NULL, DateString, 0);
+ DateStringCopy = StrnCatGrow (&DateStringCopy, NULL, DateString, 0);
if (DateStringCopy == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
+
Walker = DateStringCopy;
TheTime.Month = 0xFF;
TheTime.Day = 0xFF;
TheTime.Year = 0xFFFF;
- Walker1 = StrStr(Walker, L"/");
- if (Walker1 != NULL && *Walker1 == L'/') {
+ Walker1 = StrStr (Walker, L"/");
+ if ((Walker1 != NULL) && (*Walker1 == L'/')) {
*Walker1 = CHAR_NULL;
}
@@ -120,20 +127,24 @@ CheckAndSetDate (
if (Walker1 != NULL) {
Walker = Walker1 + 1;
}
- Walker1 = Walker!=NULL?StrStr(Walker, L"/"):NULL;
- if (Walker1 != NULL && *Walker1 == L'/') {
+
+ Walker1 = Walker != NULL ? StrStr (Walker, L"/") : NULL;
+ if ((Walker1 != NULL) && (*Walker1 == L'/')) {
*Walker1 = CHAR_NULL;
}
- if (Walker != NULL && Walker[0] != CHAR_NULL) {
+
+ if ((Walker != NULL) && (Walker[0] != CHAR_NULL)) {
TheTime.Day = (UINT8)ShellStrToUintn (Walker);
if (Walker1 != NULL) {
Walker = Walker1 + 1;
}
- Walker1 = Walker!=NULL?StrStr(Walker, L"/"):NULL;
- if (Walker1 != NULL && *Walker1 == L'/') {
+
+ Walker1 = Walker != NULL ? StrStr (Walker, L"/") : NULL;
+ if ((Walker1 != NULL) && (*Walker1 == L'/')) {
*Walker1 = CHAR_NULL;
}
- if (Walker != NULL && Walker[0] != CHAR_NULL) {
+
+ if ((Walker != NULL) && (Walker[0] != CHAR_NULL)) {
TheTime.Year = (UINT16)ShellStrToUintn (Walker);
}
}
@@ -146,11 +157,12 @@ CheckAndSetDate (
}
}
- Status = gRT->SetTime(&TheTime);
+ Status = gRT->SetTime (&TheTime);
- if (!EFI_ERROR(Status)){
+ if (!EFI_ERROR (Status)) {
return (SHELL_SUCCESS);
}
+
return (SHELL_INVALID_PARAMETER);
}
@@ -180,49 +192,49 @@ ShellCommandRunDate (
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"date", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"date", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"date");
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
+ } else if (ShellCommandLineGetRawValue (Package, 2) != NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"date");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// If there are 0 value parameters, then print the current date
// else If there are any value paramerers, then print error
//
- if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
+ if (ShellCommandLineGetRawValue (Package, 1) == NULL) {
//
// get the current date
//
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"date", L"gRT->GetTime", Status);
+ Status = gRT->GetTime (&TheTime, NULL);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"date", L"gRT->GetTime", Status);
return (SHELL_DEVICE_ERROR);
}
//
// ShellPrintEx the date in SFO or regular format
//
- if (ShellCommandLineGetFlag(Package, L"-sfo")) {
+ if (ShellCommandLineGetFlag (Package, L"-sfo")) {
//
// Match UEFI Shell spec:
// ShellCommand,"date"
@@ -231,30 +243,32 @@ ShellCommandRunDate (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellLevel2HiiHandle, L"date");
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DATE_SFO_FORMAT), gShellLevel2HiiHandle, TheTime.Day, TheTime.Month, TheTime.Year);
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DATE_FORMAT), gShellLevel2HiiHandle, TheTime.Month, TheTime.Day, TheTime.Year);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DATE_FORMAT), gShellLevel2HiiHandle, TheTime.Month, TheTime.Day, TheTime.Year);
}
} else {
- if (PcdGet8(PcdShellSupportLevel) == 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"date");
+ if (PcdGet8 (PcdShellSupportLevel) == 2) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"date");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// perform level 3 operation here.
//
- Param1 = ShellCommandLineGetRawValue(Package, 1);
+ Param1 = ShellCommandLineGetRawValue (Package, 1);
if (Param1 == NULL) {
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ShellStatus = CheckAndSetDate(Param1);
+ ShellStatus = CheckAndSetDate (Param1);
}
+
if (ShellStatus != SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"date", Param1);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"date", Param1);
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
}
}
}
+
//
// free the command line package
//
@@ -269,16 +283,16 @@ ShellCommandRunDate (
//
// Note "-tz" is invalid for this (non-interactive) version of 'time'.
//
-STATIC CONST SHELL_PARAM_ITEM TimeParamList2[] = {
- {L"-d", TypeValue},
- {NULL, TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM TimeParamList2[] = {
+ { L"-d", TypeValue },
+ { NULL, TypeMax }
+};
-STATIC CONST SHELL_PARAM_ITEM TimeParamList3[] = {
- {L"-d", TypeValue},
- {L"-tz", TypeValue},
- {NULL, TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM TimeParamList3[] = {
+ { L"-d", TypeValue },
+ { L"-tz", TypeValue },
+ { NULL, TypeMax }
+};
/**
Verify that the TimeString is valid and if so set that as the current
@@ -294,67 +308,70 @@ STATIC CONST SHELL_PARAM_ITEM TimeParamList3[] = {
**/
SHELL_STATUS
CheckAndSetTime (
- IN CONST CHAR16 *TimeString,
- IN CONST INT16 Tz,
- IN CONST UINT8 Daylight
+ IN CONST CHAR16 *TimeString,
+ IN CONST INT16 Tz,
+ IN CONST UINT8 Daylight
)
{
- EFI_TIME TheTime;
- EFI_STATUS Status;
- CHAR16 *TimeStringCopy;
- CHAR16 *Walker1;
- CHAR16 *Walker2;
+ EFI_TIME TheTime;
+ EFI_STATUS Status;
+ CHAR16 *TimeStringCopy;
+ CHAR16 *Walker1;
+ CHAR16 *Walker2;
- if (TimeString != NULL && !InternalIsTimeLikeString(TimeString, L':', 1, 2, FALSE)) {
+ if ((TimeString != NULL) && !InternalIsTimeLikeString (TimeString, L':', 1, 2, FALSE)) {
return (SHELL_INVALID_PARAMETER);
}
- if (Daylight != 0xFF &&((Daylight & (EFI_TIME_IN_DAYLIGHT|EFI_TIME_ADJUST_DAYLIGHT)) != Daylight)) {
+
+ if ((Daylight != 0xFF) && ((Daylight & (EFI_TIME_IN_DAYLIGHT|EFI_TIME_ADJUST_DAYLIGHT)) != Daylight)) {
return (SHELL_INVALID_PARAMETER);
}
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status);
+ Status = gRT->GetTime (&TheTime, NULL);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status);
return (SHELL_DEVICE_ERROR);
}
if (TimeString != NULL) {
TimeStringCopy = NULL;
- TimeStringCopy = StrnCatGrow(&TimeStringCopy, NULL, TimeString, 0);
- Walker1 = TimeStringCopy;
- TheTime.Hour = 0xFF;
- TheTime.Minute = 0xFF;
+ TimeStringCopy = StrnCatGrow (&TimeStringCopy, NULL, TimeString, 0);
+ Walker1 = TimeStringCopy;
+ TheTime.Hour = 0xFF;
+ TheTime.Minute = 0xFF;
- Walker2 = Walker1!=NULL?StrStr(Walker1, L":"):NULL;
- if (Walker2 != NULL && *Walker2 == L':') {
+ Walker2 = Walker1 != NULL ? StrStr (Walker1, L":") : NULL;
+ if ((Walker2 != NULL) && (*Walker2 == L':')) {
*Walker2 = CHAR_NULL;
}
- TheTime.Hour = (UINT8)ShellStrToUintn (Walker1);
+
+ TheTime.Hour = (UINT8)ShellStrToUintn (Walker1);
if (Walker2 != NULL) {
Walker1 = Walker2 + 1;
}
- Walker2 = Walker1!=NULL?StrStr(Walker1, L":"):NULL;
- if (Walker2 != NULL && *Walker2 == L':') {
- *Walker2 = CHAR_NULL;
+
+ Walker2 = Walker1 != NULL ? StrStr (Walker1, L":") : NULL;
+ if ((Walker2 != NULL) && (*Walker2 == L':')) {
+ *Walker2 = CHAR_NULL;
TheTime.Second = (UINT8)0;
- }
- else if (Walker2 == NULL) {
+ } else if (Walker2 == NULL) {
TheTime.Second = (UINT8)0;
}
- if (Walker1 != NULL && Walker1[0] != CHAR_NULL) {
+
+ if ((Walker1 != NULL) && (Walker1[0] != CHAR_NULL)) {
TheTime.Minute = (UINT8)ShellStrToUintn (Walker1);
if (Walker2 != NULL) {
Walker1 = Walker2 + 1;
- if (Walker1 != NULL && Walker1[0] != CHAR_NULL) {
+ if ((Walker1 != NULL) && (Walker1[0] != CHAR_NULL)) {
TheTime.Second = (UINT8)ShellStrToUintn (Walker1);
}
}
}
- SHELL_FREE_NON_NULL(TimeStringCopy);
- }
+ SHELL_FREE_NON_NULL (TimeStringCopy);
+ }
- if (Tz >= -1440 && Tz <= 1440) {
+ if ((Tz >= -1440) && (Tz <= 1440)) {
//
// EFI_TIME TimeZone is stored to meet the following calculation (see UEFI Spec):
// Localtime = UTC - TimeZone
@@ -372,9 +389,9 @@ CheckAndSetTime (
TheTime.Daylight = Daylight;
}
- Status = gRT->SetTime(&TheTime);
+ Status = gRT->SetTime (&TheTime);
- if (!EFI_ERROR(Status)){
+ if (!EFI_ERROR (Status)) {
return (SHELL_SUCCESS);
}
@@ -413,55 +430,57 @@ ShellCommandRunTime (
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
- if (PcdGet8(PcdShellSupportLevel) == 2) {
+ if (PcdGet8 (PcdShellSupportLevel) == 2) {
Status = ShellCommandLineParseEx (TimeParamList2, &Package, &ProblemParam, TRUE, TRUE);
} else {
- ASSERT(PcdGet8(PcdShellSupportLevel) == 3);
+ ASSERT (PcdGet8 (PcdShellSupportLevel) == 3);
Status = ShellCommandLineParseEx (TimeParamList3, &Package, &ProblemParam, TRUE, TRUE);
}
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"time", ProblemParam);
- FreePool(ProblemParam);
+
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"time", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status);
+ Status = gRT->GetTime (&TheTime, NULL);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", Status);
return (SHELL_DEVICE_ERROR);
}
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time");
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
+ } else if (ShellCommandLineGetRawValue (Package, 2) != NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// If there are no parameters, then print the current time
//
- if (ShellCommandLineGetRawValue(Package, 1) == NULL
- && !ShellCommandLineGetFlag(Package, L"-d")
- && !ShellCommandLineGetFlag(Package, L"-tz")) {
+ if ( (ShellCommandLineGetRawValue (Package, 1) == NULL)
+ && !ShellCommandLineGetFlag (Package, L"-d")
+ && !ShellCommandLineGetFlag (Package, L"-tz"))
+ {
//
// ShellPrintEx the current time
//
if (TheTime.TimeZone == EFI_UNSPECIFIED_TIMEZONE) {
TzMinutes = 0;
} else {
- TzMinutes = (ABS(TheTime.TimeZone)) % 60;
+ TzMinutes = (ABS (TheTime.TimeZone)) % 60;
}
if (TheTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
@@ -474,8 +493,8 @@ ShellCommandRunTime (
TheTime.Hour,
TheTime.Minute,
TheTime.Second,
- (TheTime.TimeZone > 0?L"-":L"+"),
- ((ABS(TheTime.TimeZone)) / 60),
+ (TheTime.TimeZone > 0 ? L"-" : L"+"),
+ ((ABS (TheTime.TimeZone)) / 60),
TzMinutes
);
} else {
@@ -490,8 +509,9 @@ ShellCommandRunTime (
TheTime.Second
);
}
+
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF), gShellLevel2HiiHandle);
- } else if (ShellCommandLineGetFlag(Package, L"-d") && ShellCommandLineGetValue(Package, L"-d") == NULL) {
+ } else if (ShellCommandLineGetFlag (Package, L"-d") && (ShellCommandLineGetValue (Package, L"-d") == NULL)) {
if (TheTime.TimeZone == EFI_UNSPECIFIED_TIMEZONE) {
ShellPrintHiiEx (
-1,
@@ -504,7 +524,7 @@ ShellCommandRunTime (
TheTime.Second
);
} else {
- TzMinutes = (ABS(TheTime.TimeZone)) % 60;
+ TzMinutes = (ABS (TheTime.TimeZone)) % 60;
ShellPrintHiiEx (
-1,
-1,
@@ -514,49 +534,49 @@ ShellCommandRunTime (
TheTime.Hour,
TheTime.Minute,
TheTime.Second,
- (TheTime.TimeZone > 0?L"-":L"+"),
- ((ABS(TheTime.TimeZone)) / 60),
+ (TheTime.TimeZone > 0 ? L"-" : L"+"),
+ ((ABS (TheTime.TimeZone)) / 60),
TzMinutes
- );
+ );
+ }
+
+ switch (TheTime.Daylight) {
+ case 0:
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_TIME_DST0), gShellLevel2HiiHandle);
+ break;
+ case EFI_TIME_ADJUST_DAYLIGHT:
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_TIME_DST1), gShellLevel2HiiHandle);
+ break;
+ case EFI_TIME_IN_DAYLIGHT:
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_TIME_DST2), gShellLevel2HiiHandle);
+ break;
+ case EFI_TIME_IN_DAYLIGHT|EFI_TIME_ADJUST_DAYLIGHT:
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_TIME_DST3), gShellLevel2HiiHandle);
+ break;
+ default:
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_ERROR), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", L"TheTime.Daylight", TheTime.Daylight);
}
- switch (TheTime.Daylight) {
- case 0:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST0), gShellLevel2HiiHandle);
- break;
- case EFI_TIME_ADJUST_DAYLIGHT:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST1), gShellLevel2HiiHandle);
- break;
- case EFI_TIME_IN_DAYLIGHT:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST2), gShellLevel2HiiHandle);
- break;
- case EFI_TIME_IN_DAYLIGHT|EFI_TIME_ADJUST_DAYLIGHT:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TIME_DST3), gShellLevel2HiiHandle);
- break;
- default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_ERROR), gShellLevel2HiiHandle, L"time", L"gRT->GetTime", L"TheTime.Daylight", TheTime.Daylight);
- }
} else {
- if (PcdGet8(PcdShellSupportLevel) == 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time");
+ if (PcdGet8 (PcdShellSupportLevel) == 2) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"time");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// perform level 3 operation here.
//
- if ((TempLocation = ShellCommandLineGetValue(Package, L"-tz")) != NULL) {
- if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16 *)TempLocation, L"_local") == 0) {
+ if ((TempLocation = ShellCommandLineGetValue (Package, L"-tz")) != NULL) {
+ if (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)TempLocation, L"_local") == 0) {
Tz = EFI_UNSPECIFIED_TIMEZONE;
} else if (TempLocation[0] == L'-') {
-
- Tz = (INT16) ShellStrToUintn (++TempLocation);
+ Tz = (INT16)ShellStrToUintn (++TempLocation);
//
// When the argument of "time [-tz tz]" is not numeric, ShellStrToUintn() returns "-1".
// Here we can detect the argument error by checking the return of ShellStrToUintn().
//
if (Tz == -1) {
- Tz = 1441; //make it to be out of bounds value
+ Tz = 1441; // make it to be out of bounds value
} else {
- Tz *= (-1); //sign convert
+ Tz *= (-1); // sign convert
}
} else {
if (TempLocation[0] == L'+') {
@@ -564,15 +584,17 @@ ShellCommandRunTime (
} else {
Tz = (INT16)ShellStrToUintn (TempLocation);
}
+
//
// Detect the return of ShellStrToUintn() to make sure the argument is valid.
//
if (Tz == -1) {
- Tz = 1441; //make it to be out of bounds value
+ Tz = 1441; // make it to be out of bounds value
}
}
- if (!(Tz >= -1440 && Tz <= 1440) && Tz != EFI_UNSPECIFIED_TIMEZONE) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"time", TempLocation, L"-tz");
+
+ if (!((Tz >= -1440) && (Tz <= 1440)) && (Tz != EFI_UNSPECIFIED_TIMEZONE)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"time", TempLocation, L"-tz");
ShellStatus = SHELL_INVALID_PARAMETER;
}
} else {
@@ -581,19 +603,21 @@ ShellCommandRunTime (
//
Tz = 1441;
}
- TempLocation = ShellCommandLineGetValue(Package, L"-d");
+
+ TempLocation = ShellCommandLineGetValue (Package, L"-d");
if (TempLocation != NULL) {
- Daylight = (UINT8)ShellStrToUintn(TempLocation);
+ Daylight = (UINT8)ShellStrToUintn (TempLocation);
//
// The argument of "time [-d dl]" is unsigned, if the first character is '-',
// the argument is incorrect. That's because ShellStrToUintn() will skip past
// any '-' sign and convert what's next, forgetting the sign is here.
//
if (TempLocation[0] == '-') {
- Daylight = 0xff; //make it invalid = will not use
+ Daylight = 0xff; // make it invalid = will not use
}
- if (Daylight != 0 && Daylight != 1 && Daylight != 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"time", TempLocation, L"-d");
+
+ if ((Daylight != 0) && (Daylight != 1) && (Daylight != 3)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"time", TempLocation, L"-d");
ShellStatus = SHELL_INVALID_PARAMETER;
}
} else {
@@ -602,10 +626,11 @@ ShellCommandRunTime (
//
Daylight = 0xFF;
}
+
if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = CheckAndSetTime(ShellCommandLineGetRawValue(Package, 1), Tz, Daylight);
+ ShellStatus = CheckAndSetTime (ShellCommandLineGetRawValue (Package, 1), Tz, Daylight);
if (ShellStatus != SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"time", ShellCommandLineGetRawValue(Package, 1));
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"time", ShellCommandLineGetRawValue (Package, 1));
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
@@ -626,59 +651,59 @@ ShellCommandRunTime (
}
typedef struct {
- INT16 TimeZone;
- EFI_STRING_ID StringId;
+ INT16 TimeZone;
+ EFI_STRING_ID StringId;
} TIME_ZONE_ITEM;
-STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList2[] = {
- {L"-l", TypeFlag},
- {L"-f", TypeFlag},
- {NULL, TypeMax}
- };
-STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3[] = {
- {L"-l", TypeFlag},
- {L"-f", TypeFlag},
- {L"-s", TypeTimeValue},
- {NULL, TypeMax}
- };
-
- STATIC CONST TIME_ZONE_ITEM TimeZoneList[] = {
- {720, STRING_TOKEN (STR_TIMEZONE_M12)},
- {660, STRING_TOKEN (STR_TIMEZONE_M11)},
- {600, STRING_TOKEN (STR_TIMEZONE_M10)},
- {540, STRING_TOKEN (STR_TIMEZONE_M9)},
- {480, STRING_TOKEN (STR_TIMEZONE_M8)},
- {420, STRING_TOKEN (STR_TIMEZONE_M7)},
- {360, STRING_TOKEN (STR_TIMEZONE_M6)},
- {300, STRING_TOKEN (STR_TIMEZONE_M5)},
- {270, STRING_TOKEN (STR_TIMEZONE_M430)},
- {240, STRING_TOKEN (STR_TIMEZONE_M4)},
- {210, STRING_TOKEN (STR_TIMEZONE_M330)},
- {180, STRING_TOKEN (STR_TIMEZONE_M3)},
- {120, STRING_TOKEN (STR_TIMEZONE_M2)},
- {60 , STRING_TOKEN (STR_TIMEZONE_M1)},
- {0 , STRING_TOKEN (STR_TIMEZONE_0)},
- {-60 , STRING_TOKEN (STR_TIMEZONE_P1)},
- {-120 , STRING_TOKEN (STR_TIMEZONE_P2)},
- {-180 , STRING_TOKEN (STR_TIMEZONE_P3)},
- {-210 , STRING_TOKEN (STR_TIMEZONE_P330)},
- {-240 , STRING_TOKEN (STR_TIMEZONE_P4)},
- {-270 , STRING_TOKEN (STR_TIMEZONE_P430)},
- {-300 , STRING_TOKEN (STR_TIMEZONE_P5)},
- {-330 , STRING_TOKEN (STR_TIMEZONE_P530)},
- {-345 , STRING_TOKEN (STR_TIMEZONE_P545)},
- {-360 , STRING_TOKEN (STR_TIMEZONE_P6)},
- {-390 , STRING_TOKEN (STR_TIMEZONE_P630)},
- {-420 , STRING_TOKEN (STR_TIMEZONE_P7)},
- {-480 , STRING_TOKEN (STR_TIMEZONE_P8)},
- {-540 , STRING_TOKEN (STR_TIMEZONE_P9)},
- {-570 , STRING_TOKEN (STR_TIMEZONE_P930)},
- {-600 , STRING_TOKEN (STR_TIMEZONE_P10)},
- {-660 , STRING_TOKEN (STR_TIMEZONE_P11)},
- {-720 , STRING_TOKEN (STR_TIMEZONE_P12)},
- {-780 , STRING_TOKEN (STR_TIMEZONE_P13)},
- {-840 , STRING_TOKEN (STR_TIMEZONE_P14)},
- {EFI_UNSPECIFIED_TIMEZONE, STRING_TOKEN (STR_TIMEZONE_LOCAL)}
+STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList2[] = {
+ { L"-l", TypeFlag },
+ { L"-f", TypeFlag },
+ { NULL, TypeMax }
+};
+STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3[] = {
+ { L"-l", TypeFlag },
+ { L"-f", TypeFlag },
+ { L"-s", TypeTimeValue },
+ { NULL, TypeMax }
+};
+
+STATIC CONST TIME_ZONE_ITEM TimeZoneList[] = {
+ { 720, STRING_TOKEN (STR_TIMEZONE_M12) },
+ { 660, STRING_TOKEN (STR_TIMEZONE_M11) },
+ { 600, STRING_TOKEN (STR_TIMEZONE_M10) },
+ { 540, STRING_TOKEN (STR_TIMEZONE_M9) },
+ { 480, STRING_TOKEN (STR_TIMEZONE_M8) },
+ { 420, STRING_TOKEN (STR_TIMEZONE_M7) },
+ { 360, STRING_TOKEN (STR_TIMEZONE_M6) },
+ { 300, STRING_TOKEN (STR_TIMEZONE_M5) },
+ { 270, STRING_TOKEN (STR_TIMEZONE_M430) },
+ { 240, STRING_TOKEN (STR_TIMEZONE_M4) },
+ { 210, STRING_TOKEN (STR_TIMEZONE_M330) },
+ { 180, STRING_TOKEN (STR_TIMEZONE_M3) },
+ { 120, STRING_TOKEN (STR_TIMEZONE_M2) },
+ { 60, STRING_TOKEN (STR_TIMEZONE_M1) },
+ { 0, STRING_TOKEN (STR_TIMEZONE_0) },
+ { -60, STRING_TOKEN (STR_TIMEZONE_P1) },
+ { -120, STRING_TOKEN (STR_TIMEZONE_P2) },
+ { -180, STRING_TOKEN (STR_TIMEZONE_P3) },
+ { -210, STRING_TOKEN (STR_TIMEZONE_P330) },
+ { -240, STRING_TOKEN (STR_TIMEZONE_P4) },
+ { -270, STRING_TOKEN (STR_TIMEZONE_P430) },
+ { -300, STRING_TOKEN (STR_TIMEZONE_P5) },
+ { -330, STRING_TOKEN (STR_TIMEZONE_P530) },
+ { -345, STRING_TOKEN (STR_TIMEZONE_P545) },
+ { -360, STRING_TOKEN (STR_TIMEZONE_P6) },
+ { -390, STRING_TOKEN (STR_TIMEZONE_P630) },
+ { -420, STRING_TOKEN (STR_TIMEZONE_P7) },
+ { -480, STRING_TOKEN (STR_TIMEZONE_P8) },
+ { -540, STRING_TOKEN (STR_TIMEZONE_P9) },
+ { -570, STRING_TOKEN (STR_TIMEZONE_P930) },
+ { -600, STRING_TOKEN (STR_TIMEZONE_P10) },
+ { -660, STRING_TOKEN (STR_TIMEZONE_P11) },
+ { -720, STRING_TOKEN (STR_TIMEZONE_P12) },
+ { -780, STRING_TOKEN (STR_TIMEZONE_P13) },
+ { -840, STRING_TOKEN (STR_TIMEZONE_P14) },
+ { EFI_UNSPECIFIED_TIMEZONE, STRING_TOKEN (STR_TIMEZONE_LOCAL) }
};
/**
@@ -693,63 +718,69 @@ STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3[] = {
**/
SHELL_STATUS
CheckAndSetTimeZone (
- IN CONST CHAR16 *TimeZoneString
+ IN CONST CHAR16 *TimeZoneString
)
{
- EFI_TIME TheTime;
- EFI_STATUS Status;
- CHAR16 *TimeZoneCopy;
- CHAR16 *Walker;
- CHAR16 *Walker2;
- UINTN LoopVar;
+ EFI_TIME TheTime;
+ EFI_STATUS Status;
+ CHAR16 *TimeZoneCopy;
+ CHAR16 *Walker;
+ CHAR16 *Walker2;
+ UINTN LoopVar;
if (TimeZoneString == NULL) {
return (SHELL_INVALID_PARAMETER);
}
- if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16 *)TimeZoneString, L"_local") == 0) {
+ if (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)TimeZoneString, L"_local") == 0) {
Status = gRT->GetTime (&TheTime, NULL);
if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);
return (SHELL_DEVICE_ERROR);
}
TheTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
- Status = gRT->SetTime (&TheTime);
- if (!EFI_ERROR(Status)){
+ Status = gRT->SetTime (&TheTime);
+ if (!EFI_ERROR (Status)) {
return (SHELL_SUCCESS);
}
+
return (SHELL_INVALID_PARAMETER);
}
- if (TimeZoneString != NULL && !InternalIsTimeLikeString(TimeZoneString, L':', 1, 1, TRUE)) {
+
+ if ((TimeZoneString != NULL) && !InternalIsTimeLikeString (TimeZoneString, L':', 1, 1, TRUE)) {
return (SHELL_INVALID_PARAMETER);
}
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"timezone", L"gRT->GetTime", Status);
+ Status = gRT->GetTime (&TheTime, NULL);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"timezone", L"gRT->GetTime", Status);
return (SHELL_DEVICE_ERROR);
}
TimeZoneCopy = NULL;
- TimeZoneCopy = StrnCatGrow(&TimeZoneCopy, NULL, TimeZoneString, 0);
+ TimeZoneCopy = StrnCatGrow (&TimeZoneCopy, NULL, TimeZoneString, 0);
if (TimeZoneCopy == NULL) {
return (SHELL_OUT_OF_RESOURCES);
}
- Walker = TimeZoneCopy;
- Walker2 = StrStr(Walker, L":");
- if (Walker2 != NULL && *Walker2 == L':') {
+
+ Walker = TimeZoneCopy;
+ Walker2 = StrStr (Walker, L":");
+ if ((Walker2 != NULL) && (*Walker2 == L':')) {
*Walker2 = CHAR_NULL;
}
+
if (*Walker == L'-') {
TheTime.TimeZone = (INT16)((ShellStrToUintn (++Walker)) * 60);
} else {
TheTime.TimeZone = (INT16)((INT16)(ShellStrToUintn (Walker)) * -60);
}
+
if (Walker2 != NULL) {
Walker = Walker2 + 1;
}
- if (Walker != NULL && Walker[0] != CHAR_NULL) {
+
+ if ((Walker != NULL) && (Walker[0] != CHAR_NULL)) {
if (TheTime.TimeZone < 0) {
TheTime.TimeZone = (INT16)(TheTime.TimeZone - (UINT8)ShellStrToUintn (Walker));
} else {
@@ -760,24 +791,25 @@ CheckAndSetTimeZone (
Status = EFI_INVALID_PARAMETER;
for ( LoopVar = 0
- ; LoopVar < sizeof(TimeZoneList) / sizeof(TimeZoneList[0])
- ; LoopVar++
- ){
+ ; LoopVar < sizeof (TimeZoneList) / sizeof (TimeZoneList[0])
+ ; LoopVar++
+ )
+ {
if (TheTime.TimeZone == TimeZoneList[LoopVar].TimeZone) {
- Status = gRT->SetTime(&TheTime);
- break;
+ Status = gRT->SetTime (&TheTime);
+ break;
}
}
- FreePool(TimeZoneCopy);
+ FreePool (TimeZoneCopy);
- if (!EFI_ERROR(Status)){
+ if (!EFI_ERROR (Status)) {
return (SHELL_SUCCESS);
}
+
return (SHELL_INVALID_PARAMETER);
}
-
/**
Function for 'timezone' command.
@@ -809,83 +841,86 @@ ShellCommandRunTimeZone (
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
- if (PcdGet8(PcdShellSupportLevel) == 2) {
+ if (PcdGet8 (PcdShellSupportLevel) == 2) {
Status = ShellCommandLineParse (TimeZoneParamList2, &Package, &ProblemParam, TRUE);
} else {
- ASSERT(PcdGet8(PcdShellSupportLevel) == 3);
+ ASSERT (PcdGet8 (PcdShellSupportLevel) == 3);
Status = ShellCommandLineParseEx (TimeZoneParamList3, &Package, &ProblemParam, TRUE, TRUE);
}
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"timezone", ProblemParam);
- FreePool(ProblemParam);
+
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"timezone", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetCount(Package) > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"timezone");
+ if (ShellCommandLineGetCount (Package) > 1) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"timezone");
ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
- } else if (ShellCommandLineGetFlag(Package, L"-s")) {
- if ((ShellCommandLineGetFlag(Package, L"-l")) || (ShellCommandLineGetFlag(Package, L"-f"))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"timezone", L"-l or -f");
+ } else if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
+ } else if (ShellCommandLineGetFlag (Package, L"-s")) {
+ if ((ShellCommandLineGetFlag (Package, L"-l")) || (ShellCommandLineGetFlag (Package, L"-f"))) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"timezone", L"-l or -f");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(PcdGet8(PcdShellSupportLevel) == 3);
- if (ShellCommandLineGetValue(Package, L"-s") == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"timezone", L"-s");
+ ASSERT (PcdGet8 (PcdShellSupportLevel) == 3);
+ if (ShellCommandLineGetValue (Package, L"-s") == NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"timezone", L"-s");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
// Set the time zone
//
- ShellStatus = CheckAndSetTimeZone(ShellCommandLineGetValue(Package, L"-s"));
+ ShellStatus = CheckAndSetTimeZone (ShellCommandLineGetValue (Package, L"-s"));
if (ShellStatus != SHELL_SUCCESS) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"timezone", ShellCommandLineGetValue(Package, L"-s"));
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"timezone", ShellCommandLineGetValue (Package, L"-s"));
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
}
- } else if (ShellCommandLineGetFlag(Package, L"-l")) {
+ } else if (ShellCommandLineGetFlag (Package, L"-l")) {
//
// Print a list of all time zones
//
for ( LoopVar = 0
- ; LoopVar < sizeof(TimeZoneList) / sizeof(TimeZoneList[0])
- ; LoopVar++
- ){
+ ; LoopVar < sizeof (TimeZoneList) / sizeof (TimeZoneList[0])
+ ; LoopVar++
+ )
+ {
ShellPrintHiiEx (-1, -1, NULL, TimeZoneList[LoopVar].StringId, gShellLevel2HiiHandle);
}
} else {
//
// Get Current Time Zone Info
//
- Status = gRT->GetTime(&TheTime, NULL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"timezone", L"gRT->GetTime", Status);
+ Status = gRT->GetTime (&TheTime, NULL);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"timezone", L"gRT->GetTime", Status);
return (SHELL_DEVICE_ERROR);
}
if (TheTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
Found = FALSE;
for ( LoopVar = 0
- ; LoopVar < sizeof(TimeZoneList) / sizeof(TimeZoneList[0])
- ; LoopVar++
- ){
+ ; LoopVar < sizeof (TimeZoneList) / sizeof (TimeZoneList[0])
+ ; LoopVar++
+ )
+ {
if (TheTime.TimeZone == TimeZoneList[LoopVar].TimeZone) {
- if (ShellCommandLineGetFlag(Package, L"-f")) {
+ if (ShellCommandLineGetFlag (Package, L"-f")) {
//
// Print all info about current time zone
//
@@ -894,40 +929,44 @@ ShellCommandRunTimeZone (
//
// Print basic info only
//
- TzMinutes = (ABS(TheTime.TimeZone)) % 60;
+ TzMinutes = (ABS (TheTime.TimeZone)) % 60;
ShellPrintHiiEx (
-1,
-1,
NULL,
- STRING_TOKEN(STR_TIMEZONE_SIMPLE),
+ STRING_TOKEN (STR_TIMEZONE_SIMPLE),
gShellLevel2HiiHandle,
- (TheTime.TimeZone > 0?L"-":L"+"),
- (ABS(TheTime.TimeZone)) / 60,
- TzMinutes);
+ (TheTime.TimeZone > 0 ? L"-" : L"+"),
+ (ABS (TheTime.TimeZone)) / 60,
+ TzMinutes
+ );
}
+
Found = TRUE;
break;
}
}
+
if (!Found) {
//
// Print basic info only
//
- TzMinutes = (ABS(TheTime.TimeZone)) % 60;
+ TzMinutes = (ABS (TheTime.TimeZone)) % 60;
ShellPrintHiiEx (
-1,
-1,
NULL,
- STRING_TOKEN(STR_TIMEZONE_SIMPLE),
+ STRING_TOKEN (STR_TIMEZONE_SIMPLE),
gShellLevel2HiiHandle,
- (TheTime.TimeZone > 0?L"-":L"+"),
- (ABS(TheTime.TimeZone)) / 60,
- TzMinutes);
+ (TheTime.TimeZone > 0 ? L"-" : L"+"),
+ (ABS (TheTime.TimeZone)) / 60,
+ TzMinutes
+ );
- if (ShellCommandLineGetFlag(Package, L"-f")) {
- ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_TIMEZONE_NI), gShellLevel2HiiHandle);
+ if (ShellCommandLineGetFlag (Package, L"-f")) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_TIMEZONE_NI), gShellLevel2HiiHandle);
}
}
} else {
@@ -936,9 +975,10 @@ ShellCommandRunTimeZone (
//
if (ShellCommandLineGetFlag (Package, L"-f")) {
for ( LoopVar = 0
- ; LoopVar < ARRAY_SIZE (TimeZoneList)
- ; LoopVar++
- ){
+ ; LoopVar < ARRAY_SIZE (TimeZoneList)
+ ; LoopVar++
+ )
+ {
if (TheTime.TimeZone == TimeZoneList[LoopVar].TimeZone) {
//
// Print all info about current time zone
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
index 69427637bb..794284d02e 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
@@ -28,15 +28,15 @@
**/
#include "UefiShellLevel2CommandsLib.h"
-CONST CHAR16 mFileName[] = L"ShellCommands";
-EFI_HII_HANDLE gShellLevel2HiiHandle = NULL;
+CONST CHAR16 mFileName[] = L"ShellCommands";
+EFI_HII_HANDLE gShellLevel2HiiHandle = NULL;
/**
Get the filename to get help text from if not using HII.
@retval The filename.
**/
-CONST CHAR16*
+CONST CHAR16 *
EFIAPI
ShellCommandGetManFileNameLevel2 (
VOID
@@ -66,7 +66,7 @@ ShellLevel2CommandsLibConstructor (
//
// if shell level is less than 2 do nothing
//
- if (PcdGet8(PcdShellSupportLevel) < 2) {
+ if (PcdGet8 (PcdShellSupportLevel) < 2) {
return (EFI_SUCCESS);
}
@@ -78,48 +78,48 @@ ShellLevel2CommandsLibConstructor (
//
// install our shell command handlers that are always installed
//
- ShellCommandRegisterCommandName(L"attrib", ShellCommandRunAttrib , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_ATTRIB) );
- ShellCommandRegisterCommandName(L"cd", ShellCommandRunCd , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_CD) );
- ShellCommandRegisterCommandName(L"cp", ShellCommandRunCp , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_CP) );
- ShellCommandRegisterCommandName(L"load", ShellCommandRunLoad , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_LOAD) );
- ShellCommandRegisterCommandName(L"map", ShellCommandRunMap , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_MAP) );
- ShellCommandRegisterCommandName(L"mkdir", ShellCommandRunMkDir , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_MKDIR) );
- ShellCommandRegisterCommandName(L"mv", ShellCommandRunMv , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_MV) );
- ShellCommandRegisterCommandName(L"parse", ShellCommandRunParse , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_PARSE) );
- ShellCommandRegisterCommandName(L"reset", ShellCommandRunReset , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_RESET) );
- ShellCommandRegisterCommandName(L"set", ShellCommandRunSet , ShellCommandGetManFileNameLevel2, 2, L"",FALSE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_SET) );
- ShellCommandRegisterCommandName(L"ls", ShellCommandRunLs , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_LS) );
- ShellCommandRegisterCommandName(L"rm", ShellCommandRunRm , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_RM) );
- ShellCommandRegisterCommandName(L"vol", ShellCommandRunVol , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_VOL) );
+ ShellCommandRegisterCommandName (L"attrib", ShellCommandRunAttrib, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_ATTRIB));
+ ShellCommandRegisterCommandName (L"cd", ShellCommandRunCd, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_CD));
+ ShellCommandRegisterCommandName (L"cp", ShellCommandRunCp, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_CP));
+ ShellCommandRegisterCommandName (L"load", ShellCommandRunLoad, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_LOAD));
+ ShellCommandRegisterCommandName (L"map", ShellCommandRunMap, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_MAP));
+ ShellCommandRegisterCommandName (L"mkdir", ShellCommandRunMkDir, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_MKDIR));
+ ShellCommandRegisterCommandName (L"mv", ShellCommandRunMv, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_MV));
+ ShellCommandRegisterCommandName (L"parse", ShellCommandRunParse, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_PARSE));
+ ShellCommandRegisterCommandName (L"reset", ShellCommandRunReset, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_RESET));
+ ShellCommandRegisterCommandName (L"set", ShellCommandRunSet, ShellCommandGetManFileNameLevel2, 2, L"", FALSE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_SET));
+ ShellCommandRegisterCommandName (L"ls", ShellCommandRunLs, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_LS));
+ ShellCommandRegisterCommandName (L"rm", ShellCommandRunRm, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_RM));
+ ShellCommandRegisterCommandName (L"vol", ShellCommandRunVol, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_VOL));
//
// support for permanent (built in) aliases
//
- ShellCommandRegisterAlias(L"rm", L"del");
- ShellCommandRegisterAlias(L"ls", L"dir");
- ShellCommandRegisterAlias(L"cp", L"copy");
- ShellCommandRegisterAlias(L"mkdir", L"md");
- ShellCommandRegisterAlias(L"cd ..", L"cd..");
- ShellCommandRegisterAlias(L"cd \\", L"cd\\");
- ShellCommandRegisterAlias(L"mv", L"ren");
- ShellCommandRegisterAlias(L"mv", L"move");
- ShellCommandRegisterAlias(L"map", L"mount");
+ ShellCommandRegisterAlias (L"rm", L"del");
+ ShellCommandRegisterAlias (L"ls", L"dir");
+ ShellCommandRegisterAlias (L"cp", L"copy");
+ ShellCommandRegisterAlias (L"mkdir", L"md");
+ ShellCommandRegisterAlias (L"cd ..", L"cd..");
+ ShellCommandRegisterAlias (L"cd \\", L"cd\\");
+ ShellCommandRegisterAlias (L"mv", L"ren");
+ ShellCommandRegisterAlias (L"mv", L"move");
+ ShellCommandRegisterAlias (L"map", L"mount");
//
// These are installed in level 2 or 3...
//
- if (PcdGet8(PcdShellSupportLevel) == 2 || PcdGet8(PcdShellSupportLevel) == 3) {
- ShellCommandRegisterCommandName(L"date", ShellCommandRunDate , ShellCommandGetManFileNameLevel2, PcdGet8(PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_DATE) );
- ShellCommandRegisterCommandName(L"time", ShellCommandRunTime , ShellCommandGetManFileNameLevel2, PcdGet8(PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIME) );
- ShellCommandRegisterCommandName(L"timezone", ShellCommandRunTimeZone, ShellCommandGetManFileNameLevel2, PcdGet8(PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIMEZONE));
+ if ((PcdGet8 (PcdShellSupportLevel) == 2) || (PcdGet8 (PcdShellSupportLevel) == 3)) {
+ ShellCommandRegisterCommandName (L"date", ShellCommandRunDate, ShellCommandGetManFileNameLevel2, PcdGet8 (PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_DATE));
+ ShellCommandRegisterCommandName (L"time", ShellCommandRunTime, ShellCommandGetManFileNameLevel2, PcdGet8 (PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_TIME));
+ ShellCommandRegisterCommandName (L"timezone", ShellCommandRunTimeZone, ShellCommandGetManFileNameLevel2, PcdGet8 (PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_TIMEZONE));
} else {
- DEBUG_CODE_BEGIN();
+ DEBUG_CODE_BEGIN ();
//
// we want to be able to test these so install them under a different name in debug mode...
//
- ShellCommandRegisterCommandName(L"l2date", ShellCommandRunDate , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_DATE) );
- ShellCommandRegisterCommandName(L"l2time", ShellCommandRunTime , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIME) );
- ShellCommandRegisterCommandName(L"l2timezone", ShellCommandRunTimeZone, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIMEZONE));
- DEBUG_CODE_END();
+ ShellCommandRegisterCommandName (L"l2date", ShellCommandRunDate, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_DATE));
+ ShellCommandRegisterCommandName (L"l2time", ShellCommandRunTime, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_TIME));
+ ShellCommandRegisterCommandName (L"l2timezone", ShellCommandRunTimeZone, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_TIMEZONE));
+ DEBUG_CODE_END ();
}
return (EFI_SUCCESS);
@@ -141,8 +141,9 @@ ShellLevel2CommandsLibDestructor (
)
{
if (gShellLevel2HiiHandle != NULL) {
- HiiRemovePackages(gShellLevel2HiiHandle);
+ HiiRemovePackages (gShellLevel2HiiHandle);
}
+
return (EFI_SUCCESS);
}
@@ -162,40 +163,41 @@ ShellLevel2CommandsLibDestructor (
@retval NULL A fully qualified path could not be discovered.
@retval other An allocated pointer to a fuly qualified path.
**/
-CHAR16*
-GetFullyQualifiedPath(
- IN CONST CHAR16* Path
+CHAR16 *
+GetFullyQualifiedPath (
+ IN CONST CHAR16 *Path
)
{
CHAR16 *PathToReturn;
UINTN Size;
CONST CHAR16 *CurDir;
- PathToReturn = NULL;
- Size = 0;
+ PathToReturn = NULL;
+ Size = 0;
- ASSERT((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL));
+ ASSERT ((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL));
//
// convert a local path to an absolute path
//
- if (StrStr(Path, L":") == NULL) {
- CurDir = gEfiShellProtocol->GetCurDir(NULL);
- StrnCatGrow(&PathToReturn, &Size, CurDir, 0);
- StrnCatGrow(&PathToReturn, &Size, L"\\", 0);
+ if (StrStr (Path, L":") == NULL) {
+ CurDir = gEfiShellProtocol->GetCurDir (NULL);
+ StrnCatGrow (&PathToReturn, &Size, CurDir, 0);
+ StrnCatGrow (&PathToReturn, &Size, L"\\", 0);
if (*Path == L'\\') {
Path++;
}
}
- StrnCatGrow(&PathToReturn, &Size, Path, 0);
- PathCleanUpDirectories(PathToReturn);
+ StrnCatGrow (&PathToReturn, &Size, Path, 0);
+
+ PathCleanUpDirectories (PathToReturn);
if (PathToReturn == NULL) {
return NULL;
}
- while (PathToReturn[StrLen(PathToReturn)-1] == L'*') {
- PathToReturn[StrLen(PathToReturn)-1] = CHAR_NULL;
+ while (PathToReturn[StrLen (PathToReturn)-1] == L'*') {
+ PathToReturn[StrLen (PathToReturn)-1] = CHAR_NULL;
}
return (PathToReturn);
@@ -210,46 +212,47 @@ GetFullyQualifiedPath(
**/
EFI_STATUS
VerifyIntermediateDirectories (
- IN CONST CHAR16 *Path
+ IN CONST CHAR16 *Path
)
{
- EFI_STATUS Status;
- CHAR16 *PathCopy;
- CHAR16 *TempSpot;
- SHELL_FILE_HANDLE FileHandle;
+ EFI_STATUS Status;
+ CHAR16 *PathCopy;
+ CHAR16 *TempSpot;
+ SHELL_FILE_HANDLE FileHandle;
- ASSERT(Path != NULL);
+ ASSERT (Path != NULL);
- Status = EFI_SUCCESS;
- PathCopy = NULL;
- PathCopy = StrnCatGrow(&PathCopy, NULL, Path, 0);
- FileHandle = NULL;
+ Status = EFI_SUCCESS;
+ PathCopy = NULL;
+ PathCopy = StrnCatGrow (&PathCopy, NULL, Path, 0);
+ FileHandle = NULL;
if (PathCopy == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- for (TempSpot = &PathCopy[StrLen(PathCopy)-1] ; *TempSpot != CHAR_NULL && *TempSpot != L'\\' ; TempSpot = &PathCopy[StrLen(PathCopy)-1]){
+ for (TempSpot = &PathCopy[StrLen (PathCopy)-1]; *TempSpot != CHAR_NULL && *TempSpot != L'\\'; TempSpot = &PathCopy[StrLen (PathCopy)-1]) {
*TempSpot = CHAR_NULL;
}
+
if (*TempSpot == L'\\') {
*TempSpot = CHAR_NULL;
}
- if (PathCopy != NULL && *PathCopy != CHAR_NULL) {
- Status = VerifyIntermediateDirectories(PathCopy);
+ if ((PathCopy != NULL) && (*PathCopy != CHAR_NULL)) {
+ Status = VerifyIntermediateDirectories (PathCopy);
- if (PathCopy[StrLen(PathCopy)-1] != L':') {
- if (!EFI_ERROR(Status)) {
- Status = ShellOpenFileByName(PathCopy, &FileHandle, EFI_FILE_MODE_READ, 0);
+ if (PathCopy[StrLen (PathCopy)-1] != L':') {
+ if (!EFI_ERROR (Status)) {
+ Status = ShellOpenFileByName (PathCopy, &FileHandle, EFI_FILE_MODE_READ, 0);
if (FileHandle != NULL) {
- ShellCloseFile(&FileHandle);
+ ShellCloseFile (&FileHandle);
}
}
}
}
- SHELL_FREE_NON_NULL(PathCopy);
+ SHELL_FREE_NON_NULL (PathCopy);
return (Status);
}
@@ -266,17 +269,17 @@ VerifyIntermediateDirectories (
**/
INTN
-StrniCmp(
- IN CONST CHAR16 *Source,
- IN CONST CHAR16 *Target,
- IN CONST UINTN Count
+StrniCmp (
+ IN CONST CHAR16 *Source,
+ IN CONST CHAR16 *Target,
+ IN CONST UINTN Count
)
{
- CHAR16 *SourceCopy;
- CHAR16 *TargetCopy;
- UINTN SourceLength;
- UINTN TargetLength;
- INTN Result;
+ CHAR16 *SourceCopy;
+ CHAR16 *TargetCopy;
+ UINTN SourceLength;
+ UINTN TargetLength;
+ INTN Result;
if (Count == 0) {
return 0;
@@ -286,10 +289,11 @@ StrniCmp(
TargetLength = StrLen (Target);
SourceLength = MIN (SourceLength, Count);
TargetLength = MIN (TargetLength, Count);
- SourceCopy = AllocateCopyPool ((SourceLength + 1) * sizeof (CHAR16), Source);
+ SourceCopy = AllocateCopyPool ((SourceLength + 1) * sizeof (CHAR16), Source);
if (SourceCopy == NULL) {
return -1;
}
+
TargetCopy = AllocateCopyPool ((TargetLength + 1) * sizeof (CHAR16), Target);
if (TargetCopy == NULL) {
FreePool (SourceCopy);
@@ -298,13 +302,12 @@ StrniCmp(
SourceCopy[SourceLength] = L'\0';
TargetCopy[TargetLength] = L'\0';
- Result = gUnicodeCollation->StriColl (gUnicodeCollation, SourceCopy, TargetCopy);
+ Result = gUnicodeCollation->StriColl (gUnicodeCollation, SourceCopy, TargetCopy);
FreePool (SourceCopy);
FreePool (TargetCopy);
return Result;
}
-
/**
Cleans off all the quotes in the string.
@@ -317,13 +320,13 @@ StrniCmp(
**/
EFI_STATUS
ShellLevel2StripQuotes (
- IN CONST CHAR16 *OriginalString,
- OUT CHAR16 **CleanString
+ IN CONST CHAR16 *OriginalString,
+ OUT CHAR16 **CleanString
)
{
- CHAR16 *Walker;
+ CHAR16 *Walker;
- if (OriginalString == NULL || CleanString == NULL) {
+ if ((OriginalString == NULL) || (CleanString == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -332,13 +335,11 @@ ShellLevel2StripQuotes (
return EFI_OUT_OF_RESOURCES;
}
- for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {
+ for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL; Walker++) {
if (*Walker == L'\"') {
- CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));
+ CopyMem (Walker, Walker+1, StrSize (Walker) - sizeof (Walker[0]));
}
}
return EFI_SUCCESS;
}
-
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
index 426b6490f4..7c525b31d0 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
@@ -42,8 +42,8 @@
#include <Library/SortLib.h>
#include <Library/FileHandleLib.h>
-extern CONST CHAR16 mFileName[];
-extern EFI_HII_HANDLE gShellLevel2HiiHandle;
+extern CONST CHAR16 mFileName[];
+extern EFI_HII_HANDLE gShellLevel2HiiHandle;
/**
Function for 'attrib' command.
@@ -256,9 +256,9 @@ ShellCommandRunMv (
@retval NULL a fully qualified path could not be discovered.
@retval other pointer to a fuly qualified path.
**/
-CHAR16*
-GetFullyQualifiedPath(
- IN CONST CHAR16* Path
+CHAR16 *
+GetFullyQualifiedPath (
+ IN CONST CHAR16 *Path
);
/**
@@ -270,7 +270,7 @@ GetFullyQualifiedPath(
**/
EFI_STATUS
VerifyIntermediateDirectories (
- IN CONST CHAR16 *Path
+ IN CONST CHAR16 *Path
);
/**
@@ -285,10 +285,10 @@ VerifyIntermediateDirectories (
**/
INTN
-StrniCmp(
- IN CONST CHAR16 *Source,
- IN CONST CHAR16 *Target,
- IN CONST UINTN Count
+StrniCmp (
+ IN CONST CHAR16 *Source,
+ IN CONST CHAR16 *Target,
+ IN CONST UINTN Count
);
/**
@@ -303,8 +303,8 @@ StrniCmp(
**/
EFI_STATUS
ShellLevel2StripQuotes (
- IN CONST CHAR16 *OriginalString,
- OUT CHAR16 **CleanString
+ IN CONST CHAR16 *OriginalString,
+ OUT CHAR16 **CleanString
);
/**
@@ -334,12 +334,12 @@ ShellCommandRunVol (
@retval SHELL_SUCCESS The source file was copied to the destination
**/
SHELL_STATUS
-CopySingleFile(
- IN CONST CHAR16 *Source,
- IN CONST CHAR16 *Dest,
- OUT VOID **Resp,
- IN BOOLEAN SilentMode,
- IN CONST CHAR16 *CmdName
+CopySingleFile (
+ IN CONST CHAR16 *Source,
+ IN CONST CHAR16 *Dest,
+ OUT VOID **Resp,
+ IN BOOLEAN SilentMode,
+ IN CONST CHAR16 *CmdName
);
/**
@@ -354,10 +354,9 @@ CopySingleFile(
@retval SHELL_DEVICE_ERROR A device error occurred reading this Node.
**/
SHELL_STATUS
-CascadeDelete(
+CascadeDelete (
IN EFI_SHELL_FILE_INFO *Node,
IN CONST BOOLEAN Quiet
);
#endif
-
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c
index 2ed97666b9..8f7310c074 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c
@@ -21,10 +21,10 @@
@retval SHELL_SUCCESS The operation was sucessful.
**/
SHELL_STATUS
-HandleVol(
- IN CONST CHAR16 *Path,
- IN CONST BOOLEAN Delete,
- IN CONST CHAR16 *Name OPTIONAL
+HandleVol (
+ IN CONST CHAR16 *Path,
+ IN CONST BOOLEAN Delete,
+ IN CONST CHAR16 *Name OPTIONAL
)
{
EFI_STATUS Status;
@@ -36,38 +36,40 @@ HandleVol(
UINTN Size1;
UINTN Size2;
- ShellStatus = SHELL_SUCCESS;
+ ShellStatus = SHELL_SUCCESS;
if (
- Name != NULL && (
- StrStr(Name, L"%") != NULL ||
- StrStr(Name, L"^") != NULL ||
- StrStr(Name, L"*") != NULL ||
- StrStr(Name, L"+") != NULL ||
- StrStr(Name, L"=") != NULL ||
- StrStr(Name, L"[") != NULL ||
- StrStr(Name, L"]") != NULL ||
- StrStr(Name, L"|") != NULL ||
- StrStr(Name, L":") != NULL ||
- StrStr(Name, L";") != NULL ||
- StrStr(Name, L"\"") != NULL ||
- StrStr(Name, L"<") != NULL ||
- StrStr(Name, L">") != NULL ||
- StrStr(Name, L"?") != NULL ||
- StrStr(Name, L"/") != NULL ||
- StrStr(Name, L" ") != NULL )
- ){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"vol", Name);
+ (Name != NULL) && (
+ (StrStr (Name, L"%") != NULL) ||
+ (StrStr (Name, L"^") != NULL) ||
+ (StrStr (Name, L"*") != NULL) ||
+ (StrStr (Name, L"+") != NULL) ||
+ (StrStr (Name, L"=") != NULL) ||
+ (StrStr (Name, L"[") != NULL) ||
+ (StrStr (Name, L"]") != NULL) ||
+ (StrStr (Name, L"|") != NULL) ||
+ (StrStr (Name, L":") != NULL) ||
+ (StrStr (Name, L";") != NULL) ||
+ (StrStr (Name, L"\"") != NULL) ||
+ (StrStr (Name, L"<") != NULL) ||
+ (StrStr (Name, L">") != NULL) ||
+ (StrStr (Name, L"?") != NULL) ||
+ (StrStr (Name, L"/") != NULL) ||
+ (StrStr (Name, L" ") != NULL))
+ )
+ {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"vol", Name);
return (SHELL_INVALID_PARAMETER);
}
- Status = gEfiShellProtocol->OpenFileByName(
- Path,
- &ShellFileHandle,
- Name != NULL?EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE:EFI_FILE_MODE_READ);
+ Status = gEfiShellProtocol->OpenFileByName (
+ Path,
+ &ShellFileHandle,
+ Name != NULL ? EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE : EFI_FILE_MODE_READ
+ );
- if (EFI_ERROR(Status) || ShellFileHandle == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"vol", Path);
+ if (EFI_ERROR (Status) || (ShellFileHandle == NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, L"vol", Path);
return (SHELL_ACCESS_DENIED);
}
@@ -76,86 +78,94 @@ HandleVol(
//
SysInfo = NULL;
SysInfoSize = 0;
- EfiFpHandle = ConvertShellHandleToEfiFileProtocol(ShellFileHandle);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo);
+ EfiFpHandle = ConvertShellHandleToEfiFileProtocol (ShellFileHandle);
+ Status = EfiFpHandle->GetInfo (
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ &SysInfoSize,
+ SysInfo
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- SysInfo = AllocateZeroPool(SysInfoSize);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo);
+ SysInfo = AllocateZeroPool (SysInfoSize);
+ Status = EfiFpHandle->GetInfo (
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ &SysInfoSize,
+ SysInfo
+ );
}
- ASSERT(SysInfo != NULL);
+ ASSERT (SysInfo != NULL);
if (Delete) {
- *((CHAR16 *) SysInfo->VolumeLabel) = CHAR_NULL;
- SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize(SysInfo->VolumeLabel);
- Status = EfiFpHandle->SetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- (UINTN)SysInfo->Size,
- SysInfo);
+ *((CHAR16 *)SysInfo->VolumeLabel) = CHAR_NULL;
+ SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (SysInfo->VolumeLabel);
+ Status = EfiFpHandle->SetInfo (
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ (UINTN)SysInfo->Size,
+ SysInfo
+ );
} else if (Name != NULL) {
- Size1 = StrSize(Name);
- Size2 = StrSize(SysInfo->VolumeLabel);
+ Size1 = StrSize (Name);
+ Size2 = StrSize (SysInfo->VolumeLabel);
if (Size1 > Size2) {
- SysInfo = ReallocatePool((UINTN)SysInfo->Size, (UINTN)SysInfo->Size + Size1 - Size2, SysInfo);
+ SysInfo = ReallocatePool ((UINTN)SysInfo->Size, (UINTN)SysInfo->Size + Size1 - Size2, SysInfo);
if (SysInfo == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"vol");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"vol");
ShellStatus = SHELL_OUT_OF_RESOURCES;
}
}
+
if (SysInfo != NULL) {
- StrCpyS ( (CHAR16 *) SysInfo->VolumeLabel,
- (Size1>Size2? Size1/sizeof(CHAR16) : Size2/sizeof(CHAR16)),
- Name
- );
+ StrCpyS (
+ (CHAR16 *)SysInfo->VolumeLabel,
+ (Size1 > Size2 ? Size1/sizeof (CHAR16) : Size2/sizeof (CHAR16)),
+ Name
+ );
SysInfo->Size = SIZE_OF_EFI_FILE_SYSTEM_INFO + Size1;
- Status = EfiFpHandle->SetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- (UINTN)SysInfo->Size,
- SysInfo);
+ Status = EfiFpHandle->SetInfo (
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ (UINTN)SysInfo->Size,
+ SysInfo
+ );
}
}
- FreePool(SysInfo);
+ FreePool (SysInfo);
- if (Delete || Name != NULL) {
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, L"vol", Path);
+ if (Delete || (Name != NULL)) {
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, L"vol", Path);
ShellStatus = SHELL_ACCESS_DENIED;
}
}
SysInfoSize = 0;
- SysInfo = NULL;
+ SysInfo = NULL;
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo);
+ Status = EfiFpHandle->GetInfo (
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ &SysInfoSize,
+ SysInfo
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- SysInfo = AllocateZeroPool(SysInfoSize);
- Status = EfiFpHandle->GetInfo(
- EfiFpHandle,
- &gEfiFileSystemInfoGuid,
- &SysInfoSize,
- SysInfo);
+ SysInfo = AllocateZeroPool (SysInfoSize);
+ Status = EfiFpHandle->GetInfo (
+ EfiFpHandle,
+ &gEfiFileSystemInfoGuid,
+ &SysInfoSize,
+ SysInfo
+ );
}
- gEfiShellProtocol->CloseFile(ShellFileHandle);
+ gEfiShellProtocol->CloseFile (ShellFileHandle);
- ASSERT(SysInfo != NULL);
+ ASSERT (SysInfo != NULL);
if (SysInfo != NULL) {
//
@@ -168,22 +178,22 @@ HandleVol(
STRING_TOKEN (STR_VOL_VOLINFO),
gShellLevel2HiiHandle,
SysInfo->VolumeLabel,
- SysInfo->ReadOnly?L"r":L"rw",
+ SysInfo->ReadOnly ? L"r" : L"rw",
SysInfo->VolumeSize,
SysInfo->FreeSpace,
SysInfo->BlockSize
- );
- SHELL_FREE_NON_NULL(SysInfo);
+ );
+ SHELL_FREE_NON_NULL (SysInfo);
}
return (ShellStatus);
}
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-d", TypeFlag},
- {L"-n", TypeValue},
- {NULL, TypeMax}
- };
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
+ { L"-d", TypeFlag },
+ { L"-n", TypeValue },
+ { NULL, TypeMax }
+};
/**
Function for 'Vol' command.
@@ -210,93 +220,96 @@ ShellCommandRunVol (
UINTN Length;
CONST CHAR16 *NewName;
- Length = 0;
- ProblemParam = NULL;
- ShellStatus = SHELL_SUCCESS;
- PathName = NULL;
- CurDir = NULL;
- FullPath = NULL;
+ Length = 0;
+ ProblemParam = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ PathName = NULL;
+ CurDir = NULL;
+ FullPath = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
//
// Fix local copies of the protocol pointers
//
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
+ Status = CommandInit ();
+ ASSERT_EFI_ERROR (Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"vol", ProblemParam);
- FreePool(ProblemParam);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"vol", ProblemParam);
+ FreePool (ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
} else {
//
// check for "-?"
//
- if (ShellCommandLineGetFlag(Package, L"-?")) {
- ASSERT(FALSE);
+ if (ShellCommandLineGetFlag (Package, L"-?")) {
+ ASSERT (FALSE);
}
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"vol");
+ if (ShellCommandLineGetCount (Package) > 2) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"vol");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- PathName = ShellCommandLineGetRawValue(Package, 1);
+ PathName = ShellCommandLineGetRawValue (Package, 1);
if (PathName == NULL) {
- CurDir = gEfiShellProtocol->GetCurDir(NULL);
+ CurDir = gEfiShellProtocol->GetCurDir (NULL);
if (CurDir == NULL) {
ShellStatus = SHELL_NOT_FOUND;
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"vol");
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"vol");
} else {
PathName = CurDir;
}
}
+
if (PathName != NULL) {
- TempSpot = StrStr(PathName, L":");
+ TempSpot = StrStr (PathName, L":");
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
- TempSpot = StrStr(PathName, L"\\");
+
+ TempSpot = StrStr (PathName, L"\\");
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
- StrnCatGrow(&FullPath, &Length, PathName, 0);
- StrnCatGrow(&FullPath, &Length, L":\\", 0);
- DeleteMode = ShellCommandLineGetFlag(Package, L"-d");
- NewName = ShellCommandLineGetValue(Package, L"-n");
- if (DeleteMode && ShellCommandLineGetFlag(Package, L"-n")) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellLevel2HiiHandle, L"vol", L"-d", L"-n");
+
+ StrnCatGrow (&FullPath, &Length, PathName, 0);
+ StrnCatGrow (&FullPath, &Length, L":\\", 0);
+ DeleteMode = ShellCommandLineGetFlag (Package, L"-d");
+ NewName = ShellCommandLineGetValue (Package, L"-n");
+ if (DeleteMode && ShellCommandLineGetFlag (Package, L"-n")) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellLevel2HiiHandle, L"vol", L"-d", L"-n");
ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-n") && NewName == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"vol", L"-n");
+ } else if (ShellCommandLineGetFlag (Package, L"-n") && (NewName == NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"vol", L"-n");
ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (NewName != NULL && StrLen(NewName) > 11) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"vol", NewName, L"-n");
+ } else if ((NewName != NULL) && (StrLen (NewName) > 11)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"vol", NewName, L"-n");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellStatus == SHELL_SUCCESS) {
- ShellStatus = HandleVol(
- FullPath,
- DeleteMode,
- NewName
- );
+ ShellStatus = HandleVol (
+ FullPath,
+ DeleteMode,
+ NewName
+ );
}
}
}
}
- SHELL_FREE_NON_NULL(FullPath);
+ SHELL_FREE_NON_NULL (FullPath);
//
// free the command line package