]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c
Refine code to make code follow the coding style.
[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
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
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
39\r
40 ShellStatus = SHELL_SUCCESS;\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 //\r
52 // parse the command line\r
53 //\r
54 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
55 if (EFI_ERROR(Status)) {\r
56 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
57 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, ProblemParam);\r
58 FreePool(ProblemParam);\r
59 ShellStatus = SHELL_INVALID_PARAMETER;\r
60 } else {\r
61 ASSERT(FALSE);\r
62 }\r
63 } else {\r
64\r
65 //\r
66 // If we are in a batch file and /b then pass TRUE otherwise false...\r
67 //\r
68 ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")));\r
69\r
70 //\r
71 // return the specified error code\r
72 //\r
73 if (ShellCommandLineGetRawValue(Package, 1) != NULL) {\r
74 ShellStatus = (SHELL_STATUS)(ShellStrToUintn(ShellCommandLineGetRawValue(Package, 1)));\r
75 }\r
76\r
77 ShellCommandLineFreeVarList (Package);\r
78 }\r
79 return (ShellStatus);\r
80}\r
81\r