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