]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | Main file for Echo shell level 3 function.\r | |
3 | \r | |
eefe286b | 4 | Copyright (c) 2009 - 2012, 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 | #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 | |
a405b86d | 40 | SHELL_STATUS ShellStatus;\r |
41 | UINTN ParamCount;\r | |
345cd235 | 42 | CHAR16 *ProblemParam;\r |
eefe286b | 43 | UINTN Size;\r |
44 | CHAR16 *PrintString;\r | |
a405b86d | 45 | \r |
eefe286b | 46 | Size = 0;\r |
345cd235 | 47 | ProblemParam = NULL;\r |
eefe286b | 48 | PrintString = NULL;\r |
a405b86d | 49 | ShellStatus = SHELL_SUCCESS;\r |
50 | \r | |
51 | //\r | |
52 | // initialize the shell lib (we must be in non-auto-init...)\r | |
53 | //\r | |
54 | Status = ShellInitialize();\r | |
55 | ASSERT_EFI_ERROR(Status);\r | |
56 | \r | |
57 | //\r | |
58 | // parse the command line\r | |
59 | //\r | |
345cd235 | 60 | Status = ShellCommandLineParseEx (ParamList, &Package, &ProblemParam, TRUE, TRUE);\r |
61 | if (EFI_ERROR(Status)) {\r | |
62 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r | |
63 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r | |
64 | FreePool(ProblemParam);\r | |
65 | ShellStatus = SHELL_INVALID_PARAMETER;\r | |
66 | } else {\r | |
67 | ASSERT(FALSE);\r | |
68 | }\r | |
69 | } else {\r | |
a405b86d | 70 | //\r |
71 | // check for "-?"\r | |
72 | //\r | |
73 | if (ShellCommandLineGetFlag(Package, L"-?")) {\r | |
74 | ASSERT(FALSE);\r | |
75 | }\r | |
76 | if (ShellCommandLineGetFlag(Package, L"-on")) {\r | |
77 | //\r | |
78 | // Turn it on\r | |
79 | //\r | |
80 | ShellCommandSetEchoState(TRUE);\r | |
81 | } else if (ShellCommandLineGetFlag(Package, L"-off")) {\r | |
82 | //\r | |
83 | // turn it off\r | |
84 | //\r | |
85 | ShellCommandSetEchoState(FALSE);\r | |
86 | } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {\r | |
87 | //\r | |
88 | // output its current state\r | |
89 | //\r | |
90 | if (ShellCommandGetEchoState()) {\r | |
91 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_ON), gShellLevel3HiiHandle);\r | |
92 | } else {\r | |
93 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_ECHO_OFF), gShellLevel3HiiHandle);\r | |
94 | }\r | |
95 | } else {\r | |
96 | //\r | |
97 | // print the line\r | |
98 | //\r | |
99 | for ( ParamCount = 1\r | |
100 | ; ShellCommandLineGetRawValue(Package, ParamCount) != NULL\r | |
101 | ; ParamCount++\r | |
102 | ) {\r | |
eefe286b | 103 | StrnCatGrow(&PrintString, &Size, ShellCommandLineGetRawValue(Package, ParamCount), 0);\r |
a405b86d | 104 | if (ShellCommandLineGetRawValue(Package, ParamCount+1) != NULL) {\r |
eefe286b | 105 | StrnCatGrow(&PrintString, &Size, L" ", 0);\r |
106 | } \r | |
a405b86d | 107 | }\r |
eefe286b | 108 | ShellPrintEx(-1, -1, L"%s\r\n", PrintString);\r |
109 | SHELL_FREE_NON_NULL(PrintString);\r | |
a405b86d | 110 | }\r |
111 | \r | |
112 | //\r | |
113 | // free the command line package\r | |
114 | //\r | |
115 | ShellCommandLineFreeVarList (Package);\r | |
345cd235 | 116 | }\r |
a405b86d | 117 | \r |
118 | return (ShellStatus);\r | |
119 | }\r | |
120 | \r |