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