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