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