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