From 6c128c65b5ec0e5b8b5a0ccb165f3afd29e485f8 Mon Sep 17 00:00:00 2001 From: Guo Mang Date: Wed, 2 Aug 2017 09:54:47 +0800 Subject: Remove core packages since we can get them from edk2 repository Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang --- ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c | 97 -- ShellPkg/Library/UefiShellLevel1CommandsLib/For.c | 748 ------------- ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c | 105 -- ShellPkg/Library/UefiShellLevel1CommandsLib/If.c | 1099 -------------------- .../Library/UefiShellLevel1CommandsLib/Shift.c | 64 -- .../Library/UefiShellLevel1CommandsLib/Stall.c | 84 -- .../UefiShellLevel1CommandsLib.c | 310 ------ .../UefiShellLevel1CommandsLib.h | 211 ---- .../UefiShellLevel1CommandsLib.inf | 58 -- .../UefiShellLevel1CommandsLib.uni | Bin 43930 -> 0 bytes 10 files changed, 2776 deletions(-) delete mode 100644 ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c delete mode 100644 ShellPkg/Library/UefiShellLevel1CommandsLib/For.c delete mode 100644 ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c delete mode 100644 ShellPkg/Library/UefiShellLevel1CommandsLib/If.c delete mode 100644 ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c delete mode 100644 ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c delete mode 100644 ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c delete mode 100644 ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.h delete mode 100644 ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf delete mode 100644 ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni (limited to 'ShellPkg/Library/UefiShellLevel1CommandsLib') diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c deleted file mode 100644 index 08e40dfc05..0000000000 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c +++ /dev/null @@ -1,97 +0,0 @@ -/** @file - Main file for exit shell level 1 function. - - (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "UefiShellLevel1CommandsLib.h" - -STATIC CONST SHELL_PARAM_ITEM ParamList[] = { - {L"/b", TypeFlag}, - {NULL, TypeMax} - }; - -/** - Function for 'exit' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunExit ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - LIST_ENTRY *Package; - CHAR16 *ProblemParam; - SHELL_STATUS ShellStatus; - UINT64 RetVal; - CONST CHAR16 *Return; - - ShellStatus = SHELL_SUCCESS; - - // - // initialize the shell lib (we must be in non-auto-init...) - // - Status = ShellInitialize(); - 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); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - ASSERT(FALSE); - } - } else { - - // - // return the specified error code - // - 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); - 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); - - 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); - - ShellStatus = SHELL_SUCCESS; - } - - ShellCommandLineFreeVarList (Package); - } - return (ShellStatus); -} - diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c deleted file mode 100644 index cbf0517013..0000000000 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c +++ /dev/null @@ -1,748 +0,0 @@ -/** @file - Main file for endfor and for shell level 1 functions. - - (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "UefiShellLevel1CommandsLib.h" -#include - -/** - Determine if a valid string is a valid number for the 'for' command. - - @param[in] Number The pointer to the string representation of the number to test. - - @retval TRUE The number is valid. - @retval FALSE The number is not valid. -**/ -BOOLEAN -EFIAPI -ShellIsValidForNumber ( - IN CONST CHAR16 *Number - ) -{ - if (Number == NULL || *Number == CHAR_NULL) { - return (FALSE); - } - - if (*Number == L'-') { - Number++; - } - - if (StrLen(Number) == 0) { - return (FALSE); - } - - if (StrLen(Number) >= 7) { - if ((StrStr(Number, L" ") == NULL) || (((StrStr(Number, L" ") != NULL) && (StrStr(Number, L" ") - Number) >= 7))) { - return (FALSE); - } - } - - if (!ShellIsDecimalDigitCharacter(*Number)) { - return (FALSE); - } - - return (TRUE); -} - -/** - Function for 'endfor' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunEndFor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - BOOLEAN Found; - SCRIPT_FILE *CurrentScriptFile; - - Status = CommandInit(); - ASSERT_EFI_ERROR(Status); - - 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"); - return (SHELL_INVALID_PARAMETER); - } - - Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE); - - if (!Found) { - CurrentScriptFile = ShellCommandGetCurrentScriptFile(); - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - L"For", - L"EndFor", - 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') - -/** - Update the value of a given alias on the list. If the alias is not there then add it. - - @param[in] Alias The alias to test for. - @param[in] CommandString The updated command string. - @param[in, out] List The list to search. - - @retval EFI_SUCCESS The operation was completed successfully. - @retval EFI_OUT_OF_RESOURCES There was not enough free memory. -**/ -EFI_STATUS -EFIAPI -InternalUpdateAliasOnList( - IN CONST CHAR16 *Alias, - IN CONST CHAR16 *CommandString, - IN OUT LIST_ENTRY *List - ) -{ - ALIAS_LIST *Node; - BOOLEAN Found; - - // - // assert for NULL parameter - // - 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); - Node->CommandString = NULL; - Node->CommandString = StrnCatGrow(&Node->CommandString, NULL, CommandString, 0); - Found = TRUE; - break; - } - } - if (!Found) { - 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); - } - return (EFI_SUCCESS); -} - -/** - Find out if an alias is on the given list. - - @param[in] Alias The alias to test for. - @param[in] List The list to search. - - @retval TRUE The alias is on the list. - @retval FALSE The alias is not on the list. -**/ -BOOLEAN -EFIAPI -InternalIsAliasOnList( - IN CONST CHAR16 *Alias, - IN CONST LIST_ENTRY *List - ) -{ - ALIAS_LIST *Node; - - // - // assert for NULL parameter - // - 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) { - return (TRUE); - } - } - return (FALSE); -} - -/** - Remove an alias from the given list. - - @param[in] Alias The alias to remove. - @param[in, out] List The list to search. -**/ -BOOLEAN -EFIAPI -InternalRemoveAliasFromList( - IN CONST CHAR16 *Alias, - IN OUT LIST_ENTRY *List - ) -{ - ALIAS_LIST *Node; - - // - // assert for NULL parameter - // - 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); - return (TRUE); - } - } - return (FALSE); -} - -/** - Function to determine whether a string is decimal or hex representation of a number - and return the number converted from the string. - - @param[in] String String representation of a number - - @return the number - @retval (UINTN)(-1) An error ocurred. -**/ -UINTN -EFIAPI -ReturnUintn( - IN CONST CHAR16 *String - ) -{ - UINT64 RetVal; - - if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, FALSE, TRUE))) { - return ((UINTN)RetVal); - } - return ((UINTN)(-1)); -} - -/** - Function for 'for' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunFor ( - IN EFI_HANDLE ImageHandle, - 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; - - 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 = CommandInit(); - ASSERT_EFI_ERROR(Status); - - 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"); - return (SHELL_INVALID_PARAMETER); - } - - CurrentScriptFile = ShellCommandGetCurrentScriptFile(); - ASSERT(CurrentScriptFile != NULL); - - if ((CurrentScriptFile->CurrentCommand != NULL) && (CurrentScriptFile->CurrentCommand->Data == NULL)) { - FirstPass = TRUE; - - // - // Make sure that an End exists. - // - if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - L"EndFor", - L"For", - 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]); - 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) { - 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); - } 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); - } - 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); - } else { - 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); - ASSERT(Info != NULL); - 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; - } - 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 - ) { - return (SHELL_INVALID_PARAMETER); - } - if (ArgSet == NULL) { -// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0); - } else { - 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])); - ASSERT(Info != NULL); - Info->Signature = SHELL_FOR_INFO_SIGNATURE; - CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1])); - Info->ReplacementName = Info->Set; - Info->CurrentValue = NULL; - ArgSetWalker = ArgSet; - if (ArgSetWalker[0] != L'(') { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), - gShellLevel1HiiHandle, - ArgSet, - CurrentScriptFile->CurrentCommand->Line); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - TempSpot = StrStr(ArgSetWalker, L")"); - if (TempSpot != NULL) { - TempString = TempSpot+1; - if (*(TempString) != CHAR_NULL) { - while(TempString != NULL && *TempString == L' ') { - TempString++; - } - if (StrLen(TempString) > 0) { - TempSpot = NULL; - } - } - } - if (TempSpot == NULL) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), - gShellLevel1HiiHandle, - CurrentScriptFile->CurrentCommand->Line); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - *TempSpot = CHAR_NULL; - ArgSetWalker++; - while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') { - ArgSetWalker++; - } - if (!ShellIsValidForNumber(ArgSetWalker)) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), - gShellLevel1HiiHandle, - ArgSet, - CurrentScriptFile->CurrentCommand->Line); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - if (ArgSetWalker[0] == L'-') { - Info->Current = 0 - (INTN)ReturnUintn(ArgSetWalker+1); - } else { - Info->Current = (INTN)ReturnUintn(ArgSetWalker); - } - ArgSetWalker = StrStr(ArgSetWalker, L" "); - while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') { - ArgSetWalker++; - } - if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){ - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), - gShellLevel1HiiHandle, - ArgSet, - CurrentScriptFile->CurrentCommand->Line); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - if (ArgSetWalker[0] == L'-') { - 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; - } - - 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( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), - gShellLevel1HiiHandle, - ArgSet, - CurrentScriptFile->CurrentCommand->Line); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - if (*ArgSetWalker == L')') { - ASSERT(Info->Step == 1 || Info->Step == -1); - } else { - if (ArgSetWalker[0] == L'-') { - Info->Step = 0 - (INTN)ReturnUintn(ArgSetWalker+1); - } else { - Info->Step = (INTN)ReturnUintn(ArgSetWalker); - } - - if (StrStr(ArgSetWalker, L" ") != NULL) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), - gShellLevel1HiiHandle, - ArgSet, - CurrentScriptFile->CurrentCommand->Line); - ShellStatus = SHELL_INVALID_PARAMETER; - } - } - } - - } - } - } - } - } - if (ShellStatus == SHELL_SUCCESS) { - if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) { - Info->RemoveSubstAlias = FALSE; - } else { - Info->RemoveSubstAlias = TRUE; - } - } - if (CurrentScriptFile->CurrentCommand != NULL) { - CurrentScriptFile->CurrentCommand->Data = Info; - } - } - } else { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), - gShellLevel1HiiHandle, - ArgSet, - 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); - } - - if (CurrentScriptFile != NULL && CurrentScriptFile->CurrentCommand != NULL) { - Info = (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data; - if (CurrentScriptFile->CurrentCommand->Reset) { - Info->CurrentValue = (CHAR16*)Info->Set; - FirstPass = TRUE; - CurrentScriptFile->CurrentCommand->Reset = FALSE; - } - } else { - ShellStatus = SHELL_UNSUPPORTED; - Info = NULL; - } - if (ShellStatus == SHELL_SUCCESS) { - ASSERT(Info != NULL); - if (Info->Step != 0) { - // - // only advance if not the first pass - // - if (!FirstPass) { - // - // sequence version of for loop... - // - 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); - - 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( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - L"EndFor", - L"For", - 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); - } - FreePool(Info); - } - } else { - // - // Must be in 'in' version of for loop... - // - 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); - if (TempString == NULL) { - ShellStatus = SHELL_OUT_OF_RESOURCES; - } else { - TempSpot = StrStr(TempString, L"\" \""); - if (TempSpot != NULL) { - *TempSpot = CHAR_NULL; - } - while (TempString[StrLen(TempString)-1] == L'\"') { - TempString[StrLen(TempString)-1] = CHAR_NULL; - } - InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList); - Info->CurrentValue += StrLen(TempString); - - if (Info->CurrentValue[0] == L'\"') { - Info->CurrentValue++; - } - 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( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - L"EndFor", - L"For", - 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); - } - FreePool(Info); - } - } - } - if (ArgSet != NULL) { - FreePool(ArgSet); - } - return (ShellStatus); -} - diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c deleted file mode 100644 index 88e290daa7..0000000000 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c +++ /dev/null @@ -1,105 +0,0 @@ -/** @file - Main file for goto shell level 1 function. - - (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "UefiShellLevel1CommandsLib.h" - -/** - Function for 'goto' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunGoto ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - LIST_ENTRY *Package; - CHAR16 *ProblemParam; - SHELL_STATUS ShellStatus; - CHAR16 *CompareString; - UINTN Size; - SCRIPT_FILE *CurrentScriptFile; - - ShellStatus = SHELL_SUCCESS; - CompareString = NULL; - - // - // initialize the shell lib (we must be in non-auto-init...) - // - Status = ShellInitialize(); - 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"); - return (SHELL_UNSUPPORTED); - } - - // - // 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); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - ASSERT(FALSE); - } - } else { - 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"); - 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); - // - // Check forwards and then backwards for a label... - // - if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) { - CurrentScriptFile = ShellCommandGetCurrentScriptFile(); - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - CompareString, - L"Goto", - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); - ShellStatus = SHELL_NOT_FOUND; - } - FreePool(CompareString); - } - ShellCommandLineFreeVarList (Package); - } - - return (ShellStatus); -} - diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c deleted file mode 100644 index 7abfd8944b..0000000000 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c +++ /dev/null @@ -1,1099 +0,0 @@ -/** @file - Main file for If and else shell level 1 function. - - (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "UefiShellLevel1CommandsLib.h" -#include - -typedef enum { - EndTagOr, - EndTagAnd, - EndTagThen, - EndTagMax -} END_TAG_TYPE; - -typedef enum { - OperatorGreaterThan, - OperatorLessThan, - OperatorEqual, - OperatorNotEqual, - OperatorGreatorOrEqual, - OperatorLessOrEqual, - OperatorUnisgnedGreaterThan, - OperatorUnsignedLessThan, - OperatorUnsignedGreaterOrEqual, - OperatorUnsignedLessOrEqual, - OperatorMax -} BIN_OPERATOR_TYPE; - -/** - Extract the next fragment, if there is one. - - @param[in, out] Statement The current remaining statement. - @param[in] Fragment The current fragment. - - @retval FALSE There is not another fragment. - @retval TRUE There is another fragment. -**/ -BOOLEAN -EFIAPI -IsNextFragment ( - IN OUT CONST CHAR16 **Statement, - IN CONST CHAR16 *Fragment - ) -{ - CHAR16 *Tester; - - Tester = NULL; - - Tester = StrnCatGrow(&Tester, NULL, *Statement, StrLen(Fragment)); - ASSERT(Tester != NULL); - Tester[StrLen(Fragment)] = CHAR_NULL; - if (gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)Fragment, - Tester) == 0) { - // - // increment the string pointer to the end of what we found and then chop off spaces... - // - *Statement+=StrLen(Fragment); - while (*Statement[0] == L' ') { - (*Statement)++; - } - FreePool(Tester); - return (TRUE); - } - FreePool(Tester); - return (FALSE); -} - -/** - Determine if String represents a valid profile. - - @param[in] String The pointer to the string to test. - - @retval TRUE String is a valid profile. - @retval FALSE String is not a valid profile. -**/ -BOOLEAN -EFIAPI -IsValidProfile ( - IN CONST CHAR16 *String - ) -{ - CONST CHAR16 *ProfilesString; - CONST CHAR16 *TempLocation; - - ProfilesString = ShellGetEnvironmentVariable(L"profiles"); - ASSERT(ProfilesString != NULL); - TempLocation = StrStr(ProfilesString, String); - if ((TempLocation != NULL) && (*(TempLocation-1) == L';') && (*(TempLocation+StrLen(String)) == L';')) { - return (TRUE); - } - return (FALSE); -} - -/** - Do a comparison between 2 things. - - @param[in] Compare1 The first item to compare. - @param[in] Compare2 The second item to compare. - @param[in] BinOp The type of comparison to perform. - @param[in] CaseInsensitive TRUE to do non-case comparison, FALSE otherwise. - @param[in] ForceStringCompare TRUE to force string comparison, FALSE otherwise. - - @return The result of the comparison. -**/ -BOOLEAN -EFIAPI -TestOperation ( - IN CONST CHAR16 *Compare1, - IN CONST CHAR16 *Compare2, - IN CONST BIN_OPERATOR_TYPE BinOp, - IN CONST BOOLEAN CaseInsensitive, - IN CONST BOOLEAN ForceStringCompare - ) -{ - INTN Cmp1; - INTN Cmp2; - - // - // "Compare1 BinOp Compare2" - // - switch (BinOp) { - case OperatorUnisgnedGreaterThan: - case OperatorGreaterThan: - if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) { - // - // string compare - // - if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) > 0) || (StringCompare(&Compare1, &Compare2) > 0)) { - return (TRUE); - } - } else { - // - // numeric compare - // - if (Compare1[0] == L'-') { - Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1); - } else { - Cmp1 = (INTN)ShellStrToUintn(Compare1); - } - if (Compare2[0] == L'-') { - Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1); - } else { - Cmp2 = (INTN)ShellStrToUintn(Compare2); - } - if (BinOp == OperatorGreaterThan) { - if (Cmp1 > Cmp2) { - return (TRUE); - } - } else { - if ((UINTN)Cmp1 > (UINTN)Cmp2) { - return (TRUE); - } - } - } - return (FALSE); - case OperatorUnsignedLessThan: - case OperatorLessThan: - if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) { - // - // string compare - // - if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) < 0) || (StringCompare(&Compare1, &Compare2) < 0)) { - return (TRUE); - } - } else { - // - // numeric compare - // - if (Compare1[0] == L'-') { - Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1); - } else { - Cmp1 = (INTN)ShellStrToUintn(Compare1); - } - if (Compare2[0] == L'-') { - Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1); - } else { - Cmp2 = (INTN)ShellStrToUintn(Compare2); - } - if (BinOp == OperatorLessThan) { - if (Cmp1 < Cmp2) { - return (TRUE); - } - } else { - if ((UINTN)Cmp1 < (UINTN)Cmp2) { - return (TRUE); - } - } - - } - return (FALSE); - case OperatorEqual: - if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) { - // - // string compare - // - if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) == 0) || (StringCompare(&Compare1, &Compare2) == 0)) { - return (TRUE); - } - } else { - // - // numeric compare - // - if (Compare1[0] == L'-') { - Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1); - } else { - Cmp1 = (INTN)ShellStrToUintn(Compare1); - } - if (Compare2[0] == L'-') { - Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1); - } else { - Cmp2 = (INTN)ShellStrToUintn(Compare2); - } - if (Cmp1 == Cmp2) { - return (TRUE); - } - } - return (FALSE); - case OperatorNotEqual: - if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) { - // - // string compare - // - if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) != 0) || (StringCompare(&Compare1, &Compare2) != 0)) { - return (TRUE); - } - } else { - // - // numeric compare - // - if (Compare1[0] == L'-') { - Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1); - } else { - Cmp1 = (INTN)ShellStrToUintn(Compare1); - } - if (Compare2[0] == L'-') { - Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1); - } else { - Cmp2 = (INTN)ShellStrToUintn(Compare2); - } - if (Cmp1 != Cmp2) { - return (TRUE); - } - } - return (FALSE); - case OperatorUnsignedGreaterOrEqual: - case OperatorGreatorOrEqual: - if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) { - // - // string compare - // - if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) >= 0) || (StringCompare(&Compare1, &Compare2) >= 0)) { - return (TRUE); - } - } else { - // - // numeric compare - // - if (Compare1[0] == L'-') { - Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1); - } else { - Cmp1 = (INTN)ShellStrToUintn(Compare1); - } - if (Compare2[0] == L'-') { - Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1); - } else { - Cmp2 = (INTN)ShellStrToUintn(Compare2); - } - if (BinOp == OperatorGreatorOrEqual) { - if (Cmp1 >= Cmp2) { - return (TRUE); - } - } else { - if ((UINTN)Cmp1 >= (UINTN)Cmp2) { - return (TRUE); - } - } - } - return (FALSE); - case OperatorLessOrEqual: - case OperatorUnsignedLessOrEqual: - if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) { - // - // string compare - // - if ((CaseInsensitive && StringNoCaseCompare(&Compare1, &Compare2) <= 0) || (StringCompare(&Compare1, &Compare2) <= 0)) { - return (TRUE); - } - } else { - // - // numeric compare - // - if (Compare1[0] == L'-') { - Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1); - } else { - Cmp1 = (INTN)ShellStrToUintn(Compare1); - } - if (Compare2[0] == L'-') { - Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1); - } else { - Cmp2 = (INTN)ShellStrToUintn(Compare2); - } - if (BinOp == OperatorLessOrEqual) { - if (Cmp1 <= Cmp2) { - return (TRUE); - } - } else { - if ((UINTN)Cmp1 <= (UINTN)Cmp2) { - return (TRUE); - } - } - } - return (FALSE); - default: - ASSERT(FALSE); - return (FALSE); - } -} - -/** - Process an if statement and determine if its is valid or not. - - @param[in, out] PassingState Opon entry, the current state. Upon exit, - the new state. - @param[in] StartParameterNumber The number of the first parameter of - this statement. - @param[in] EndParameterNumber The number of the final parameter of - this statement. - @param[in] OperatorToUse The type of termination operator. - @param[in] CaseInsensitive TRUE for case insensitive, FALSE otherwise. - @param[in] ForceStringCompare TRUE for all string based, FALSE otherwise. - - @retval EFI_INVALID_PARAMETER A parameter was invalid. - @retval EFI_SUCCESS The operation was successful. -**/ -EFI_STATUS -EFIAPI -ProcessStatement ( - IN OUT BOOLEAN *PassingState, - IN UINTN StartParameterNumber, - IN UINTN EndParameterNumber, - IN CONST END_TAG_TYPE OperatorToUse, - IN CONST BOOLEAN CaseInsensitive, - IN CONST BOOLEAN ForceStringCompare - ) -{ - EFI_STATUS Status; - BOOLEAN OperationResult; - BOOLEAN NotPresent; - CHAR16 *StatementWalker; - BIN_OPERATOR_TYPE BinOp; - CHAR16 *Compare1; - CHAR16 *Compare2; - CHAR16 HexString[20]; - CHAR16 *TempSpot; - - ASSERT((END_TAG_TYPE)OperatorToUse != EndTagThen); - - Status = EFI_SUCCESS; - BinOp = OperatorMax; - OperationResult = FALSE; - StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber]; - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"not")) { - NotPresent = TRUE; - StatementWalker = gEfiShellParametersProtocol->Argv[++StartParameterNumber]; - } else { - NotPresent = FALSE; - } - - // - // now check for 'boolfunc' operators - // - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"isint")) { - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') { - StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL; - OperationResult = ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE); - } else { - Status = EFI_INVALID_PARAMETER; - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"isint"); - } - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"exists") || IsNextFragment((CONST CHAR16**)(&StatementWalker), L"exist")) { - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') { - StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL; - // - // is what remains a file in CWD??? - // - OperationResult = (BOOLEAN)(ShellFileExists(StatementWalker)==EFI_SUCCESS); - } else if (StatementWalker[0] == CHAR_NULL && StartParameterNumber+1 == EndParameterNumber) { - OperationResult = (BOOLEAN)(ShellFileExists(gEfiShellParametersProtocol->Argv[++StartParameterNumber])==EFI_SUCCESS); - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"exist(s)"); - Status = EFI_INVALID_PARAMETER; - } - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"available")) { - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') { - StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL; - // - // is what remains a file in the CWD or path??? - // - OperationResult = (BOOLEAN)(ShellIsFileInPath(StatementWalker)==EFI_SUCCESS); - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"available"); - Status = EFI_INVALID_PARAMETER; - } - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"profile")) { - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && StatementWalker[StrLen(StatementWalker)-1] == L')') { - // - // Chop off that ')' - // - StatementWalker[StrLen(StatementWalker)-1] = CHAR_NULL; - OperationResult = IsValidProfile(StatementWalker); - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"profile"); - Status = EFI_INVALID_PARAMETER; - } - } else if (StartParameterNumber+1 >= EndParameterNumber) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[StartParameterNumber]); - Status = EFI_INVALID_PARAMETER; - } else { - // - // must be 'item binop item' style - // - Compare1 = NULL; - Compare2 = NULL; - BinOp = OperatorMax; - - // - // get the first item - // - StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber]; - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"efierror")) { - TempSpot = StrStr(StatementWalker, L")"); - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) { - *TempSpot = CHAR_NULL; - if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) { - UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT); - ASSERT(Compare1 == NULL); - Compare1 = StrnCatGrow(&Compare1, NULL, HexString, 0); - StatementWalker += StrLen(StatementWalker) + 1; - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"efierror"); - Status = EFI_INVALID_PARAMETER; - } - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"efierror"); - Status = EFI_INVALID_PARAMETER; - } - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"pierror")) { - TempSpot = StrStr(StatementWalker, L")"); - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) { - *TempSpot = CHAR_NULL; - if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) { - UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>2)); - ASSERT(Compare1 == NULL); - Compare1 = StrnCatGrow(&Compare1, NULL, HexString, 0); - StatementWalker += StrLen(StatementWalker) + 1; - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"pierror"); - Status = EFI_INVALID_PARAMETER; - } - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"pierror"); - Status = EFI_INVALID_PARAMETER; - } - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"oemerror")) { - TempSpot = StrStr(StatementWalker, L")"); - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) { - TempSpot = CHAR_NULL; - if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) { - UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>1)); - ASSERT(Compare1 == NULL); - Compare1 = StrnCatGrow(&Compare1, NULL, HexString, 0); - StatementWalker += StrLen(StatementWalker) + 1; - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"oemerror"); - Status = EFI_INVALID_PARAMETER; - } - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"oemerror"); - Status = EFI_INVALID_PARAMETER; - } - } else { - ASSERT(Compare1 == NULL); - if (EndParameterNumber - StartParameterNumber > 2) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_STARTING), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[StartParameterNumber+2]); - Status = EFI_INVALID_PARAMETER; - } else { - // - // must be a raw string - // - Compare1 = StrnCatGrow(&Compare1, NULL, StatementWalker, 0); - } - } - - // - // get the operator - // - ASSERT(StartParameterNumber+1Argv[StartParameterNumber+1]; - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"gt")) { - BinOp = OperatorGreaterThan; - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"lt")) { - BinOp = OperatorLessThan; - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"eq")) { - BinOp = OperatorEqual; - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ne")) { - BinOp = OperatorNotEqual; - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ge")) { - BinOp = OperatorGreatorOrEqual; - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"le")) { - BinOp = OperatorLessOrEqual; - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"==")) { - BinOp = OperatorEqual; - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ugt")) { - BinOp = OperatorUnisgnedGreaterThan; - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ult")) { - BinOp = OperatorUnsignedLessThan; - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"uge")) { - BinOp = OperatorUnsignedGreaterOrEqual; - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ule")) { - BinOp = OperatorUnsignedLessOrEqual; - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_INVALID_BINOP), gShellLevel1HiiHandle, StatementWalker); - Status = EFI_INVALID_PARAMETER; - } - - // - // get the second item - // - ASSERT(StartParameterNumber+2<=EndParameterNumber); - StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber+2]; - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"efierror")) { - TempSpot = StrStr(StatementWalker, L")"); - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) { - TempSpot = CHAR_NULL; - if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) { - UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT); - ASSERT(Compare2 == NULL); - Compare2 = StrnCatGrow(&Compare2, NULL, HexString, 0); - StatementWalker += StrLen(StatementWalker) + 1; - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"efierror"); - Status = EFI_INVALID_PARAMETER; - } - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"efierror"); - Status = EFI_INVALID_PARAMETER; - } - // - // can this be collapsed into the above? - // - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"pierror")) { - TempSpot = StrStr(StatementWalker, L")"); - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) { - TempSpot = CHAR_NULL; - if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) { - UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>2)); - ASSERT(Compare2 == NULL); - Compare2 = StrnCatGrow(&Compare2, NULL, HexString, 0); - StatementWalker += StrLen(StatementWalker) + 1; - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"pierror"); - Status = EFI_INVALID_PARAMETER; - } - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"pierror"); - Status = EFI_INVALID_PARAMETER; - } - } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"oemerror")) { - TempSpot = StrStr(StatementWalker, L")"); - if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"(") && TempSpot != NULL) { - TempSpot = CHAR_NULL; - if (ShellIsHexOrDecimalNumber(StatementWalker, FALSE, FALSE)) { - UnicodeSPrint(HexString, sizeof(HexString), L"0x%x", ShellStrToUintn(StatementWalker)|MAX_BIT|(MAX_BIT>>1)); - ASSERT(Compare2 == NULL); - Compare2 = StrnCatGrow(&Compare2, NULL, HexString, 0); - StatementWalker += StrLen(StatementWalker) + 1; - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"oemerror"); - Status = EFI_INVALID_PARAMETER; - } - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_IN), gShellLevel1HiiHandle, L"oemerror"); - Status = EFI_INVALID_PARAMETER; - } - } else { - // - // must be a raw string - // - ASSERT(Compare2 == NULL); - Compare2 = StrnCatGrow(&Compare2, NULL, StatementWalker, 0); - } - - if (Compare1 != NULL && Compare2 != NULL && BinOp != OperatorMax) { - OperationResult = TestOperation(Compare1, Compare2, BinOp, CaseInsensitive, ForceStringCompare); - } - - SHELL_FREE_NON_NULL(Compare1); - SHELL_FREE_NON_NULL(Compare2); - } - - // - // done processing do result... - // - - if (!EFI_ERROR(Status)) { - if (NotPresent) { - OperationResult = (BOOLEAN)(!OperationResult); - } - switch(OperatorToUse) { - case EndTagOr: - *PassingState = (BOOLEAN)(*PassingState || OperationResult); - break; - case EndTagAnd: - *PassingState = (BOOLEAN)(*PassingState && OperationResult); - break; - case EndTagMax: - *PassingState = (BOOLEAN)(OperationResult); - break; - default: - ASSERT(FALSE); - } - } - return (Status); -} - -/** - Break up the next part of the if statement (until the next 'and', 'or', or 'then'). - - @param[in] ParameterNumber The current parameter number. - @param[out] EndParameter Upon successful return, will point to the - parameter to start the next iteration with. - @param[out] EndTag Upon successful return, will point to the - type that was found at the end of this statement. - - @retval TRUE A valid statement was found. - @retval FALSE A valid statement was not found. -**/ -BOOLEAN -EFIAPI -BuildNextStatement ( - IN UINTN ParameterNumber, - OUT UINTN *EndParameter, - OUT END_TAG_TYPE *EndTag - ) -{ - *EndTag = EndTagMax; - - for( - ; ParameterNumber < gEfiShellParametersProtocol->Argc - ; ParameterNumber++ - ) { - if (gUnicodeCollation->StriColl( - gUnicodeCollation, - gEfiShellParametersProtocol->Argv[ParameterNumber], - L"or") == 0) { - *EndParameter = ParameterNumber - 1; - *EndTag = EndTagOr; - break; - } else if (gUnicodeCollation->StriColl( - gUnicodeCollation, - gEfiShellParametersProtocol->Argv[ParameterNumber], - L"and") == 0) { - *EndParameter = ParameterNumber - 1; - *EndTag = EndTagAnd; - break; - } else if (gUnicodeCollation->StriColl( - gUnicodeCollation, - gEfiShellParametersProtocol->Argv[ParameterNumber], - L"then") == 0) { - *EndParameter = ParameterNumber - 1; - *EndTag = EndTagThen; - break; - } - } - if (*EndTag == EndTagMax) { - return (FALSE); - } - return (TRUE); -} - -/** - Move the script file pointer to a different place in the script file. - This one is special since it handles the if/else/endif syntax. - - @param[in] ScriptFile The script file from GetCurrnetScriptFile(). - - @retval TRUE The move target was found and the move was successful. - @retval FALSE Something went wrong. -**/ -BOOLEAN -EFIAPI -MoveToTagSpecial ( - IN SCRIPT_FILE *ScriptFile - ) -{ - SCRIPT_COMMAND_LIST *CommandNode; - BOOLEAN Found; - UINTN TargetCount; - CHAR16 *CommandName; - CHAR16 *CommandWalker; - CHAR16 *TempLocation; - - TargetCount = 1; - Found = FALSE; - - if (ScriptFile == NULL) { - return FALSE; - } - - for (CommandNode = (SCRIPT_COMMAND_LIST *)GetNextNode(&ScriptFile->CommandList, &ScriptFile->CurrentCommand->Link), Found = FALSE - ; !IsNull(&ScriptFile->CommandList, &CommandNode->Link) && !Found - ; CommandNode = (SCRIPT_COMMAND_LIST *)GetNextNode(&ScriptFile->CommandList, &CommandNode->Link) - ){ - - // - // get just the first part of the command line... - // - CommandName = NULL; - CommandName = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0); - if (CommandName == NULL) { - continue; - } - CommandWalker = CommandName; - - // - // Skip leading spaces and tabs. - // - while ((CommandWalker[0] == L' ') || (CommandWalker[0] == L'\t')) { - CommandWalker++; - } - TempLocation = StrStr(CommandWalker, L" "); - - if (TempLocation != NULL) { - *TempLocation = CHAR_NULL; - } - - // - // did we find a nested item ? - // - if (gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)CommandWalker, - L"If") == 0) { - TargetCount++; - } else if (TargetCount == 1 && gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)CommandWalker, - (CHAR16*)L"else") == 0) { - // - // else can only decrement the last part... not an nested if - // hence the TargetCount compare added - // - TargetCount--; - } else if (gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)CommandWalker, - (CHAR16*)L"endif") == 0) { - TargetCount--; - } - if (TargetCount == 0) { - ScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)GetNextNode(&ScriptFile->CommandList, &CommandNode->Link); - Found = TRUE; - } - - // - // Free the memory for this loop... - // - SHELL_FREE_NON_NULL(CommandName); - } - return (Found); -} - -/** - Deal with the result of the if operation. - - @param[in] Result The result of the if. - - @retval EFI_SUCCESS The operation was successful. - @retval EFI_NOT_FOUND The ending tag could not be found. -**/ -EFI_STATUS -EFIAPI -PerformResultOperation ( - IN CONST BOOLEAN Result - ) -{ - if (Result || MoveToTagSpecial(ShellCommandGetCurrentScriptFile())) { - return (EFI_SUCCESS); - } - return (EFI_NOT_FOUND); -} - -/** - Function for 'if' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunIf ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - SHELL_STATUS ShellStatus; - BOOLEAN CaseInsensitive; - BOOLEAN ForceString; - UINTN CurrentParameter; - UINTN EndParameter; - BOOLEAN CurrentValue; - END_TAG_TYPE Ending; - END_TAG_TYPE PreviousEnding; - SCRIPT_FILE *CurrentScriptFile; - - Status = CommandInit(); - ASSERT_EFI_ERROR(Status); - - if (!gEfiShellProtocol->BatchIsActive()) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"if"); - return (SHELL_UNSUPPORTED); - } - - if (gEfiShellParametersProtocol->Argc < 3) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"if"); - return (SHELL_INVALID_PARAMETER); - } - - // - // Make sure that an End exists. - // - CurrentScriptFile = ShellCommandGetCurrentScriptFile(); - if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - L"EndIf", - L"If", - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); - return (SHELL_DEVICE_ERROR); - } - - // - // initialize the shell lib (we must be in non-auto-init...) - // - Status = ShellInitialize(); - ASSERT_EFI_ERROR(Status); - - CurrentParameter = 1; - EndParameter = 0; - - if (gUnicodeCollation->StriColl( - gUnicodeCollation, - gEfiShellParametersProtocol->Argv[1], - L"/i") == 0 || - gUnicodeCollation->StriColl( - gUnicodeCollation, - gEfiShellParametersProtocol->Argv[2], - L"/i") == 0 || - (gEfiShellParametersProtocol->Argc > 3 && gUnicodeCollation->StriColl( - gUnicodeCollation, - gEfiShellParametersProtocol->Argv[3], - L"/i") == 0)) { - CaseInsensitive = TRUE; - CurrentParameter++; - } else { - CaseInsensitive = FALSE; - } - if (gUnicodeCollation->StriColl( - gUnicodeCollation, - gEfiShellParametersProtocol->Argv[1], - L"/s") == 0 || - gUnicodeCollation->StriColl( - gUnicodeCollation, - gEfiShellParametersProtocol->Argv[2], - L"/s") == 0 || - (gEfiShellParametersProtocol->Argc > 3 && gUnicodeCollation->StriColl( - gUnicodeCollation, - gEfiShellParametersProtocol->Argv[3], - L"/s") == 0)) { - ForceString = TRUE; - CurrentParameter++; - } else { - ForceString = FALSE; - } - - for ( ShellStatus = SHELL_SUCCESS, CurrentValue = FALSE, Ending = EndTagMax - ; CurrentParameter < gEfiShellParametersProtocol->Argc && ShellStatus == SHELL_SUCCESS - ; CurrentParameter++) { - if (gUnicodeCollation->StriColl( - gUnicodeCollation, - gEfiShellParametersProtocol->Argv[CurrentParameter], - L"then") == 0) { - // - // we are at the then - // - if (CurrentParameter+1 != gEfiShellParametersProtocol->Argc) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TEXT_AFTER_THEN), gShellLevel1HiiHandle, L"if"); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - Status = PerformResultOperation(CurrentValue); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_AFTER_BAD), gShellLevel1HiiHandle, L"if", gEfiShellParametersProtocol->Argv[CurrentParameter]); - ShellStatus = SHELL_INVALID_PARAMETER; - } - } - } else { - PreviousEnding = Ending; - // - // build up the next statement for analysis - // - if (!BuildNextStatement(CurrentParameter, &EndParameter, &Ending)) { - CurrentScriptFile = ShellCommandGetCurrentScriptFile(); - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - L"Then", - L"If", - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - // - // Analyze the statement - // - Status = ProcessStatement(&CurrentValue, CurrentParameter, EndParameter, PreviousEnding, CaseInsensitive, ForceString); - if (EFI_ERROR(Status)) { -// ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_STARTING), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[CurrentParameter]); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - // - // Optomize to get out of the loop early... - // - if ((Ending == EndTagOr && CurrentValue) || (Ending == EndTagAnd && !CurrentValue)) { - Status = PerformResultOperation(CurrentValue); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_AFTER_BAD), gShellLevel1HiiHandle, L"if", gEfiShellParametersProtocol->Argv[CurrentParameter]); - ShellStatus = SHELL_INVALID_PARAMETER; - } - break; - } - } - } - if (ShellStatus == SHELL_SUCCESS){ - CurrentParameter = EndParameter; - // - // Skip over the or or and parameter. - // - if (Ending == EndTagOr || Ending == EndTagAnd) { - CurrentParameter++; - } - } - } - } - return (ShellStatus); -} - -/** - Function for 'else' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunElse ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - SCRIPT_FILE *CurrentScriptFile; - ASSERT_EFI_ERROR(CommandInit()); - - if (gEfiShellParametersProtocol->Argc > 1) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"if"); - return (SHELL_INVALID_PARAMETER); - } - - if (!gEfiShellProtocol->BatchIsActive()) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Else"); - return (SHELL_UNSUPPORTED); - } - - CurrentScriptFile = ShellCommandGetCurrentScriptFile(); - - if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - L"If", - L"Else", - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); - return (SHELL_DEVICE_ERROR); - } - if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - L"If", - L"Else", - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); - return (SHELL_DEVICE_ERROR); - } - - if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, FALSE, FALSE, FALSE)) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - L"EndIf", - "Else", - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); - return (SHELL_DEVICE_ERROR); - } - - return (SHELL_SUCCESS); -} - -/** - Function for 'endif' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunEndIf ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - SCRIPT_FILE *CurrentScriptFile; - ASSERT_EFI_ERROR(CommandInit()); - - if (gEfiShellParametersProtocol->Argc > 1) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"if"); - return (SHELL_INVALID_PARAMETER); - } - - if (!gEfiShellProtocol->BatchIsActive()) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Endif"); - return (SHELL_UNSUPPORTED); - } - - CurrentScriptFile = ShellCommandGetCurrentScriptFile(); - if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_SYNTAX_NO_MATCHING), - gShellLevel1HiiHandle, - L"If", - L"EndIf", - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); - return (SHELL_DEVICE_ERROR); - } - - return (SHELL_SUCCESS); -} diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c deleted file mode 100644 index 08c54f8f7a..0000000000 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c +++ /dev/null @@ -1,64 +0,0 @@ -/** @file - Main file for Shift shell level 1 function. - - (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "UefiShellLevel1CommandsLib.h" - -/** - Function for 'shift' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunShift ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - SCRIPT_FILE *CurrentScriptFile; - UINTN LoopVar; - - Status = CommandInit(); - ASSERT_EFI_ERROR(Status); - - if (!gEfiShellProtocol->BatchIsActive()) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"shift"); - return (SHELL_UNSUPPORTED); - } - - CurrentScriptFile = ShellCommandGetCurrentScriptFile(); - ASSERT(CurrentScriptFile != NULL); - - if (CurrentScriptFile->Argc < 2) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"shift"); - return (SHELL_UNSUPPORTED); - } - - for (LoopVar = 0 ; LoopVar < CurrentScriptFile->Argc ; LoopVar++) { - if (LoopVar == 0) { - 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); -} - diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c deleted file mode 100644 index 476b1bc47f..0000000000 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c +++ /dev/null @@ -1,84 +0,0 @@ -/** @file - Main file for stall shell level 1 function. - - (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "UefiShellLevel1CommandsLib.h" - -/** - Function for 'stall' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunStall ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - LIST_ENTRY *Package; - CHAR16 *ProblemParam; - SHELL_STATUS ShellStatus; - UINT64 Intermediate; - - ShellStatus = SHELL_SUCCESS; - - // - // initialize the shell lib (we must be in non-auto-init...) - // - Status = ShellInitialize(); - 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); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - ASSERT(FALSE); - } - } else { - 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"); - 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)); - 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"); - ShellStatus = SHELL_DEVICE_ERROR; - } - } - } - ShellCommandLineFreeVarList (Package); - } - return (ShellStatus); -} - diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c deleted file mode 100644 index 80d0dfe652..0000000000 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c +++ /dev/null @@ -1,310 +0,0 @@ -/** @file - Main file for NULL named library for level 1 shell command functions. - - (C) Copyright 2013 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "UefiShellLevel1CommandsLib.h" - -STATIC CONST CHAR16 mFileName[] = L"ShellCommands"; -EFI_HANDLE gShellLevel1HiiHandle = NULL; - -/** - Return the help text filename. Only used if no HII information found. - - @retval the filename. -**/ -CONST CHAR16* -EFIAPI -ShellCommandGetManFileNameLevel1 ( - VOID - ) -{ - return (mFileName); -} - -/** - Constructor for the Shell Level 1 Commands library. - - Install the handlers for level 1 UEFI Shell 2.0 commands. - - @param ImageHandle the image handle of the process - @param SystemTable the EFI System Table pointer - - @retval EFI_SUCCESS the shell command handlers were installed sucessfully - @retval EFI_UNSUPPORTED the shell level required was not found. -**/ -EFI_STATUS -EFIAPI -ShellLevel1CommandsLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - // - // if shell level is less than 2 do nothing - // - if (PcdGet8(PcdShellSupportLevel) < 1) { - return (EFI_SUCCESS); - } - - gShellLevel1HiiHandle = HiiAddPackages (&gShellLevel1HiiGuid, gImageHandle, UefiShellLevel1CommandsLibStrings, NULL); - if (gShellLevel1HiiHandle == NULL) { - return (EFI_DEVICE_ERROR); - } - - // - // 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))); - - return (EFI_SUCCESS); -} - -/** - Destructor for the library. free any resources. - - @param ImageHandle The image handle of the process. - @param SystemTable The EFI System Table pointer. -**/ -EFI_STATUS -EFIAPI -ShellLevel1CommandsLibDestructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - if (gShellLevel1HiiHandle != NULL) { - HiiRemovePackages(gShellLevel1HiiHandle); - } - return (EFI_SUCCESS); -} - -/** - Test a node to see if meets the criterion. - - It functions so that count starts at 1 and it increases or decreases when it - hits the specified tags. when it hits zero the location has been found. - - DecrementerTag and IncrementerTag are used to get around for/endfor and - similar paired types where the entire middle should be ignored. - - If label is used it will be used instead of the count. - - @param[in] Function The function to use to enumerate through the - list. Normally GetNextNode or GetPreviousNode. - @param[in] DecrementerTag The tag to decrement the count at. - @param[in] IncrementerTag The tag to increment the count at. - @param[in] Label A label to look for. - @param[in, out] ScriptFile The pointer to the current script file structure. - @param[in] MovePast TRUE makes function return 1 past the found - location. - @param[in] FindOnly TRUE to not change the ScriptFile. - @param[in] CommandNode The pointer to the Node to test. - @param[in, out] TargetCount The pointer to the current count. -**/ -BOOLEAN -EFIAPI -TestNodeForMove ( - 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 SCRIPT_COMMAND_LIST *CommandNode, - IN OUT UINTN *TargetCount - ) -{ - 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); - if (CommandName == NULL) { - return (FALSE); - } - - CommandNameWalker = CommandName; - - // - // Skip leading spaces and tabs. - // - while ((CommandNameWalker[0] == L' ') || (CommandNameWalker[0] == L'\t')) { - CommandNameWalker++; - } - TempLocation = StrStr(CommandNameWalker, L" "); - - if (TempLocation != NULL) { - *TempLocation = CHAR_NULL; - } - - // - // did we find a nested item ? - // - if (gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)CommandNameWalker, - (CHAR16*)IncrementerTag) == 0) { - (*TargetCount)++; - } else if (gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)CommandNameWalker, - (CHAR16*)DecrementerTag) == 0) { - if (*TargetCount > 0) { - (*TargetCount)--; - } - } - - // - // did we find the matching one... - // - if (Label == NULL) { - if (*TargetCount == 0) { - Found = TRUE; - if (!FindOnly) { - if (MovePast) { - ScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &CommandNode->Link); - } else { - ScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)CommandNode; - } - } - } - } else { - if (gUnicodeCollation->StriColl( - gUnicodeCollation, - (CHAR16*)CommandNameWalker, - (CHAR16*)Label) == 0 - && (*TargetCount) == 0) { - Found = TRUE; - if (!FindOnly) { - // - // we found the target label without loops - // - if (MovePast) { - ScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)(*Function)(&ScriptFile->CommandList, &CommandNode->Link); - } else { - ScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)CommandNode; - } - } - } - } - - // - // Free the memory for this loop... - // - FreePool(CommandName); - return (Found); -} - -/** - Move the script pointer from 1 tag (line) to another. - - It functions so that count starts at 1 and it increases or decreases when it - hits the specified tags. when it hits zero the location has been found. - - DecrementerTag and IncrementerTag are used to get around for/endfor and - similar paired types where the entire middle should be ignored. - - If label is used it will be used instead of the count. - - @param[in] Function The function to use to enumerate through the - list. Normally GetNextNode or GetPreviousNode. - @param[in] DecrementerTag The tag to decrement the count at. - @param[in] IncrementerTag The tag to increment the count at. - @param[in] Label A label to look for. - @param[in, out] ScriptFile The pointer to the current script file structure. - @param[in] MovePast TRUE makes function return 1 past the found - location. - @param[in] FindOnly TRUE to not change the ScriptFile. - @param[in] WrapAroundScript TRUE to wrap end-to-begining or vise versa in - searching. -**/ -BOOLEAN -EFIAPI -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 - ) -{ - SCRIPT_COMMAND_LIST *CommandNode; - BOOLEAN Found; - UINTN TargetCount; - - if (Label == NULL) { - TargetCount = 1; - } else { - TargetCount = 0; - } - - if (ScriptFile == NULL) { - return FALSE; - } - - 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); - } - - 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); - } - } - return (Found); -} - diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.h b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.h deleted file mode 100644 index c4ef536202..0000000000 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.h +++ /dev/null @@ -1,211 +0,0 @@ -/** @file - Main file for NULL named library for level 1 shell command functions. - - Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _UEFI_SHELL_LEVEL1_COMMANDS_LIB_H_ -#define _UEFI_SHELL_LEVEL1_COMMANDS_LIB_H_ - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern EFI_HANDLE gShellLevel1HiiHandle; - -/** - Function for 'stall' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunStall ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -/** - Function for 'exit' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunExit ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -/** - Function for 'endif' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunEndIf ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -/** - Function for 'for' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunFor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -/** - Function for 'endfor' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunEndFor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -/** - Function for 'if' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunIf ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -/** - Function for 'goto' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunGoto ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -/** - Function for 'shift' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunShift ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - - -/** - Function for 'else' command. - - @param[in] ImageHandle Handle to the Image (NULL if Internal). - @param[in] SystemTable Pointer to the System Table (NULL if Internal). -**/ -SHELL_STATUS -EFIAPI -ShellCommandRunElse ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -/// -/// Function prototype for BOTH GetNextNode and GetPreviousNode... -/// This is used to control the MoveToTag function direction... -/// -typedef -LIST_ENTRY * -(EFIAPI *LIST_MANIP_FUNC)( - IN CONST LIST_ENTRY *List, - IN CONST LIST_ENTRY *Node - ); - -/** - Move the script pointer from 1 tag (line) to another. - - It functions so that count starts at 1 and it increases or decreases when it - hits the specified tags. when it hits zero the location has been found. - - DecrementerTag and IncrementerTag are used to get around for/endfor and - similar paired types where the entire middle should be ignored. - - If label is used it will be used instead of the count. - - @param[in] Function The function to use to enumerate through the - list. Normally GetNextNode or GetPreviousNode. - @param[in] DecrementerTag The tag to decrement the count at. - @param[in] IncrementerTag The tag to increment the count at. - @param[in] Label A label to look for. - @param[in, out] ScriptFile The pointer to the current script file structure. - @param[in] MovePast TRUE makes function return 1 past the found - location. - @param[in] FindOnly TRUE to not change the ScriptFile. - @param[in] WrapAroundScript TRUE to wrap end-to-begining or vise versa in - searching. -**/ -BOOLEAN -EFIAPI -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 - ); - -#endif - diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf deleted file mode 100644 index 4d3713b460..0000000000 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf +++ /dev/null @@ -1,58 +0,0 @@ -## @file -# Provides shell level 1 functions -# -# Copyright (c) 2009-2015, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -## -[Defines] - INF_VERSION = 0x00010006 - BASE_NAME = UefiShellLevel1CommandsLib - FILE_GUID = 50cb6037-1102-47af-b2dd-9944b6eb1abe - MODULE_TYPE = UEFI_APPLICATION - VERSION_STRING = 1.0 - LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER - CONSTRUCTOR = ShellLevel1CommandsLibConstructor - DESTRUCTOR = ShellLevel1CommandsLibDestructor - -[Sources.common] - UefiShellLevel1CommandsLib.c - UefiShellLevel1CommandsLib.h - UefiShellLevel1CommandsLib.uni - Exit.c - Goto.c - If.c - For.c - Shift.c - Stall.c - -[Packages] - MdePkg/MdePkg.dec - ShellPkg/ShellPkg.dec - MdeModulePkg/MdeModulePkg.dec - -[LibraryClasses] - MemoryAllocationLib - BaseLib - BaseMemoryLib - DebugLib - ShellCommandLib - ShellLib - UefiLib - UefiRuntimeServicesTableLib - UefiBootServicesTableLib - SortLib - PrintLib - -[Pcd.common] - gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel ## CONSUMES - -[Guids] - gShellLevel1HiiGuid ## SOMETIMES_CONSUMES ## HII diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni deleted file mode 100644 index 40fa57eb02..0000000000 Binary files a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni and /dev/null differ -- cgit v1.2.3