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