edfdde7e8d32c79cc1e075c567d6c41f8090c3e7
[mirror_edk2.git] / SignedCapsulePkg / Include / Library / IniParsingLib.h
1 /** @file
2 INI configuration parsing library.
3
4 The INI file format is:
5 ================
6 [SectionName]
7 EntryName=EntryValue
8 ================
9
10 Where:
11 1) SectionName is an ASCII string. The valid format is [A-Za-z0-9_]+
12 2) EntryName is an ASCII string. The valid format is [A-Za-z0-9_]+
13 3) EntryValue can be:
14 3.1) an ASCII String. The valid format is [A-Za-z0-9_]+
15 3.2) a GUID. The valid format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where x is [A-Fa-f0-9]
16 3.3) a decimal value. The valid format is [0-9]+
17 3.4) a hexadecimal value. The valid format is 0x[A-Fa-f0-9]+
18 4) '#' or ';' can be used as comment at anywhere.
19 5) TAB(0x20) or SPACE(0x9) can be used as separator.
20 6) LF(\n, 0xA) or CR(\r, 0xD) can be used as line break.
21
22 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
23 SPDX-License-Identifier: BSD-2-Clause-Patent
24
25 **/
26
27
28 #ifndef __INI_PARSING_LIB_H__
29 #define __INI_PARSING_LIB_H__
30
31 /**
32 Open an INI config file and return a context.
33
34 @param[in] DataBuffer Config raw file buffer.
35 @param[in] BufferSize Size of raw buffer.
36
37 @return Config data buffer is opened and context is returned.
38 @retval NULL No enough memory is allocated.
39 @retval NULL Config data buffer is invalid.
40 **/
41 VOID *
42 EFIAPI
43 OpenIniFile (
44 IN UINT8 *DataBuffer,
45 IN UINTN BufferSize
46 );
47
48 /**
49 Get section entry string value.
50
51 @param[in] Context INI Config file context.
52 @param[in] SectionName Section name.
53 @param[in] EntryName Section entry name.
54 @param[out] EntryValue Point to the got entry string value.
55
56 @retval EFI_SUCCESS Section entry string value is got.
57 @retval EFI_NOT_FOUND Section is not found.
58 **/
59 EFI_STATUS
60 EFIAPI
61 GetStringFromDataFile (
62 IN VOID *Context,
63 IN CHAR8 *SectionName,
64 IN CHAR8 *EntryName,
65 OUT CHAR8 **EntryValue
66 );
67
68 /**
69 Get section entry GUID value.
70
71 @param[in] Context INI Config file context.
72 @param[in] SectionName Section name.
73 @param[in] EntryName Section entry name.
74 @param[out] Guid Point to the got GUID value.
75
76 @retval EFI_SUCCESS Section entry GUID value is got.
77 @retval EFI_NOT_FOUND Section is not found.
78 **/
79 EFI_STATUS
80 EFIAPI
81 GetGuidFromDataFile (
82 IN VOID *Context,
83 IN CHAR8 *SectionName,
84 IN CHAR8 *EntryName,
85 OUT EFI_GUID *Guid
86 );
87
88 /**
89 Get section entry decimal UINTN value.
90
91 @param[in] Context INI Config file context.
92 @param[in] SectionName Section name.
93 @param[in] EntryName Section entry name.
94 @param[out] Data Point to the got decimal UINTN value.
95
96 @retval EFI_SUCCESS Section entry decimal UINTN value is got.
97 @retval EFI_NOT_FOUND Section is not found.
98 **/
99 EFI_STATUS
100 EFIAPI
101 GetDecimalUintnFromDataFile (
102 IN VOID *Context,
103 IN CHAR8 *SectionName,
104 IN CHAR8 *EntryName,
105 OUT UINTN *Data
106 );
107
108 /**
109 Get section entry hexadecimal UINTN value.
110
111 @param[in] Context INI Config file context.
112 @param[in] SectionName Section name.
113 @param[in] EntryName Section entry name.
114 @param[out] Data Point to the got hexadecimal UINTN value.
115
116 @retval EFI_SUCCESS Section entry hexadecimal UINTN value is got.
117 @retval EFI_NOT_FOUND Section is not found.
118 **/
119 EFI_STATUS
120 EFIAPI
121 GetHexUintnFromDataFile (
122 IN VOID *Context,
123 IN CHAR8 *SectionName,
124 IN CHAR8 *EntryName,
125 OUT UINTN *Data
126 );
127
128 /**
129 Get section entry hexadecimal UINT64 value.
130
131 @param[in] Context INI Config file context.
132 @param[in] SectionName Section name.
133 @param[in] EntryName Section entry name.
134 @param[out] Data Point to the got hexadecimal UINT64 value.
135
136 @retval EFI_SUCCESS Section entry hexadecimal UINT64 value is got.
137 @retval EFI_NOT_FOUND Section is not found.
138 **/
139 EFI_STATUS
140 EFIAPI
141 GetHexUint64FromDataFile (
142 IN VOID *Context,
143 IN CHAR8 *SectionName,
144 IN CHAR8 *EntryName,
145 OUT UINT64 *Data
146 );
147
148 /**
149 Close an INI config file and free the context.
150
151 @param[in] Context INI Config file context.
152 **/
153 VOID
154 EFIAPI
155 CloseIniFile (
156 IN VOID *Context
157 );
158
159 #endif
160