]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Application/Shell/ShellManParser.c
1) Removing ASSERTs for proper return values.
[mirror_edk2.git] / ShellPkg / Application / Shell / ShellManParser.c
CommitLineData
a405b86d 1/** @file\r
2 Provides interface to shell MAN file parser.\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 "Shell.h"\r
16\r
17/**\r
18 Verifies that the filename has .MAN on the end.\r
19\r
20 allocates a new buffer and copies the name (appending .MAN if necessary)\r
21\r
22 ASSERT if ManFileName is NULL\r
23\r
24 @param[in] ManFileName original filename\r
25\r
26 @return the new filename with .man as the extension.\r
27**/\r
28CHAR16 *\r
29EFIAPI\r
30GetManFileName(\r
31 IN CONST CHAR16 *ManFileName\r
32 )\r
33{\r
34 CHAR16 *Buffer;\r
3c865f20 35 if (ManFileName == NULL) {\r
36 return (NULL);\r
37 }\r
a405b86d 38 //\r
39 // Fix the file name\r
40 //\r
41 if (StrnCmp(ManFileName+StrLen(ManFileName)-4, L".man", 4)==0) {\r
42 Buffer = AllocateZeroPool(StrSize(ManFileName));\r
3c865f20 43 if (Buffer != NULL) {\r
44 StrCpy(Buffer, ManFileName);\r
45 }\r
a405b86d 46 } else {\r
47 Buffer = AllocateZeroPool(StrSize(ManFileName) + 4*sizeof(CHAR16));\r
3c865f20 48 if (Buffer != NULL) {\r
49 StrCpy(Buffer, ManFileName);\r
50 StrCat(Buffer, L".man");\r
51 }\r
a405b86d 52 }\r
53 return (Buffer);\r
54}\r
55\r
56/**\r
57 Search the path environment variable for possible locations and test for\r
58 which one contains a man file with the name specified. If a valid file is found\r
59 stop searching and return the (opened) SHELL_FILE_HANDLE for that file.\r
60\r
61 @param[in] FileName Name of the file to find and open.\r
62 @param[out] Handle Pointer to the handle of the found file. The\r
63 value of this is undefined for return values\r
64 except EFI_SUCCESS.\r
65\r
66 @retval EFI_SUCCESS The file was found. Handle is a valid SHELL_FILE_HANDLE\r
67 @retval EFI_INVALID_PARAMETER A parameter had an invalid value.\r
68 @retval EFI_NOT_FOUND The file was not found.\r
69**/\r
70EFI_STATUS\r
71EFIAPI\r
72SearchPathForFile(\r
73 IN CONST CHAR16 *FileName,\r
74 OUT SHELL_FILE_HANDLE *Handle\r
75 )\r
76{\r
77 CHAR16 *FullFileName;\r
78 EFI_STATUS Status;\r
79\r
80 if ( FileName == NULL\r
81 || Handle == NULL\r
82 || StrLen(FileName) == 0\r
83 ){\r
84 return (EFI_INVALID_PARAMETER);\r
85 }\r
86\r
87 FullFileName = ShellFindFilePath(FileName);\r
88 if (FullFileName == NULL) {\r
89 return (EFI_NOT_FOUND);\r
90 }\r
91\r
92 //\r
93 // now open that file\r
94 //\r
95 Status = EfiShellOpenFileByName(FullFileName, Handle, EFI_FILE_MODE_READ);\r
96 FreePool(FullFileName);\r
97\r
98 return (Status);\r
99}\r
100\r
101/**\r
102 parses through Buffer (which is MAN file formatted) and returns the\r
103 detailed help for any sub section specified in the comma seperated list of\r
104 sections provided. If the end of the file or a .TH section is found then\r
105 return.\r
106\r
107 Upon a sucessful return the caller is responsible to free the memory in *HelpText\r
108\r
109 @param[in] Buffer Buffer to read from\r
110 @param[in] Sections name of command's sub sections to find\r
111 @param[in] HelpText pointer to pointer to string where text goes.\r
112 @param[in] HelpSize pointer to size of allocated HelpText (may be updated)\r
113\r
114 @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
115 @retval EFI_SUCCESS the section was found and its description sotred in\r
116 an alloceted buffer.\r
117**/\r
118EFI_STATUS\r
119EFIAPI\r
120ManBufferFindSections(\r
121 IN CONST CHAR16 *Buffer,\r
122 IN CONST CHAR16 *Sections,\r
123 IN CHAR16 **HelpText,\r
124 IN UINTN *HelpSize\r
125 )\r
126{\r
127 EFI_STATUS Status;\r
128 CONST CHAR16 *CurrentLocation;\r
129 BOOLEAN CurrentlyReading;\r
130 CHAR16 *SectionName;\r
131 UINTN SectionLen;\r
132 BOOLEAN Found;\r
133 CHAR16 *TempString;\r
134 CHAR16 *TempString2;\r
135\r
136 if ( Buffer == NULL\r
137 || HelpText == NULL\r
138 || HelpSize == NULL\r
139 ){\r
140 return (EFI_INVALID_PARAMETER);\r
141 }\r
142\r
143 Status = EFI_SUCCESS;\r
144 CurrentlyReading = FALSE;\r
145 Found = FALSE;\r
146\r
147 for (CurrentLocation = Buffer,TempString = NULL\r
148 ; CurrentLocation != NULL && *CurrentLocation != CHAR_NULL\r
149 ; CurrentLocation=StrStr(CurrentLocation, L"\r\n"),TempString = NULL\r
150 ){\r
151 while(CurrentLocation[0] == L'\r' || CurrentLocation[0] == L'\n') {\r
152 CurrentLocation++;\r
153 }\r
154 if (CurrentLocation[0] == L'#') {\r
155 //\r
156 // Skip comment lines\r
157 //\r
158 continue;\r
159 }\r
160 if (StrnCmp(CurrentLocation, L".TH", 3) == 0) {\r
161 //\r
162 // we hit the end of this commands section so stop.\r
163 //\r
164 break;\r
165 }\r
166 if (StrnCmp(CurrentLocation, L".SH ", 4) == 0) {\r
167 if (Sections == NULL) {\r
168 CurrentlyReading = TRUE;\r
169 continue;\r
170 } else if (CurrentlyReading) {\r
171 CurrentlyReading = FALSE;\r
172 }\r
173 CurrentLocation += 4;\r
174 //\r
175 // is this a section we want to read in?\r
176 //\r
177 if (StrLen(CurrentLocation)!=0) {\r
178 TempString2 = StrStr(CurrentLocation, L" ");\r
179 TempString2 = MIN(TempString2, StrStr(CurrentLocation, L"\r"));\r
180 TempString2 = MIN(TempString2, StrStr(CurrentLocation, L"\n"));\r
181 ASSERT(TempString == NULL);\r
182 TempString = StrnCatGrow(&TempString, NULL, CurrentLocation, TempString2==NULL?0:TempString2 - CurrentLocation);\r
183 SectionName = TempString;\r
184 SectionLen = StrLen(SectionName);\r
185 SectionName = StrStr(Sections, SectionName);\r
186 if (SectionName == NULL) {\r
187 continue;\r
188 }\r
189 if (*(SectionName + SectionLen) == CHAR_NULL || *(SectionName + SectionLen) == L',') {\r
190 CurrentlyReading = TRUE;\r
191 }\r
192 }\r
193 } else if (CurrentlyReading) {\r
194 Found = TRUE;\r
195 if (StrLen(CurrentLocation)!=0) {\r
196 TempString2 = StrStr(CurrentLocation, L"\r");\r
197 TempString2 = MIN(TempString2, StrStr(CurrentLocation, L"\n"));\r
198 ASSERT(TempString == NULL);\r
199 TempString = StrnCatGrow(&TempString, NULL, CurrentLocation, TempString2==NULL?0:TempString2 - CurrentLocation);\r
200 //\r
201 // copy and save the current line.\r
202 //\r
203 ASSERT((*HelpText == NULL && *HelpSize == 0) || (*HelpText != NULL));\r
204 StrnCatGrow (HelpText, HelpSize, TempString, 0);\r
205 StrnCatGrow (HelpText, HelpSize, L"\r\n", 0);\r
206 }\r
207 }\r
208 SHELL_FREE_NON_NULL(TempString);\r
209 }\r
210 if (!Found && !EFI_ERROR(Status)) {\r
211 return (EFI_NOT_FOUND);\r
212 }\r
213 return (Status);\r
214}\r
215\r
216/**\r
217 parses through the MAN file specified by SHELL_FILE_HANDLE and returns the\r
218 detailed help for any sub section specified in the comma seperated list of\r
219 sections provided. If the end of the file or a .TH section is found then\r
220 return.\r
221\r
222 Upon a sucessful return the caller is responsible to free the memory in *HelpText\r
223\r
224 @param[in] Handle FileHandle to read from\r
225 @param[in] Sections name of command's sub sections to find\r
226 @param[out] HelpText pointer to pointer to string where text goes.\r
227 @param[out] HelpSize pointer to size of allocated HelpText (may be updated)\r
228 @param[in] Ascii TRUE if the file is ASCII, FALSE otherwise.\r
229\r
230 @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
231 @retval EFI_SUCCESS the section was found and its description sotred in\r
232 an alloceted buffer.\r
233**/\r
234EFI_STATUS\r
235EFIAPI\r
236ManFileFindSections(\r
237 IN SHELL_FILE_HANDLE Handle,\r
238 IN CONST CHAR16 *Sections,\r
239 OUT CHAR16 **HelpText,\r
240 OUT UINTN *HelpSize,\r
241 IN BOOLEAN Ascii\r
242 )\r
243{\r
244 EFI_STATUS Status;\r
245 CHAR16 *ReadLine;\r
246 UINTN Size;\r
247 BOOLEAN CurrentlyReading;\r
248 CHAR16 *SectionName;\r
249 UINTN SectionLen;\r
250 BOOLEAN Found;\r
251\r
252 if ( Handle == NULL\r
253 || HelpText == NULL\r
254 || HelpSize == NULL\r
255 ){\r
256 return (EFI_INVALID_PARAMETER);\r
257 }\r
258\r
259 Status = EFI_SUCCESS;\r
260 CurrentlyReading = FALSE;\r
261 Size = 1024;\r
262 Found = FALSE;\r
263\r
264 ReadLine = AllocateZeroPool(Size);\r
265 if (ReadLine == NULL) {\r
266 return (EFI_OUT_OF_RESOURCES);\r
267 }\r
268\r
269 for (;!ShellFileHandleEof(Handle);Size = 1024) {\r
270 Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, &Ascii);\r
271 if (ReadLine[0] == L'#') {\r
272 //\r
273 // Skip comment lines\r
274 //\r
275 continue;\r
276 }\r
277 //\r
278 // ignore too small of buffer...\r
279 //\r
280 if (Status == EFI_BUFFER_TOO_SMALL) {\r
281 Status = EFI_SUCCESS;\r
282 }\r
283 if (EFI_ERROR(Status)) {\r
284 break;\r
285 } else if (StrnCmp(ReadLine, L".TH", 3) == 0) {\r
286 //\r
287 // we hit the end of this commands section so stop.\r
288 //\r
289 break;\r
290 } else if (StrnCmp(ReadLine, L".SH", 3) == 0) {\r
291 if (Sections == NULL) {\r
292 CurrentlyReading = TRUE;\r
293 continue;\r
294 }\r
295 //\r
296 // we found a section\r
297 //\r
298 if (CurrentlyReading) {\r
299 CurrentlyReading = FALSE;\r
300 }\r
301 //\r
302 // is this a section we want to read in?\r
303 //\r
304 for ( SectionName = ReadLine + 3\r
305 ; *SectionName == L' '\r
306 ; SectionName++);\r
307 SectionLen = StrLen(SectionName);\r
308 SectionName = StrStr(Sections, SectionName);\r
309 if (SectionName == NULL) {\r
310 continue;\r
311 }\r
312 if (*(SectionName + SectionLen) == CHAR_NULL || *(SectionName + SectionLen) == L',') {\r
313 CurrentlyReading = TRUE;\r
314 }\r
315 } else if (CurrentlyReading) {\r
316 Found = TRUE;\r
317 //\r
318 // copy and save the current line.\r
319 //\r
320 ASSERT((*HelpText == NULL && *HelpSize == 0) || (*HelpText != NULL));\r
321 StrnCatGrow (HelpText, HelpSize, ReadLine, 0);\r
322 StrnCatGrow (HelpText, HelpSize, L"\r\n", 0);\r
323 }\r
324 }\r
325 FreePool(ReadLine);\r
326 if (!Found && !EFI_ERROR(Status)) {\r
327 return (EFI_NOT_FOUND);\r
328 }\r
329 return (Status);\r
330}\r
331\r
332/**\r
333 parses through the MAN file formatted Buffer and returns the\r
334 "Brief Description" for the .TH section as specified by Command. If the\r
335 command section is not found return EFI_NOT_FOUND.\r
336\r
337 Upon a sucessful return the caller is responsible to free the memory in *BriefDesc\r
338\r
339 @param[in] Handle Buffer to read from\r
340 @param[in] Command name of command's section to find\r
341 @param[in] BriefDesc pointer to pointer to string where description goes.\r
342 @param[in] BriefSize pointer to size of allocated BriefDesc\r
343\r
344 @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
345 @retval EFI_SUCCESS the section was found and its description sotred in\r
346 an alloceted buffer.\r
347**/\r
348EFI_STATUS\r
349EFIAPI\r
350ManBufferFindTitleSection(\r
351 IN CHAR16 **Buffer,\r
352 IN CONST CHAR16 *Command,\r
353 IN CHAR16 **BriefDesc,\r
354 IN UINTN *BriefSize\r
355 )\r
356{\r
357 EFI_STATUS Status;\r
358 CHAR16 *TitleString;\r
359 CHAR16 *TitleEnd;\r
360 CHAR16 *CurrentLocation;\r
361\r
362 if ( Buffer == NULL\r
363 || Command == NULL\r
364 || (BriefDesc != NULL && BriefSize == NULL)\r
365 ){\r
366 return (EFI_INVALID_PARAMETER);\r
367 }\r
368\r
369 Status = EFI_SUCCESS;\r
370\r
371 TitleString = AllocatePool((7*sizeof(CHAR16)) + StrSize(Command));\r
372 if (TitleString == NULL) {\r
373 return (EFI_OUT_OF_RESOURCES);\r
374 }\r
375 StrCpy(TitleString, L".TH ");\r
376 StrCat(TitleString, Command);\r
377 StrCat(TitleString, L" 0 ");\r
378\r
379 CurrentLocation = StrStr(*Buffer, TitleString);\r
380 if (CurrentLocation == NULL){\r
381 Status = EFI_NOT_FOUND;\r
382 } else {\r
383 //\r
384 // we found it so copy out the rest of the line into BriefDesc\r
385 // After skipping any spaces or zeroes\r
386 //\r
387 for (CurrentLocation += StrLen(TitleString)\r
388 ; *CurrentLocation == L' ' || *CurrentLocation == L'0' || *CurrentLocation == L'1' || *CurrentLocation == L'\"'\r
389 ; CurrentLocation++);\r
390\r
391 TitleEnd = StrStr(CurrentLocation, L"\"");\r
392 ASSERT(TitleEnd != NULL);\r
393 if (BriefDesc != NULL) {\r
394 *BriefSize = StrSize(TitleEnd);\r
395 *BriefDesc = AllocateZeroPool(*BriefSize);\r
396 if (*BriefDesc == NULL) {\r
397 Status = EFI_OUT_OF_RESOURCES;\r
398 } else {\r
399 StrnCpy(*BriefDesc, CurrentLocation, TitleEnd-CurrentLocation);\r
400 }\r
401 }\r
402\r
403 for (CurrentLocation = TitleEnd\r
404 ; *CurrentLocation != L'\n'\r
405 ; CurrentLocation++);\r
406 for (\r
407 ; *CurrentLocation == L' ' || *CurrentLocation == L'\n' || *CurrentLocation == L'\r'\r
408 ; CurrentLocation++);\r
409 *Buffer = CurrentLocation;\r
410 }\r
411\r
412 FreePool(TitleString);\r
413 return (Status);\r
414}\r
415\r
416/**\r
417 parses through the MAN file specified by SHELL_FILE_HANDLE and returns the\r
418 "Brief Description" for the .TH section as specified by Command. if the\r
419 command section is not found return EFI_NOT_FOUND.\r
420\r
421 Upon a sucessful return the caller is responsible to free the memory in *BriefDesc\r
422\r
423 @param[in] Handle FileHandle to read from\r
424 @param[in] Command name of command's section to find\r
425 @param[out] BriefDesc pointer to pointer to string where description goes.\r
426 @param[out] BriefSize pointer to size of allocated BriefDesc\r
427 @param[in,out] Ascii TRUE if the file is ASCII, FALSE otherwise, will be\r
428 set if the file handle is at the 0 position.\r
429\r
430 @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
431 @retval EFI_SUCCESS the section was found and its description sotred in\r
432 an alloceted buffer.\r
433**/\r
434EFI_STATUS\r
435EFIAPI\r
436ManFileFindTitleSection(\r
437 IN SHELL_FILE_HANDLE Handle,\r
438 IN CONST CHAR16 *Command,\r
439 OUT CHAR16 **BriefDesc OPTIONAL,\r
440 OUT UINTN *BriefSize OPTIONAL,\r
441 IN OUT BOOLEAN *Ascii\r
442 )\r
443{\r
444 EFI_STATUS Status;\r
445 CHAR16 *TitleString;\r
446 CHAR16 *ReadLine;\r
447 UINTN Size;\r
448 CHAR16 *TitleEnd;\r
449 UINTN TitleLen;\r
450 BOOLEAN Found;\r
451\r
452 if ( Handle == NULL\r
453 || Command == NULL\r
454 || (BriefDesc != NULL && BriefSize == NULL)\r
455 ){\r
456 return (EFI_INVALID_PARAMETER);\r
457 }\r
458\r
459 Status = EFI_SUCCESS;\r
460 Size = 1024;\r
461 Found = FALSE;\r
462\r
463 ReadLine = AllocateZeroPool(Size);\r
464 if (ReadLine == NULL) {\r
465 return (EFI_OUT_OF_RESOURCES);\r
466 }\r
467\r
468 TitleString = AllocatePool((4*sizeof(CHAR16)) + StrSize(Command));\r
469 if (TitleString == NULL) {\r
470 FreePool(ReadLine);\r
471 return (EFI_OUT_OF_RESOURCES);\r
472 }\r
473 StrCpy(TitleString, L".TH ");\r
474 StrCat(TitleString, Command);\r
475 TitleLen = StrLen(TitleString);\r
476 for (;!ShellFileHandleEof(Handle);Size = 1024) {\r
477 Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, Ascii);\r
478 if (ReadLine[0] == L'#') {\r
479 //\r
480 // Skip comment lines\r
481 //\r
482 continue;\r
483 }\r
484 //\r
485 // ignore too small of buffer...\r
486 //\r
487 if (Status == EFI_BUFFER_TOO_SMALL) {\r
488 Status = EFI_SUCCESS;\r
489 }\r
490 if (EFI_ERROR(Status)) {\r
491 break;\r
492 }\r
493 if (StrnCmp(ReadLine, TitleString, TitleLen) == 0) {\r
494 Found = TRUE;\r
495 //\r
496 // we found it so copy out the rest of the line into BriefDesc\r
497 // After skipping any spaces or zeroes\r
498 //\r
499 for ( TitleEnd = ReadLine+TitleLen\r
500 ; *TitleEnd == L' ' || *TitleEnd == L'0' || *TitleEnd == L'1'\r
501 ; TitleEnd++);\r
502 if (BriefDesc != NULL) {\r
503 *BriefSize = StrSize(TitleEnd);\r
504 *BriefDesc = AllocateZeroPool(*BriefSize);\r
505 if (*BriefDesc == NULL) {\r
506 Status = EFI_OUT_OF_RESOURCES;\r
507 break;\r
508 }\r
509 StrCpy(*BriefDesc, TitleEnd);\r
510 }\r
511 break;\r
512 }\r
513 }\r
514 FreePool(ReadLine);\r
515 FreePool(TitleString);\r
516 if (!Found && !EFI_ERROR(Status)) {\r
517 return (EFI_NOT_FOUND);\r
518 }\r
519 return (Status);\r
520}\r
521\r
522/**\r
523 This function returns the help information for the specified command. The help text\r
524 will be parsed from a UEFI Shell manual page. (see UEFI Shell 2.0 Appendix B)\r
525\r
526 If Sections is specified, then each section name listed will be compared in a casesensitive\r
527 manner, to the section names described in Appendix B. If the section exists,\r
528 it will be appended to the returned help text. If the section does not exist, no\r
529 information will be returned. If Sections is NULL, then all help text information\r
530 available will be returned.\r
531\r
532 if BriefDesc is NULL, then the breif description will not be savedd seperatly,\r
533 but placed first in the main HelpText.\r
534\r
535 @param[in] ManFileName Points to the NULL-terminated UEFI Shell MAN file name.\r
536 @param[in] Command Points to the NULL-terminated UEFI Shell command name.\r
537 @param[in] Sections Points to the NULL-terminated comma-delimited\r
538 section names to return. If NULL, then all\r
539 sections will be returned.\r
540 @param[out] BriefDesc On return, points to a callee-allocated buffer\r
541 containing brief description text.\r
542 @param[out] HelpText On return, points to a callee-allocated buffer\r
543 containing all specified help text.\r
544\r
545 @retval EFI_SUCCESS The help text was returned.\r
546 @retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the\r
547 returned help text.\r
548 @retval EFI_INVALID_PARAMETER HelpText is NULL\r
549 @retval EFI_NOT_FOUND There is no help text available for Command.\r
550**/\r
551EFI_STATUS\r
552EFIAPI\r
553ProcessManFile(\r
554 IN CONST CHAR16 *ManFileName,\r
555 IN CONST CHAR16 *Command,\r
556 IN CONST CHAR16 *Sections OPTIONAL,\r
557 OUT CHAR16 **BriefDesc OPTIONAL,\r
558 OUT CHAR16 **HelpText\r
559 )\r
560{\r
561 CHAR16 *TempString;\r
562 SHELL_FILE_HANDLE FileHandle;\r
563 EFI_STATUS Status;\r
564 UINTN HelpSize;\r
565 UINTN BriefSize;\r
566 BOOLEAN Ascii;\r
567 CHAR16 *TempString2;\r
568 EFI_DEVICE_PATH_PROTOCOL *FileDevPath;\r
569 EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
570\r
571 if ( ManFileName == NULL\r
572 || Command == NULL\r
573 || HelpText == NULL\r
574 ){\r
575 return (EFI_INVALID_PARAMETER);\r
576 }\r
577\r
578 HelpSize = 0;\r
579 BriefSize = 0;\r
580 TempString = NULL;\r
581 //\r
582 // See if it's in HII first\r
583 //\r
584 TempString = ShellCommandGetCommandHelp(Command);\r
585 if (TempString != NULL) {\r
586 TempString2 = TempString;\r
587 Status = ManBufferFindTitleSection(&TempString2, Command, BriefDesc, &BriefSize);\r
588 if (!EFI_ERROR(Status) && HelpText != NULL){\r
589 Status = ManBufferFindSections(TempString2, Sections, HelpText, &HelpSize);\r
590 }\r
591 } else {\r
592 FileHandle = NULL;\r
593 TempString = GetManFileName(ManFileName);\r
594\r
595 Status = SearchPathForFile(TempString, &FileHandle);\r
596 if (EFI_ERROR(Status)) {\r
597 FileDevPath = FileDevicePath(NULL, TempString);\r
598 DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, FileDevPath);\r
599 Status = InternalOpenFileDevicePath(DevPath, &FileHandle, EFI_FILE_MODE_READ, 0);\r
600 FreePool(FileDevPath);\r
601 FreePool(DevPath);\r
602 }\r
603\r
604 if (!EFI_ERROR(Status)) {\r
605 HelpSize = 0;\r
606 BriefSize = 0;\r
607 Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii);\r
608 if (!EFI_ERROR(Status) && HelpText != NULL){\r
609 Status = ManFileFindSections(FileHandle, Sections, HelpText, &HelpSize, Ascii);\r
610 }\r
611 ShellInfoObject.NewEfiShellProtocol->CloseFile(FileHandle);\r
612 } else {\r
613 *HelpText = NULL;\r
614 }\r
615 }\r
616 if (TempString != NULL) {\r
617 FreePool(TempString);\r
618 }\r
619\r
620 return (Status);\r
621}\r