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