]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c
add support to easily remove profiles and shell levels. the libraries will not do...
[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
32 CHAR16 *Message;\r
33 UINTN Background;\r
34 UINTN ForeColor;\r
35 CHAR16 *ProblemParam;\r
36 SHELL_STATUS ShellStatus;\r
37 CONST CHAR16 *Param1;\r
38\r
39 ShellStatus = SHELL_SUCCESS;\r
40 ProblemParam = NULL;\r
41 Background = 0;\r
42\r
43 //\r
44 // Initialize variables\r
45 //\r
46 Message = NULL;\r
47\r
48 //\r
49 // initialize the shell lib (we must be in non-auto-init...)\r
50 //\r
51 Status = ShellInitialize();\r
52 ASSERT_EFI_ERROR(Status);\r
53\r
54 //\r
55 // parse the command line\r
56 //\r
57 Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r
58 if (EFI_ERROR(Status)) {\r
59 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
60 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
61 FreePool(ProblemParam);\r
62 ShellStatus = SHELL_INVALID_PARAMETER;\r
63 } else {\r
64 ASSERT(FALSE);\r
65 }\r
66 } else {\r
67 //\r
68 // check for "-?"\r
69 //\r
70 if (ShellCommandLineGetFlag(Package, L"-?")) {\r
71 ASSERT(FALSE);\r
72 } else {\r
73 //\r
74 // If there are 0 value parameters, clear sceen\r
75 //\r
76 Param1 = ShellCommandLineGetRawValue(Package, 1);\r
77 if (Param1 == NULL) {\r
78 //\r
79 // clear screen\r
80 //\r
81 gST->ConOut->ClearScreen (gST->ConOut);\r
82 } else if (ShellCommandLineGetCount(Package) > 2) {\r
83 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);\r
84 ShellStatus = SHELL_INVALID_PARAMETER;\r
85 } else {\r
345cd235 86 if (ShellStrToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {\r
a405b86d 87 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, Param1);\r
88 ShellStatus = SHELL_INVALID_PARAMETER;\r
89 } else {\r
345cd235 90 switch (ShellStrToUintn(Param1)) {\r
a405b86d 91 case 0:\r
92 Background = EFI_BACKGROUND_BLACK;\r
93 break;\r
94 case 1:\r
95 Background = EFI_BACKGROUND_BLUE;\r
96 break;\r
97 case 2:\r
98 Background = EFI_BACKGROUND_GREEN;\r
99 break;\r
100 case 3:\r
101 Background = EFI_BACKGROUND_CYAN;\r
102 break;\r
103 case 4:\r
104 Background = EFI_BACKGROUND_RED;\r
105 break;\r
106 case 5:\r
107 Background = EFI_BACKGROUND_MAGENTA;\r
108 break;\r
109 case 6:\r
110 Background = EFI_BACKGROUND_BROWN;\r
111 break;\r
112 case 7:\r
113 Background = EFI_BACKGROUND_LIGHTGRAY;\r
114 break;\r
115 }\r
345cd235 116 ForeColor = (~ShellStrToUintn(Param1)) & 0xF;\r
a405b86d 117 Status = gST->ConOut->SetAttribute (gST->ConOut, ForeColor | Background);\r
118 ASSERT_EFI_ERROR(Status);\r
119 Status = gST->ConOut->ClearScreen (gST->ConOut);\r
120 ASSERT_EFI_ERROR(Status);\r
121 }\r
122 }\r
123 }\r
124 }\r
125 //\r
126 // free the command line package\r
127 //\r
128 ShellCommandLineFreeVarList (Package);\r
129\r
130 //\r
131 // return the status\r
132 //\r
133 return (ShellStatus);\r
134}\r
135\r