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