]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | Main file for Help shell level 3 function.\r | |
3 | \r | |
ba0014b9 | 4 | Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. <BR>\r |
710db4e8 | 5 | Copyright (c) 2014, ARM Limited. All rights reserved. <BR>\r |
c011b6c9 | 6 | (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r |
e54a10bb | 7 | \r |
56ba3746 | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
a405b86d | 9 | \r |
10 | **/\r | |
11 | \r | |
12 | #include "UefiShellLevel3CommandsLib.h"\r | |
13 | \r | |
14 | #include <Library/ShellLib.h>\r | |
cab102c3 JC |
15 | #include <Library/HandleParsingLib.h>\r |
16 | \r | |
28165f24 | 17 | #include <Protocol/ShellDynamicCommand.h>\r |
cab102c3 | 18 | \r |
b9a9f56c JC |
19 | /**\r |
20 | function to insert string items into a list in the correct alphabetical place\r | |
21 | \r | |
22 | the resultant list is a double NULL terminated list of NULL terminated strings.\r | |
23 | \r | |
ba0014b9 | 24 | upon successful return the memory must be caller freed (unless passed back in\r |
b9a9f56c JC |
25 | via a loop where it will get reallocated).\r |
26 | \r | |
27 | @param[in,out] DestList double pointer to the list. may be NULL.\r | |
28 | @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL.\r | |
29 | @param[in] Item the item to insert.\r | |
30 | \r | |
31 | @retval EFI_SUCCESS the operation was successful.\r | |
32 | **/\r | |
33 | EFI_STATUS\r | |
47d20b54 MK |
34 | LexicalInsertIntoList (\r |
35 | IN OUT CHAR16 **DestList,\r | |
36 | IN OUT UINTN *DestSize,\r | |
37 | IN CONST CHAR16 *Item\r | |
b9a9f56c JC |
38 | )\r |
39 | {\r | |
47d20b54 MK |
40 | CHAR16 *NewList;\r |
41 | INTN LexicalMatchValue;\r | |
42 | CHAR16 *LexicalSpot;\r | |
43 | UINTN SizeOfAddedNameInBytes;\r | |
b9a9f56c JC |
44 | \r |
45 | //\r | |
46 | // If there are none, then just return with success\r | |
47 | //\r | |
47d20b54 | 48 | if ((Item == NULL) || (*Item == CHAR_NULL) || (StrLen (Item) == 0)) {\r |
b9a9f56c JC |
49 | return (EFI_SUCCESS);\r |
50 | }\r | |
51 | \r | |
52 | NewList = *DestList;\r | |
53 | \r | |
47d20b54 MK |
54 | SizeOfAddedNameInBytes = StrSize (Item);\r |
55 | NewList = ReallocatePool (*DestSize, (*DestSize) + SizeOfAddedNameInBytes, NewList);\r | |
56 | (*DestSize) = (*DestSize) + SizeOfAddedNameInBytes;\r | |
b9a9f56c JC |
57 | \r |
58 | //\r | |
59 | // Find the correct spot in the list\r | |
60 | //\r | |
61 | for (LexicalSpot = NewList\r | |
47d20b54 MK |
62 | ; LexicalSpot != NULL && LexicalSpot < NewList + (*DestSize)\r |
63 | ; LexicalSpot += StrLen (LexicalSpot) + 1\r | |
64 | )\r | |
65 | {\r | |
b9a9f56c JC |
66 | //\r |
67 | // Get Lexical Comparison Value between PrevCommand and Command list entry\r | |
68 | //\r | |
69 | LexicalMatchValue = gUnicodeCollation->StriColl (\r | |
47d20b54 MK |
70 | gUnicodeCollation,\r |
71 | (CHAR16 *)LexicalSpot,\r | |
72 | (CHAR16 *)Item\r | |
73 | );\r | |
b9a9f56c JC |
74 | //\r |
75 | // The new item goes before this one.\r | |
76 | //\r | |
47d20b54 MK |
77 | if ((LexicalMatchValue > 0) || (StrLen (LexicalSpot) == 0)) {\r |
78 | if (StrLen (LexicalSpot) != 0) {\r | |
b9a9f56c JC |
79 | //\r |
80 | // Move this and all other items out of the way\r | |
81 | //\r | |
47d20b54 MK |
82 | CopyMem (\r |
83 | LexicalSpot + (SizeOfAddedNameInBytes/sizeof (CHAR16)),\r | |
b9a9f56c | 84 | LexicalSpot,\r |
47d20b54 | 85 | (*DestSize) - SizeOfAddedNameInBytes - ((LexicalSpot - NewList) * sizeof (CHAR16))\r |
b9a9f56c JC |
86 | );\r |
87 | }\r | |
88 | \r | |
89 | //\r | |
90 | // Stick this one in place\r | |
91 | //\r | |
47d20b54 | 92 | StrCpyS (LexicalSpot, SizeOfAddedNameInBytes/sizeof (CHAR16), Item);\r |
b9a9f56c JC |
93 | break;\r |
94 | }\r | |
95 | }\r | |
96 | \r | |
97 | *DestList = NewList;\r | |
98 | return (EFI_SUCCESS);\r | |
99 | }\r | |
100 | \r | |
101 | /**\r | |
102 | function to add each command name from the linked list to the string list.\r | |
103 | \r | |
104 | the resultant list is a double NULL terminated list of NULL terminated strings.\r | |
105 | \r | |
106 | @param[in,out] DestList double pointer to the list. may be NULL.\r | |
107 | @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL.\r | |
108 | @param[in] SourceList the double linked list of commands.\r | |
109 | \r | |
110 | @retval EFI_SUCCESS the operation was successful.\r | |
111 | **/\r | |
112 | EFI_STATUS\r | |
47d20b54 MK |
113 | CopyListOfCommandNames (\r |
114 | IN OUT CHAR16 **DestList,\r | |
115 | IN OUT UINTN *DestSize,\r | |
116 | IN CONST COMMAND_LIST *SourceList\r | |
b9a9f56c JC |
117 | )\r |
118 | {\r | |
119 | CONST COMMAND_LIST *Node;\r | |
120 | \r | |
47d20b54 MK |
121 | for ( Node = (COMMAND_LIST *)GetFirstNode (&SourceList->Link)\r |
122 | ; SourceList != NULL && !IsListEmpty (&SourceList->Link) && !IsNull (&SourceList->Link, &Node->Link)\r | |
123 | ; Node = (COMMAND_LIST *)GetNextNode (&SourceList->Link, &Node->Link)\r | |
124 | )\r | |
125 | {\r | |
126 | LexicalInsertIntoList (DestList, DestSize, Node->CommandString);\r | |
b9a9f56c | 127 | }\r |
47d20b54 | 128 | \r |
b9a9f56c JC |
129 | return (EFI_SUCCESS);\r |
130 | }\r | |
131 | \r | |
132 | /**\r | |
133 | function to add each dynamic command name to the string list.\r | |
134 | \r | |
135 | the resultant list is a double NULL terminated list of NULL terminated strings.\r | |
136 | \r | |
137 | @param[in,out] DestList double pointer to the list. may be NULL.\r | |
138 | @param[in,out] DestSize pointer to the size of list. may be 0, if DestList is NULL.\r | |
139 | \r | |
140 | @retval EFI_SUCCESS the operation was successful.\r | |
141 | @return an error from HandleProtocol\r | |
142 | **/\r | |
143 | STATIC\r | |
144 | EFI_STATUS\r | |
47d20b54 MK |
145 | CopyListOfCommandNamesWithDynamic (\r |
146 | IN OUT CHAR16 **DestList,\r | |
147 | IN OUT UINTN *DestSize\r | |
b9a9f56c JC |
148 | )\r |
149 | {\r | |
150 | EFI_HANDLE *CommandHandleList;\r | |
151 | CONST EFI_HANDLE *NextCommand;\r | |
152 | EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *DynamicCommand;\r | |
153 | EFI_STATUS Status;\r | |
154 | \r | |
47d20b54 | 155 | CommandHandleList = GetHandleListByProtocol (&gEfiShellDynamicCommandProtocolGuid);\r |
b9a9f56c JC |
156 | \r |
157 | //\r | |
158 | // If there are none, then just return with success\r | |
159 | //\r | |
160 | if (CommandHandleList == NULL) {\r | |
161 | return (EFI_SUCCESS);\r | |
162 | }\r | |
163 | \r | |
164 | Status = EFI_SUCCESS;\r | |
165 | \r | |
166 | //\r | |
167 | // Append those to the list.\r | |
168 | //\r | |
47d20b54 MK |
169 | for (NextCommand = CommandHandleList; *NextCommand != NULL && !EFI_ERROR (Status); NextCommand++) {\r |
170 | Status = gBS->HandleProtocol (\r | |
171 | *NextCommand,\r | |
172 | &gEfiShellDynamicCommandProtocolGuid,\r | |
173 | (VOID **)&DynamicCommand\r | |
174 | );\r | |
175 | \r | |
176 | if (EFI_ERROR (Status)) {\r | |
b9a9f56c JC |
177 | continue;\r |
178 | }\r | |
179 | \r | |
47d20b54 | 180 | Status = LexicalInsertIntoList (DestList, DestSize, DynamicCommand->CommandName);\r |
b9a9f56c JC |
181 | }\r |
182 | \r | |
47d20b54 | 183 | SHELL_FREE_NON_NULL (CommandHandleList);\r |
b9a9f56c JC |
184 | return (Status);\r |
185 | }\r | |
186 | \r | |
cab102c3 JC |
187 | /**\r |
188 | Attempt to print help from a dynamically added command.\r | |
189 | \r | |
710db4e8 HL |
190 | @param[in] CommandToGetHelpOn The unicode name of the command that help is\r |
191 | requested on.\r | |
192 | @param[in] SectionToGetHelpOn Pointer to the section specifier(s).\r | |
193 | @param[in] PrintCommandText Print the command followed by the help content\r | |
194 | or just help.\r | |
cab102c3 JC |
195 | \r |
196 | @retval EFI_SUCCESS The help was displayed\r | |
710db4e8 HL |
197 | @retval EFI_NOT_FOUND The command name could not be found\r |
198 | @retval EFI_DEVICE_ERROR The help data format was incorrect.\r | |
cab102c3 | 199 | **/\r |
cab102c3 | 200 | EFI_STATUS\r |
47d20b54 | 201 | PrintDynamicCommandHelp (\r |
b9a9f56c JC |
202 | IN CONST CHAR16 *CommandToGetHelpOn,\r |
203 | IN CONST CHAR16 *SectionToGetHelpOn,\r | |
204 | IN BOOLEAN PrintCommandText\r | |
47d20b54 | 205 | )\r |
cab102c3 JC |
206 | {\r |
207 | EFI_STATUS Status;\r | |
f5ba4007 QS |
208 | BOOLEAN Found;\r |
209 | EFI_HANDLE *CommandHandleList;\r | |
cab102c3 JC |
210 | EFI_HANDLE *NextCommand;\r |
211 | EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *DynamicCommand;\r | |
710db4e8 | 212 | \r |
47d20b54 MK |
213 | Status = EFI_NOT_FOUND;\r |
214 | Found = FALSE;\r | |
f5ba4007 | 215 | CommandHandleList = NULL;\r |
cab102c3 | 216 | \r |
47d20b54 | 217 | CommandHandleList = GetHandleListByProtocol (&gEfiShellDynamicCommandProtocolGuid);\r |
cab102c3 JC |
218 | \r |
219 | if (CommandHandleList == NULL) {\r | |
220 | //\r | |
221 | // not found or out of resources\r | |
222 | //\r | |
710db4e8 | 223 | return Status;\r |
cab102c3 JC |
224 | }\r |
225 | \r | |
226 | for (NextCommand = CommandHandleList; *NextCommand != NULL; NextCommand++) {\r | |
47d20b54 MK |
227 | Status = gBS->HandleProtocol (\r |
228 | *NextCommand,\r | |
229 | &gEfiShellDynamicCommandProtocolGuid,\r | |
230 | (VOID **)&DynamicCommand\r | |
231 | );\r | |
cab102c3 | 232 | \r |
47d20b54 | 233 | if (EFI_ERROR (Status)) {\r |
cab102c3 JC |
234 | continue;\r |
235 | }\r | |
236 | \r | |
710db4e8 HL |
237 | //\r |
238 | // Check execution break flag when printing multiple command help information.\r | |
239 | //\r | |
240 | if (ShellGetExecutionBreakFlag ()) {\r | |
cab102c3 JC |
241 | break;\r |
242 | }\r | |
243 | \r | |
47d20b54 MK |
244 | if ((gUnicodeCollation->MetaiMatch (gUnicodeCollation, (CHAR16 *)DynamicCommand->CommandName, (CHAR16 *)CommandToGetHelpOn)) ||\r |
245 | ((gEfiShellProtocol->GetAlias (CommandToGetHelpOn, NULL) != NULL) && (gUnicodeCollation->MetaiMatch (gUnicodeCollation, (CHAR16 *)DynamicCommand->CommandName, (CHAR16 *)(gEfiShellProtocol->GetAlias (CommandToGetHelpOn, NULL))))))\r | |
246 | {\r | |
710db4e8 | 247 | // Print as Shell Help if in ManPage format.\r |
47d20b54 MK |
248 | Status = ShellPrintHelp (\r |
249 | DynamicCommand->CommandName,\r | |
250 | SectionToGetHelpOn,\r | |
251 | PrintCommandText\r | |
252 | );\r | |
710db4e8 | 253 | if (Status == EFI_DEVICE_ERROR) {\r |
47d20b54 MK |
254 | ShellPrintHiiEx (\r |
255 | -1,\r | |
256 | -1,\r | |
257 | NULL,\r | |
258 | STRING_TOKEN (STR_HELP_INV),\r | |
259 | gShellLevel3HiiHandle,\r | |
260 | DynamicCommand->CommandName\r | |
261 | );\r | |
262 | } else if (EFI_ERROR (Status)) {\r | |
263 | ShellPrintHiiEx (\r | |
264 | -1,\r | |
265 | -1,\r | |
266 | NULL,\r | |
267 | STRING_TOKEN (STR_HELP_NF),\r | |
268 | gShellLevel3HiiHandle,\r | |
269 | DynamicCommand->CommandName\r | |
270 | );\r | |
710db4e8 HL |
271 | } else {\r |
272 | Found = TRUE;\r | |
273 | }\r | |
274 | }\r | |
cab102c3 JC |
275 | }\r |
276 | \r | |
47d20b54 | 277 | SHELL_FREE_NON_NULL (CommandHandleList);\r |
74760c96 | 278 | \r |
710db4e8 | 279 | return (Found ? EFI_SUCCESS : Status);\r |
cab102c3 | 280 | }\r |
a405b86d | 281 | \r |
47d20b54 MK |
282 | STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r |
283 | { L"-usage", TypeFlag },\r | |
284 | { L"-section", TypeMaxValue },\r | |
285 | { L"-verbose", TypeFlag },\r | |
286 | { L"-v", TypeFlag },\r | |
287 | { NULL, TypeMax }\r | |
288 | };\r | |
a405b86d | 289 | \r |
290 | /**\r | |
291 | Function for 'help' command.\r | |
292 | \r | |
293 | @param[in] ImageHandle Handle to the Image (NULL if Internal).\r | |
294 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r | |
295 | **/\r | |
296 | SHELL_STATUS\r | |
297 | EFIAPI\r | |
298 | ShellCommandRunHelp (\r | |
299 | IN EFI_HANDLE ImageHandle,\r | |
300 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
301 | )\r | |
302 | {\r | |
47d20b54 MK |
303 | EFI_STATUS Status;\r |
304 | LIST_ENTRY *Package;\r | |
305 | CHAR16 *ProblemParam;\r | |
306 | SHELL_STATUS ShellStatus;\r | |
307 | CHAR16 *SortedCommandList;\r | |
308 | CONST CHAR16 *CurrentCommand;\r | |
309 | CHAR16 *CommandToGetHelpOn;\r | |
310 | CHAR16 *SectionToGetHelpOn;\r | |
311 | CHAR16 *HiiString;\r | |
312 | BOOLEAN Found;\r | |
313 | BOOLEAN PrintCommandText;\r | |
314 | UINTN SortedCommandListSize;\r | |
315 | \r | |
316 | PrintCommandText = TRUE;\r | |
317 | ProblemParam = NULL;\r | |
318 | ShellStatus = SHELL_SUCCESS;\r | |
319 | CommandToGetHelpOn = NULL;\r | |
320 | SectionToGetHelpOn = NULL;\r | |
321 | SortedCommandList = NULL;\r | |
322 | Found = FALSE;\r | |
a405b86d | 323 | \r |
324 | //\r | |
325 | // initialize the shell lib (we must be in non-auto-init...)\r | |
326 | //\r | |
47d20b54 MK |
327 | Status = ShellInitialize ();\r |
328 | ASSERT_EFI_ERROR (Status);\r | |
a405b86d | 329 | \r |
47d20b54 MK |
330 | Status = CommandInit ();\r |
331 | ASSERT_EFI_ERROR (Status);\r | |
a405b86d | 332 | \r |
333 | //\r | |
334 | // parse the command line\r | |
335 | //\r | |
336 | Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r | |
47d20b54 MK |
337 | if (EFI_ERROR (Status)) {\r |
338 | if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {\r | |
339 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"help", ProblemParam);\r | |
340 | FreePool (ProblemParam);\r | |
a405b86d | 341 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
342 | } else {\r | |
47d20b54 | 343 | ASSERT (FALSE);\r |
a405b86d | 344 | }\r |
345 | } else {\r | |
346 | //\r | |
347 | // Check for conflicting parameters.\r | |
348 | //\r | |
47d20b54 MK |
349 | if ( ShellCommandLineGetFlag (Package, L"-usage")\r |
350 | && ShellCommandLineGetFlag (Package, L"-section")\r | |
351 | && (ShellCommandLineGetFlag (Package, L"-verbose") || ShellCommandLineGetFlag (Package, L"-v"))\r | |
352 | )\r | |
353 | {\r | |
354 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel3HiiHandle, L"help");\r | |
a405b86d | 355 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
47d20b54 MK |
356 | } else if (ShellCommandLineGetRawValue (Package, 2) != NULL) {\r |
357 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"help");\r | |
a405b86d | 358 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
359 | } else {\r | |
360 | //\r | |
361 | // Get the command name we are getting help on\r | |
362 | //\r | |
47d20b54 MK |
363 | ASSERT (CommandToGetHelpOn == NULL);\r |
364 | StrnCatGrow (&CommandToGetHelpOn, NULL, ShellCommandLineGetRawValue (Package, 1), 0);\r | |
365 | if ((CommandToGetHelpOn == NULL) && ShellCommandLineGetFlag (Package, L"-?")) {\r | |
a405b86d | 366 | //\r |
367 | // If we dont have a command and we got a simple -?\r | |
368 | // we are looking for help on help command.\r | |
369 | //\r | |
47d20b54 | 370 | StrnCatGrow (&CommandToGetHelpOn, NULL, L"help", 0);\r |
a405b86d | 371 | }\r |
372 | \r | |
373 | if (CommandToGetHelpOn == NULL) {\r | |
47d20b54 MK |
374 | StrnCatGrow (&CommandToGetHelpOn, NULL, L"*", 0);\r |
375 | ASSERT (SectionToGetHelpOn == NULL);\r | |
376 | StrnCatGrow (&SectionToGetHelpOn, NULL, L"NAME", 0);\r | |
a405b86d | 377 | } else {\r |
7c8e7960 | 378 | PrintCommandText = FALSE;\r |
47d20b54 | 379 | ASSERT (SectionToGetHelpOn == NULL);\r |
a405b86d | 380 | //\r |
381 | // Get the section name for the given command name\r | |
382 | //\r | |
47d20b54 MK |
383 | if (ShellCommandLineGetFlag (Package, L"-section")) {\r |
384 | StrnCatGrow (&SectionToGetHelpOn, NULL, ShellCommandLineGetValue (Package, L"-section"), 0);\r | |
385 | } else if (ShellCommandLineGetFlag (Package, L"-usage")) {\r | |
386 | StrnCatGrow (&SectionToGetHelpOn, NULL, L"NAME,SYNOPSIS", 0);\r | |
387 | } else if (ShellCommandLineGetFlag (Package, L"-verbose") || ShellCommandLineGetFlag (Package, L"-v")) {\r | |
a405b86d | 388 | } else {\r |
d51088b7 | 389 | //\r |
390 | // The output of help <command> will display NAME, SYNOPSIS, OPTIONS, DESCRIPTION, and EXAMPLES sections.\r | |
391 | //\r | |
392 | StrnCatGrow (&SectionToGetHelpOn, NULL, L"NAME,SYNOPSIS,OPTIONS,DESCRIPTION,EXAMPLES", 0);\r | |
a405b86d | 393 | }\r |
394 | }\r | |
395 | \r | |
47d20b54 | 396 | if (gUnicodeCollation->StriColl (gUnicodeCollation, CommandToGetHelpOn, L"special") == 0) {\r |
a405b86d | 397 | //\r |
398 | // we need info on the special characters\r | |
399 | //\r | |
47d20b54 MK |
400 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_SC_HEADER), gShellLevel3HiiHandle);\r |
401 | HiiString = HiiGetString (gShellLevel3HiiHandle, STRING_TOKEN (STR_HELP_SC_DATA), NULL);\r | |
402 | ShellPrintEx (-1, -1, L"%s", HiiString);\r | |
403 | FreePool (HiiString);\r | |
a405b86d | 404 | Found = TRUE;\r |
405 | } else {\r | |
47d20b54 | 406 | SortedCommandList = NULL;\r |
b9a9f56c | 407 | SortedCommandListSize = 0;\r |
47d20b54 MK |
408 | CopyListOfCommandNames (&SortedCommandList, &SortedCommandListSize, ShellCommandGetCommandList (TRUE));\r |
409 | CopyListOfCommandNamesWithDynamic (&SortedCommandList, &SortedCommandListSize);\r | |
b9a9f56c | 410 | \r |
ba0014b9 | 411 | for (CurrentCommand = SortedCommandList\r |
47d20b54 MK |
412 | ; CurrentCommand != NULL && CurrentCommand < SortedCommandList + SortedCommandListSize/sizeof (CHAR16) && *CurrentCommand != CHAR_NULL\r |
413 | ; CurrentCommand += StrLen (CurrentCommand) + 1\r | |
414 | )\r | |
415 | {\r | |
d51088b7 | 416 | //\r |
417 | // Checking execution break flag when print multiple command help information.\r | |
418 | //\r | |
419 | if (ShellGetExecutionBreakFlag ()) {\r | |
420 | break;\r | |
ba0014b9 | 421 | }\r |
b9a9f56c | 422 | \r |
47d20b54 MK |
423 | if ((gUnicodeCollation->MetaiMatch (gUnicodeCollation, (CHAR16 *)CurrentCommand, CommandToGetHelpOn)) ||\r |
424 | ((gEfiShellProtocol->GetAlias (CommandToGetHelpOn, NULL) != NULL) && (gUnicodeCollation->MetaiMatch (gUnicodeCollation, (CHAR16 *)CurrentCommand, (CHAR16 *)(gEfiShellProtocol->GetAlias (CommandToGetHelpOn, NULL))))))\r | |
425 | {\r | |
a405b86d | 426 | //\r |
427 | // We have a command to look for help on.\r | |
428 | //\r | |
47d20b54 MK |
429 | Status = ShellPrintHelp (CurrentCommand, SectionToGetHelpOn, PrintCommandText);\r |
430 | if (EFI_ERROR (Status)) {\r | |
b9a9f56c JC |
431 | //\r |
432 | // now try to match against the dynamic command list and print help\r | |
433 | //\r | |
434 | Status = PrintDynamicCommandHelp (CurrentCommand, SectionToGetHelpOn, PrintCommandText);\r | |
435 | }\r | |
47d20b54 | 436 | \r |
7c8e7960 | 437 | if (Status == EFI_DEVICE_ERROR) {\r |
47d20b54 MK |
438 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, CurrentCommand);\r |
439 | } else if (EFI_ERROR (Status)) {\r | |
440 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, CurrentCommand);\r | |
a405b86d | 441 | } else {\r |
47d20b54 | 442 | Found = TRUE;\r |
a405b86d | 443 | }\r |
444 | }\r | |
445 | }\r | |
710db4e8 | 446 | \r |
d51088b7 | 447 | //\r |
448 | // Search the .man file for Shell applications (Shell external commands).\r | |
449 | //\r | |
450 | if (!Found) {\r | |
47d20b54 | 451 | Status = ShellPrintHelp (CommandToGetHelpOn, SectionToGetHelpOn, FALSE);\r |
cab102c3 | 452 | if (Status == EFI_DEVICE_ERROR) {\r |
47d20b54 MK |
453 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, CommandToGetHelpOn);\r |
454 | } else if (EFI_ERROR (Status)) {\r | |
455 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, CommandToGetHelpOn);\r | |
cab102c3 JC |
456 | } else {\r |
457 | Found = TRUE;\r | |
458 | }\r | |
459 | }\r | |
a405b86d | 460 | }\r |
461 | \r | |
7c8e7960 | 462 | if (!Found) {\r |
a405b86d | 463 | ShellStatus = SHELL_NOT_FOUND;\r |
464 | }\r | |
465 | \r | |
466 | //\r | |
467 | // free the command line package\r | |
468 | //\r | |
469 | ShellCommandLineFreeVarList (Package);\r | |
470 | }\r | |
471 | }\r | |
7c8e7960 | 472 | \r |
47d20b54 | 473 | if ((CommandToGetHelpOn != NULL) && (StrCmp (CommandToGetHelpOn, L"*") == 0)) {\r |
7c8e7960 | 474 | //\r |
475 | // If '*' then the command entered was 'Help' without qualifiers, This footer\r | |
476 | // provides additional info on help switches\r | |
477 | //\r | |
47d20b54 | 478 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_HELP_FOOTER), gShellLevel3HiiHandle);\r |
7c8e7960 | 479 | }\r |
47d20b54 | 480 | \r |
a405b86d | 481 | if (CommandToGetHelpOn != NULL) {\r |
47d20b54 | 482 | FreePool (CommandToGetHelpOn);\r |
a405b86d | 483 | }\r |
47d20b54 | 484 | \r |
a405b86d | 485 | if (SectionToGetHelpOn != NULL) {\r |
47d20b54 | 486 | FreePool (SectionToGetHelpOn);\r |
a405b86d | 487 | }\r |
47d20b54 MK |
488 | \r |
489 | SHELL_FREE_NON_NULL (SortedCommandList);\r | |
a405b86d | 490 | \r |
491 | return (ShellStatus);\r | |
492 | }\r |