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