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