/** @file
Main file for endfor and for shell level 1 functions.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
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
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 <Library/PrintLib.h>
/**
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.
**/
)
{
return (FALSE);
}
if (*Number == L'-') {
Number++;
}
return (FALSE);
}
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).
**/
)
{
Status = CommandInit();
if (!gEfiShellProtocol->BatchIsActive()) {
return (SHELL_UNSUPPORTED);
}
return (SHELL_INVALID_PARAMETER);
}
Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE);
if (!Found) {
-1,
-1,
NULL,
L"For",
L"EndFor",
return (SHELL_NOT_FOUND);
}
return (SHELL_SUCCESS);
}
typedef struct {
/**
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.
**/
)
{
//
// assert for NULL parameter
//
//
// check for the Alias
//
){
break;
}
}
if (!Found) {
return (EFI_OUT_OF_RESOURCES);
}
}
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.
**/
)
{
//
// assert for NULL parameter
//
//
// check for the Alias
//
){
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.
**/
)
{
//
// assert for NULL parameter
//
//
// check for the Alias
//
){
return (TRUE);
}
}
return (FALSE);
}
/**
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).
**/
)
{
ArgSize = 0;
ArgSetWalker = NULL;
TempString = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
Status = CommandInit();
if (!gEfiShellProtocol->BatchIsActive()) {
return (SHELL_UNSUPPORTED);
}
return (SHELL_INVALID_PARAMETER);
}
//
// Make sure that an End exists.
//
-1,
-1,
NULL,
L"EndFor",
L"For",
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(
L"in",
// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
} else {
}
Status = ShellOpenFileMetaArg ((CHAR16*)gEfiShellParametersProtocol->Argv[LoopVar], EFI_FILE_MODE_READ, &FileList);
} else {
){
}
}
} else {
}
}
} else {
//
// set up for an 'in' for loop
//
CopyMem(Info->Set+(StrSize(ArgSet)/sizeof(Info->Set[0])), gEfiShellParametersProtocol->Argv[1], NewSize);
} else {
}
}
} else if (gUnicodeCollation->StriColl(
L"run",
// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
} else {
}
// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
}
} else {
//
// set up for a 'run' for loop
//
CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1]));
if (ArgSetWalker[0] != L'(') {
-1,
-1,
NULL,
} else {
if (*(TempString) != CHAR_NULL) {
TempString++;
}
if (StrLen(TempString) > 0) {
}
}
}
-1,
-1,
NULL,
} else {
ArgSetWalker++;
ArgSetWalker++;
}
if (!ShellIsValidForNumber(ArgSetWalker)) {
-1,
-1,
NULL,
} else {
if (ArgSetWalker[0] == L'-') {
} else {
}
ArgSetWalker++;
}
-1,
-1,
NULL,
} else {
if (ArgSetWalker[0] == L'-') {
} else {
}
} else {
}
ArgSetWalker++;
}
-1,
-1,
NULL,
} else {
if (*ArgSetWalker == L')') {
} else {
if (ArgSetWalker[0] == L'-') {
} else {
}
-1,
-1,
NULL,
}
}
}
}
}
}
}
}
if (ShellStatus == SHELL_SUCCESS) {
} else {
}
}
}
}
} else {
-1,
-1,
NULL,
}
} else {
//
// These need to be NULL since they are used to determine if this is the first pass later on...
//
}
}
} else {
}
if (ShellStatus == SHELL_SUCCESS) {
//
// only advance if not the first pass
//
if (!FirstPass) {
//
// sequence version of for loop...
//
}
if ((Info->Step > 0 && Info->Current > Info->End) || (Info->Step < 0 && Info->Current < Info->End)) {
//
// find the matching endfor (we're done with the loop)
//
-1,
-1,
NULL,
L"EndFor",
L"For",
}
if (Info->RemoveSubstAlias) {
//
// remove item from list
//
}
}
} else {
//
// Must be in 'in' version of for loop...
//
Info->CurrentValue++;
}
// while (Info->CurrentValue[0] == L' ') {
// Info->CurrentValue++;
// }
Info->CurrentValue++;
}
//
// do the next one of the set
//
if (TempString == NULL) {
} else {
}
}
Info->CurrentValue++;
}
Info->CurrentValue++;
}
Info->CurrentValue++;
}
}
} else {
//
// find the matching endfor (we're done with the loop)
//
-1,
-1,
NULL,
L"EndFor",
L"For",
}
if (Info->RemoveSubstAlias) {
//
// remove item from list
//
}
}
}
}
}
return (ShellStatus);
}