]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellLevel3CommandsLib/Pause.c
udk2010.up2.shell initial release.
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel3CommandsLib / Pause.c
1 /** @file
2 Main file for Pause shell level 3 function.
3
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "UefiShellLevel3CommandsLib.h"
16
17 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
18 {L"-q", TypeFlag},
19 {NULL, TypeMax}
20 };
21
22 /**
23 Function for 'pause' command.
24
25 @param[in] ImageHandle Handle to the Image (NULL if Internal).
26 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
27 **/
28 SHELL_STATUS
29 EFIAPI
30 ShellCommandRunPause (
31 IN EFI_HANDLE ImageHandle,
32 IN EFI_SYSTEM_TABLE *SystemTable
33 )
34 {
35 EFI_STATUS Status;
36 LIST_ENTRY *Package;
37 CHAR16 *ProblemParam;
38 SHELL_STATUS ShellStatus;
39 SHELL_PROMPT_RESPONSE *Resp;
40
41 ProblemParam = NULL;
42 ShellStatus = SHELL_SUCCESS;
43
44 //
45 // initialize the shell lib (we must be in non-auto-init...)
46 //
47 Status = ShellInitialize();
48 ASSERT_EFI_ERROR(Status);
49
50 Status = CommandInit();
51 ASSERT_EFI_ERROR(Status);
52
53 if (!gEfiShellProtocol->BatchIsActive()) {
54 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_SCRIPT_ONLY), gShellLevel3HiiHandle);
55 return (SHELL_UNSUPPORTED);
56 }
57
58 //
59 // parse the command line
60 //
61 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
62 if (EFI_ERROR(Status)) {
63 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
64 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
65 FreePool(ProblemParam);
66 ShellStatus = SHELL_INVALID_PARAMETER;
67 } else {
68 ASSERT(FALSE);
69 }
70 } else {
71 //
72 // check for "-?"
73 //
74 if (ShellCommandLineGetFlag(Package, L"-?")) {
75 ASSERT(FALSE);
76 } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
77 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
78 ShellStatus = SHELL_INVALID_PARAMETER;
79 } else {
80 if (!ShellCommandLineGetFlag(Package, L"-q")) {
81 Status = ShellPromptForResponseHii(ShellPromptResponseTypeQuitContinue, STRING_TOKEN (STR_PAUSE_PROMPT), gShellLevel3HiiHandle, (VOID**)&Resp);
82 } else {
83 Status = ShellPromptForResponse(ShellPromptResponseTypeQuitContinue, NULL, (VOID**)&Resp);
84 }
85 ASSERT_EFI_ERROR(Status);
86
87 if (Resp == NULL || *Resp == ShellPromptResponseQuit) {
88 ShellCommandRegisterExit(TRUE);
89 ShellStatus = SHELL_ABORTED;
90 }
91
92 if (Resp != NULL) {
93 FreePool(Resp);
94 }
95 }
96
97 //
98 // free the command line package
99 //
100 ShellCommandLineFreeVarList (Package);
101 }
102
103
104 return (ShellStatus);
105 }
106