]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | Main file for Echo shell level 3 function.\r | |
3 | \r | |
4 | Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r | |
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 | #include <Library/ShellLib.h>\r | |
18 | \r | |
19 | STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r | |
20 | {L"-on", TypeFlag},\r | |
21 | {L"-off", TypeFlag},\r | |
22 | {NULL, TypeMax}\r | |
23 | };\r | |
24 | \r | |
25 | /**\r | |
26 | Function for 'echo' command.\r | |
27 | \r | |
28 | @param[in] ImageHandle Handle to the Image (NULL if Internal).\r | |
29 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r | |
30 | **/\r | |
31 | SHELL_STATUS\r | |
32 | EFIAPI\r | |
33 | ShellCommandRunEcho (\r | |
34 | IN EFI_HANDLE ImageHandle,\r | |
35 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
36 | )\r | |
37 | {\r | |
38 | EFI_STATUS Status;\r | |
39 | LIST_ENTRY *Package;\r | |
40 | // CHAR16 *ProblemParam;\r | |
41 | SHELL_STATUS ShellStatus;\r | |
42 | UINTN ParamCount;\r | |
43 | \r | |
44 | // ProblemParam = NULL;\r | |
45 | ShellStatus = SHELL_SUCCESS;\r | |
46 | \r | |
47 | //\r | |
48 | // initialize the shell lib (we must be in non-auto-init...)\r | |
49 | //\r | |
50 | Status = ShellInitialize();\r | |
51 | ASSERT_EFI_ERROR(Status);\r | |
52 | \r | |
53 | //\r | |
54 | // parse the command line\r | |
55 | //\r | |
56 | Status = ShellCommandLineParseEx (ParamList, &Package, NULL, TRUE, TRUE);\r | |
57 | // if (EFI_ERROR(Status)) {\r | |
58 | // if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r | |
59 | // ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r | |
60 | // FreePool(ProblemParam);\r | |
61 | // ShellStatus = SHELL_INVALID_PARAMETER;\r | |
62 | // } else {\r | |
63 | // ASSERT(FALSE);\r | |
64 | // }\r | |
65 | // } else {\r | |
66 | //\r | |
67 | // check for "-?"\r | |
68 | //\r | |
69 | if (ShellCommandLineGetFlag(Package, L"-?")) {\r | |
70 | ASSERT(FALSE);\r | |
71 | }\r | |
72 | if (ShellCommandLineGetFlag(Package, L"-on")) {\r | |
73 | //\r | |
74 | // Turn it on\r | |
75 | //\r | |
76 | ShellCommandSetEchoState(TRUE);\r | |
77 | } else if (ShellCommandLineGetFlag(Package, L"-off")) {\r | |
78 | //\r | |
79 | // turn it off\r | |
80 | //\r | |
81 | ShellCommandSetEchoState(FALSE);\r | |
82 | } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {\r | |
83 | //\r | |
84 | // output its current state\r | |
85 | //\r | |
86 | if (ShellCommandGetEchoState()) {\r | |
87 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_ON), gShellLevel3HiiHandle);\r | |
88 | } else {\r | |
89 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_OFF), gShellLevel3HiiHandle);\r | |
90 | }\r | |
91 | } else {\r | |
92 | //\r | |
93 | // print the line\r | |
94 | //\r | |
95 | for ( ParamCount = 1\r | |
96 | ; ShellCommandLineGetRawValue(Package, ParamCount) != NULL\r | |
97 | ; ParamCount++\r | |
98 | ) {\r | |
99 | if (ShellCommandLineGetRawValue(Package, ParamCount+1) != NULL) {\r | |
100 | ShellPrintEx(-1, -1, L"%s ", ShellCommandLineGetRawValue(Package, ParamCount));\r | |
101 | } else {\r | |
102 | ShellPrintEx(-1, -1, L"%s", ShellCommandLineGetRawValue(Package, ParamCount));\r | |
103 | }\r | |
104 | }\r | |
105 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF), gShellLevel3HiiHandle);\r | |
106 | }\r | |
107 | \r | |
108 | //\r | |
109 | // free the command line package\r | |
110 | //\r | |
111 | ShellCommandLineFreeVarList (Package);\r | |
112 | // }\r | |
113 | \r | |
114 | return (ShellStatus);\r | |
115 | }\r | |
116 | \r |