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