]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Common/ParseInf.h
6215ea2e786817b0b27624e196cdebb555b589c0
[mirror_edk2.git] / BaseTools / Source / C / Common / ParseInf.h
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 ParseInf.h
15
16 Abstract:
17
18 Header file for helper functions useful for parsing INF files.
19
20 **/
21
22 #ifndef _EFI_PARSE_INF_H
23 #define _EFI_PARSE_INF_H
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <Common/UefiBaseTypes.h>
28 #include <MemoryFile.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 //
34 // Functions declarations
35 //
36 CHAR8 *
37 ReadLine (
38 IN MEMORY_FILE *InputFile,
39 IN OUT CHAR8 *InputBuffer,
40 IN UINTN MaxLength
41 )
42 ;
43
44 /*++
45
46 Routine Description:
47
48 This function reads a line, stripping any comments.
49 The function reads a string from the input stream argument and stores it in
50 the input string. ReadLine reads characters from the current file position
51 to and including the first newline character, to the end of the stream, or
52 until the number of characters read is equal to MaxLength - 1, whichever
53 comes first. The newline character, if read, is replaced with a \0.
54
55 Arguments:
56
57 InputFile Memory file image.
58 InputBuffer Buffer to read into, must be MaxLength size.
59 MaxLength The maximum size of the input buffer.
60
61 Returns:
62
63 NULL if error or EOF
64 InputBuffer otherwise
65
66 --*/
67 BOOLEAN
68 FindSection (
69 IN MEMORY_FILE *InputFile,
70 IN CHAR8 *Section
71 )
72 ;
73
74 /*++
75
76 Routine Description:
77
78 This function parses a file from the beginning to find a section.
79 The section string may be anywhere within a line.
80
81 Arguments:
82
83 InputFile Memory file image.
84 Section Section to search for
85
86 Returns:
87
88 FALSE if error or EOF
89 TRUE if section found
90
91 --*/
92 EFI_STATUS
93 FindToken (
94 IN MEMORY_FILE *InputFile,
95 IN CHAR8 *Section,
96 IN CHAR8 *Token,
97 IN UINTN Instance,
98 OUT CHAR8 *Value
99 )
100 ;
101
102 /*++
103
104 Routine Description:
105
106 Finds a token value given the section and token to search for.
107
108 Arguments:
109
110 InputFile Memory file image.
111 Section The section to search for, a string within [].
112 Token The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.
113 Instance The instance of the token to search for. Zero is the first instance.
114 Value The string that holds the value following the =. Must be MAX_LONG_FILE_PATH in size.
115
116 Returns:
117
118 EFI_SUCCESS Value found.
119 EFI_ABORTED Format error detected in INF file.
120 EFI_INVALID_PARAMETER Input argument was null.
121 EFI_LOAD_ERROR Error reading from the file.
122 EFI_NOT_FOUND Section/Token/Value not found.
123
124 --*/
125 EFI_STATUS
126 StringToGuid (
127 IN CHAR8 *AsciiGuidBuffer,
128 OUT EFI_GUID *GuidBuffer
129 )
130 ;
131
132 /*++
133
134 Routine Description:
135
136 Converts a string to an EFI_GUID. The string must be in the
137 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.
138
139 Arguments:
140
141 GuidBuffer - pointer to destination Guid
142 AsciiGuidBuffer - pointer to ascii string
143
144 Returns:
145
146 EFI_ABORTED Could not convert the string
147 EFI_SUCCESS The string was successfully converted
148
149 --*/
150 EFI_STATUS
151 AsciiStringToUint64 (
152 IN CONST CHAR8 *AsciiString,
153 IN BOOLEAN IsHex,
154 OUT UINT64 *ReturnValue
155 )
156 ;
157
158 /*++
159
160 Routine Description:
161
162 Converts a null terminated ascii string that represents a number into a
163 UINT64 value. A hex number may be preceeded by a 0x, but may not be
164 succeeded by an h. A number without 0x or 0X is considered to be base 10
165 unless the IsHex input is true.
166
167 Arguments:
168
169 AsciiString The string to convert.
170 IsHex Force the string to be treated as a hex number.
171 ReturnValue The return value.
172
173 Returns:
174
175 EFI_SUCCESS Number successfully converted.
176 EFI_ABORTED Invalid character encountered.
177
178 --*/
179 CHAR8 *
180 ReadLineInStream (
181 IN FILE *InputFile,
182 IN OUT CHAR8 *InputBuffer
183 )
184 ;
185
186 /*++
187
188 Routine Description:
189
190 This function reads a line, stripping any comments.
191
192 Arguments:
193
194 InputFile Stream pointer.
195 InputBuffer Buffer to read into, must be MAX_LONG_FILE_PATH size.
196
197 Returns:
198
199 NULL if error or EOF
200 InputBuffer otherwise
201
202 --*/
203 BOOLEAN
204 FindSectionInStream (
205 IN FILE *InputFile,
206 IN CHAR8 *Section
207 )
208 ;
209
210 /*++
211
212 Routine Description:
213
214 This function parses a stream file from the beginning to find a section.
215 The section string may be anywhere within a line.
216
217 Arguments:
218
219 InputFile Stream pointer.
220 Section Section to search for
221
222 Returns:
223
224 FALSE if error or EOF
225 TRUE if section found
226
227 --*/
228
229 #ifdef __cplusplus
230 }
231 #endif
232
233 #endif