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>
This commit is contained in:
committed by
mergify[bot]
parent
c411b485b6
commit
47d20b54f9
@ -9,10 +9,10 @@
|
||||
|
||||
#include "UefiShellLevel1CommandsLib.h"
|
||||
|
||||
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
||||
{L"/b", TypeFlag},
|
||||
{NULL, TypeMax}
|
||||
};
|
||||
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
||||
{ L"/b", TypeFlag },
|
||||
{ NULL, TypeMax }
|
||||
};
|
||||
|
||||
/**
|
||||
Function for 'exit' command.
|
||||
@ -27,65 +27,64 @@ ShellCommandRunExit (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
LIST_ENTRY *Package;
|
||||
CHAR16 *ProblemParam;
|
||||
SHELL_STATUS ShellStatus;
|
||||
UINT64 RetVal;
|
||||
CONST CHAR16 *Return;
|
||||
EFI_STATUS Status;
|
||||
LIST_ENTRY *Package;
|
||||
CHAR16 *ProblemParam;
|
||||
SHELL_STATUS ShellStatus;
|
||||
UINT64 RetVal;
|
||||
CONST CHAR16 *Return;
|
||||
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
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);
|
||||
|
||||
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), gShellLevel1HiiHandle, L"exit", ProblemParam);
|
||||
FreePool(ProblemParam);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"exit", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
} else {
|
||||
|
||||
//
|
||||
// return the specified error code
|
||||
//
|
||||
Return = ShellCommandLineGetRawValue(Package, 1);
|
||||
Return = ShellCommandLineGetRawValue (Package, 1);
|
||||
if (Return != NULL) {
|
||||
Status = ShellConvertStringToUint64(Return, &RetVal, FALSE, FALSE);
|
||||
if (EFI_ERROR(Status)) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"exit", Return);
|
||||
Status = ShellConvertStringToUint64 (Return, &RetVal, FALSE, FALSE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"exit", Return);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
//
|
||||
// If we are in a batch file and /b then pass TRUE otherwise false...
|
||||
//
|
||||
ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), RetVal);
|
||||
ShellCommandRegisterExit ((BOOLEAN)(gEfiShellProtocol->BatchIsActive () && ShellCommandLineGetFlag (Package, L"/b")), RetVal);
|
||||
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
// If we are in a batch file and /b then pass TRUE otherwise false...
|
||||
//
|
||||
ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), 0);
|
||||
ShellCommandRegisterExit ((BOOLEAN)(gEfiShellProtocol->BatchIsActive () && ShellCommandLineGetFlag (Package, L"/b")), 0);
|
||||
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
}
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
|
@ -20,10 +20,10 @@
|
||||
**/
|
||||
BOOLEAN
|
||||
ShellIsValidForNumber (
|
||||
IN CONST CHAR16 *Number
|
||||
IN CONST CHAR16 *Number
|
||||
)
|
||||
{
|
||||
if (Number == NULL || *Number == CHAR_NULL) {
|
||||
if ((Number == NULL) || (*Number == CHAR_NULL)) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -31,17 +31,17 @@ ShellIsValidForNumber (
|
||||
Number++;
|
||||
}
|
||||
|
||||
if (StrLen(Number) == 0) {
|
||||
if (StrLen (Number) == 0) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if (StrLen(Number) >= 7) {
|
||||
if ((StrStr(Number, L" ") == NULL) || (((StrStr(Number, L" ") != NULL) && (StrStr(Number, L" ") - Number) >= 7))) {
|
||||
if (StrLen (Number) >= 7) {
|
||||
if ((StrStr (Number, L" ") == NULL) || (((StrStr (Number, L" ") != NULL) && ((StrStr (Number, L" ") - Number) >= 7)))) {
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ShellIsDecimalDigitCharacter(*Number)) {
|
||||
if (!ShellIsDecimalDigitCharacter (*Number)) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -61,28 +61,28 @@ ShellCommandRunEndFor (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN Found;
|
||||
SCRIPT_FILE *CurrentScriptFile;
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN Found;
|
||||
SCRIPT_FILE *CurrentScriptFile;
|
||||
|
||||
Status = CommandInit();
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
Status = CommandInit ();
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
if (!gEfiShellProtocol->BatchIsActive()) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"endfor");
|
||||
if (!gEfiShellProtocol->BatchIsActive ()) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"endfor");
|
||||
return (SHELL_UNSUPPORTED);
|
||||
}
|
||||
|
||||
if (gEfiShellParametersProtocol->Argc > 1) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"endfor");
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"endfor");
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE);
|
||||
Found = MoveToTag (GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile (), FALSE, FALSE, FALSE);
|
||||
|
||||
if (!Found) {
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile();
|
||||
ShellPrintHiiEx(
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
@ -90,26 +90,28 @@ ShellCommandRunEndFor (
|
||||
gShellLevel1HiiHandle,
|
||||
L"For",
|
||||
L"EndFor",
|
||||
CurrentScriptFile!=NULL
|
||||
&& CurrentScriptFile->CurrentCommand!=NULL
|
||||
? CurrentScriptFile->CurrentCommand->Line:0);
|
||||
CurrentScriptFile != NULL
|
||||
&& CurrentScriptFile->CurrentCommand != NULL
|
||||
? CurrentScriptFile->CurrentCommand->Line : 0
|
||||
);
|
||||
return (SHELL_NOT_FOUND);
|
||||
}
|
||||
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
INTN Current;
|
||||
INTN End;
|
||||
INTN Step;
|
||||
CHAR16 *ReplacementName;
|
||||
CHAR16 *CurrentValue;
|
||||
BOOLEAN RemoveSubstAlias;
|
||||
CHAR16 Set[1];
|
||||
} SHELL_FOR_INFO;
|
||||
#define SIZE_OF_SHELL_FOR_INFO OFFSET_OF (SHELL_FOR_INFO, Set)
|
||||
#define SHELL_FOR_INFO_SIGNATURE SIGNATURE_32 ('S', 'F', 'I', 's')
|
||||
UINT32 Signature;
|
||||
INTN Current;
|
||||
INTN End;
|
||||
INTN Step;
|
||||
CHAR16 *ReplacementName;
|
||||
CHAR16 *CurrentValue;
|
||||
BOOLEAN RemoveSubstAlias;
|
||||
CHAR16 Set[1];
|
||||
} SHELL_FOR_INFO;
|
||||
#define SIZE_OF_SHELL_FOR_INFO OFFSET_OF (SHELL_FOR_INFO, Set)
|
||||
#define SHELL_FOR_INFO_SIGNATURE SIGNATURE_32 ('S', 'F', 'I', 's')
|
||||
|
||||
/**
|
||||
Update the value of a given alias on the list. If the alias is not there then add it.
|
||||
@ -122,48 +124,52 @@ typedef struct {
|
||||
@retval EFI_OUT_OF_RESOURCES There was not enough free memory.
|
||||
**/
|
||||
EFI_STATUS
|
||||
InternalUpdateAliasOnList(
|
||||
IN CONST CHAR16 *Alias,
|
||||
IN CONST CHAR16 *CommandString,
|
||||
IN OUT LIST_ENTRY *List
|
||||
InternalUpdateAliasOnList (
|
||||
IN CONST CHAR16 *Alias,
|
||||
IN CONST CHAR16 *CommandString,
|
||||
IN OUT LIST_ENTRY *List
|
||||
)
|
||||
{
|
||||
ALIAS_LIST *Node;
|
||||
BOOLEAN Found;
|
||||
ALIAS_LIST *Node;
|
||||
BOOLEAN Found;
|
||||
|
||||
//
|
||||
// assert for NULL parameter
|
||||
//
|
||||
ASSERT(Alias != NULL);
|
||||
ASSERT (Alias != NULL);
|
||||
|
||||
//
|
||||
// check for the Alias
|
||||
//
|
||||
for ( Node = (ALIAS_LIST *)GetFirstNode(List), Found = FALSE
|
||||
; !IsNull(List, &Node->Link)
|
||||
; Node = (ALIAS_LIST *)GetNextNode(List, &Node->Link)
|
||||
){
|
||||
ASSERT(Node->CommandString != NULL);
|
||||
ASSERT(Node->Alias != NULL);
|
||||
if (StrCmp(Node->Alias, Alias)==0) {
|
||||
FreePool(Node->CommandString);
|
||||
for ( Node = (ALIAS_LIST *)GetFirstNode (List), Found = FALSE
|
||||
; !IsNull (List, &Node->Link)
|
||||
; Node = (ALIAS_LIST *)GetNextNode (List, &Node->Link)
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
ASSERT (Node->Alias != NULL);
|
||||
if (StrCmp (Node->Alias, Alias) == 0) {
|
||||
FreePool (Node->CommandString);
|
||||
Node->CommandString = NULL;
|
||||
Node->CommandString = StrnCatGrow(&Node->CommandString, NULL, CommandString, 0);
|
||||
Found = TRUE;
|
||||
Node->CommandString = StrnCatGrow (&Node->CommandString, NULL, CommandString, 0);
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Found) {
|
||||
Node = AllocateZeroPool(sizeof(ALIAS_LIST));
|
||||
Node = AllocateZeroPool (sizeof (ALIAS_LIST));
|
||||
if (Node == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
ASSERT(Node->Alias == NULL);
|
||||
Node->Alias = StrnCatGrow(&Node->Alias, NULL, Alias, 0);
|
||||
ASSERT(Node->CommandString == NULL);
|
||||
Node->CommandString = StrnCatGrow(&Node->CommandString, NULL, CommandString, 0);
|
||||
InsertTailList(List, &Node->Link);
|
||||
|
||||
ASSERT (Node->Alias == NULL);
|
||||
Node->Alias = StrnCatGrow (&Node->Alias, NULL, Alias, 0);
|
||||
ASSERT (Node->CommandString == NULL);
|
||||
Node->CommandString = StrnCatGrow (&Node->CommandString, NULL, CommandString, 0);
|
||||
InsertTailList (List, &Node->Link);
|
||||
}
|
||||
|
||||
return (EFI_SUCCESS);
|
||||
}
|
||||
|
||||
@ -177,31 +183,33 @@ InternalUpdateAliasOnList(
|
||||
@retval FALSE The alias is not on the list.
|
||||
**/
|
||||
BOOLEAN
|
||||
InternalIsAliasOnList(
|
||||
IN CONST CHAR16 *Alias,
|
||||
IN CONST LIST_ENTRY *List
|
||||
InternalIsAliasOnList (
|
||||
IN CONST CHAR16 *Alias,
|
||||
IN CONST LIST_ENTRY *List
|
||||
)
|
||||
{
|
||||
ALIAS_LIST *Node;
|
||||
ALIAS_LIST *Node;
|
||||
|
||||
//
|
||||
// assert for NULL parameter
|
||||
//
|
||||
ASSERT(Alias != NULL);
|
||||
ASSERT (Alias != NULL);
|
||||
|
||||
//
|
||||
// check for the Alias
|
||||
//
|
||||
for ( Node = (ALIAS_LIST *)GetFirstNode(List)
|
||||
; !IsNull(List, &Node->Link)
|
||||
; Node = (ALIAS_LIST *)GetNextNode(List, &Node->Link)
|
||||
){
|
||||
ASSERT(Node->CommandString != NULL);
|
||||
ASSERT(Node->Alias != NULL);
|
||||
if (StrCmp(Node->Alias, Alias)==0) {
|
||||
for ( Node = (ALIAS_LIST *)GetFirstNode (List)
|
||||
; !IsNull (List, &Node->Link)
|
||||
; Node = (ALIAS_LIST *)GetNextNode (List, &Node->Link)
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
ASSERT (Node->Alias != NULL);
|
||||
if (StrCmp (Node->Alias, Alias) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -212,35 +220,37 @@ InternalIsAliasOnList(
|
||||
@param[in, out] List The list to search.
|
||||
**/
|
||||
BOOLEAN
|
||||
InternalRemoveAliasFromList(
|
||||
IN CONST CHAR16 *Alias,
|
||||
IN OUT LIST_ENTRY *List
|
||||
InternalRemoveAliasFromList (
|
||||
IN CONST CHAR16 *Alias,
|
||||
IN OUT LIST_ENTRY *List
|
||||
)
|
||||
{
|
||||
ALIAS_LIST *Node;
|
||||
ALIAS_LIST *Node;
|
||||
|
||||
//
|
||||
// assert for NULL parameter
|
||||
//
|
||||
ASSERT(Alias != NULL);
|
||||
ASSERT (Alias != NULL);
|
||||
|
||||
//
|
||||
// check for the Alias
|
||||
//
|
||||
for ( Node = (ALIAS_LIST *)GetFirstNode(List)
|
||||
; !IsNull(List, &Node->Link)
|
||||
; Node = (ALIAS_LIST *)GetNextNode(List, &Node->Link)
|
||||
){
|
||||
ASSERT(Node->CommandString != NULL);
|
||||
ASSERT(Node->Alias != NULL);
|
||||
if (StrCmp(Node->Alias, Alias)==0) {
|
||||
RemoveEntryList(&Node->Link);
|
||||
FreePool(Node->Alias);
|
||||
FreePool(Node->CommandString);
|
||||
FreePool(Node);
|
||||
for ( Node = (ALIAS_LIST *)GetFirstNode (List)
|
||||
; !IsNull (List, &Node->Link)
|
||||
; Node = (ALIAS_LIST *)GetNextNode (List, &Node->Link)
|
||||
)
|
||||
{
|
||||
ASSERT (Node->CommandString != NULL);
|
||||
ASSERT (Node->Alias != NULL);
|
||||
if (StrCmp (Node->Alias, Alias) == 0) {
|
||||
RemoveEntryList (&Node->Link);
|
||||
FreePool (Node->Alias);
|
||||
FreePool (Node->CommandString);
|
||||
FreePool (Node);
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@ -254,15 +264,16 @@ InternalRemoveAliasFromList(
|
||||
@retval (UINTN)(-1) An error ocurred.
|
||||
**/
|
||||
UINTN
|
||||
ReturnUintn(
|
||||
IN CONST CHAR16 *String
|
||||
ReturnUintn (
|
||||
IN CONST CHAR16 *String
|
||||
)
|
||||
{
|
||||
UINT64 RetVal;
|
||||
UINT64 RetVal;
|
||||
|
||||
if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, FALSE, TRUE))) {
|
||||
if (!EFI_ERROR (ShellConvertStringToUint64 (String, &RetVal, FALSE, TRUE))) {
|
||||
return ((UINTN)RetVal);
|
||||
}
|
||||
|
||||
return ((UINTN)(-1));
|
||||
}
|
||||
|
||||
@ -279,51 +290,51 @@ ShellCommandRunFor (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
SHELL_STATUS ShellStatus;
|
||||
SCRIPT_FILE *CurrentScriptFile;
|
||||
CHAR16 *ArgSet;
|
||||
CHAR16 *ArgSetWalker;
|
||||
CHAR16 *Parameter;
|
||||
UINTN ArgSize;
|
||||
UINTN LoopVar;
|
||||
SHELL_FOR_INFO *Info;
|
||||
CHAR16 *TempString;
|
||||
CHAR16 *TempSpot;
|
||||
BOOLEAN FirstPass;
|
||||
EFI_SHELL_FILE_INFO *Node;
|
||||
EFI_SHELL_FILE_INFO *FileList;
|
||||
UINTN NewSize;
|
||||
EFI_STATUS Status;
|
||||
SHELL_STATUS ShellStatus;
|
||||
SCRIPT_FILE *CurrentScriptFile;
|
||||
CHAR16 *ArgSet;
|
||||
CHAR16 *ArgSetWalker;
|
||||
CHAR16 *Parameter;
|
||||
UINTN ArgSize;
|
||||
UINTN LoopVar;
|
||||
SHELL_FOR_INFO *Info;
|
||||
CHAR16 *TempString;
|
||||
CHAR16 *TempSpot;
|
||||
BOOLEAN FirstPass;
|
||||
EFI_SHELL_FILE_INFO *Node;
|
||||
EFI_SHELL_FILE_INFO *FileList;
|
||||
UINTN NewSize;
|
||||
|
||||
ArgSet = NULL;
|
||||
ArgSize = 0;
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
ArgSetWalker = NULL;
|
||||
TempString = NULL;
|
||||
Parameter = NULL;
|
||||
FirstPass = FALSE;
|
||||
ArgSet = NULL;
|
||||
ArgSize = 0;
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
ArgSetWalker = NULL;
|
||||
TempString = NULL;
|
||||
Parameter = NULL;
|
||||
FirstPass = FALSE;
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
if (!gEfiShellProtocol->BatchIsActive()) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"for");
|
||||
if (!gEfiShellProtocol->BatchIsActive ()) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"for");
|
||||
return (SHELL_UNSUPPORTED);
|
||||
}
|
||||
|
||||
if (gEfiShellParametersProtocol->Argc < 4) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"for");
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"for");
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile();
|
||||
ASSERT(CurrentScriptFile != NULL);
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
|
||||
ASSERT (CurrentScriptFile != NULL);
|
||||
|
||||
if ((CurrentScriptFile->CurrentCommand != NULL) && (CurrentScriptFile->CurrentCommand->Data == NULL)) {
|
||||
FirstPass = TRUE;
|
||||
@ -331,8 +342,8 @@ ShellCommandRunFor (
|
||||
//
|
||||
// Make sure that an End exists.
|
||||
//
|
||||
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx(
|
||||
if (!MoveToTag (GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
@ -340,156 +351,177 @@ ShellCommandRunFor (
|
||||
gShellLevel1HiiHandle,
|
||||
L"EndFor",
|
||||
L"For",
|
||||
CurrentScriptFile->CurrentCommand->Line);
|
||||
CurrentScriptFile->CurrentCommand->Line
|
||||
);
|
||||
return (SHELL_DEVICE_ERROR);
|
||||
}
|
||||
|
||||
//
|
||||
// Process the line.
|
||||
//
|
||||
if (gEfiShellParametersProtocol->Argv[1][0] != L'%' || gEfiShellParametersProtocol->Argv[1][2] != CHAR_NULL
|
||||
||!((gEfiShellParametersProtocol->Argv[1][1] >= L'a' && gEfiShellParametersProtocol->Argv[1][1] <= L'z')
|
||||
||(gEfiShellParametersProtocol->Argv[1][1] >= L'A' && gEfiShellParametersProtocol->Argv[1][1] <= L'Z'))
|
||||
) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_VAR), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[1]);
|
||||
if ( (gEfiShellParametersProtocol->Argv[1][0] != L'%') || (gEfiShellParametersProtocol->Argv[1][2] != CHAR_NULL)
|
||||
|| !( ((gEfiShellParametersProtocol->Argv[1][1] >= L'a') && (gEfiShellParametersProtocol->Argv[1][1] <= L'z'))
|
||||
|| ((gEfiShellParametersProtocol->Argv[1][1] >= L'A') && (gEfiShellParametersProtocol->Argv[1][1] <= L'Z')))
|
||||
)
|
||||
{
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_VAR), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[1]);
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if (gUnicodeCollation->StriColl(
|
||||
gUnicodeCollation,
|
||||
L"in",
|
||||
gEfiShellParametersProtocol->Argv[2]) == 0) {
|
||||
for (LoopVar = 0x3 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {
|
||||
ASSERT((ArgSet == NULL && ArgSize == 0) || (ArgSet != NULL));
|
||||
if (StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"*") != NULL
|
||||
||StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"?") != NULL
|
||||
||StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"[") != NULL
|
||||
||StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"]") != NULL) {
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
L"in",
|
||||
gEfiShellParametersProtocol->Argv[2]
|
||||
) == 0)
|
||||
{
|
||||
for (LoopVar = 0x3; LoopVar < gEfiShellParametersProtocol->Argc; LoopVar++) {
|
||||
ASSERT ((ArgSet == NULL && ArgSize == 0) || (ArgSet != NULL));
|
||||
if ( (StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L"*") != NULL)
|
||||
|| (StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L"?") != NULL)
|
||||
|| (StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L"[") != NULL)
|
||||
|| (StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L"]") != NULL))
|
||||
{
|
||||
FileList = NULL;
|
||||
Status = ShellOpenFileMetaArg ((CHAR16*)gEfiShellParametersProtocol->Argv[LoopVar], EFI_FILE_MODE_READ, &FileList);
|
||||
if (EFI_ERROR(Status) || FileList == NULL || IsListEmpty(&FileList->Link)) {
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0);
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
|
||||
Status = ShellOpenFileMetaArg ((CHAR16 *)gEfiShellParametersProtocol->Argv[LoopVar], EFI_FILE_MODE_READ, &FileList);
|
||||
if (EFI_ERROR (Status) || (FileList == NULL) || IsListEmpty (&FileList->Link)) {
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, L" \"", 0);
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, L"\"", 0);
|
||||
} else {
|
||||
for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
|
||||
; !IsNull(&FileList->Link, &Node->Link)
|
||||
; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
|
||||
){
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0);
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Node->FullName, 0);
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
|
||||
for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link)
|
||||
; !IsNull (&FileList->Link, &Node->Link)
|
||||
; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &Node->Link)
|
||||
)
|
||||
{
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, L" \"", 0);
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, Node->FullName, 0);
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, L"\"", 0);
|
||||
}
|
||||
ShellCloseFileMetaArg(&FileList);
|
||||
|
||||
ShellCloseFileMetaArg (&FileList);
|
||||
}
|
||||
} else {
|
||||
Parameter = gEfiShellParametersProtocol->Argv[LoopVar];
|
||||
if (Parameter[0] == L'\"' && Parameter[StrLen(Parameter)-1] == L'\"') {
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Parameter, 0);
|
||||
if ((Parameter[0] == L'\"') && (Parameter[StrLen (Parameter)-1] == L'\"')) {
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, L" ", 0);
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, Parameter, 0);
|
||||
} else {
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0);
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Parameter, 0);
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, L" \"", 0);
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, Parameter, 0);
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, L"\"", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ArgSet == NULL) {
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
//
|
||||
// set up for an 'in' for loop
|
||||
//
|
||||
NewSize = StrSize(ArgSet);
|
||||
NewSize += sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]);
|
||||
Info = AllocateZeroPool(NewSize);
|
||||
NewSize = StrSize (ArgSet);
|
||||
NewSize += sizeof (SHELL_FOR_INFO)+StrSize (gEfiShellParametersProtocol->Argv[1]);
|
||||
Info = AllocateZeroPool (NewSize);
|
||||
if (Info == NULL) {
|
||||
FreePool (ArgSet);
|
||||
return SHELL_OUT_OF_RESOURCES;
|
||||
}
|
||||
Info->Signature = SHELL_FOR_INFO_SIGNATURE;
|
||||
CopyMem(Info->Set, ArgSet, StrSize(ArgSet));
|
||||
NewSize = StrSize(gEfiShellParametersProtocol->Argv[1]);
|
||||
CopyMem(Info->Set+(StrSize(ArgSet)/sizeof(Info->Set[0])), gEfiShellParametersProtocol->Argv[1], NewSize);
|
||||
Info->ReplacementName = Info->Set+StrSize(ArgSet)/sizeof(Info->Set[0]);
|
||||
Info->CurrentValue = (CHAR16*)Info->Set;
|
||||
Info->Step = 0;
|
||||
Info->Current = 0;
|
||||
Info->End = 0;
|
||||
|
||||
if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) {
|
||||
Info->RemoveSubstAlias = FALSE;
|
||||
Info->Signature = SHELL_FOR_INFO_SIGNATURE;
|
||||
CopyMem (Info->Set, ArgSet, StrSize (ArgSet));
|
||||
NewSize = StrSize (gEfiShellParametersProtocol->Argv[1]);
|
||||
CopyMem (Info->Set+(StrSize (ArgSet)/sizeof (Info->Set[0])), gEfiShellParametersProtocol->Argv[1], NewSize);
|
||||
Info->ReplacementName = Info->Set+StrSize (ArgSet)/sizeof (Info->Set[0]);
|
||||
Info->CurrentValue = (CHAR16 *)Info->Set;
|
||||
Info->Step = 0;
|
||||
Info->Current = 0;
|
||||
Info->End = 0;
|
||||
|
||||
if (InternalIsAliasOnList (Info->ReplacementName, &CurrentScriptFile->SubstList)) {
|
||||
Info->RemoveSubstAlias = FALSE;
|
||||
} else {
|
||||
Info->RemoveSubstAlias = TRUE;
|
||||
Info->RemoveSubstAlias = TRUE;
|
||||
}
|
||||
|
||||
CurrentScriptFile->CurrentCommand->Data = Info;
|
||||
}
|
||||
} else if (gUnicodeCollation->StriColl(
|
||||
gUnicodeCollation,
|
||||
L"run",
|
||||
gEfiShellParametersProtocol->Argv[2]) == 0) {
|
||||
for (LoopVar = 0x3 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {
|
||||
ASSERT((ArgSet == NULL && ArgSize == 0) || (ArgSet != NULL));
|
||||
if (StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L")") != NULL &&
|
||||
(LoopVar + 1) < gEfiShellParametersProtocol->Argc
|
||||
) {
|
||||
} else if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
L"run",
|
||||
gEfiShellParametersProtocol->Argv[2]
|
||||
) == 0)
|
||||
{
|
||||
for (LoopVar = 0x3; LoopVar < gEfiShellParametersProtocol->Argc; LoopVar++) {
|
||||
ASSERT ((ArgSet == NULL && ArgSize == 0) || (ArgSet != NULL));
|
||||
if ((StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L")") != NULL) &&
|
||||
((LoopVar + 1) < gEfiShellParametersProtocol->Argc)
|
||||
)
|
||||
{
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if (ArgSet == NULL) {
|
||||
// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
|
||||
// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
|
||||
} else {
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, L" ", 0);
|
||||
}
|
||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);
|
||||
// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
|
||||
|
||||
ArgSet = StrnCatGrow (&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);
|
||||
// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
|
||||
}
|
||||
|
||||
if (ArgSet == NULL) {
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
//
|
||||
// set up for a 'run' for loop
|
||||
//
|
||||
Info = AllocateZeroPool(sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]));
|
||||
Info = AllocateZeroPool (sizeof (SHELL_FOR_INFO)+StrSize (gEfiShellParametersProtocol->Argv[1]));
|
||||
if (Info == NULL) {
|
||||
FreePool (ArgSet);
|
||||
return SHELL_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Info->Signature = SHELL_FOR_INFO_SIGNATURE;
|
||||
CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1]));
|
||||
CopyMem (Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize (gEfiShellParametersProtocol->Argv[1]));
|
||||
Info->ReplacementName = Info->Set;
|
||||
Info->CurrentValue = NULL;
|
||||
ArgSetWalker = ArgSet;
|
||||
ArgSetWalker = ArgSet;
|
||||
if (ArgSetWalker[0] != L'(') {
|
||||
ShellPrintHiiEx(
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||
gShellLevel1HiiHandle,
|
||||
ArgSet,
|
||||
CurrentScriptFile->CurrentCommand->Line);
|
||||
CurrentScriptFile->CurrentCommand->Line
|
||||
);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
TempSpot = StrStr(ArgSetWalker, L")");
|
||||
TempSpot = StrStr (ArgSetWalker, L")");
|
||||
if (TempSpot != NULL) {
|
||||
TempString = TempSpot+1;
|
||||
if (*(TempString) != CHAR_NULL) {
|
||||
while(TempString != NULL && *TempString == L' ') {
|
||||
while (TempString != NULL && *TempString == L' ') {
|
||||
TempString++;
|
||||
}
|
||||
if (StrLen(TempString) > 0) {
|
||||
|
||||
if (StrLen (TempString) > 0) {
|
||||
TempSpot = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TempSpot == NULL) {
|
||||
ShellPrintHiiEx(
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||
gShellLevel1HiiHandle,
|
||||
CurrentScriptFile->CurrentCommand->Line);
|
||||
CurrentScriptFile->CurrentCommand->Line
|
||||
);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
*TempSpot = CHAR_NULL;
|
||||
@ -497,139 +529,152 @@ ShellCommandRunFor (
|
||||
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
|
||||
ArgSetWalker++;
|
||||
}
|
||||
if (!ShellIsValidForNumber(ArgSetWalker)) {
|
||||
ShellPrintHiiEx(
|
||||
|
||||
if (!ShellIsValidForNumber (ArgSetWalker)) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||
gShellLevel1HiiHandle,
|
||||
ArgSet,
|
||||
CurrentScriptFile->CurrentCommand->Line);
|
||||
CurrentScriptFile->CurrentCommand->Line
|
||||
);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
if (ArgSetWalker[0] == L'-') {
|
||||
Info->Current = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
|
||||
Info->Current = 0 - (INTN)ReturnUintn (ArgSetWalker+1);
|
||||
} else {
|
||||
Info->Current = (INTN)ReturnUintn(ArgSetWalker);
|
||||
Info->Current = (INTN)ReturnUintn (ArgSetWalker);
|
||||
}
|
||||
ArgSetWalker = StrStr(ArgSetWalker, L" ");
|
||||
|
||||
ArgSetWalker = StrStr (ArgSetWalker, L" ");
|
||||
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
|
||||
ArgSetWalker++;
|
||||
}
|
||||
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
|
||||
ShellPrintHiiEx(
|
||||
|
||||
if ((ArgSetWalker == NULL) || (*ArgSetWalker == CHAR_NULL) || !ShellIsValidForNumber (ArgSetWalker)) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||
gShellLevel1HiiHandle,
|
||||
ArgSet,
|
||||
CurrentScriptFile->CurrentCommand->Line);
|
||||
CurrentScriptFile->CurrentCommand->Line
|
||||
);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
if (ArgSetWalker[0] == L'-') {
|
||||
Info->End = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
|
||||
Info->End = 0 - (INTN)ReturnUintn (ArgSetWalker+1);
|
||||
} else {
|
||||
Info->End = (INTN)ReturnUintn(ArgSetWalker);
|
||||
}
|
||||
if (Info->Current < Info->End) {
|
||||
Info->Step = 1;
|
||||
} else {
|
||||
Info->Step = -1;
|
||||
Info->End = (INTN)ReturnUintn (ArgSetWalker);
|
||||
}
|
||||
|
||||
ArgSetWalker = StrStr(ArgSetWalker, L" ");
|
||||
if (Info->Current < Info->End) {
|
||||
Info->Step = 1;
|
||||
} else {
|
||||
Info->Step = -1;
|
||||
}
|
||||
|
||||
ArgSetWalker = StrStr (ArgSetWalker, L" ");
|
||||
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
|
||||
ArgSetWalker++;
|
||||
}
|
||||
if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) {
|
||||
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
|
||||
ShellPrintHiiEx(
|
||||
|
||||
if ((ArgSetWalker != NULL) && (*ArgSetWalker != CHAR_NULL)) {
|
||||
if ((ArgSetWalker == NULL) || (*ArgSetWalker == CHAR_NULL) || !ShellIsValidForNumber (ArgSetWalker)) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||
gShellLevel1HiiHandle,
|
||||
ArgSet,
|
||||
CurrentScriptFile->CurrentCommand->Line);
|
||||
CurrentScriptFile->CurrentCommand->Line
|
||||
);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
if (*ArgSetWalker == L')') {
|
||||
ASSERT(Info->Step == 1 || Info->Step == -1);
|
||||
ASSERT (Info->Step == 1 || Info->Step == -1);
|
||||
} else {
|
||||
if (ArgSetWalker[0] == L'-') {
|
||||
Info->Step = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
|
||||
Info->Step = 0 - (INTN)ReturnUintn (ArgSetWalker+1);
|
||||
} else {
|
||||
Info->Step = (INTN)ReturnUintn(ArgSetWalker);
|
||||
Info->Step = (INTN)ReturnUintn (ArgSetWalker);
|
||||
}
|
||||
|
||||
if (StrStr(ArgSetWalker, L" ") != NULL) {
|
||||
ShellPrintHiiEx(
|
||||
if (StrStr (ArgSetWalker, L" ") != NULL) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||
gShellLevel1HiiHandle,
|
||||
ArgSet,
|
||||
CurrentScriptFile->CurrentCommand->Line);
|
||||
CurrentScriptFile->CurrentCommand->Line
|
||||
);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) {
|
||||
Info->RemoveSubstAlias = FALSE;
|
||||
if (InternalIsAliasOnList (Info->ReplacementName, &CurrentScriptFile->SubstList)) {
|
||||
Info->RemoveSubstAlias = FALSE;
|
||||
} else {
|
||||
Info->RemoveSubstAlias = TRUE;
|
||||
Info->RemoveSubstAlias = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (CurrentScriptFile->CurrentCommand != NULL) {
|
||||
CurrentScriptFile->CurrentCommand->Data = Info;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ShellPrintHiiEx(
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||
gShellLevel1HiiHandle,
|
||||
ArgSet,
|
||||
CurrentScriptFile!=NULL
|
||||
&& CurrentScriptFile->CurrentCommand!=NULL
|
||||
? CurrentScriptFile->CurrentCommand->Line:0);
|
||||
CurrentScriptFile != NULL
|
||||
&& CurrentScriptFile->CurrentCommand != NULL
|
||||
? CurrentScriptFile->CurrentCommand->Line : 0
|
||||
);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// These need to be NULL since they are used to determine if this is the first pass later on...
|
||||
//
|
||||
ASSERT(ArgSetWalker == NULL);
|
||||
ASSERT(ArgSet == NULL);
|
||||
ASSERT (ArgSetWalker == NULL);
|
||||
ASSERT (ArgSet == NULL);
|
||||
}
|
||||
|
||||
if (CurrentScriptFile != NULL && CurrentScriptFile->CurrentCommand != NULL) {
|
||||
Info = (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data;
|
||||
if ((CurrentScriptFile != NULL) && (CurrentScriptFile->CurrentCommand != NULL)) {
|
||||
Info = (SHELL_FOR_INFO *)CurrentScriptFile->CurrentCommand->Data;
|
||||
if (CurrentScriptFile->CurrentCommand->Reset) {
|
||||
if (Info != NULL) {
|
||||
Info->CurrentValue = (CHAR16*)Info->Set;
|
||||
Info->CurrentValue = (CHAR16 *)Info->Set;
|
||||
}
|
||||
FirstPass = TRUE;
|
||||
|
||||
FirstPass = TRUE;
|
||||
CurrentScriptFile->CurrentCommand->Reset = FALSE;
|
||||
}
|
||||
} else {
|
||||
ShellStatus = SHELL_UNSUPPORTED;
|
||||
Info = NULL;
|
||||
Info = NULL;
|
||||
}
|
||||
|
||||
if (ShellStatus == SHELL_SUCCESS) {
|
||||
ASSERT(Info != NULL);
|
||||
ASSERT (Info != NULL);
|
||||
if (Info->Step != 0) {
|
||||
//
|
||||
// only advance if not the first pass
|
||||
@ -641,18 +686,18 @@ ShellCommandRunFor (
|
||||
Info->Current += Info->Step;
|
||||
}
|
||||
|
||||
TempString = AllocateZeroPool(50*sizeof(CHAR16));
|
||||
UnicodeSPrint(TempString, 50*sizeof(CHAR16), L"%d", Info->Current);
|
||||
InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);
|
||||
FreePool(TempString);
|
||||
TempString = AllocateZeroPool (50*sizeof (CHAR16));
|
||||
UnicodeSPrint (TempString, 50*sizeof (CHAR16), L"%d", Info->Current);
|
||||
InternalUpdateAliasOnList (Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);
|
||||
FreePool (TempString);
|
||||
|
||||
if ((Info->Step > 0 && Info->Current > Info->End) || (Info->Step < 0 && Info->Current < Info->End)) {
|
||||
if (((Info->Step > 0) && (Info->Current > Info->End)) || ((Info->Step < 0) && (Info->Current < Info->End))) {
|
||||
CurrentScriptFile->CurrentCommand->Data = NULL;
|
||||
//
|
||||
// find the matching endfor (we're done with the loop)
|
||||
//
|
||||
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
|
||||
ShellPrintHiiEx(
|
||||
if (!MoveToTag (GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
@ -660,61 +705,69 @@ ShellCommandRunFor (
|
||||
gShellLevel1HiiHandle,
|
||||
L"EndFor",
|
||||
L"For",
|
||||
CurrentScriptFile!=NULL
|
||||
&& CurrentScriptFile->CurrentCommand!=NULL
|
||||
? CurrentScriptFile->CurrentCommand->Line:0);
|
||||
CurrentScriptFile != NULL
|
||||
&& CurrentScriptFile->CurrentCommand != NULL
|
||||
? CurrentScriptFile->CurrentCommand->Line : 0
|
||||
);
|
||||
ShellStatus = SHELL_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (Info->RemoveSubstAlias) {
|
||||
//
|
||||
// remove item from list
|
||||
//
|
||||
InternalRemoveAliasFromList(Info->ReplacementName, &CurrentScriptFile->SubstList);
|
||||
InternalRemoveAliasFromList (Info->ReplacementName, &CurrentScriptFile->SubstList);
|
||||
}
|
||||
FreePool(Info);
|
||||
|
||||
FreePool (Info);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Must be in 'in' version of for loop...
|
||||
//
|
||||
ASSERT(Info->Set != NULL);
|
||||
if (Info->CurrentValue != NULL && *Info->CurrentValue != CHAR_NULL) {
|
||||
ASSERT (Info->Set != NULL);
|
||||
if ((Info->CurrentValue != NULL) && (*Info->CurrentValue != CHAR_NULL)) {
|
||||
if (Info->CurrentValue[0] == L' ') {
|
||||
Info->CurrentValue++;
|
||||
}
|
||||
|
||||
if (Info->CurrentValue[0] == L'\"') {
|
||||
Info->CurrentValue++;
|
||||
}
|
||||
|
||||
//
|
||||
// do the next one of the set
|
||||
//
|
||||
ASSERT(TempString == NULL);
|
||||
TempString = StrnCatGrow(&TempString, NULL, Info->CurrentValue, 0);
|
||||
ASSERT (TempString == NULL);
|
||||
TempString = StrnCatGrow (&TempString, NULL, Info->CurrentValue, 0);
|
||||
if (TempString == NULL) {
|
||||
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
TempSpot = StrStr(TempString, L"\" \"");
|
||||
TempSpot = StrStr (TempString, L"\" \"");
|
||||
if (TempSpot != NULL) {
|
||||
*TempSpot = CHAR_NULL;
|
||||
}
|
||||
while (TempString[StrLen(TempString)-1] == L'\"') {
|
||||
TempString[StrLen(TempString)-1] = CHAR_NULL;
|
||||
|
||||
while (TempString[StrLen (TempString)-1] == L'\"') {
|
||||
TempString[StrLen (TempString)-1] = CHAR_NULL;
|
||||
}
|
||||
InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);
|
||||
Info->CurrentValue += StrLen(TempString);
|
||||
|
||||
InternalUpdateAliasOnList (Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);
|
||||
Info->CurrentValue += StrLen (TempString);
|
||||
|
||||
if (Info->CurrentValue[0] == L'\"') {
|
||||
Info->CurrentValue++;
|
||||
}
|
||||
FreePool(TempString);
|
||||
|
||||
FreePool (TempString);
|
||||
}
|
||||
} else {
|
||||
CurrentScriptFile->CurrentCommand->Data = NULL;
|
||||
//
|
||||
// find the matching endfor (we're done with the loop)
|
||||
//
|
||||
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
|
||||
ShellPrintHiiEx(
|
||||
if (!MoveToTag (GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
@ -722,24 +775,28 @@ ShellCommandRunFor (
|
||||
gShellLevel1HiiHandle,
|
||||
L"EndFor",
|
||||
L"For",
|
||||
CurrentScriptFile!=NULL
|
||||
&& CurrentScriptFile->CurrentCommand!=NULL
|
||||
? CurrentScriptFile->CurrentCommand->Line:0);
|
||||
CurrentScriptFile != NULL
|
||||
&& CurrentScriptFile->CurrentCommand != NULL
|
||||
? CurrentScriptFile->CurrentCommand->Line : 0
|
||||
);
|
||||
ShellStatus = SHELL_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (Info->RemoveSubstAlias) {
|
||||
//
|
||||
// remove item from list
|
||||
//
|
||||
InternalRemoveAliasFromList(Info->ReplacementName, &CurrentScriptFile->SubstList);
|
||||
InternalRemoveAliasFromList (Info->ReplacementName, &CurrentScriptFile->SubstList);
|
||||
}
|
||||
FreePool(Info);
|
||||
|
||||
FreePool (Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ArgSet != NULL) {
|
||||
FreePool(ArgSet);
|
||||
FreePool (ArgSet);
|
||||
}
|
||||
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
|
@ -22,28 +22,28 @@ ShellCommandRunGoto (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
LIST_ENTRY *Package;
|
||||
CHAR16 *ProblemParam;
|
||||
SHELL_STATUS ShellStatus;
|
||||
CHAR16 *CompareString;
|
||||
UINTN Size;
|
||||
SCRIPT_FILE *CurrentScriptFile;
|
||||
EFI_STATUS Status;
|
||||
LIST_ENTRY *Package;
|
||||
CHAR16 *ProblemParam;
|
||||
SHELL_STATUS ShellStatus;
|
||||
CHAR16 *CompareString;
|
||||
UINTN Size;
|
||||
SCRIPT_FILE *CurrentScriptFile;
|
||||
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
CompareString = NULL;
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
CompareString = 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);
|
||||
|
||||
if (!gEfiShellProtocol->BatchIsActive()) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Goto");
|
||||
if (!gEfiShellProtocol->BatchIsActive ()) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Goto");
|
||||
return (SHELL_UNSUPPORTED);
|
||||
}
|
||||
|
||||
@ -51,32 +51,32 @@ ShellCommandRunGoto (
|
||||
// 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), gShellLevel1HiiHandle, L"goto", ProblemParam);
|
||||
FreePool(ProblemParam);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"goto", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
} else {
|
||||
if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"goto");
|
||||
if (ShellCommandLineGetRawValue (Package, 2) != NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"goto");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"goto");
|
||||
} else if (ShellCommandLineGetRawValue (Package, 1) == NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"goto");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
Size = 0;
|
||||
ASSERT((CompareString == NULL && Size == 0) || (CompareString != NULL));
|
||||
CompareString = StrnCatGrow(&CompareString, &Size, L":", 0);
|
||||
CompareString = StrnCatGrow(&CompareString, &Size, ShellCommandLineGetRawValue(Package, 1), 0);
|
||||
ASSERT ((CompareString == NULL && Size == 0) || (CompareString != NULL));
|
||||
CompareString = StrnCatGrow (&CompareString, &Size, L":", 0);
|
||||
CompareString = StrnCatGrow (&CompareString, &Size, ShellCommandLineGetRawValue (Package, 1), 0);
|
||||
//
|
||||
// Check forwards and then backwards for a label...
|
||||
//
|
||||
if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) {
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile();
|
||||
ShellPrintHiiEx(
|
||||
if (!MoveToTag (GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile (), FALSE, FALSE, TRUE)) {
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
-1,
|
||||
NULL,
|
||||
@ -84,16 +84,18 @@ ShellCommandRunGoto (
|
||||
gShellLevel1HiiHandle,
|
||||
CompareString,
|
||||
L"Goto",
|
||||
CurrentScriptFile!=NULL
|
||||
&& CurrentScriptFile->CurrentCommand!=NULL
|
||||
? CurrentScriptFile->CurrentCommand->Line:0);
|
||||
CurrentScriptFile != NULL
|
||||
&& CurrentScriptFile->CurrentCommand != NULL
|
||||
? CurrentScriptFile->CurrentCommand->Line : 0
|
||||
);
|
||||
ShellStatus = SHELL_NOT_FOUND;
|
||||
}
|
||||
FreePool(CompareString);
|
||||
|
||||
FreePool (CompareString);
|
||||
}
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -22,37 +22,38 @@ ShellCommandRunShift (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
SCRIPT_FILE *CurrentScriptFile;
|
||||
UINTN LoopVar;
|
||||
EFI_STATUS Status;
|
||||
SCRIPT_FILE *CurrentScriptFile;
|
||||
UINTN LoopVar;
|
||||
|
||||
Status = CommandInit();
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
Status = CommandInit ();
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
if (!gEfiShellProtocol->BatchIsActive()) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"shift");
|
||||
if (!gEfiShellProtocol->BatchIsActive ()) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"shift");
|
||||
return (SHELL_UNSUPPORTED);
|
||||
}
|
||||
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile();
|
||||
ASSERT(CurrentScriptFile != NULL);
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
|
||||
ASSERT (CurrentScriptFile != NULL);
|
||||
|
||||
if (CurrentScriptFile->Argc < 2) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"shift");
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"shift");
|
||||
return (SHELL_UNSUPPORTED);
|
||||
}
|
||||
|
||||
for (LoopVar = 0 ; LoopVar < CurrentScriptFile->Argc ; LoopVar++) {
|
||||
for (LoopVar = 0; LoopVar < CurrentScriptFile->Argc; LoopVar++) {
|
||||
if (LoopVar == 0) {
|
||||
SHELL_FREE_NON_NULL(CurrentScriptFile->Argv[LoopVar]);
|
||||
SHELL_FREE_NON_NULL (CurrentScriptFile->Argv[LoopVar]);
|
||||
}
|
||||
|
||||
if (LoopVar < CurrentScriptFile->Argc -1) {
|
||||
CurrentScriptFile->Argv[LoopVar] = CurrentScriptFile->Argv[LoopVar+1];
|
||||
} else {
|
||||
CurrentScriptFile->Argv[LoopVar] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
CurrentScriptFile->Argc--;
|
||||
return (SHELL_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -22,57 +22,58 @@ ShellCommandRunStall (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
LIST_ENTRY *Package;
|
||||
CHAR16 *ProblemParam;
|
||||
SHELL_STATUS ShellStatus;
|
||||
UINT64 Intermediate;
|
||||
EFI_STATUS Status;
|
||||
LIST_ENTRY *Package;
|
||||
CHAR16 *ProblemParam;
|
||||
SHELL_STATUS ShellStatus;
|
||||
UINT64 Intermediate;
|
||||
|
||||
ShellStatus = SHELL_SUCCESS;
|
||||
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);
|
||||
|
||||
Status = CommandInit();
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
Status = CommandInit ();
|
||||
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), gShellLevel1HiiHandle, L"stall", ProblemParam);
|
||||
FreePool(ProblemParam);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"stall", ProblemParam);
|
||||
FreePool (ProblemParam);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
} else {
|
||||
if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"stall");
|
||||
if (ShellCommandLineGetRawValue (Package, 2) != NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"stall");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"stall");
|
||||
} else if (ShellCommandLineGetRawValue (Package, 1) == NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"stall");
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
Status = ShellConvertStringToUint64(ShellCommandLineGetRawValue(Package, 1), &Intermediate, FALSE, FALSE);
|
||||
if (EFI_ERROR(Status) || ((UINT64)(UINTN)(Intermediate)) != Intermediate) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"stall", ShellCommandLineGetRawValue(Package, 1));
|
||||
Status = ShellConvertStringToUint64 (ShellCommandLineGetRawValue (Package, 1), &Intermediate, FALSE, FALSE);
|
||||
if (EFI_ERROR (Status) || (((UINT64)(UINTN)(Intermediate)) != Intermediate)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"stall", ShellCommandLineGetRawValue (Package, 1));
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
} else {
|
||||
Status = gBS->Stall((UINTN)Intermediate);
|
||||
if (EFI_ERROR(Status)) {
|
||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_STALL_FAILED), gShellLevel1HiiHandle, L"stall");
|
||||
Status = gBS->Stall ((UINTN)Intermediate);
|
||||
if (EFI_ERROR (Status)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_STALL_FAILED), gShellLevel1HiiHandle, L"stall");
|
||||
ShellStatus = SHELL_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
}
|
||||
|
||||
return (ShellStatus);
|
||||
}
|
||||
|
||||
|
@ -9,15 +9,15 @@
|
||||
|
||||
#include "UefiShellLevel1CommandsLib.h"
|
||||
|
||||
STATIC CONST CHAR16 mFileName[] = L"ShellCommands";
|
||||
EFI_HII_HANDLE gShellLevel1HiiHandle = NULL;
|
||||
STATIC CONST CHAR16 mFileName[] = L"ShellCommands";
|
||||
EFI_HII_HANDLE gShellLevel1HiiHandle = NULL;
|
||||
|
||||
/**
|
||||
Return the help text filename. Only used if no HII information found.
|
||||
|
||||
@retval the filename.
|
||||
**/
|
||||
CONST CHAR16*
|
||||
CONST CHAR16 *
|
||||
EFIAPI
|
||||
ShellCommandGetManFileNameLevel1 (
|
||||
VOID
|
||||
@ -47,7 +47,7 @@ ShellLevel1CommandsLibConstructor (
|
||||
//
|
||||
// if shell level is less than 2 do nothing
|
||||
//
|
||||
if (PcdGet8(PcdShellSupportLevel) < 1) {
|
||||
if (PcdGet8 (PcdShellSupportLevel) < 1) {
|
||||
return (EFI_SUCCESS);
|
||||
}
|
||||
|
||||
@ -59,15 +59,15 @@ ShellLevel1CommandsLibConstructor (
|
||||
//
|
||||
// install our shell command handlers that are always installed
|
||||
//
|
||||
ShellCommandRegisterCommandName(L"stall", ShellCommandRunStall , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_STALL) ));
|
||||
ShellCommandRegisterCommandName(L"for", ShellCommandRunFor , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_FOR) ));
|
||||
ShellCommandRegisterCommandName(L"goto", ShellCommandRunGoto , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_GOTO) ));
|
||||
ShellCommandRegisterCommandName(L"if", ShellCommandRunIf , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_IF) ));
|
||||
ShellCommandRegisterCommandName(L"shift", ShellCommandRunShift , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_SHIFT) ));
|
||||
ShellCommandRegisterCommandName(L"exit", ShellCommandRunExit , ShellCommandGetManFileNameLevel1, 1, L"", TRUE , gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_EXIT) ));
|
||||
ShellCommandRegisterCommandName(L"else", ShellCommandRunElse , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_ELSE) ));
|
||||
ShellCommandRegisterCommandName(L"endif", ShellCommandRunEndIf , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_ENDIF) ));
|
||||
ShellCommandRegisterCommandName(L"endfor", ShellCommandRunEndFor , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_ENDFOR)));
|
||||
ShellCommandRegisterCommandName (L"stall", ShellCommandRunStall, ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8 (PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN (STR_GET_HELP_STALL)));
|
||||
ShellCommandRegisterCommandName (L"for", ShellCommandRunFor, ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8 (PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN (STR_GET_HELP_FOR)));
|
||||
ShellCommandRegisterCommandName (L"goto", ShellCommandRunGoto, ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8 (PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN (STR_GET_HELP_GOTO)));
|
||||
ShellCommandRegisterCommandName (L"if", ShellCommandRunIf, ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8 (PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN (STR_GET_HELP_IF)));
|
||||
ShellCommandRegisterCommandName (L"shift", ShellCommandRunShift, ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8 (PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN (STR_GET_HELP_SHIFT)));
|
||||
ShellCommandRegisterCommandName (L"exit", ShellCommandRunExit, ShellCommandGetManFileNameLevel1, 1, L"", TRUE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8 (PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN (STR_GET_HELP_EXIT)));
|
||||
ShellCommandRegisterCommandName (L"else", ShellCommandRunElse, ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8 (PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN (STR_GET_HELP_ELSE)));
|
||||
ShellCommandRegisterCommandName (L"endif", ShellCommandRunEndIf, ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8 (PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN (STR_GET_HELP_ENDIF)));
|
||||
ShellCommandRegisterCommandName (L"endfor", ShellCommandRunEndFor, ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8 (PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN (STR_GET_HELP_ENDFOR)));
|
||||
|
||||
return (EFI_SUCCESS);
|
||||
}
|
||||
@ -86,8 +86,9 @@ ShellLevel1CommandsLibDestructor (
|
||||
)
|
||||
{
|
||||
if (gShellLevel1HiiHandle != NULL) {
|
||||
HiiRemovePackages(gShellLevel1HiiHandle);
|
||||
HiiRemovePackages (gShellLevel1HiiHandle);
|
||||
}
|
||||
|
||||
return (EFI_SUCCESS);
|
||||
}
|
||||
|
||||
@ -127,18 +128,18 @@ TestNodeForMove (
|
||||
IN OUT UINTN *TargetCount
|
||||
)
|
||||
{
|
||||
BOOLEAN Found;
|
||||
CHAR16 *CommandName;
|
||||
CHAR16 *CommandNameWalker;
|
||||
CHAR16 *TempLocation;
|
||||
BOOLEAN Found;
|
||||
CHAR16 *CommandName;
|
||||
CHAR16 *CommandNameWalker;
|
||||
CHAR16 *TempLocation;
|
||||
|
||||
Found = FALSE;
|
||||
|
||||
//
|
||||
// get just the first part of the command line...
|
||||
//
|
||||
CommandName = NULL;
|
||||
CommandName = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0);
|
||||
CommandName = NULL;
|
||||
CommandName = StrnCatGrow (&CommandName, NULL, CommandNode->Cl, 0);
|
||||
if (CommandName == NULL) {
|
||||
return (FALSE);
|
||||
}
|
||||
@ -151,7 +152,8 @@ TestNodeForMove (
|
||||
while ((CommandNameWalker[0] == L' ') || (CommandNameWalker[0] == L'\t')) {
|
||||
CommandNameWalker++;
|
||||
}
|
||||
TempLocation = StrStr(CommandNameWalker, L" ");
|
||||
|
||||
TempLocation = StrStr (CommandNameWalker, L" ");
|
||||
|
||||
if (TempLocation != NULL) {
|
||||
*TempLocation = CHAR_NULL;
|
||||
@ -160,15 +162,19 @@ TestNodeForMove (
|
||||
//
|
||||
// did we find a nested item ?
|
||||
//
|
||||
if (gUnicodeCollation->StriColl(
|
||||
gUnicodeCollation,
|
||||
(CHAR16*)CommandNameWalker,
|
||||
(CHAR16*)IncrementerTag) == 0) {
|
||||
if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandNameWalker,
|
||||
(CHAR16 *)IncrementerTag
|
||||
) == 0)
|
||||
{
|
||||
(*TargetCount)++;
|
||||
} else if (gUnicodeCollation->StriColl(
|
||||
gUnicodeCollation,
|
||||
(CHAR16*)CommandNameWalker,
|
||||
(CHAR16*)DecrementerTag) == 0) {
|
||||
} else if (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandNameWalker,
|
||||
(CHAR16 *)DecrementerTag
|
||||
) == 0)
|
||||
{
|
||||
if (*TargetCount > 0) {
|
||||
(*TargetCount)--;
|
||||
}
|
||||
@ -189,11 +195,13 @@ TestNodeForMove (
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (gUnicodeCollation->StriColl(
|
||||
gUnicodeCollation,
|
||||
(CHAR16*)CommandNameWalker,
|
||||
(CHAR16*)Label) == 0
|
||||
&& (*TargetCount) == 0) {
|
||||
if ( (gUnicodeCollation->StriColl (
|
||||
gUnicodeCollation,
|
||||
(CHAR16 *)CommandNameWalker,
|
||||
(CHAR16 *)Label
|
||||
) == 0)
|
||||
&& ((*TargetCount) == 0))
|
||||
{
|
||||
Found = TRUE;
|
||||
if (!FindOnly) {
|
||||
//
|
||||
@ -211,7 +219,7 @@ TestNodeForMove (
|
||||
//
|
||||
// Free the memory for this loop...
|
||||
//
|
||||
FreePool(CommandName);
|
||||
FreePool (CommandName);
|
||||
return (Found);
|
||||
}
|
||||
|
||||
@ -240,24 +248,24 @@ TestNodeForMove (
|
||||
**/
|
||||
BOOLEAN
|
||||
MoveToTag (
|
||||
IN CONST LIST_MANIP_FUNC Function,
|
||||
IN CONST CHAR16 *DecrementerTag,
|
||||
IN CONST CHAR16 *IncrementerTag,
|
||||
IN CONST CHAR16 *Label OPTIONAL,
|
||||
IN OUT SCRIPT_FILE *ScriptFile,
|
||||
IN CONST BOOLEAN MovePast,
|
||||
IN CONST BOOLEAN FindOnly,
|
||||
IN CONST BOOLEAN WrapAroundScript
|
||||
IN CONST LIST_MANIP_FUNC Function,
|
||||
IN CONST CHAR16 *DecrementerTag,
|
||||
IN CONST CHAR16 *IncrementerTag,
|
||||
IN CONST CHAR16 *Label OPTIONAL,
|
||||
IN OUT SCRIPT_FILE *ScriptFile,
|
||||
IN CONST BOOLEAN MovePast,
|
||||
IN CONST BOOLEAN FindOnly,
|
||||
IN CONST BOOLEAN WrapAroundScript
|
||||
)
|
||||
{
|
||||
SCRIPT_COMMAND_LIST *CommandNode;
|
||||
BOOLEAN Found;
|
||||
UINTN TargetCount;
|
||||
SCRIPT_COMMAND_LIST *CommandNode;
|
||||
BOOLEAN Found;
|
||||
UINTN TargetCount;
|
||||
|
||||
if (Label == NULL) {
|
||||
TargetCount = 1;
|
||||
TargetCount = 1;
|
||||
} else {
|
||||
TargetCount = 0;
|
||||
TargetCount = 0;
|
||||
}
|
||||
|
||||
if (ScriptFile == NULL) {
|
||||
@ -265,38 +273,42 @@ MoveToTag (
|
||||
}
|
||||
|
||||
for (CommandNode = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &ScriptFile->CurrentCommand->Link), Found = FALSE
|
||||
; !IsNull(&ScriptFile->CommandList, &CommandNode->Link)&& !Found
|
||||
; CommandNode = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &CommandNode->Link)
|
||||
){
|
||||
Found = TestNodeForMove(
|
||||
Function,
|
||||
DecrementerTag,
|
||||
IncrementerTag,
|
||||
Label,
|
||||
ScriptFile,
|
||||
MovePast,
|
||||
FindOnly,
|
||||
CommandNode,
|
||||
&TargetCount);
|
||||
; !IsNull (&ScriptFile->CommandList, &CommandNode->Link) && !Found
|
||||
; CommandNode = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &CommandNode->Link)
|
||||
)
|
||||
{
|
||||
Found = TestNodeForMove (
|
||||
Function,
|
||||
DecrementerTag,
|
||||
IncrementerTag,
|
||||
Label,
|
||||
ScriptFile,
|
||||
MovePast,
|
||||
FindOnly,
|
||||
CommandNode,
|
||||
&TargetCount
|
||||
);
|
||||
}
|
||||
|
||||
if (WrapAroundScript && !Found) {
|
||||
for (CommandNode = (SCRIPT_COMMAND_LIST *)GetFirstNode(&ScriptFile->CommandList), Found = FALSE
|
||||
; CommandNode != ScriptFile->CurrentCommand && !Found
|
||||
; CommandNode = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &CommandNode->Link)
|
||||
){
|
||||
Found = TestNodeForMove(
|
||||
Function,
|
||||
DecrementerTag,
|
||||
IncrementerTag,
|
||||
Label,
|
||||
ScriptFile,
|
||||
MovePast,
|
||||
FindOnly,
|
||||
CommandNode,
|
||||
&TargetCount);
|
||||
for (CommandNode = (SCRIPT_COMMAND_LIST *)GetFirstNode (&ScriptFile->CommandList), Found = FALSE
|
||||
; CommandNode != ScriptFile->CurrentCommand && !Found
|
||||
; CommandNode = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &CommandNode->Link)
|
||||
)
|
||||
{
|
||||
Found = TestNodeForMove (
|
||||
Function,
|
||||
DecrementerTag,
|
||||
IncrementerTag,
|
||||
Label,
|
||||
ScriptFile,
|
||||
MovePast,
|
||||
FindOnly,
|
||||
CommandNode,
|
||||
&TargetCount
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (Found);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <Library/HiiLib.h>
|
||||
#include <Library/FileHandleLib.h>
|
||||
|
||||
extern EFI_HII_HANDLE gShellLevel1HiiHandle;
|
||||
extern EFI_HII_HANDLE gShellLevel1HiiHandle;
|
||||
|
||||
/**
|
||||
Function for 'stall' command.
|
||||
@ -139,7 +139,6 @@ ShellCommandRunShift (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Function for 'else' command.
|
||||
|
||||
@ -189,15 +188,14 @@ LIST_ENTRY *
|
||||
**/
|
||||
BOOLEAN
|
||||
MoveToTag (
|
||||
IN CONST LIST_MANIP_FUNC Function,
|
||||
IN CONST CHAR16 *DecrementerTag,
|
||||
IN CONST CHAR16 *IncrementerTag,
|
||||
IN CONST CHAR16 *Label OPTIONAL,
|
||||
IN OUT SCRIPT_FILE *ScriptFile,
|
||||
IN CONST BOOLEAN MovePast,
|
||||
IN CONST BOOLEAN FindOnly,
|
||||
IN CONST BOOLEAN WrapAroundScript
|
||||
IN CONST LIST_MANIP_FUNC Function,
|
||||
IN CONST CHAR16 *DecrementerTag,
|
||||
IN CONST CHAR16 *IncrementerTag,
|
||||
IN CONST CHAR16 *Label OPTIONAL,
|
||||
IN OUT SCRIPT_FILE *ScriptFile,
|
||||
IN CONST BOOLEAN MovePast,
|
||||
IN CONST BOOLEAN FindOnly,
|
||||
IN CONST BOOLEAN WrapAroundScript
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user