2 Main file for attrib shell level 2 function.
4 Copyright (c) 2009 - 2011, 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
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.
15 #include "UefiShellLevel3CommandsLib.h"
18 Function for 'cls' command.
20 @param[in] ImageHandle Handle to the Image (NULL if Internal).
21 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
26 IN EFI_HANDLE ImageHandle
,
27 IN EFI_SYSTEM_TABLE
*SystemTable
35 SHELL_STATUS ShellStatus
;
39 // Initialize variables
41 ShellStatus
= SHELL_SUCCESS
;
46 // initialize the shell lib (we must be in non-auto-init...)
48 Status
= ShellInitialize();
49 ASSERT_EFI_ERROR(Status
);
52 // parse the command line
54 Status
= ShellCommandLineParse (EmptyParamList
, &Package
, &ProblemParam
, TRUE
);
55 if (EFI_ERROR(Status
)) {
56 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
57 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel3HiiHandle
, ProblemParam
);
58 FreePool(ProblemParam
);
59 ShellStatus
= SHELL_INVALID_PARAMETER
;
67 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
71 // If there are 0 value parameters, clear sceen
73 Param1
= ShellCommandLineGetRawValue(Package
, 1);
78 gST
->ConOut
->ClearScreen (gST
->ConOut
);
79 } else if (ShellCommandLineGetCount(Package
) > 2) {
80 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel3HiiHandle
);
81 ShellStatus
= SHELL_INVALID_PARAMETER
;
83 if (ShellStrToUintn(Param1
) > 7 || StrLen(Param1
) > 1 || !ShellIsDecimalDigitCharacter(*Param1
)) {
84 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel3HiiHandle
, Param1
);
85 ShellStatus
= SHELL_INVALID_PARAMETER
;
87 switch (ShellStrToUintn(Param1
)) {
89 Background
= EFI_BACKGROUND_BLACK
;
92 Background
= EFI_BACKGROUND_BLUE
;
95 Background
= EFI_BACKGROUND_GREEN
;
98 Background
= EFI_BACKGROUND_CYAN
;
101 Background
= EFI_BACKGROUND_RED
;
104 Background
= EFI_BACKGROUND_MAGENTA
;
107 Background
= EFI_BACKGROUND_BROWN
;
110 Background
= EFI_BACKGROUND_LIGHTGRAY
;
113 ForeColor
= (~ShellStrToUintn(Param1
)) & 0xF;
114 Status
= gST
->ConOut
->SetAttribute (gST
->ConOut
, ForeColor
| Background
);
115 ASSERT_EFI_ERROR(Status
);
116 Status
= gST
->ConOut
->ClearScreen (gST
->ConOut
);
117 ASSERT_EFI_ERROR(Status
);
123 // free the command line package
125 ShellCommandLineFreeVarList (Package
);
130 return (ShellStatus
);