]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/CodeTools/Source/String/String.c
More renames for Tool Packages
[mirror_edk2.git] / Tools / CodeTools / Source / String / String.c
CommitLineData
56fe62ce 1/*++\r
d2ec0d9e 2\r
cf171110 3Copyright (c) 2004-2006 Intel Corporation. All rights reserved\r
56fe62ce 4This program and the accompanying materials are licensed and made available\r
5under the terms and conditions of the BSD License which accompanies this\r
6distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
d2ec0d9e 8\r
56fe62ce 9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
d2ec0d9e 11\r
d2ec0d9e 12\r
56fe62ce 13Module Name:\r
14\r
15 String.c\r
16\r
17Abstract:\r
18\r
19 Unicode and ASCII string primatives.\r
20\r
21--*/\r
d2ec0d9e 22\r
23#include <assert.h>\r
ce53a8c3 24\r
25#include <Common/UefiBaseTypes.h>\r
26\r
9776330c 27#include <string.h>\r
28\r
ce53a8c3 29#include "CommonLib.h"\r
d2ec0d9e 30\r
3ce2b1a8 31/**\r
32 Returns the length of a Null-terminated Unicode string.\r
33\r
34 This function returns the number of Unicode characters in the Null-terminated\r
35 Unicode string specified by String.\r
36\r
37 If String is NULL, then ASSERT().\r
38\r
39 @param String Pointer to a Null-terminated Unicode string.\r
40\r
41 @return The length of String.\r
42\r
43**/\r
44UINTN\r
45EFIAPI\r
46StrLen (\r
47 IN CONST CHAR16 *String\r
48 )\r
49{\r
50 UINTN Length;\r
51\r
52 ASSERT (String != NULL);\r
53\r
54 for (Length = 0; *String != L'\0'; String++, Length++) {\r
55 ;\r
56 }\r
57 return Length;\r
58}\r
59\r
60/**\r
61 Returns the length of a Null-terminated ASCII string.\r
62\r
63 This function returns the number of ASCII characters in the Null-terminated\r
64 ASCII string specified by String.\r
65\r
66 If String is NULL, then ASSERT().\r
67\r
68 @param String Pointer to a Null-terminated ASCII string.\r
69\r
70 @return The length of String.\r
71\r
72**/\r
73UINTN\r
74EFIAPI\r
75AsciiStrLen (\r
76 IN CONST CHAR8 *String\r
77 )\r
78{\r
79 UINTN Length;\r
80\r
81 ASSERT (String != NULL);\r
82\r
83 for (Length = 0; *String != '\0'; String++, Length++) {\r
84 ;\r
85 }\r
86 return Length;\r
87}\r
88\r
d2ec0d9e 89/**\r
90 Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
91 string and returns the new Unicode string.\r
92\r
93 This function copies the contents of the Unicode string Source to the Unicode\r
94 string Destination, and returns Destination. If Source and Destination\r
95 overlap, then the results are undefined.\r
96\r
97 If Destination is NULL, then ASSERT().\r
98 If Source is NULL, then ASSERT().\r
99 If Source and Destination overlap, then ASSERT().\r
d2ec0d9e 100\r
101 @param Destination Pointer to a Null-terminated Unicode string.\r
102 @param Source Pointer to a Null-terminated Unicode string.\r
103\r
104 @return Destiantion\r
105\r
106**/\r
107CHAR16 *\r
108EFIAPI\r
109StrCpy (\r
110 OUT CHAR16 *Destination,\r
111 IN CONST CHAR16 *Source\r
112 )\r
113{\r
114 CHAR16 *ReturnValue;\r
115\r
116 //\r
117 // Destination cannot be NULL\r
118 //\r
119 ASSERT (Destination != NULL);\r
120\r
121 //\r
122 // Destination and source cannot overlap\r
123 //\r
124 ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r
125 ASSERT ((UINTN)(Source - Destination) > StrLen (Source));\r
126\r
127 ReturnValue = Destination;\r
128 while (*Source) {\r
129 *(Destination++) = *(Source++);\r
130 }\r
131 *Destination = 0;\r
132 return ReturnValue;\r
133}\r
134\r
135/**\r
136 Copies one Null-terminated Unicode string with a maximum length to another\r
137 Null-terminated Unicode string with a maximum length and returns the new\r
138 Unicode string.\r
139\r
140 This function copies the contents of the Unicode string Source to the Unicode\r
141 string Destination, and returns Destination. At most, Length Unicode\r
142 characters are copied from Source to Destination. If Length is 0, then\r
143 Destination is returned unmodified. If Length is greater that the number of\r
144 Unicode characters in Source, then Destination is padded with Null Unicode\r
145 characters. If Source and Destination overlap, then the results are\r
146 undefined.\r
147\r
148 If Destination is NULL, then ASSERT().\r
149 If Source is NULL, then ASSERT().\r
150 If Source and Destination overlap, then ASSERT().\r
d2ec0d9e 151\r
152 @param Destination Pointer to a Null-terminated Unicode string.\r
153 @param Source Pointer to a Null-terminated Unicode string.\r
154 @param Length Maximum number of Unicode characters to copy.\r
155\r
156 @return Destination\r
157\r
158**/\r
159CHAR16 *\r
160EFIAPI\r
161StrnCpy (\r
162 OUT CHAR16 *Destination,\r
163 IN CONST CHAR16 *Source,\r
164 IN UINTN Length\r
165 )\r
166{\r
167 CHAR16 *ReturnValue;\r
168\r
169 if (Length == 0) {\r
170 return Destination;\r
171 }\r
172\r
173 //\r
174 // Destination cannot be NULL if Length is not zero\r
175 //\r
176 ASSERT (Destination != NULL);\r
177\r
178 //\r
179 // Destination and source cannot overlap\r
180 // Q: Does Source have to be NULL-terminated?\r
181 //\r
182 ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r
183 ASSERT ((UINTN)(Source - Destination) >= Length);\r
184\r
185 ReturnValue = Destination;\r
186\r
187 while ((*Source != L'\0') && (Length > 0)) {\r
188 *(Destination++) = *(Source++);\r
189 Length--;\r
190 }\r
191\r
d2ec0d9e 192 memset (Destination, 0, Length * sizeof (*Destination));\r
193 return ReturnValue;\r
194}\r
195\r
d2ec0d9e 196/**\r
197 Returns the size of a Null-terminated Unicode string in bytes, including the\r
198 Null terminator.\r
199\r
200 This function returns the size, in bytes, of the Null-terminated Unicode\r
201 string specified by String.\r
202\r
203 If String is NULL, then ASSERT().\r
d2ec0d9e 204\r
205 @param String Pointer to a Null-terminated Unicode string.\r
206\r
207 @return The size of String.\r
208\r
209**/\r
210UINTN\r
211EFIAPI\r
212StrSize (\r
213 IN CONST CHAR16 *String\r
214 )\r
215{\r
216 return (StrLen (String) + 1) * sizeof (*String);\r
217}\r
218\r
219/**\r
220 Compares two Null-terminated Unicode strings, and returns the difference\r
221 between the first mismatched Unicode characters.\r
222\r
223 This function compares the Null-terminated Unicode string FirstString to the\r
224 Null-terminated Unicode string SecondString. If FirstString is identical to\r
225 SecondString, then 0 is returned. Otherwise, the value returned is the first\r
226 mismatched Unicode character in SecondString subtracted from the first\r
227 mismatched Unicode character in FirstString.\r
228\r
229 If FirstString is NULL, then ASSERT().\r
230 If SecondString is NULL, then ASSERT().\r
d2ec0d9e 231\r
232 @param FirstString Pointer to a Null-terminated Unicode string.\r
233 @param SecondString Pointer to a Null-terminated Unicode string.\r
234\r
235 @retval 0 FirstString is identical to SecondString.\r
236 @retval !=0 FirstString is not identical to SecondString.\r
237\r
238**/\r
239INTN\r
240EFIAPI\r
241StrCmp (\r
242 IN CONST CHAR16 *FirstString,\r
243 IN CONST CHAR16 *SecondString\r
244 )\r
245{\r
246 //\r
ce53a8c3 247 // ASSERT both strings should never be zero\r
d2ec0d9e 248 //\r
249 ASSERT (StrSize (FirstString) != 0);\r
250 ASSERT (StrSize (SecondString) != 0);\r
251\r
252 while ((*FirstString != L'\0') && (*FirstString == *SecondString)) {\r
253 FirstString++;\r
254 SecondString++;\r
255 }\r
256 return *FirstString - *SecondString;\r
257}\r
258\r
259/**\r
260 Compares two Null-terminated Unicode strings with maximum lengths, and\r
261 returns the difference between the first mismatched Unicode characters.\r
262\r
263 This function compares the Null-terminated Unicode string FirstString to the\r
264 Null-terminated Unicode string SecondString. At most, Length Unicode\r
265 characters will be compared. If Length is 0, then 0 is returned. If\r
266 FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
267 value returned is the first mismatched Unicode character in SecondString\r
268 subtracted from the first mismatched Unicode character in FirstString.\r
269\r
270 If FirstString is NULL, then ASSERT().\r
271 If SecondString is NULL, then ASSERT().\r
d2ec0d9e 272\r
273 @param FirstString Pointer to a Null-terminated Unicode string.\r
274 @param SecondString Pointer to a Null-terminated Unicode string.\r
275 @param Length Maximum number of Unicode characters to compare.\r
276\r
277 @retval 0 FirstString is identical to SecondString.\r
278 @retval !=0 FirstString is not identical to SecondString.\r
279\r
280**/\r
281INTN\r
282EFIAPI\r
283StrnCmp (\r
284 IN CONST CHAR16 *FirstString,\r
285 IN CONST CHAR16 *SecondString,\r
286 IN UINTN Length\r
287 )\r
288{\r
289 if (Length == 0) {\r
290 return 0;\r
291 }\r
292\r
293 //\r
ce53a8c3 294 // ASSERT both strings should never be zero\r
d2ec0d9e 295 //\r
296 ASSERT (StrSize (FirstString) != 0);\r
297 ASSERT (StrSize (SecondString) != 0);\r
298\r
299 while ((*FirstString != L'\0') &&\r
300 (*FirstString == *SecondString) &&\r
301 (Length > 1)) {\r
302 FirstString++;\r
303 SecondString++;\r
304 Length--;\r
305 }\r
306\r
307 return *FirstString - *SecondString;\r
308}\r
309\r
310/**\r
311 Concatenates one Null-terminated Unicode string to another Null-terminated\r
312 Unicode string, and returns the concatenated Unicode string.\r
313\r
314 This function concatenates two Null-terminated Unicode strings. The contents\r
315 of Null-terminated Unicode string Source are concatenated to the end of\r
316 Null-terminated Unicode string Destination. The Null-terminated concatenated\r
317 Unicode String is returned. If Source and Destination overlap, then the\r
318 results are undefined.\r
319\r
320 If Destination is NULL, then ASSERT().\r
321 If Source is NULL, then ASSERT().\r
322 If Source and Destination overlap, then ASSERT().\r
d2ec0d9e 323\r
324 @param Destination Pointer to a Null-terminated Unicode string.\r
325 @param Source Pointer to a Null-terminated Unicode string.\r
326\r
327 @return Destination\r
328\r
329**/\r
330CHAR16 *\r
331EFIAPI\r
332StrCat (\r
333 IN OUT CHAR16 *Destination,\r
334 IN CONST CHAR16 *Source\r
335 )\r
336{\r
337 StrCpy (Destination + StrLen (Destination), Source);\r
338\r
339 //\r
340 // Size of the resulting string should never be zero.\r
d2ec0d9e 341 //\r
342 ASSERT (StrSize (Destination) != 0);\r
343 return Destination;\r
344}\r
345\r
346/**\r
347 Concatenates one Null-terminated Unicode string with a maximum length to the\r
348 end of another Null-terminated Unicode string, and returns the concatenated\r
349 Unicode string.\r
350\r
351 This function concatenates two Null-terminated Unicode strings. The contents\r
352 of Null-terminated Unicode string Source are concatenated to the end of\r
353 Null-terminated Unicode string Destination, and Destination is returned. At\r
354 most, Length Unicode characters are concatenated from Source to the end of\r
355 Destination, and Destination is always Null-terminated. If Length is 0, then\r
356 Destination is returned unmodified. If Source and Destination overlap, then\r
357 the results are undefined.\r
358\r
359 If Destination is NULL, then ASSERT().\r
360 If Source is NULL, then ASSERT().\r
361 If Source and Destination overlap, then ASSERT().\r
d2ec0d9e 362\r
363 @param Destination Pointer to a Null-terminated Unicode string.\r
364 @param Source Pointer to a Null-terminated Unicode string.\r
365 @param Length Maximum number of Unicode characters to concatenate from\r
366 Source.\r
367\r
368 @return Destination\r
369\r
370**/\r
371CHAR16 *\r
372EFIAPI\r
373StrnCat (\r
374 IN OUT CHAR16 *Destination,\r
375 IN CONST CHAR16 *Source,\r
376 IN UINTN Length\r
377 )\r
378{\r
379 StrnCpy (Destination + StrLen (Destination), Source, Length);\r
380\r
381 //\r
382 // Size of the resulting string should never be zero.\r
d2ec0d9e 383 //\r
384 ASSERT (StrSize (Destination) != 0);\r
385 return Destination;\r
386}\r
387\r
388/**\r
389 Copies one Null-terminated ASCII string to another Null-terminated ASCII\r
390 string and returns the new ASCII string.\r
391\r
392 This function copies the contents of the ASCII string Source to the ASCII\r
393 string Destination, and returns Destination. If Source and Destination\r
394 overlap, then the results are undefined.\r
395\r
396 If Destination is NULL, then ASSERT().\r
397 If Source is NULL, then ASSERT().\r
398 If Source and Destination overlap, then ASSERT().\r
d2ec0d9e 399\r
400 @param Destination Pointer to a Null-terminated ASCII string.\r
401 @param Source Pointer to a Null-terminated ASCII string.\r
402\r
403 @return Destination\r
404\r
405**/\r
406CHAR8 *\r
407EFIAPI\r
408AsciiStrCpy (\r
409 OUT CHAR8 *Destination,\r
410 IN CONST CHAR8 *Source\r
411 )\r
412{\r
413 CHAR8 *ReturnValue;\r
414\r
415 //\r
416 // Destination cannot be NULL\r
417 //\r
418 ASSERT (Destination != NULL);\r
419\r
420 //\r
421 // Destination and source cannot overlap\r
422 //\r
423 ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r
424 ASSERT ((UINTN)(Source - Destination) > AsciiStrLen (Source));\r
425\r
426 ReturnValue = Destination;\r
427 while (*Source) {\r
428 *(Destination++) = *(Source++);\r
429 }\r
430 *Destination = 0;\r
431 return ReturnValue;\r
432}\r
433\r
434/**\r
435 Copies one Null-terminated ASCII string with a maximum length to another\r
436 Null-terminated ASCII string with a maximum length and returns the new ASCII\r
437 string.\r
438\r
439 This function copies the contents of the ASCII string Source to the ASCII\r
440 string Destination, and returns Destination. At most, Length ASCII characters\r
441 are copied from Source to Destination. If Length is 0, then Destination is\r
442 returned unmodified. If Length is greater that the number of ASCII characters\r
443 in Source, then Destination is padded with Null ASCII characters. If Source\r
444 and Destination overlap, then the results are undefined.\r
445\r
446 If Destination is NULL, then ASSERT().\r
447 If Source is NULL, then ASSERT().\r
448 If Source and Destination overlap, then ASSERT().\r
d2ec0d9e 449\r
450 @param Destination Pointer to a Null-terminated ASCII string.\r
451 @param Source Pointer to a Null-terminated ASCII string.\r
452 @param Length Maximum number of ASCII characters to copy.\r
453\r
454 @return Destination\r
455\r
456**/\r
457CHAR8 *\r
458EFIAPI\r
459AsciiStrnCpy (\r
460 OUT CHAR8 *Destination,\r
461 IN CONST CHAR8 *Source,\r
462 IN UINTN Length\r
463 )\r
464{\r
465 CHAR8 *ReturnValue;\r
466\r
467 if (Length == 0) {\r
468 return Destination;\r
469 }\r
470\r
471 //\r
472 // Destination cannot be NULL\r
473 //\r
474 ASSERT (Destination != NULL);\r
475\r
476 //\r
477 // Destination and source cannot overlap\r
478 //\r
479 ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r
480 ASSERT ((UINTN)(Source - Destination) >= Length);\r
481\r
482 ReturnValue = Destination;\r
483\r
484 while (*Source && Length > 0) {\r
485 *(Destination++) = *(Source++);\r
486 Length--;\r
487 }\r
488\r
489 // ZeroMem (Destination, Length * sizeof (*Destination));\r
490 memset (Destination, 0, Length * sizeof (*Destination));\r
491 return ReturnValue;\r
492}\r
493\r
d2ec0d9e 494/**\r
495 Returns the size of a Null-terminated ASCII string in bytes, including the\r
496 Null terminator.\r
497\r
498 This function returns the size, in bytes, of the Null-terminated ASCII string\r
499 specified by String.\r
500\r
501 If String is NULL, then ASSERT().\r
d2ec0d9e 502\r
503 @param String Pointer to a Null-terminated ASCII string.\r
504\r
505 @return The size of String.\r
506\r
507**/\r
508UINTN\r
509EFIAPI\r
510AsciiStrSize (\r
511 IN CONST CHAR8 *String\r
512 )\r
513{\r
514 return (AsciiStrLen (String) + 1) * sizeof (*String);\r
515}\r
516\r
517/**\r
518 Compares two Null-terminated ASCII strings, and returns the difference\r
519 between the first mismatched ASCII characters.\r
520\r
521 This function compares the Null-terminated ASCII string FirstString to the\r
522 Null-terminated ASCII string SecondString. If FirstString is identical to\r
523 SecondString, then 0 is returned. Otherwise, the value returned is the first\r
524 mismatched ASCII character in SecondString subtracted from the first\r
525 mismatched ASCII character in FirstString.\r
526\r
527 If FirstString is NULL, then ASSERT().\r
528 If SecondString is NULL, then ASSERT().\r
d2ec0d9e 529\r
530 @param FirstString Pointer to a Null-terminated ASCII string.\r
531 @param SecondString Pointer to a Null-terminated ASCII string.\r
532\r
533 @retval 0 FirstString is identical to SecondString.\r
534 @retval !=0 FirstString is not identical to SecondString.\r
535\r
536**/\r
537INTN\r
538EFIAPI\r
539AsciiStrCmp (\r
540 IN CONST CHAR8 *FirstString,\r
541 IN CONST CHAR8 *SecondString\r
542 )\r
543{\r
544 //\r
ce53a8c3 545 // ASSERT both strings should never be zero\r
d2ec0d9e 546 //\r
547 ASSERT (AsciiStrSize (FirstString));\r
548 ASSERT (AsciiStrSize (SecondString));\r
549\r
550 while ((*FirstString != '\0') && (*FirstString == *SecondString)) {\r
551 FirstString++;\r
552 SecondString++;\r
553 }\r
554\r
555 return *FirstString - *SecondString;\r
556}\r
557\r
558STATIC\r
559CHAR8\r
560EFIAPI\r
561AsciiToUpper (\r
562 IN CHAR8 Chr\r
563 )\r
564{\r
565 return (Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr;\r
566}\r
567\r
568/**\r
569 Performs a case insensitive comparison of two Null-terminated ASCII strings,\r
570 and returns the difference between the first mismatched ASCII characters.\r
571\r
572 This function performs a case insensitive comparison of the Null-terminated\r
573 ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r
574 FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
575 value returned is the first mismatched lower case ASCII character in\r
576 SecondString subtracted from the first mismatched lower case ASCII character\r
577 in FirstString.\r
578\r
579 If FirstString is NULL, then ASSERT().\r
580 If SecondString is NULL, then ASSERT().\r
d2ec0d9e 581\r
582 @param FirstString Pointer to a Null-terminated ASCII string.\r
583 @param SecondString Pointer to a Null-terminated ASCII string.\r
584\r
585 @retval 0 FirstString is identical to SecondString using case insensitive\r
586 comparisons.\r
587 @retval !=0 FirstString is not identical to SecondString using case\r
588 insensitive comparisons.\r
589\r
590**/\r
591INTN\r
592EFIAPI\r
593AsciiStriCmp (\r
594 IN CONST CHAR8 *FirstString,\r
595 IN CONST CHAR8 *SecondString\r
596 )\r
597{\r
598 //\r
ce53a8c3 599 // ASSERT both strings should never be zero\r
d2ec0d9e 600 //\r
601 ASSERT (AsciiStrSize (FirstString));\r
602 ASSERT (AsciiStrSize (SecondString));\r
603\r
604 while ((*FirstString != '\0') &&\r
605 (AsciiToUpper (*FirstString) == AsciiToUpper (*SecondString))) {\r
606 FirstString++;\r
607 SecondString++;\r
608 }\r
609\r
610 return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString);\r
611}\r
612\r
613/**\r
614 Compares two Null-terminated ASCII strings with maximum lengths, and returns\r
615 the difference between the first mismatched ASCII characters.\r
616\r
617 This function compares the Null-terminated ASCII string FirstString to the\r
618 Null-terminated ASCII string SecondString. At most, Length ASCII characters\r
619 will be compared. If Length is 0, then 0 is returned. If FirstString is\r
620 identical to SecondString, then 0 is returned. Otherwise, the value returned\r
621 is the first mismatched ASCII character in SecondString subtracted from the\r
622 first mismatched ASCII character in FirstString.\r
623\r
624 If FirstString is NULL, then ASSERT().\r
625 If SecondString is NULL, then ASSERT().\r
d2ec0d9e 626\r
627 @param FirstString Pointer to a Null-terminated ASCII string.\r
628 @param SecondString Pointer to a Null-terminated ASCII string.\r
629\r
630 @retval 0 FirstString is identical to SecondString.\r
631 @retval !=0 FirstString is not identical to SecondString.\r
632\r
633**/\r
634INTN\r
635EFIAPI\r
636AsciiStrnCmp (\r
637 IN CONST CHAR8 *FirstString,\r
638 IN CONST CHAR8 *SecondString,\r
639 IN UINTN Length\r
640 )\r
641{\r
642 //\r
ce53a8c3 643 // ASSERT both strings should never be zero\r
d2ec0d9e 644 //\r
645 ASSERT (AsciiStrSize (FirstString));\r
646 ASSERT (AsciiStrSize (SecondString));\r
647\r
648 while ((*FirstString != '\0') &&\r
649 (*FirstString == *SecondString) &&\r
650 (Length > 1)) {\r
651 FirstString++;\r
652 SecondString++;\r
653 Length--;\r
654 }\r
655 return *FirstString - *SecondString;\r
656}\r
657\r
658/**\r
659 Concatenates one Null-terminated ASCII string to another Null-terminated\r
660 ASCII string, and returns the concatenated ASCII string.\r
661\r
662 This function concatenates two Null-terminated ASCII strings. The contents of\r
663 Null-terminated ASCII string Source are concatenated to the end of Null-\r
664 terminated ASCII string Destination. The Null-terminated concatenated ASCII\r
665 String is returned.\r
666\r
667 If Destination is NULL, then ASSERT().\r
668 If Source is NULL, then ASSERT().\r
d2ec0d9e 669\r
670 @param Destination Pointer to a Null-terminated ASCII string.\r
671 @param Source Pointer to a Null-terminated ASCII string.\r
672\r
673 @return Destination\r
674\r
675**/\r
676CHAR8 *\r
677EFIAPI\r
678AsciiStrCat (\r
679 IN OUT CHAR8 *Destination,\r
680 IN CONST CHAR8 *Source\r
681 )\r
682{\r
683 AsciiStrCpy (Destination + AsciiStrLen (Destination), Source);\r
684\r
685 //\r
686 // Size of the resulting string should never be zero.\r
d2ec0d9e 687 //\r
688 ASSERT (AsciiStrSize (Destination) != 0);\r
689 return Destination;\r
690}\r
691\r
692/**\r
693 Concatenates one Null-terminated ASCII string with a maximum length to the\r
694 end of another Null-terminated ASCII string, and returns the concatenated\r
695 ASCII string.\r
696\r
697 This function concatenates two Null-terminated ASCII strings. The contents\r
698 of Null-terminated ASCII string Source are concatenated to the end of Null-\r
699 terminated ASCII string Destination, and Destination is returned. At most,\r
700 Length ASCII characters are concatenated from Source to the end of\r
701 Destination, and Destination is always Null-terminated. If Length is 0, then\r
702 Destination is returned unmodified. If Source and Destination overlap, then\r
703 the results are undefined.\r
704\r
705 If Destination is NULL, then ASSERT().\r
706 If Source is NULL, then ASSERT().\r
707 If Source and Destination overlap, then ASSERT().\r
d2ec0d9e 708\r
709 @param Destination Pointer to a Null-terminated ASCII string.\r
710 @param Source Pointer to a Null-terminated ASCII string.\r
711 @param Length Maximum number of ASCII characters to concatenate from\r
712 Source.\r
713\r
714 @return Destination\r
715\r
716**/\r
717CHAR8 *\r
718EFIAPI\r
719AsciiStrnCat (\r
720 IN OUT CHAR8 *Destination,\r
721 IN CONST CHAR8 *Source,\r
722 IN UINTN Length\r
723 )\r
724{\r
725 AsciiStrnCpy (Destination + AsciiStrLen (Destination), Source, Length);\r
726\r
727 //\r
728 // Size of the resulting string should never be zero.\r
d2ec0d9e 729 //\r
730 ASSERT (AsciiStrSize (Destination) != 0);\r
731 return Destination;\r
732}\r