]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c
Update code to support VS2013 tool chain.
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel3CommandsLib / Pause.c
CommitLineData
a405b86d 1/** @file\r
2 Main file for Pause shell level 3 function.\r
3\r
0d807dae 4 Copyright (c) 2009 - 2014, 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 "UefiShellLevel3CommandsLib.h"\r
16\r
17STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
18 {L"-q", TypeFlag},\r
19 {NULL, TypeMax}\r
20 };\r
21\r
22/**\r
23 Function for 'pause' 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
30ShellCommandRunPause (\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 SHELL_PROMPT_RESPONSE *Resp;\r
40\r
41 ProblemParam = NULL;\r
42 ShellStatus = SHELL_SUCCESS;\r
0d807dae 43 Resp = NULL;\r
a405b86d 44\r
45 //\r
46 // initialize the shell lib (we must be in non-auto-init...)\r
47 //\r
48 Status = ShellInitialize();\r
49 ASSERT_EFI_ERROR(Status);\r
50\r
51 Status = CommandInit();\r
52 ASSERT_EFI_ERROR(Status);\r
53\r
54 if (!gEfiShellProtocol->BatchIsActive()) {\r
55 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_SCRIPT_ONLY), gShellLevel3HiiHandle);\r
56 return (SHELL_UNSUPPORTED);\r
57 }\r
58\r
59 //\r
60 // parse the command line\r
61 //\r
62 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
63 if (EFI_ERROR(Status)) {\r
64 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
65 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
66 FreePool(ProblemParam);\r
67 ShellStatus = SHELL_INVALID_PARAMETER;\r
68 } else {\r
69 ASSERT(FALSE);\r
70 }\r
71 } else {\r
72 //\r
73 // check for "-?"\r
74 //\r
75 if (ShellCommandLineGetFlag(Package, L"-?")) {\r
76 ASSERT(FALSE);\r
77 } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {\r
78 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);\r
79 ShellStatus = SHELL_INVALID_PARAMETER;\r
80 } else {\r
81 if (!ShellCommandLineGetFlag(Package, L"-q")) {\r
82 Status = ShellPromptForResponseHii(ShellPromptResponseTypeQuitContinue, STRING_TOKEN (STR_PAUSE_PROMPT), gShellLevel3HiiHandle, (VOID**)&Resp);\r
83 } else {\r
84 Status = ShellPromptForResponse(ShellPromptResponseTypeQuitContinue, NULL, (VOID**)&Resp);\r
85 }\r
a405b86d 86\r
a49f6a2f 87 if (EFI_ERROR(Status) || Resp == NULL || *Resp == ShellPromptResponseQuit) {\r
b6b22b13 88 ShellCommandRegisterExit(TRUE, 0);\r
a405b86d 89 ShellStatus = SHELL_ABORTED;\r
90 }\r
91\r
92 if (Resp != NULL) {\r
93 FreePool(Resp);\r
94 }\r
95 }\r
96\r
97 //\r
98 // free the command line package\r
99 //\r
100 ShellCommandLineFreeVarList (Package);\r
101 }\r
102\r
103\r
104 return (ShellStatus);\r
105}\r
106\r