]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/C/Common/ParseInf.h
Sync BaseTools Branch (version r2271) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / C / Common / ParseInf.h
CommitLineData
30fdf114
LG
1/** @file\r
2\r
40d841f6
LG
3Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
30fdf114
LG
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 <stdio.h>\r
26#include <stdlib.h>\r
27#include <Common/UefiBaseTypes.h>\r
28#include <MemoryFile.h>\r
29\r
30#ifndef _MAX_PATH\r
31#define _MAX_PATH 500\r
32#endif\r
33\r
4234283c
LG
34#ifdef __cplusplus\r
35extern "C" {\r
36#endif\r
30fdf114
LG
37//\r
38// Functions declarations\r
39//\r
40CHAR8 *\r
41ReadLine (\r
42 IN MEMORY_FILE *InputFile,\r
43 IN OUT CHAR8 *InputBuffer,\r
44 IN UINTN MaxLength\r
45 )\r
46;\r
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
75 )\r
76;\r
77\r
78/*++\r
79\r
80Routine Description:\r
81\r
82 This function parses a file from the beginning to find a section.\r
83 The section string may be anywhere within a line.\r
84\r
85Arguments:\r
86\r
87 InputFile Memory file image.\r
88 Section Section to search for\r
89\r
90Returns:\r
91\r
92 FALSE if error or EOF\r
93 TRUE if section found\r
94\r
95--*/\r
96EFI_STATUS\r
97FindToken (\r
98 IN MEMORY_FILE *InputFile,\r
99 IN CHAR8 *Section,\r
100 IN CHAR8 *Token,\r
101 IN UINTN Instance,\r
102 OUT CHAR8 *Value\r
103 )\r
104;\r
105\r
106/*++\r
107\r
108Routine Description:\r
109\r
110 Finds a token value given the section and token to search for.\r
111\r
112Arguments:\r
113\r
114 InputFile Memory file image.\r
115 Section The section to search for, a string within [].\r
116 Token The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.\r
117 Instance The instance of the token to search for. Zero is the first instance.\r
118 Value The string that holds the value following the =. Must be _MAX_PATH in size.\r
119\r
120Returns:\r
121\r
122 EFI_SUCCESS Value found.\r
123 EFI_ABORTED Format error detected in INF file.\r
124 EFI_INVALID_PARAMETER Input argument was null.\r
125 EFI_LOAD_ERROR Error reading from the file.\r
126 EFI_NOT_FOUND Section/Token/Value not found.\r
127\r
128--*/\r
129EFI_STATUS\r
130StringToGuid (\r
131 IN CHAR8 *AsciiGuidBuffer,\r
132 OUT EFI_GUID *GuidBuffer\r
133 )\r
134;\r
135\r
136/*++\r
137\r
138Routine Description: \r
139\r
140 Converts a string to an EFI_GUID. The string must be in the \r
141 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.\r
142\r
143Arguments: \r
144\r
145 GuidBuffer - pointer to destination Guid\r
146 AsciiGuidBuffer - pointer to ascii string\r
147\r
148Returns: \r
149\r
150 EFI_ABORTED Could not convert the string\r
151 EFI_SUCCESS The string was successfully converted\r
152\r
153--*/\r
154EFI_STATUS\r
155AsciiStringToUint64 (\r
156 IN CONST CHAR8 *AsciiString,\r
157 IN BOOLEAN IsHex,\r
158 OUT UINT64 *ReturnValue\r
159 )\r
160;\r
161\r
162/*++\r
163\r
164Routine Description:\r
165\r
166 Converts a null terminated ascii string that represents a number into a \r
167 UINT64 value. A hex number may be preceeded by a 0x, but may not be \r
168 succeeded by an h. A number without 0x or 0X is considered to be base 10 \r
169 unless the IsHex input is true.\r
170\r
171Arguments:\r
172\r
173 AsciiString The string to convert.\r
174 IsHex Force the string to be treated as a hex number.\r
175 ReturnValue The return value.\r
176\r
177Returns:\r
178\r
179 EFI_SUCCESS Number successfully converted.\r
180 EFI_ABORTED Invalid character encountered.\r
181\r
182--*/\r
183CHAR8 *\r
184ReadLineInStream (\r
185 IN FILE *InputFile,\r
186 IN OUT CHAR8 *InputBuffer\r
187 )\r
188;\r
189\r
190/*++\r
191\r
192Routine Description:\r
193\r
194 This function reads a line, stripping any comments.\r
195\r
196Arguments:\r
197\r
198 InputFile Stream pointer.\r
199 InputBuffer Buffer to read into, must be _MAX_PATH size.\r
200\r
201Returns:\r
202\r
203 NULL if error or EOF\r
204 InputBuffer otherwise\r
205\r
206--*/\r
207BOOLEAN\r
208FindSectionInStream (\r
209 IN FILE *InputFile,\r
210 IN CHAR8 *Section\r
211 )\r
212;\r
213\r
214/*++\r
215\r
216Routine Description:\r
217\r
218 This function parses a stream file from the beginning to find a section.\r
219 The section string may be anywhere within a line.\r
220\r
221Arguments:\r
222\r
223 InputFile Stream pointer.\r
224 Section Section to search for\r
225\r
226Returns:\r
227\r
228 FALSE if error or EOF\r
229 TRUE if section found\r
230\r
231--*/\r
4234283c
LG
232\r
233#ifdef __cplusplus\r
234}\r
235#endif\r
236\r
30fdf114 237#endif\r