]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c
ShellPkg: Update behavior for GetTime() errors.
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel3CommandsLib / Cls.c
CommitLineData
a405b86d 1/** @file\r
2 Main file for attrib shell level 2 function.\r
3\r
345cd235 4 Copyright (c) 2009 - 2011, 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
17/**\r
18 Function for 'cls' command.\r
19\r
20 @param[in] ImageHandle Handle to the Image (NULL if Internal).\r
21 @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r
22**/\r
23SHELL_STATUS\r
24EFIAPI\r
25ShellCommandRunCls (\r
26 IN EFI_HANDLE ImageHandle,\r
27 IN EFI_SYSTEM_TABLE *SystemTable\r
28 )\r
29{\r
30 EFI_STATUS Status;\r
31 LIST_ENTRY *Package;\r
a405b86d 32 UINTN Background;\r
33 UINTN ForeColor;\r
34 CHAR16 *ProblemParam;\r
35 SHELL_STATUS ShellStatus;\r
36 CONST CHAR16 *Param1;\r
37\r
a405b86d 38 //\r
39 // Initialize variables\r
40 //\r
e755a4ca 41 ShellStatus = SHELL_SUCCESS;\r
42 ProblemParam = NULL;\r
43 Background = 0;\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 //\r
52 // parse the command line\r
53 //\r
54 Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r
55 if (EFI_ERROR(Status)) {\r
56 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
57 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
58 FreePool(ProblemParam);\r
59 ShellStatus = SHELL_INVALID_PARAMETER;\r
60 } else {\r
61 ASSERT(FALSE);\r
62 }\r
63 } else {\r
64 //\r
65 // check for "-?"\r
66 //\r
67 if (ShellCommandLineGetFlag(Package, L"-?")) {\r
68 ASSERT(FALSE);\r
69 } else {\r
70 //\r
71 // If there are 0 value parameters, clear sceen\r
72 //\r
73 Param1 = ShellCommandLineGetRawValue(Package, 1);\r
74 if (Param1 == NULL) {\r
75 //\r
76 // clear screen\r
77 //\r
78 gST->ConOut->ClearScreen (gST->ConOut);\r
79 } else if (ShellCommandLineGetCount(Package) > 2) {\r
80 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);\r
81 ShellStatus = SHELL_INVALID_PARAMETER;\r
82 } else {\r
345cd235 83 if (ShellStrToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {\r
a405b86d 84 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, Param1);\r
85 ShellStatus = SHELL_INVALID_PARAMETER;\r
86 } else {\r
345cd235 87 switch (ShellStrToUintn(Param1)) {\r
a405b86d 88 case 0:\r
89 Background = EFI_BACKGROUND_BLACK;\r
90 break;\r
91 case 1:\r
92 Background = EFI_BACKGROUND_BLUE;\r
93 break;\r
94 case 2:\r
95 Background = EFI_BACKGROUND_GREEN;\r
96 break;\r
97 case 3:\r
98 Background = EFI_BACKGROUND_CYAN;\r
99 break;\r
100 case 4:\r
101 Background = EFI_BACKGROUND_RED;\r
102 break;\r
103 case 5:\r
104 Background = EFI_BACKGROUND_MAGENTA;\r
105 break;\r
106 case 6:\r
107 Background = EFI_BACKGROUND_BROWN;\r
108 break;\r
109 case 7:\r
110 Background = EFI_BACKGROUND_LIGHTGRAY;\r
111 break;\r
112 }\r
345cd235 113 ForeColor = (~ShellStrToUintn(Param1)) & 0xF;\r
a405b86d 114 Status = gST->ConOut->SetAttribute (gST->ConOut, ForeColor | Background);\r
115 ASSERT_EFI_ERROR(Status);\r
116 Status = gST->ConOut->ClearScreen (gST->ConOut);\r
117 ASSERT_EFI_ERROR(Status);\r
118 }\r
119 }\r
120 }\r
121 }\r
122 //\r
123 // free the command line package\r
124 //\r
125 ShellCommandLineFreeVarList (Package);\r
126\r
127 //\r
128 // return the status\r
129 //\r
130 return (ShellStatus);\r
131}\r
132\r