]>
Commit | Line | Data |
---|---|---|
97fa0ee9 YL |
1 | /** @file\r |
2 | String routines implementation\r | |
30fdf114 | 3 | \r |
f7496d71 LG |
4 | Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
30fdf114 | 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 | |
25 | typedef 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 | |
38 | CHAR8*\r | |
39 | CloneString (\r | |
40 | IN CHAR8 *String\r | |
41 | )\r | |
42 | ;\r | |
43 | /**\r | |
44 | \r | |
45 | Routine Description:\r | |
46 | \r | |
47 | Allocates a new string and copies 'String' to clone it\r | |
48 | \r | |
49 | Arguments:\r | |
50 | \r | |
51 | String The string to clone\r | |
52 | \r | |
53 | Returns:\r | |
54 | \r | |
55 | CHAR8* - NULL if there are not enough resources\r | |
56 | \r | |
57 | **/\r | |
58 | \r | |
59 | \r | |
60 | EFI_STATUS\r | |
61 | StripInfDscStringInPlace (\r | |
62 | IN CHAR8 *String\r | |
63 | )\r | |
64 | ;\r | |
65 | /**\r | |
66 | \r | |
67 | Routine Description:\r | |
68 | \r | |
69 | Remove all comments, leading and trailing whitespace from the string.\r | |
70 | \r | |
71 | Arguments:\r | |
72 | \r | |
73 | Strin The string to 'strip'\r | |
74 | \r | |
75 | Returns:\r | |
76 | \r | |
77 | EFI_STATUS\r | |
78 | \r | |
79 | **/\r | |
80 | \r | |
81 | \r | |
82 | STRING_LIST*\r | |
83 | SplitStringByWhitespace (\r | |
84 | IN CHAR8 *String\r | |
85 | )\r | |
86 | ;\r | |
87 | /**\r | |
88 | \r | |
89 | Routine Description:\r | |
90 | \r | |
91 | Creates and returns a 'split' STRING_LIST by splitting the string\r | |
92 | on whitespace boundaries.\r | |
93 | \r | |
94 | Arguments:\r | |
95 | \r | |
96 | String The string to 'split'\r | |
97 | \r | |
98 | Returns:\r | |
99 | \r | |
100 | EFI_STATUS\r | |
101 | \r | |
102 | **/\r | |
103 | \r | |
104 | \r | |
105 | STRING_LIST*\r | |
106 | NewStringList (\r | |
107 | )\r | |
108 | ;\r | |
109 | /**\r | |
110 | \r | |
111 | Routine Description:\r | |
112 | \r | |
113 | Creates a new STRING_LIST with 0 strings.\r | |
114 | \r | |
115 | Returns:\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 | |
122 | EFI_STATUS\r | |
123 | AppendCopyOfStringToList (\r | |
124 | IN OUT STRING_LIST **StringList,\r | |
125 | IN CHAR8 *String\r | |
126 | )\r | |
127 | ;\r | |
128 | /**\r | |
129 | \r | |
130 | Routine 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 | |
135 | Returns:\r | |
136 | \r | |
137 | EFI_STATUS\r | |
138 | \r | |
139 | **/\r | |
140 | \r | |
141 | \r | |
142 | EFI_STATUS\r | |
143 | RemoveLastStringFromList (\r | |
144 | IN STRING_LIST *StringList\r | |
145 | )\r | |
146 | ;\r | |
147 | /**\r | |
148 | \r | |
149 | Routine Description:\r | |
150 | \r | |
151 | Removes the last string from StringList and frees the memory associated\r | |
152 | with it.\r | |
153 | \r | |
154 | Arguments:\r | |
155 | \r | |
156 | StringList The string list to remove the string from\r | |
157 | \r | |
158 | Returns:\r | |
159 | \r | |
160 | EFI_STATUS\r | |
161 | \r | |
162 | **/\r | |
163 | \r | |
164 | \r | |
165 | STRING_LIST*\r | |
166 | AllocateStringListStruct (\r | |
167 | IN UINTN StringCount\r | |
168 | )\r | |
169 | ;\r | |
170 | /**\r | |
171 | \r | |
172 | Routine Description:\r | |
173 | \r | |
174 | Allocates a STRING_LIST structure that can store StringCount strings.\r | |
175 | \r | |
176 | Arguments:\r | |
177 | \r | |
178 | StringCount The number of strings that need to be stored\r | |
179 | \r | |
180 | Returns:\r | |
181 | \r | |
182 | EFI_STATUS\r | |
183 | \r | |
184 | **/\r | |
185 | \r | |
186 | \r | |
187 | VOID\r | |
188 | FreeStringList (\r | |
189 | IN STRING_LIST *StringList\r | |
190 | )\r | |
191 | ;\r | |
192 | /**\r | |
193 | \r | |
194 | Routine Description:\r | |
195 | \r | |
196 | Frees all memory associated with StringList.\r | |
197 | \r | |
198 | Arguments:\r | |
199 | \r | |
200 | StringList The string list to free\r | |
201 | \r | |
202 | Returns:\r | |
203 | \r | |
204 | EFI_STATUS\r | |
205 | \r | |
206 | **/\r | |
207 | \r | |
208 | \r | |
209 | CHAR8*\r | |
210 | StringListToString (\r | |
211 | IN STRING_LIST *StringList\r | |
212 | )\r | |
213 | ;\r | |
214 | /**\r | |
215 | \r | |
216 | Routine Description:\r | |
217 | \r | |
218 | Generates a string that represents the STRING_LIST\r | |
219 | \r | |
220 | Arguments:\r | |
221 | \r | |
222 | StringList The string list to convert to a string\r | |
223 | \r | |
224 | Returns:\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 | |
232 | VOID\r | |
233 | PrintStringList (\r | |
234 | IN STRING_LIST *StringList\r | |
235 | )\r | |
236 | ;\r | |
237 | /**\r | |
238 | \r | |
239 | Routine Description:\r | |
240 | \r | |
241 | Prints out the string list\r | |
242 | \r | |
243 | Arguments:\r | |
244 | \r | |
245 | StringList The string list to print\r | |
246 | \r | |
247 | **/\r | |
248 | \r | |
249 | \r | |
250 | #endif\r |