]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c
NetworkPkg: Clean the previous address since the policy changed
[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
c011b6c9 4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
17e59b33 5 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>\r
a405b86d 6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "UefiShellLevel3CommandsLib.h"\r
17\r
18/**\r
19 Function for 'cls' command.\r
20\r
21 @param[in] ImageHandle Handle to the Image (NULL if Internal).\r
22 @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r
23**/\r
24SHELL_STATUS\r
25EFIAPI\r
26ShellCommandRunCls (\r
27 IN EFI_HANDLE ImageHandle,\r
28 IN EFI_SYSTEM_TABLE *SystemTable\r
29 )\r
30{\r
31 EFI_STATUS Status;\r
32 LIST_ENTRY *Package;\r
a405b86d 33 UINTN Background;\r
34 UINTN ForeColor;\r
35 CHAR16 *ProblemParam;\r
36 SHELL_STATUS ShellStatus;\r
37 CONST CHAR16 *Param1;\r
38\r
a405b86d 39 //\r
40 // Initialize variables\r
41 //\r
e755a4ca 42 ShellStatus = SHELL_SUCCESS;\r
43 ProblemParam = NULL;\r
44 Background = 0;\r
a405b86d 45\r
46 //\r
47 // initialize the shell lib (we must be in non-auto-init...)\r
48 //\r
49 Status = ShellInitialize();\r
50 ASSERT_EFI_ERROR(Status);\r
51\r
52 //\r
53 // parse the command line\r
54 //\r
55 Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r
56 if (EFI_ERROR(Status)) {\r
57 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
e54a10bb 58 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"cls", ProblemParam); \r
a405b86d 59 FreePool(ProblemParam);\r
60 ShellStatus = SHELL_INVALID_PARAMETER;\r
61 } else {\r
62 ASSERT(FALSE);\r
63 }\r
64 } else {\r
65 //\r
66 // check for "-?"\r
67 //\r
68 if (ShellCommandLineGetFlag(Package, L"-?")) {\r
69 ASSERT(FALSE);\r
70 } else {\r
71 //\r
72 // If there are 0 value parameters, clear sceen\r
73 //\r
74 Param1 = ShellCommandLineGetRawValue(Package, 1);\r
75 if (Param1 == NULL) {\r
76 //\r
77 // clear screen\r
78 //\r
79 gST->ConOut->ClearScreen (gST->ConOut);\r
80 } else if (ShellCommandLineGetCount(Package) > 2) {\r
e54a10bb 81 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"cls"); \r
a405b86d 82 ShellStatus = SHELL_INVALID_PARAMETER;\r
83 } else {\r
345cd235 84 if (ShellStrToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {\r
e54a10bb 85 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"cls", Param1); \r
a405b86d 86 ShellStatus = SHELL_INVALID_PARAMETER;\r
87 } else {\r
345cd235 88 switch (ShellStrToUintn(Param1)) {\r
a405b86d 89 case 0:\r
90 Background = EFI_BACKGROUND_BLACK;\r
91 break;\r
92 case 1:\r
93 Background = EFI_BACKGROUND_BLUE;\r
94 break;\r
95 case 2:\r
96 Background = EFI_BACKGROUND_GREEN;\r
97 break;\r
98 case 3:\r
99 Background = EFI_BACKGROUND_CYAN;\r
100 break;\r
101 case 4:\r
102 Background = EFI_BACKGROUND_RED;\r
103 break;\r
104 case 5:\r
105 Background = EFI_BACKGROUND_MAGENTA;\r
106 break;\r
107 case 6:\r
108 Background = EFI_BACKGROUND_BROWN;\r
109 break;\r
110 case 7:\r
111 Background = EFI_BACKGROUND_LIGHTGRAY;\r
112 break;\r
113 }\r
345cd235 114 ForeColor = (~ShellStrToUintn(Param1)) & 0xF;\r
17e59b33 115 Status = gST->ConOut->SetAttribute (gST->ConOut, (ForeColor | Background) & 0x7F );\r
a405b86d 116 ASSERT_EFI_ERROR(Status);\r
117 Status = gST->ConOut->ClearScreen (gST->ConOut);\r
118 ASSERT_EFI_ERROR(Status);\r
119 }\r
120 }\r
121 }\r
122 }\r
123 //\r
124 // free the command line package\r
125 //\r
126 ShellCommandLineFreeVarList (Package);\r
127\r
128 //\r
129 // return the status\r
130 //\r
131 return (ShellStatus);\r
132}\r
133\r