]>
Commit | Line | Data |
---|---|---|
30fdf114 | 1 | /** @file\r |
97fa0ee9 | 2 | Header file for helper functions useful for parsing INF files.\r |
30fdf114 | 3 | \r |
1be2ed90 | 4 | Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r |
40d841f6 | 5 | This program and the accompanying materials \r |
30fdf114 LG |
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 | |
30fdf114 LG |
13 | **/\r |
14 | \r | |
15 | #ifndef _EFI_PARSE_INF_H\r | |
16 | #define _EFI_PARSE_INF_H\r | |
17 | \r | |
18 | #include <stdio.h>\r | |
19 | #include <stdlib.h>\r | |
20 | #include <Common/UefiBaseTypes.h>\r | |
21 | #include <MemoryFile.h>\r | |
22 | \r | |
4234283c LG |
23 | #ifdef __cplusplus\r |
24 | extern "C" {\r | |
25 | #endif\r | |
30fdf114 LG |
26 | //\r |
27 | // Functions declarations\r | |
28 | //\r | |
29 | CHAR8 *\r | |
30 | ReadLine (\r | |
31 | IN MEMORY_FILE *InputFile,\r | |
32 | IN OUT CHAR8 *InputBuffer,\r | |
33 | IN UINTN MaxLength\r | |
34 | )\r | |
35 | ;\r | |
36 | \r | |
37 | /*++\r | |
38 | \r | |
39 | Routine Description:\r | |
40 | \r | |
41 | This function reads a line, stripping any comments.\r | |
42 | The function reads a string from the input stream argument and stores it in \r | |
43 | the input string. ReadLine reads characters from the current file position \r | |
44 | to and including the first newline character, to the end of the stream, or \r | |
45 | until the number of characters read is equal to MaxLength - 1, whichever \r | |
46 | comes first. The newline character, if read, is replaced with a \0. \r | |
47 | \r | |
48 | Arguments:\r | |
49 | \r | |
50 | InputFile Memory file image.\r | |
1be2ed90 | 51 | InputBuffer Buffer to read into, must be MaxLength size.\r |
30fdf114 LG |
52 | MaxLength The maximum size of the input buffer.\r |
53 | \r | |
54 | Returns:\r | |
55 | \r | |
56 | NULL if error or EOF\r | |
57 | InputBuffer otherwise\r | |
58 | \r | |
59 | --*/\r | |
60 | BOOLEAN\r | |
61 | FindSection (\r | |
62 | IN MEMORY_FILE *InputFile,\r | |
63 | IN CHAR8 *Section\r | |
64 | )\r | |
65 | ;\r | |
66 | \r | |
67 | /*++\r | |
68 | \r | |
69 | Routine Description:\r | |
70 | \r | |
71 | This function parses a file from the beginning to find a section.\r | |
72 | The section string may be anywhere within a line.\r | |
73 | \r | |
74 | Arguments:\r | |
75 | \r | |
76 | InputFile Memory file image.\r | |
77 | Section Section to search for\r | |
78 | \r | |
79 | Returns:\r | |
80 | \r | |
81 | FALSE if error or EOF\r | |
82 | TRUE if section found\r | |
83 | \r | |
84 | --*/\r | |
85 | EFI_STATUS\r | |
86 | FindToken (\r | |
87 | IN MEMORY_FILE *InputFile,\r | |
88 | IN CHAR8 *Section,\r | |
89 | IN CHAR8 *Token,\r | |
90 | IN UINTN Instance,\r | |
91 | OUT CHAR8 *Value\r | |
92 | )\r | |
93 | ;\r | |
94 | \r | |
95 | /*++\r | |
96 | \r | |
97 | Routine Description:\r | |
98 | \r | |
99 | Finds a token value given the section and token to search for.\r | |
100 | \r | |
101 | Arguments:\r | |
102 | \r | |
103 | InputFile Memory file image.\r | |
104 | Section The section to search for, a string within [].\r | |
105 | Token The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.\r | |
106 | Instance The instance of the token to search for. Zero is the first instance.\r | |
1be2ed90 | 107 | Value The string that holds the value following the =. Must be MAX_LONG_FILE_PATH in size.\r |
30fdf114 LG |
108 | \r |
109 | Returns:\r | |
110 | \r | |
111 | EFI_SUCCESS Value found.\r | |
112 | EFI_ABORTED Format error detected in INF file.\r | |
113 | EFI_INVALID_PARAMETER Input argument was null.\r | |
114 | EFI_LOAD_ERROR Error reading from the file.\r | |
115 | EFI_NOT_FOUND Section/Token/Value not found.\r | |
116 | \r | |
117 | --*/\r | |
118 | EFI_STATUS\r | |
119 | StringToGuid (\r | |
120 | IN CHAR8 *AsciiGuidBuffer,\r | |
121 | OUT EFI_GUID *GuidBuffer\r | |
122 | )\r | |
123 | ;\r | |
124 | \r | |
125 | /*++\r | |
126 | \r | |
127 | Routine Description: \r | |
128 | \r | |
129 | Converts a string to an EFI_GUID. The string must be in the \r | |
130 | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.\r | |
131 | \r | |
132 | Arguments: \r | |
133 | \r | |
134 | GuidBuffer - pointer to destination Guid\r | |
135 | AsciiGuidBuffer - pointer to ascii string\r | |
136 | \r | |
137 | Returns: \r | |
138 | \r | |
139 | EFI_ABORTED Could not convert the string\r | |
140 | EFI_SUCCESS The string was successfully converted\r | |
141 | \r | |
142 | --*/\r | |
143 | EFI_STATUS\r | |
144 | AsciiStringToUint64 (\r | |
145 | IN CONST CHAR8 *AsciiString,\r | |
146 | IN BOOLEAN IsHex,\r | |
147 | OUT UINT64 *ReturnValue\r | |
148 | )\r | |
149 | ;\r | |
150 | \r | |
151 | /*++\r | |
152 | \r | |
153 | Routine Description:\r | |
154 | \r | |
155 | Converts a null terminated ascii string that represents a number into a \r | |
156 | UINT64 value. A hex number may be preceeded by a 0x, but may not be \r | |
157 | succeeded by an h. A number without 0x or 0X is considered to be base 10 \r | |
158 | unless the IsHex input is true.\r | |
159 | \r | |
160 | Arguments:\r | |
161 | \r | |
162 | AsciiString The string to convert.\r | |
163 | IsHex Force the string to be treated as a hex number.\r | |
164 | ReturnValue The return value.\r | |
165 | \r | |
166 | Returns:\r | |
167 | \r | |
168 | EFI_SUCCESS Number successfully converted.\r | |
169 | EFI_ABORTED Invalid character encountered.\r | |
170 | \r | |
171 | --*/\r | |
172 | CHAR8 *\r | |
173 | ReadLineInStream (\r | |
174 | IN FILE *InputFile,\r | |
175 | IN OUT CHAR8 *InputBuffer\r | |
176 | )\r | |
177 | ;\r | |
178 | \r | |
179 | /*++\r | |
180 | \r | |
181 | Routine Description:\r | |
182 | \r | |
183 | This function reads a line, stripping any comments.\r | |
184 | \r | |
185 | Arguments:\r | |
186 | \r | |
187 | InputFile Stream pointer.\r | |
1be2ed90 | 188 | InputBuffer Buffer to read into, must be MAX_LONG_FILE_PATH size.\r |
30fdf114 LG |
189 | \r |
190 | Returns:\r | |
191 | \r | |
192 | NULL if error or EOF\r | |
193 | InputBuffer otherwise\r | |
194 | \r | |
195 | --*/\r | |
196 | BOOLEAN\r | |
197 | FindSectionInStream (\r | |
198 | IN FILE *InputFile,\r | |
199 | IN CHAR8 *Section\r | |
200 | )\r | |
201 | ;\r | |
202 | \r | |
203 | /*++\r | |
204 | \r | |
205 | Routine Description:\r | |
206 | \r | |
207 | This function parses a stream file from the beginning to find a section.\r | |
208 | The section string may be anywhere within a line.\r | |
209 | \r | |
210 | Arguments:\r | |
211 | \r | |
212 | InputFile Stream pointer.\r | |
213 | Section Section to search for\r | |
214 | \r | |
215 | Returns:\r | |
216 | \r | |
217 | FALSE if error or EOF\r | |
218 | TRUE if section found\r | |
219 | \r | |
220 | --*/\r | |
4234283c LG |
221 | \r |
222 | #ifdef __cplusplus\r | |
223 | }\r | |
224 | #endif\r | |
225 | \r | |
30fdf114 | 226 | #endif\r |