]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c
ShellParametersProtocol - remove parsing from within quoted parameters.
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel1CommandsLib / Exit.c
CommitLineData
a405b86d 1/** @file\r
2 Main file for exit shell level 1 function.\r
3\r
77dcec12 4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
a405b86d 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "UefiShellLevel1CommandsLib.h"\r
16\r
17STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
18 {L"/b", TypeFlag},\r
19 {NULL, TypeMax}\r
20 };\r
21\r
22/**\r
23 Function for 'exit' command.\r
24\r
25 @param[in] ImageHandle Handle to the Image (NULL if Internal).\r
26 @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r
27**/\r
28SHELL_STATUS\r
29EFIAPI\r
30ShellCommandRunExit (\r
31 IN EFI_HANDLE ImageHandle,\r
32 IN EFI_SYSTEM_TABLE *SystemTable\r
33 )\r
34{\r
35 EFI_STATUS Status;\r
36 LIST_ENTRY *Package;\r
37 CHAR16 *ProblemParam;\r
38 SHELL_STATUS ShellStatus;\r
77dcec12 39 UINT64 RetVal;\r
40 CONST CHAR16 *Return;\r
a405b86d 41\r
42 ShellStatus = SHELL_SUCCESS;\r
43\r
44 //\r
45 // initialize the shell lib (we must be in non-auto-init...)\r
46 //\r
47 Status = ShellInitialize();\r
48 ASSERT_EFI_ERROR(Status);\r
49\r
50 Status = CommandInit();\r
51 ASSERT_EFI_ERROR(Status);\r
52\r
53 //\r
54 // parse the command line\r
55 //\r
56 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
57 if (EFI_ERROR(Status)) {\r
58 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
59 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, ProblemParam);\r
60 FreePool(ProblemParam);\r
61 ShellStatus = SHELL_INVALID_PARAMETER;\r
62 } else {\r
63 ASSERT(FALSE);\r
64 }\r
65 } else {\r
66\r
a405b86d 67 //\r
68 // return the specified error code\r
69 //\r
77dcec12 70 Return = ShellCommandLineGetRawValue(Package, 1);\r
71 if (Return != NULL) {\r
72 Status = ShellConvertStringToUint64(Return, &RetVal, FALSE, FALSE);\r
73 if (EFI_ERROR(Status)) {\r
74 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, Return);\r
75 ShellStatus = SHELL_INVALID_PARAMETER;\r
76 } else {\r
77 //\r
78 // If we are in a batch file and /b then pass TRUE otherwise false...\r
79 //\r
80 ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")));\r
81\r
82 ShellStatus = (SHELL_STATUS)(RetVal);\r
83 }\r
84 } else {\r
85 // If we are in a batch file and /b then pass TRUE otherwise false...\r
86 //\r
87 ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")));\r
88\r
89 ShellStatus = (SHELL_STATUS)0;\r
a405b86d 90 }\r
91\r
92 ShellCommandLineFreeVarList (Package);\r
93 }\r
94 return (ShellStatus);\r
95}\r
96\r