]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Application/Shell/ShellManParser.c
Refine comments and two code style.
[mirror_edk2.git] / ShellPkg / Application / Shell / ShellManParser.c
CommitLineData
a405b86d 1/** @file\r
2 Provides interface to shell MAN file parser.\r
3\r
733f138d 4 Copyright (c) 2009 - 2011, 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 "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
733f138d 371 TitleString = AllocateZeroPool((7*sizeof(CHAR16)) + StrSize(Command));\r
a405b86d 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
733f138d 392 if (TitleEnd == NULL) {\r
393 Status = EFI_DEVICE_ERROR;\r
394 } else {\r
395 if (BriefDesc != NULL) {\r
396 *BriefSize = StrSize(TitleEnd);\r
397 *BriefDesc = AllocateZeroPool(*BriefSize);\r
398 if (*BriefDesc == NULL) {\r
399 Status = EFI_OUT_OF_RESOURCES;\r
400 } else {\r
401 StrnCpy(*BriefDesc, CurrentLocation, TitleEnd-CurrentLocation);\r
402 }\r
a405b86d 403 }\r
a405b86d 404\r
733f138d 405 for (CurrentLocation = TitleEnd\r
406 ; *CurrentLocation != L'\n'\r
407 ; CurrentLocation++);\r
408 for (\r
409 ; *CurrentLocation == L' ' || *CurrentLocation == L'\n' || *CurrentLocation == L'\r'\r
410 ; CurrentLocation++);\r
411 *Buffer = CurrentLocation;\r
412 }\r
a405b86d 413 }\r
414\r
415 FreePool(TitleString);\r
416 return (Status);\r
417}\r
418\r
419/**\r
420 parses through the MAN file specified by SHELL_FILE_HANDLE and returns the\r
421 "Brief Description" for the .TH section as specified by Command. if the\r
422 command section is not found return EFI_NOT_FOUND.\r
423\r
424 Upon a sucessful return the caller is responsible to free the memory in *BriefDesc\r
425\r
4ff7e37b
ED
426 @param[in] Handle FileHandle to read from\r
427 @param[in] Command name of command's section to find\r
428 @param[out] BriefDesc pointer to pointer to string where description goes.\r
429 @param[out] BriefSize pointer to size of allocated BriefDesc\r
430 @param[in, out] Ascii TRUE if the file is ASCII, FALSE otherwise, will be\r
431 set if the file handle is at the 0 position.\r
a405b86d 432\r
433 @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
434 @retval EFI_SUCCESS the section was found and its description sotred in\r
435 an alloceted buffer.\r
436**/\r
437EFI_STATUS\r
438EFIAPI\r
439ManFileFindTitleSection(\r
440 IN SHELL_FILE_HANDLE Handle,\r
441 IN CONST CHAR16 *Command,\r
442 OUT CHAR16 **BriefDesc OPTIONAL,\r
443 OUT UINTN *BriefSize OPTIONAL,\r
444 IN OUT BOOLEAN *Ascii\r
445 )\r
446{\r
447 EFI_STATUS Status;\r
448 CHAR16 *TitleString;\r
449 CHAR16 *ReadLine;\r
450 UINTN Size;\r
451 CHAR16 *TitleEnd;\r
452 UINTN TitleLen;\r
453 BOOLEAN Found;\r
454\r
455 if ( Handle == NULL\r
456 || Command == NULL\r
457 || (BriefDesc != NULL && BriefSize == NULL)\r
458 ){\r
459 return (EFI_INVALID_PARAMETER);\r
460 }\r
461\r
462 Status = EFI_SUCCESS;\r
463 Size = 1024;\r
464 Found = FALSE;\r
465\r
466 ReadLine = AllocateZeroPool(Size);\r
467 if (ReadLine == NULL) {\r
468 return (EFI_OUT_OF_RESOURCES);\r
469 }\r
470\r
733f138d 471 TitleString = AllocateZeroPool((4*sizeof(CHAR16)) + StrSize(Command));\r
a405b86d 472 if (TitleString == NULL) {\r
473 FreePool(ReadLine);\r
474 return (EFI_OUT_OF_RESOURCES);\r
475 }\r
476 StrCpy(TitleString, L".TH ");\r
477 StrCat(TitleString, Command);\r
478 TitleLen = StrLen(TitleString);\r
479 for (;!ShellFileHandleEof(Handle);Size = 1024) {\r
480 Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, Ascii);\r
481 if (ReadLine[0] == L'#') {\r
482 //\r
483 // Skip comment lines\r
484 //\r
485 continue;\r
486 }\r
487 //\r
488 // ignore too small of buffer...\r
489 //\r
490 if (Status == EFI_BUFFER_TOO_SMALL) {\r
491 Status = EFI_SUCCESS;\r
492 }\r
493 if (EFI_ERROR(Status)) {\r
494 break;\r
495 }\r
496 if (StrnCmp(ReadLine, TitleString, TitleLen) == 0) {\r
497 Found = TRUE;\r
498 //\r
499 // we found it so copy out the rest of the line into BriefDesc\r
500 // After skipping any spaces or zeroes\r
501 //\r
502 for ( TitleEnd = ReadLine+TitleLen\r
503 ; *TitleEnd == L' ' || *TitleEnd == L'0' || *TitleEnd == L'1'\r
504 ; TitleEnd++);\r
505 if (BriefDesc != NULL) {\r
506 *BriefSize = StrSize(TitleEnd);\r
507 *BriefDesc = AllocateZeroPool(*BriefSize);\r
508 if (*BriefDesc == NULL) {\r
509 Status = EFI_OUT_OF_RESOURCES;\r
510 break;\r
511 }\r
512 StrCpy(*BriefDesc, TitleEnd);\r
513 }\r
514 break;\r
515 }\r
516 }\r
517 FreePool(ReadLine);\r
518 FreePool(TitleString);\r
519 if (!Found && !EFI_ERROR(Status)) {\r
520 return (EFI_NOT_FOUND);\r
521 }\r
522 return (Status);\r
523}\r
524\r
525/**\r
526 This function returns the help information for the specified command. The help text\r
527 will be parsed from a UEFI Shell manual page. (see UEFI Shell 2.0 Appendix B)\r
528\r
529 If Sections is specified, then each section name listed will be compared in a casesensitive\r
530 manner, to the section names described in Appendix B. If the section exists,\r
531 it will be appended to the returned help text. If the section does not exist, no\r
532 information will be returned. If Sections is NULL, then all help text information\r
533 available will be returned.\r
534\r
535 if BriefDesc is NULL, then the breif description will not be savedd seperatly,\r
536 but placed first in the main HelpText.\r
537\r
538 @param[in] ManFileName Points to the NULL-terminated UEFI Shell MAN file name.\r
539 @param[in] Command Points to the NULL-terminated UEFI Shell command name.\r
540 @param[in] Sections Points to the NULL-terminated comma-delimited\r
541 section names to return. If NULL, then all\r
542 sections will be returned.\r
543 @param[out] BriefDesc On return, points to a callee-allocated buffer\r
544 containing brief description text.\r
545 @param[out] HelpText On return, points to a callee-allocated buffer\r
546 containing all specified help text.\r
547\r
548 @retval EFI_SUCCESS The help text was returned.\r
549 @retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the\r
550 returned help text.\r
551 @retval EFI_INVALID_PARAMETER HelpText is NULL\r
552 @retval EFI_NOT_FOUND There is no help text available for Command.\r
553**/\r
554EFI_STATUS\r
555EFIAPI\r
556ProcessManFile(\r
557 IN CONST CHAR16 *ManFileName,\r
558 IN CONST CHAR16 *Command,\r
559 IN CONST CHAR16 *Sections OPTIONAL,\r
560 OUT CHAR16 **BriefDesc OPTIONAL,\r
561 OUT CHAR16 **HelpText\r
562 )\r
563{\r
564 CHAR16 *TempString;\r
565 SHELL_FILE_HANDLE FileHandle;\r
566 EFI_STATUS Status;\r
567 UINTN HelpSize;\r
568 UINTN BriefSize;\r
569 BOOLEAN Ascii;\r
570 CHAR16 *TempString2;\r
571 EFI_DEVICE_PATH_PROTOCOL *FileDevPath;\r
572 EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
573\r
574 if ( ManFileName == NULL\r
575 || Command == NULL\r
576 || HelpText == NULL\r
577 ){\r
578 return (EFI_INVALID_PARAMETER);\r
579 }\r
580\r
581 HelpSize = 0;\r
582 BriefSize = 0;\r
583 TempString = NULL;\r
584 //\r
585 // See if it's in HII first\r
586 //\r
587 TempString = ShellCommandGetCommandHelp(Command);\r
588 if (TempString != NULL) {\r
589 TempString2 = TempString;\r
590 Status = ManBufferFindTitleSection(&TempString2, Command, BriefDesc, &BriefSize);\r
591 if (!EFI_ERROR(Status) && HelpText != NULL){\r
592 Status = ManBufferFindSections(TempString2, Sections, HelpText, &HelpSize);\r
593 }\r
594 } else {\r
595 FileHandle = NULL;\r
596 TempString = GetManFileName(ManFileName);\r
597\r
598 Status = SearchPathForFile(TempString, &FileHandle);\r
599 if (EFI_ERROR(Status)) {\r
600 FileDevPath = FileDevicePath(NULL, TempString);\r
601 DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, FileDevPath);\r
602 Status = InternalOpenFileDevicePath(DevPath, &FileHandle, EFI_FILE_MODE_READ, 0);\r
603 FreePool(FileDevPath);\r
604 FreePool(DevPath);\r
605 }\r
606\r
607 if (!EFI_ERROR(Status)) {\r
608 HelpSize = 0;\r
609 BriefSize = 0;\r
610 Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii);\r
611 if (!EFI_ERROR(Status) && HelpText != NULL){\r
612 Status = ManFileFindSections(FileHandle, Sections, HelpText, &HelpSize, Ascii);\r
613 }\r
614 ShellInfoObject.NewEfiShellProtocol->CloseFile(FileHandle);\r
615 } else {\r
616 *HelpText = NULL;\r
617 }\r
618 }\r
619 if (TempString != NULL) {\r
620 FreePool(TempString);\r
621 }\r
622\r
623 return (Status);\r
624}\r