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