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