]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | Main file for goto shell level 1 function.\r | |
3 | \r | |
c011b6c9 | 4 | (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r |
a405b86d | 5 | Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "UefiShellLevel1CommandsLib.h"\r | |
17 | \r | |
18 | /**\r | |
19 | Function for 'goto' command.\r | |
20 | \r | |
21 | @param[in] ImageHandle Handle to the Image (NULL if Internal).\r | |
22 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r | |
23 | **/\r | |
24 | SHELL_STATUS\r | |
25 | EFIAPI\r | |
26 | ShellCommandRunGoto (\r | |
27 | IN EFI_HANDLE ImageHandle,\r | |
28 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
29 | )\r | |
30 | {\r | |
31 | EFI_STATUS Status;\r | |
32 | LIST_ENTRY *Package;\r | |
33 | CHAR16 *ProblemParam;\r | |
34 | SHELL_STATUS ShellStatus;\r | |
35 | CHAR16 *CompareString;\r | |
36 | UINTN Size;\r | |
ae724571 | 37 | SCRIPT_FILE *CurrentScriptFile;\r |
a405b86d | 38 | \r |
39 | ShellStatus = SHELL_SUCCESS;\r | |
40 | CompareString = NULL;\r | |
41 | \r | |
42 | //\r | |
43 | // initialize the shell lib (we must be in non-auto-init...)\r | |
44 | //\r | |
45 | Status = ShellInitialize();\r | |
46 | ASSERT_EFI_ERROR(Status);\r | |
47 | \r | |
48 | Status = CommandInit();\r | |
49 | ASSERT_EFI_ERROR(Status);\r | |
50 | \r | |
51 | if (!gEfiShellProtocol->BatchIsActive()) {\r | |
52 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"Goto");\r | |
53 | return (SHELL_UNSUPPORTED);\r | |
54 | }\r | |
55 | \r | |
56 | //\r | |
57 | // parse the command line\r | |
58 | //\r | |
59 | Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r | |
60 | if (EFI_ERROR(Status)) {\r | |
61 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r | |
0861edab | 62 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"goto", ProblemParam);\r |
a405b86d | 63 | FreePool(ProblemParam);\r |
64 | ShellStatus = SHELL_INVALID_PARAMETER;\r | |
65 | } else {\r | |
66 | ASSERT(FALSE);\r | |
67 | }\r | |
68 | } else {\r | |
69 | if (ShellCommandLineGetRawValue(Package, 2) != NULL) {\r | |
0861edab | 70 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"goto");\r |
a405b86d | 71 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
72 | } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {\r | |
0861edab | 73 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"goto");\r |
a405b86d | 74 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
75 | } else {\r | |
76 | Size = 0;\r | |
77 | ASSERT((CompareString == NULL && Size == 0) || (CompareString != NULL));\r | |
78 | CompareString = StrnCatGrow(&CompareString, &Size, L":", 0);\r | |
79 | CompareString = StrnCatGrow(&CompareString, &Size, ShellCommandLineGetRawValue(Package, 1), 0);\r | |
80 | //\r | |
81 | // Check forwards and then backwards for a label...\r | |
82 | //\r | |
83 | if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) {\r | |
ae724571 | 84 | CurrentScriptFile = ShellCommandGetCurrentScriptFile();\r |
33c031ee | 85 | ShellPrintHiiEx(\r |
86 | -1, \r | |
87 | -1, \r | |
88 | NULL, \r | |
89 | STRING_TOKEN (STR_SYNTAX_NO_MATCHING), \r | |
90 | gShellLevel1HiiHandle, \r | |
91 | CompareString, \r | |
92 | L"Goto", \r | |
ae724571 | 93 | CurrentScriptFile!=NULL \r |
94 | && CurrentScriptFile->CurrentCommand!=NULL\r | |
95 | ? CurrentScriptFile->CurrentCommand->Line:0);\r | |
a405b86d | 96 | ShellStatus = SHELL_NOT_FOUND;\r |
97 | }\r | |
98 | FreePool(CompareString);\r | |
99 | }\r | |
100 | ShellCommandLineFreeVarList (Package);\r | |
101 | }\r | |
102 | \r | |
103 | return (ShellStatus);\r | |
104 | }\r | |
105 | \r |