1 /** @file
2   Provides interface to shell MAN file parser.
3 
4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
5   SPDX-License-Identifier: BSD-2-Clause-Patent
6 
7 **/
8 
9 #ifndef _SHELL_MAN_FILE_PARSER_HEADER_
10 #define _SHELL_MAN_FILE_PARSER_HEADER_
11 
12 /**
13   This function returns the help information for the specified command. The help text
14   will be parsed from a UEFI Shell manual page. (see UEFI Shell 2.0 Appendix B)
15 
16   If Sections is specified, then each section name listed will be compared in a casesensitive
17   manner, to the section names described in Appendix B. If the section exists,
18   it will be appended to the returned help text. If the section does not exist, no
19   information will be returned. If Sections is NULL, then all help text information
20   available will be returned.
21 
22   if BriefDesc is NULL, then the breif description will not be savedd seperatly,
23   but placed first in the main HelpText.
24 
25   @param[in] ManFileName        Points to the NULL-terminated UEFI Shell MAN file name.
26   @param[in] Command            Points to the NULL-terminated UEFI Shell command name.
27   @param[in] Sections           Points to the NULL-terminated comma-delimited
28                                 section names to return. If NULL, then all
29                                 sections will be returned.
30   @param[out] BriefDesc         On return, points to a callee-allocated buffer
31                                 containing brief description text.
32   @param[out] HelpText          On return, points to a callee-allocated buffer
33                                 containing all specified help text.
34 
35   @retval EFI_SUCCESS           The help text was returned.
36   @retval EFI_OUT_OF_RESOURCES  The necessary buffer could not be allocated to hold the
37                                 returned help text.
38   @retval EFI_INVALID_PARAMETER HelpText is NULL
39   @retval EFI_NOT_FOUND         There is no help text available for Command.
40 **/
41 EFI_STATUS
42 ProcessManFile(
43   IN CONST CHAR16 *ManFileName,
44   IN CONST CHAR16 *Command,
45   IN CONST CHAR16 *Sections OPTIONAL,
46   OUT CHAR16      **BriefDesc,
47   OUT CHAR16      **HelpText
48   );
49 
50 /**
51   parses through the MAN file specified by SHELL_FILE_HANDLE and returns the
52   detailed help for any sub section specified in the comma seperated list of
53   sections provided.  If the end of the file or a .TH section is found then
54   return.
55 
56   Upon a sucessful return the caller is responsible to free the memory in *HelpText
57 
58   @param[in] Handle             FileHandle to read from
59   @param[in] Sections           name of command's sub sections to find
60   @param[out] HelpText          pointer to pointer to string where text goes.
61   @param[out] HelpSize          pointer to size of allocated HelpText (may be updated)
62   @param[in] Ascii              TRUE if the file is ASCII, FALSE otherwise.
63 
64   @retval EFI_OUT_OF_RESOURCES  a memory allocation failed.
65   @retval EFI_SUCCESS           the section was found and its description sotred in
66                                 an alloceted buffer.
67 **/
68 EFI_STATUS
69 ManFileFindSections(
70   IN SHELL_FILE_HANDLE  Handle,
71   IN CONST CHAR16       *Sections,
72   OUT CHAR16            **HelpText,
73   OUT UINTN             *HelpSize,
74   IN BOOLEAN            Ascii
75   );
76 
77 #endif //_SHELL_MAN_FILE_PARSER_HEADER_
78 
79