]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c
fix for word wrapping.
[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
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 "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
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 if (!gEfiShellProtocol->BatchIsActive()) {\r
54 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_SCRIPT_ONLY), gShellLevel3HiiHandle);\r
55 return (SHELL_UNSUPPORTED);\r
56 }\r
57\r
58 //\r
59 // parse the command line\r
60 //\r
61 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
62 if (EFI_ERROR(Status)) {\r
63 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
64 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
65 FreePool(ProblemParam);\r
66 ShellStatus = SHELL_INVALID_PARAMETER;\r
67 } else {\r
68 ASSERT(FALSE);\r
69 }\r
70 } else {\r
71 //\r
72 // check for "-?"\r
73 //\r
74 if (ShellCommandLineGetFlag(Package, L"-?")) {\r
75 ASSERT(FALSE);\r
76 } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {\r
77 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);\r
78 ShellStatus = SHELL_INVALID_PARAMETER;\r
79 } else {\r
80 if (!ShellCommandLineGetFlag(Package, L"-q")) {\r
81 Status = ShellPromptForResponseHii(ShellPromptResponseTypeQuitContinue, STRING_TOKEN (STR_PAUSE_PROMPT), gShellLevel3HiiHandle, (VOID**)&Resp);\r
82 } else {\r
83 Status = ShellPromptForResponse(ShellPromptResponseTypeQuitContinue, NULL, (VOID**)&Resp);\r
84 }\r
a405b86d 85\r
a49f6a2f 86 if (EFI_ERROR(Status) || Resp == NULL || *Resp == ShellPromptResponseQuit) {\r
a405b86d 87 ShellCommandRegisterExit(TRUE);\r
88 ShellStatus = SHELL_ABORTED;\r
89 }\r
90\r
91 if (Resp != NULL) {\r
92 FreePool(Resp);\r
93 }\r
94 }\r
95\r
96 //\r
97 // free the command line package\r
98 //\r
99 ShellCommandLineFreeVarList (Package);\r
100 }\r
101\r
102\r
103 return (ShellStatus);\r
104}\r
105\r