VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c

Last change on this file was 108794, checked in by vboxsync, 4 weeks ago

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1/** @file
2 Main file for goto shell level 1 function.
3
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#include "UefiShellLevel1CommandsLib.h"
11
12/**
13 Function for 'goto' command.
14
15 @param[in] ImageHandle Handle to the Image (NULL if Internal).
16 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
17**/
18SHELL_STATUS
19EFIAPI
20ShellCommandRunGoto (
21 IN EFI_HANDLE ImageHandle,
22 IN EFI_SYSTEM_TABLE *SystemTable
23 )
24{
25 EFI_STATUS Status;
26 LIST_ENTRY *Package;
27 CHAR16 *ProblemParam;
28 SHELL_STATUS ShellStatus;
29 CHAR16 *CompareString;
30 UINTN Size;
31 SCRIPT_FILE *CurrentScriptFile;
32
33 ShellStatus = SHELL_SUCCESS;
34 CompareString = NULL;
35
36 //
37 // initialize the shell lib (we must be in non-auto-init...)
38 //
39 Status = ShellInitialize ();
40 ASSERT_EFI_ERROR (Status);
41
42 Status = CommandInit ();
43 ASSERT_EFI_ERROR (Status);
44
45 if (!gEfiShellProtocol->BatchIsActive ()) {
46 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Goto");
47 return (SHELL_UNSUPPORTED);
48 }
49
50 //
51 // parse the command line
52 //
53 Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
54 if (EFI_ERROR (Status)) {
55 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
56 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"goto", ProblemParam);
57 FreePool (ProblemParam);
58 ShellStatus = SHELL_INVALID_PARAMETER;
59 } else {
60 ASSERT (FALSE);
61 }
62 } else {
63 if (ShellCommandLineGetRawValue (Package, 2) != NULL) {
64 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"goto");
65 ShellStatus = SHELL_INVALID_PARAMETER;
66 } else if (ShellCommandLineGetRawValue (Package, 1) == NULL) {
67 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"goto");
68 ShellStatus = SHELL_INVALID_PARAMETER;
69 } else {
70 Size = 0;
71 ASSERT ((CompareString == NULL && Size == 0) || (CompareString != NULL));
72 CompareString = StrnCatGrow (&CompareString, &Size, L":", 0);
73 CompareString = StrnCatGrow (&CompareString, &Size, ShellCommandLineGetRawValue (Package, 1), 0);
74 if (CompareString == NULL) {
75 ShellCommandLineFreeVarList (Package);
76 return SHELL_OUT_OF_RESOURCES;
77 }
78
79 //
80 // Check forwards and then backwards for a label...
81 //
82 if (!MoveToTag (GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile (), FALSE, FALSE, TRUE)) {
83 CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
84 ShellPrintHiiEx (
85 -1,
86 -1,
87 NULL,
88 STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
89 gShellLevel1HiiHandle,
90 CompareString,
91 L"Goto",
92 CurrentScriptFile != NULL
93 && CurrentScriptFile->CurrentCommand != NULL
94 ? CurrentScriptFile->CurrentCommand->Line : 0
95 );
96 ShellStatus = SHELL_NOT_FOUND;
97 }
98
99 FreePool (CompareString);
100 }
101
102 ShellCommandLineFreeVarList (Package);
103 }
104
105 return (ShellStatus);
106}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette