]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h
Maintainers.txt: Remove EdkCompatibilityPkg information
[mirror_edk2.git] / EdkCompatibilityPkg / Sample / Tools / Source / Common / ParseInf.h
CommitLineData
3eb9473e 1/*++\r
2\r
3e99020d 3Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
4b1e1121 4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 ParseInf.h\r
15\r
16Abstract:\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
32typedef 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
41CHAR8 *\r
42ReadLine (\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
50Routine 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
59Arguments:\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
65Returns:\r
66\r
67 NULL if error or EOF\r
68 InputBuffer otherwise\r
69\r
70--*/\r
71BOOLEAN\r
72FindSection (\r
73 IN MEMORY_FILE *InputFile,\r
74 IN CHAR8 *Section\r
e00e1d46 75 );\r
3eb9473e 76\r
77/*++\r
78\r
79Routine 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
84Arguments:\r
85\r
86 InputFile Memory file image.\r
87 Section Section to search for\r
88\r
89Returns:\r
90\r
91 FALSE if error or EOF\r
92 TRUE if section found\r
93\r
94--*/\r
95EFI_STATUS\r
96FindToken (\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
106Routine Description:\r
107\r
108 Finds a token value given the section and token to search for.\r
109\r
110Arguments:\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
118Returns:\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
3e99020d
LG
127\r
128EFI_STATUS\r
129FindTokenInstanceInSection (\r
130 IN MEMORY_FILE *InputFile,\r
131 IN CHAR8 *Section,\r
132 IN UINTN Instance,\r
133 OUT CHAR8 *Token,\r
134 OUT CHAR8 *Value\r
135 )\r
136;\r
137/*++\r
138\r
139Routine Description:\r
140\r
141 Finds the Instance-th token in a section.\r
142\r
143Arguments:\r
144\r
145 InputFile Memory file image.\r
146 Section The section to search for, a string within [].\r
147 Instance Specify the Instance-th token to search for, starting from zero\r
148 Token The token name to return. Caller should allocate the buffer.\r
149 Must be _MAX_PATH in size.\r
150 Value The token value to return. Caller should allocate the buffer.\r
151 Must be _MAX_PATH in size.\r
152\r
153Returns:\r
154\r
155 EFI_SUCCESS Token and Value found.\r
156 EFI_ABORTED Format error detected in INF file.\r
157 EFI_INVALID_PARAMETER Input argument was null.\r
158 EFI_LOAD_ERROR Error reading from the file.\r
159 EFI_NOT_FOUND Section/Token/Value not found.\r
160\r
161--*/\r
162\r
3eb9473e 163EFI_STATUS\r
164StringToGuid (\r
165 IN CHAR8 *AsciiGuidBuffer,\r
166 OUT EFI_GUID *GuidBuffer\r
e00e1d46 167 );\r
3eb9473e 168\r
169/*++\r
170\r
171Routine Description: \r
172\r
173 Converts a string to an EFI_GUID. The string must be in the \r
174 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.\r
175\r
176Arguments: \r
177\r
178 GuidBuffer - pointer to destination Guid\r
179 AsciiGuidBuffer - pointer to ascii string\r
180\r
181Returns: \r
182\r
183 EFI_ABORTED Could not convert the string\r
184 EFI_SUCCESS The string was successfully converted\r
185\r
186--*/\r
187EFI_STATUS\r
188AsciiStringToUint64 (\r
189 IN CONST CHAR8 *AsciiString,\r
190 IN BOOLEAN IsHex,\r
191 OUT UINT64 *ReturnValue\r
e00e1d46 192 );\r
3eb9473e 193\r
194/*++\r
195\r
196Routine Description:\r
197\r
198 Converts a null terminated ascii string that represents a number into a \r
199 UINT64 value. A hex number may be preceeded by a 0x, but may not be \r
200 succeeded by an h. A number without 0x or 0X is considered to be base 10 \r
201 unless the IsHex input is true.\r
202\r
203Arguments:\r
204\r
205 AsciiString The string to convert.\r
206 IsHex Force the string to be treated as a hex number.\r
207 ReturnValue The return value.\r
208\r
209Returns:\r
210\r
211 EFI_SUCCESS Number successfully converted.\r
212 EFI_ABORTED Invalid character encountered.\r
213\r
214--*/\r
215CHAR8 *\r
216ReadLineInStream (\r
217 IN FILE *InputFile,\r
218 IN OUT CHAR8 *InputBuffer\r
e00e1d46 219 );\r
3eb9473e 220\r
221/*++\r
222\r
223Routine Description:\r
224\r
225 This function reads a line, stripping any comments.\r
226\r
227Arguments:\r
228\r
229 InputFile Stream pointer.\r
230 InputBuffer Buffer to read into, must be _MAX_PATH size.\r
231\r
232Returns:\r
233\r
234 NULL if error or EOF\r
235 InputBuffer otherwise\r
236\r
237--*/\r
238BOOLEAN\r
239FindSectionInStream (\r
240 IN FILE *InputFile,\r
241 IN CHAR8 *Section\r
e00e1d46 242 );\r
3eb9473e 243\r
244/*++\r
245\r
246Routine Description:\r
247\r
248 This function parses a stream file from the beginning to find a section.\r
249 The section string may be anywhere within a line.\r
250\r
251Arguments:\r
252\r
253 InputFile Stream pointer.\r
254 Section Section to search for\r
255\r
256Returns:\r
257\r
258 FALSE if error or EOF\r
259 TRUE if section found\r
260\r
261--*/\r
262#endif\r