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