]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/C/Common/ParseInf.h
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / C / Common / ParseInf.h
CommitLineData
30fdf114
LG
1/** @file\r
2\r
3Copyright (c) 2004 - 2008, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
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
34\r
35//\r
36// Functions declarations\r
37//\r
38CHAR8 *\r
39ReadLine (\r
40 IN MEMORY_FILE *InputFile,\r
41 IN OUT CHAR8 *InputBuffer,\r
42 IN UINTN MaxLength\r
43 )\r
44;\r
45\r
46/*++\r
47\r
48Routine Description:\r
49\r
50 This function reads a line, stripping any comments.\r
51 The function reads a string from the input stream argument and stores it in \r
52 the input string. ReadLine reads characters from the current file position \r
53 to and including the first newline character, to the end of the stream, or \r
54 until the number of characters read is equal to MaxLength - 1, whichever \r
55 comes first. The newline character, if read, is replaced with a \0. \r
56\r
57Arguments:\r
58\r
59 InputFile Memory file image.\r
60 InputBuffer Buffer to read into, must be _MAX_PATH size.\r
61 MaxLength The maximum size of the input buffer.\r
62\r
63Returns:\r
64\r
65 NULL if error or EOF\r
66 InputBuffer otherwise\r
67\r
68--*/\r
69BOOLEAN\r
70FindSection (\r
71 IN MEMORY_FILE *InputFile,\r
72 IN CHAR8 *Section\r
73 )\r
74;\r
75\r
76/*++\r
77\r
78Routine Description:\r
79\r
80 This function parses a file from the beginning to find a section.\r
81 The section string may be anywhere within a line.\r
82\r
83Arguments:\r
84\r
85 InputFile Memory file image.\r
86 Section Section to search for\r
87\r
88Returns:\r
89\r
90 FALSE if error or EOF\r
91 TRUE if section found\r
92\r
93--*/\r
94EFI_STATUS\r
95FindToken (\r
96 IN MEMORY_FILE *InputFile,\r
97 IN CHAR8 *Section,\r
98 IN CHAR8 *Token,\r
99 IN UINTN Instance,\r
100 OUT CHAR8 *Value\r
101 )\r
102;\r
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
127EFI_STATUS\r
128StringToGuid (\r
129 IN CHAR8 *AsciiGuidBuffer,\r
130 OUT EFI_GUID *GuidBuffer\r
131 )\r
132;\r
133\r
134/*++\r
135\r
136Routine Description: \r
137\r
138 Converts a string to an EFI_GUID. The string must be in the \r
139 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.\r
140\r
141Arguments: \r
142\r
143 GuidBuffer - pointer to destination Guid\r
144 AsciiGuidBuffer - pointer to ascii string\r
145\r
146Returns: \r
147\r
148 EFI_ABORTED Could not convert the string\r
149 EFI_SUCCESS The string was successfully converted\r
150\r
151--*/\r
152EFI_STATUS\r
153AsciiStringToUint64 (\r
154 IN CONST CHAR8 *AsciiString,\r
155 IN BOOLEAN IsHex,\r
156 OUT UINT64 *ReturnValue\r
157 )\r
158;\r
159\r
160/*++\r
161\r
162Routine Description:\r
163\r
164 Converts a null terminated ascii string that represents a number into a \r
165 UINT64 value. A hex number may be preceeded by a 0x, but may not be \r
166 succeeded by an h. A number without 0x or 0X is considered to be base 10 \r
167 unless the IsHex input is true.\r
168\r
169Arguments:\r
170\r
171 AsciiString The string to convert.\r
172 IsHex Force the string to be treated as a hex number.\r
173 ReturnValue The return value.\r
174\r
175Returns:\r
176\r
177 EFI_SUCCESS Number successfully converted.\r
178 EFI_ABORTED Invalid character encountered.\r
179\r
180--*/\r
181CHAR8 *\r
182ReadLineInStream (\r
183 IN FILE *InputFile,\r
184 IN OUT CHAR8 *InputBuffer\r
185 )\r
186;\r
187\r
188/*++\r
189\r
190Routine Description:\r
191\r
192 This function reads a line, stripping any comments.\r
193\r
194Arguments:\r
195\r
196 InputFile Stream pointer.\r
197 InputBuffer Buffer to read into, must be _MAX_PATH size.\r
198\r
199Returns:\r
200\r
201 NULL if error or EOF\r
202 InputBuffer otherwise\r
203\r
204--*/\r
205BOOLEAN\r
206FindSectionInStream (\r
207 IN FILE *InputFile,\r
208 IN CHAR8 *Section\r
209 )\r
210;\r
211\r
212/*++\r
213\r
214Routine Description:\r
215\r
216 This function parses a stream file from the beginning to find a section.\r
217 The section string may be anywhere within a line.\r
218\r
219Arguments:\r
220\r
221 InputFile Stream pointer.\r
222 Section Section to search for\r
223\r
224Returns:\r
225\r
226 FALSE if error or EOF\r
227 TRUE if section found\r
228\r
229--*/\r
230#endif\r