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