]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/C/Common/StringFuncs.h
MdeModulePkg:
[mirror_edk2.git] / BaseTools / Source / C / Common / StringFuncs.h
CommitLineData
30fdf114
LG
1/**\r
2\r
3Copyright (c) 2007 - 2008, 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 StringFuncs.h\r
15\r
16Abstract:\r
17\r
18 String routines implementation.\r
19\r
20**/\r
21\r
22#ifndef _EFI_STRING_FUNCS_H\r
23#define _EFI_STRING_FUNCS_H\r
24\r
25#include <stdio.h>\r
26#include <stdlib.h>\r
27#include <Common/UefiBaseTypes.h>\r
28\r
29//\r
30// Common data structures\r
31//\r
32typedef struct {\r
33 UINTN Count;\r
34 //\r
35 // Actually this array can be 0 or more items (based on Count)\r
36 //\r
37 CHAR8* Strings[1];\r
38} STRING_LIST;\r
39\r
40\r
41//\r
42// Functions declarations\r
43//\r
44\r
45CHAR8*\r
46CloneString (\r
47 IN CHAR8 *String\r
48 )\r
49;\r
50/**\r
51\r
52Routine Description:\r
53\r
54 Allocates a new string and copies 'String' to clone it\r
55\r
56Arguments:\r
57\r
58 String The string to clone\r
59\r
60Returns:\r
61\r
62 CHAR8* - NULL if there are not enough resources\r
63\r
64**/\r
65\r
66\r
67EFI_STATUS\r
68StripInfDscStringInPlace (\r
69 IN CHAR8 *String\r
70 )\r
71;\r
72/**\r
73\r
74Routine Description:\r
75\r
76 Remove all comments, leading and trailing whitespace from the string.\r
77\r
78Arguments:\r
79\r
80 Strin The string to 'strip'\r
81\r
82Returns:\r
83\r
84 EFI_STATUS\r
85\r
86**/\r
87\r
88\r
89STRING_LIST*\r
90SplitStringByWhitespace (\r
91 IN CHAR8 *String\r
92 )\r
93;\r
94/**\r
95\r
96Routine Description:\r
97\r
98 Creates and returns a 'split' STRING_LIST by splitting the string\r
99 on whitespace boundaries.\r
100\r
101Arguments:\r
102\r
103 String The string to 'split'\r
104\r
105Returns:\r
106\r
107 EFI_STATUS\r
108\r
109**/\r
110\r
111\r
112STRING_LIST*\r
113NewStringList (\r
114 )\r
115;\r
116/**\r
117\r
118Routine Description:\r
119\r
120 Creates a new STRING_LIST with 0 strings.\r
121\r
122Returns:\r
123\r
124 STRING_LIST* - Null if there is not enough resources to create the object.\r
125\r
126**/\r
127\r
128\r
129EFI_STATUS\r
130AppendCopyOfStringToList (\r
131 IN OUT STRING_LIST **StringList,\r
132 IN CHAR8 *String\r
133 )\r
134;\r
135/**\r
136\r
137Routine Description:\r
138\r
139 Adds String to StringList. A new copy of String is made before it is\r
140 added to StringList.\r
141\r
142Returns:\r
143\r
144 EFI_STATUS\r
145\r
146**/\r
147\r
148\r
149EFI_STATUS\r
150RemoveLastStringFromList (\r
151 IN STRING_LIST *StringList\r
152 )\r
153;\r
154/**\r
155\r
156Routine Description:\r
157\r
158 Removes the last string from StringList and frees the memory associated\r
159 with it.\r
160\r
161Arguments:\r
162\r
163 StringList The string list to remove the string from\r
164\r
165Returns:\r
166\r
167 EFI_STATUS\r
168\r
169**/\r
170\r
171\r
172STRING_LIST*\r
173AllocateStringListStruct (\r
174 IN UINTN StringCount\r
175 )\r
176;\r
177/**\r
178\r
179Routine Description:\r
180\r
181 Allocates a STRING_LIST structure that can store StringCount strings.\r
182\r
183Arguments:\r
184\r
185 StringCount The number of strings that need to be stored\r
186\r
187Returns:\r
188\r
189 EFI_STATUS\r
190\r
191**/\r
192\r
193\r
194VOID\r
195FreeStringList (\r
196 IN STRING_LIST *StringList\r
197 )\r
198;\r
199/**\r
200\r
201Routine Description:\r
202\r
203 Frees all memory associated with StringList.\r
204\r
205Arguments:\r
206\r
207 StringList The string list to free\r
208\r
209Returns:\r
210\r
211 EFI_STATUS\r
212\r
213**/\r
214\r
215\r
216CHAR8*\r
217StringListToString (\r
218 IN STRING_LIST *StringList\r
219 )\r
220;\r
221/**\r
222\r
223Routine Description:\r
224\r
225 Generates a string that represents the STRING_LIST\r
226\r
227Arguments:\r
228\r
229 StringList The string list to convert to a string\r
230\r
231Returns:\r
232\r
233 CHAR8* - The string list represented with a single string. The returned\r
234 string must be freed by the caller.\r
235\r
236**/\r
237\r
238\r
239VOID\r
240PrintStringList (\r
241 IN STRING_LIST *StringList\r
242 )\r
243;\r
244/**\r
245\r
246Routine Description:\r
247\r
248 Prints out the string list\r
249\r
250Arguments:\r
251\r
252 StringList The string list to print\r
253\r
254**/\r
255\r
256\r
257#endif\r