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