2 Main file for attrib shell level 2 function.
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiShellLevel3CommandsLib.h"
19 Function for 'cls' command.
21 @param[in] ImageHandle Handle to the Image (NULL if Internal).
22 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
27 IN EFI_HANDLE ImageHandle
,
28 IN EFI_SYSTEM_TABLE
*SystemTable
36 SHELL_STATUS ShellStatus
;
40 // Initialize variables
42 ShellStatus
= SHELL_SUCCESS
;
47 // initialize the shell lib (we must be in non-auto-init...)
49 Status
= ShellInitialize();
50 ASSERT_EFI_ERROR(Status
);
53 // parse the command line
55 Status
= ShellCommandLineParse (EmptyParamList
, &Package
, &ProblemParam
, TRUE
);
56 if (EFI_ERROR(Status
)) {
57 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
58 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel3HiiHandle
, L
"cls", ProblemParam
);
59 FreePool(ProblemParam
);
60 ShellStatus
= SHELL_INVALID_PARAMETER
;
68 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
72 // If there are 0 value parameters, clear sceen
74 Param1
= ShellCommandLineGetRawValue(Package
, 1);
79 gST
->ConOut
->ClearScreen (gST
->ConOut
);
80 } else if (ShellCommandLineGetCount(Package
) > 2) {
81 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel3HiiHandle
, L
"cls");
82 ShellStatus
= SHELL_INVALID_PARAMETER
;
84 if (ShellStrToUintn(Param1
) > 7 || StrLen(Param1
) > 1 || !ShellIsDecimalDigitCharacter(*Param1
)) {
85 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellLevel3HiiHandle
, L
"cls", Param1
);
86 ShellStatus
= SHELL_INVALID_PARAMETER
;
88 switch (ShellStrToUintn(Param1
)) {
90 Background
= EFI_BACKGROUND_BLACK
;
93 Background
= EFI_BACKGROUND_BLUE
;
96 Background
= EFI_BACKGROUND_GREEN
;
99 Background
= EFI_BACKGROUND_CYAN
;
102 Background
= EFI_BACKGROUND_RED
;
105 Background
= EFI_BACKGROUND_MAGENTA
;
108 Background
= EFI_BACKGROUND_BROWN
;
111 Background
= EFI_BACKGROUND_LIGHTGRAY
;
114 ForeColor
= (~ShellStrToUintn(Param1
)) & 0xF;
115 Status
= gST
->ConOut
->SetAttribute (gST
->ConOut
, (ForeColor
| Background
) & 0x7F );
116 ASSERT_EFI_ERROR(Status
);
117 Status
= gST
->ConOut
->ClearScreen (gST
->ConOut
);
118 ASSERT_EFI_ERROR(Status
);
124 // free the command line package
126 ShellCommandLineFreeVarList (Package
);
131 return (ShellStatus
);