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