|
|
@@ -2,7 +2,7 @@
|
|
2
|
2
|
Provides string functions, linked list functions, math functions, synchronization
|
|
3
|
3
|
functions, file path functions, and CPU architecture-specific functions.
|
|
4
|
4
|
|
|
5
|
|
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
|
|
5
|
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
|
6
|
6
|
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
|
7
|
7
|
This program and the accompanying materials
|
|
8
|
8
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
@@ -189,6 +189,8 @@ typedef struct {
|
|
189
|
189
|
/**
|
|
190
|
190
|
Returns the length of a Null-terminated Unicode string.
|
|
191
|
191
|
|
|
|
192
|
+ This function is similar as strlen_s defined in C11.
|
|
|
193
|
+
|
|
192
|
194
|
If String is not aligned on a 16-bit boundary, then ASSERT().
|
|
193
|
195
|
|
|
194
|
196
|
@param String A pointer to a Null-terminated Unicode string.
|
|
|
@@ -211,10 +213,14 @@ StrnLenS (
|
|
211
|
213
|
Copies the string pointed to by Source (including the terminating null char)
|
|
212
|
214
|
to the array pointed to by Destination.
|
|
213
|
215
|
|
|
|
216
|
+ This function is similar as strcpy_s defined in C11.
|
|
|
217
|
+
|
|
214
|
218
|
If Destination is not aligned on a 16-bit boundary, then ASSERT().
|
|
215
|
219
|
If Source is not aligned on a 16-bit boundary, then ASSERT().
|
|
216
|
220
|
If an error would be returned, then the function will also ASSERT().
|
|
217
|
221
|
|
|
|
222
|
+ If an error is returned, then the Destination is unmodified.
|
|
|
223
|
+
|
|
218
|
224
|
@param Destination A pointer to a Null-terminated Unicode string.
|
|
219
|
225
|
@param DestMax The maximum number of Destination Unicode
|
|
220
|
226
|
char, including terminating null char.
|
|
|
@@ -243,10 +249,14 @@ StrCpyS (
|
|
243
|
249
|
Source to the array pointed to by Destination. If no null char is copied from
|
|
244
|
250
|
Source, then Destination[Length] is always set to null.
|
|
245
|
251
|
|
|
|
252
|
+ This function is similar as strncpy_s defined in C11.
|
|
|
253
|
+
|
|
246
|
254
|
If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
|
|
247
|
255
|
If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
|
|
248
|
256
|
If an error would be returned, then the function will also ASSERT().
|
|
249
|
257
|
|
|
|
258
|
+ If an error is returned, then the Destination is unmodified.
|
|
|
259
|
+
|
|
250
|
260
|
@param Destination A pointer to a Null-terminated Unicode string.
|
|
251
|
261
|
@param DestMax The maximum number of Destination Unicode
|
|
252
|
262
|
char, including terminating null char.
|
|
|
@@ -277,10 +287,14 @@ StrnCpyS (
|
|
277
|
287
|
Appends a copy of the string pointed to by Source (including the terminating
|
|
278
|
288
|
null char) to the end of the string pointed to by Destination.
|
|
279
|
289
|
|
|
|
290
|
+ This function is similar as strcat_s defined in C11.
|
|
|
291
|
+
|
|
280
|
292
|
If Destination is not aligned on a 16-bit boundary, then ASSERT().
|
|
281
|
293
|
If Source is not aligned on a 16-bit boundary, then ASSERT().
|
|
282
|
294
|
If an error would be returned, then the function will also ASSERT().
|
|
283
|
295
|
|
|
|
296
|
+ If an error is returned, then the Destination is unmodified.
|
|
|
297
|
+
|
|
284
|
298
|
@param Destination A pointer to a Null-terminated Unicode string.
|
|
285
|
299
|
@param DestMax The maximum number of Destination Unicode
|
|
286
|
300
|
char, including terminating null char.
|
|
|
@@ -313,10 +327,14 @@ StrCatS (
|
|
313
|
327
|
copied from Source, then Destination[StrLen(Destination) + Length] is always
|
|
314
|
328
|
set to null.
|
|
315
|
329
|
|
|
|
330
|
+ This function is similar as strncat_s defined in C11.
|
|
|
331
|
+
|
|
316
|
332
|
If Destination is not aligned on a 16-bit boundary, then ASSERT().
|
|
317
|
333
|
If Source is not aligned on a 16-bit boundary, then ASSERT().
|
|
318
|
334
|
If an error would be returned, then the function will also ASSERT().
|
|
319
|
335
|
|
|
|
336
|
+ If an error is returned, then the Destination is unmodified.
|
|
|
337
|
+
|
|
320
|
338
|
@param Destination A pointer to a Null-terminated Unicode string.
|
|
321
|
339
|
@param DestMax The maximum number of Destination Unicode
|
|
322
|
340
|
char, including terminating null char.
|
|
|
@@ -348,6 +366,8 @@ StrnCatS (
|
|
348
|
366
|
/**
|
|
349
|
367
|
Returns the length of a Null-terminated Ascii string.
|
|
350
|
368
|
|
|
|
369
|
+ This function is similar as strlen_s defined in C11.
|
|
|
370
|
+
|
|
351
|
371
|
@param String A pointer to a Null-terminated Ascii string.
|
|
352
|
372
|
@param MaxSize The maximum number of Destination Ascii
|
|
353
|
373
|
char, including terminating null char.
|
|
|
@@ -368,8 +388,12 @@ AsciiStrnLenS (
|
|
368
|
388
|
Copies the string pointed to by Source (including the terminating null char)
|
|
369
|
389
|
to the array pointed to by Destination.
|
|
370
|
390
|
|
|
|
391
|
+ This function is similar as strcpy_s defined in C11.
|
|
|
392
|
+
|
|
371
|
393
|
If an error would be returned, then the function will also ASSERT().
|
|
372
|
394
|
|
|
|
395
|
+ If an error is returned, then the Destination is unmodified.
|
|
|
396
|
+
|
|
373
|
397
|
@param Destination A pointer to a Null-terminated Ascii string.
|
|
374
|
398
|
@param DestMax The maximum number of Destination Ascii
|
|
375
|
399
|
char, including terminating null char.
|
|
|
@@ -398,8 +422,12 @@ AsciiStrCpyS (
|
|
398
|
422
|
Source to the array pointed to by Destination. If no null char is copied from
|
|
399
|
423
|
Source, then Destination[Length] is always set to null.
|
|
400
|
424
|
|
|
|
425
|
+ This function is similar as strncpy_s defined in C11.
|
|
|
426
|
+
|
|
401
|
427
|
If an error would be returned, then the function will also ASSERT().
|
|
402
|
428
|
|
|
|
429
|
+ If an error is returned, then the Destination is unmodified.
|
|
|
430
|
+
|
|
403
|
431
|
@param Destination A pointer to a Null-terminated Ascii string.
|
|
404
|
432
|
@param DestMax The maximum number of Destination Ascii
|
|
405
|
433
|
char, including terminating null char.
|
|
|
@@ -430,8 +458,12 @@ AsciiStrnCpyS (
|
|
430
|
458
|
Appends a copy of the string pointed to by Source (including the terminating
|
|
431
|
459
|
null char) to the end of the string pointed to by Destination.
|
|
432
|
460
|
|
|
|
461
|
+ This function is similar as strcat_s defined in C11.
|
|
|
462
|
+
|
|
433
|
463
|
If an error would be returned, then the function will also ASSERT().
|
|
434
|
464
|
|
|
|
465
|
+ If an error is returned, then the Destination is unmodified.
|
|
|
466
|
+
|
|
435
|
467
|
@param Destination A pointer to a Null-terminated Ascii string.
|
|
436
|
468
|
@param DestMax The maximum number of Destination Ascii
|
|
437
|
469
|
char, including terminating null char.
|
|
|
@@ -464,8 +496,12 @@ AsciiStrCatS (
|
|
464
|
496
|
copied from Source, then Destination[StrLen(Destination) + Length] is always
|
|
465
|
497
|
set to null.
|
|
466
|
498
|
|
|
|
499
|
+ This function is similar as strncat_s defined in C11.
|
|
|
500
|
+
|
|
467
|
501
|
If an error would be returned, then the function will also ASSERT().
|
|
468
|
502
|
|
|
|
503
|
+ If an error is returned, then the Destination is unmodified.
|
|
|
504
|
+
|
|
469
|
505
|
@param Destination A pointer to a Null-terminated Ascii string.
|
|
470
|
506
|
@param DestMax The maximum number of Destination Ascii
|
|
471
|
507
|
char, including terminating null char.
|
|
|
@@ -986,7 +1022,11 @@ StrHexToUint64 (
|
|
986
|
1022
|
IN CONST CHAR16 *String
|
|
987
|
1023
|
);
|
|
988
|
1024
|
|
|
|
1025
|
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
|
|
|
1026
|
+
|
|
989
|
1027
|
/**
|
|
|
1028
|
+ [ATTENTION] This function is deprecated for security reason.
|
|
|
1029
|
+
|
|
990
|
1030
|
Convert a Null-terminated Unicode string to a Null-terminated
|
|
991
|
1031
|
ASCII string and returns the ASCII string.
|
|
992
|
1032
|
|
|
|
@@ -1026,6 +1066,56 @@ UnicodeStrToAsciiStr (
|
|
1026
|
1066
|
OUT CHAR8 *Destination
|
|
1027
|
1067
|
);
|
|
1028
|
1068
|
|
|
|
1069
|
+#endif
|
|
|
1070
|
+
|
|
|
1071
|
+/**
|
|
|
1072
|
+ Convert a Null-terminated Unicode string to a Null-terminated
|
|
|
1073
|
+ ASCII string.
|
|
|
1074
|
+
|
|
|
1075
|
+ This function is similar to AsciiStrCpyS.
|
|
|
1076
|
+
|
|
|
1077
|
+ This function converts the content of the Unicode string Source
|
|
|
1078
|
+ to the ASCII string Destination by copying the lower 8 bits of
|
|
|
1079
|
+ each Unicode character. The function terminates the ASCII string
|
|
|
1080
|
+ Destination by appending a Null-terminator character at the end.
|
|
|
1081
|
+
|
|
|
1082
|
+ The caller is responsible to make sure Destination points to a buffer with size
|
|
|
1083
|
+ equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
|
|
|
1084
|
+
|
|
|
1085
|
+ If any Unicode characters in Source contain non-zero value in
|
|
|
1086
|
+ the upper 8 bits, then ASSERT().
|
|
|
1087
|
+
|
|
|
1088
|
+ If Source is not aligned on a 16-bit boundary, then ASSERT().
|
|
|
1089
|
+ If an error would be returned, then the function will also ASSERT().
|
|
|
1090
|
+
|
|
|
1091
|
+ If an error is returned, then the Destination is unmodified.
|
|
|
1092
|
+
|
|
|
1093
|
+ @param Source The pointer to a Null-terminated Unicode string.
|
|
|
1094
|
+ @param Destination The pointer to a Null-terminated ASCII string.
|
|
|
1095
|
+ @param DestMax The maximum number of Destination Ascii
|
|
|
1096
|
+ char, including terminating null char.
|
|
|
1097
|
+
|
|
|
1098
|
+ @retval RETURN_SUCCESS String is converted.
|
|
|
1099
|
+ @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
|
|
|
1100
|
+ @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
|
|
1101
|
+ If Source is NULL.
|
|
|
1102
|
+ If PcdMaximumAsciiStringLength is not zero,
|
|
|
1103
|
+ and DestMax is greater than
|
|
|
1104
|
+ PcdMaximumAsciiStringLength.
|
|
|
1105
|
+ If PcdMaximumUnicodeStringLength is not zero,
|
|
|
1106
|
+ and DestMax is greater than
|
|
|
1107
|
+ PcdMaximumUnicodeStringLength.
|
|
|
1108
|
+ If DestMax is 0.
|
|
|
1109
|
+ @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
|
|
1110
|
+
|
|
|
1111
|
+**/
|
|
|
1112
|
+RETURN_STATUS
|
|
|
1113
|
+EFIAPI
|
|
|
1114
|
+UnicodeStrToAsciiStrS (
|
|
|
1115
|
+ IN CONST CHAR16 *Source,
|
|
|
1116
|
+ OUT CHAR8 *Destination,
|
|
|
1117
|
+ IN UINTN DestMax
|
|
|
1118
|
+ );
|
|
1029
|
1119
|
|
|
1030
|
1120
|
#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
|
|
1031
|
1121
|
|
|
|
@@ -1529,8 +1619,11 @@ AsciiStrHexToUint64 (
|
|
1529
|
1619
|
IN CONST CHAR8 *String
|
|
1530
|
1620
|
);
|
|
1531
|
1621
|
|
|
|
1622
|
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
|
|
1532
|
1623
|
|
|
1533
|
1624
|
/**
|
|
|
1625
|
+ [ATTENTION] This function is deprecated for security reason.
|
|
|
1626
|
+
|
|
1534
|
1627
|
Convert one Null-terminated ASCII string to a Null-terminated
|
|
1535
|
1628
|
Unicode string and returns the Unicode string.
|
|
1536
|
1629
|
|
|
|
@@ -1564,6 +1657,52 @@ AsciiStrToUnicodeStr (
|
|
1564
|
1657
|
OUT CHAR16 *Destination
|
|
1565
|
1658
|
);
|
|
1566
|
1659
|
|
|
|
1660
|
+#endif
|
|
|
1661
|
+
|
|
|
1662
|
+/**
|
|
|
1663
|
+ Convert one Null-terminated ASCII string to a Null-terminated
|
|
|
1664
|
+ Unicode string.
|
|
|
1665
|
+
|
|
|
1666
|
+ This function is similar to StrCpyS.
|
|
|
1667
|
+
|
|
|
1668
|
+ This function converts the contents of the ASCII string Source to the Unicode
|
|
|
1669
|
+ string Destination. The function terminates the Unicode string Destination by
|
|
|
1670
|
+ appending a Null-terminator character at the end.
|
|
|
1671
|
+
|
|
|
1672
|
+ The caller is responsible to make sure Destination points to a buffer with size
|
|
|
1673
|
+ equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
|
|
|
1674
|
+
|
|
|
1675
|
+ If Destination is not aligned on a 16-bit boundary, then ASSERT().
|
|
|
1676
|
+ If an error would be returned, then the function will also ASSERT().
|
|
|
1677
|
+
|
|
|
1678
|
+ If an error is returned, then the Destination is unmodified.
|
|
|
1679
|
+
|
|
|
1680
|
+ @param Source The pointer to a Null-terminated ASCII string.
|
|
|
1681
|
+ @param Destination The pointer to a Null-terminated Unicode string.
|
|
|
1682
|
+ @param DestMax The maximum number of Destination Unicode
|
|
|
1683
|
+ char, including terminating null char.
|
|
|
1684
|
+
|
|
|
1685
|
+ @retval RETURN_SUCCESS String is converted.
|
|
|
1686
|
+ @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
|
|
|
1687
|
+ @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
|
|
1688
|
+ If Source is NULL.
|
|
|
1689
|
+ If PcdMaximumUnicodeStringLength is not zero,
|
|
|
1690
|
+ and DestMax is greater than
|
|
|
1691
|
+ PcdMaximumUnicodeStringLength.
|
|
|
1692
|
+ If PcdMaximumAsciiStringLength is not zero,
|
|
|
1693
|
+ and DestMax is greater than
|
|
|
1694
|
+ PcdMaximumAsciiStringLength.
|
|
|
1695
|
+ If DestMax is 0.
|
|
|
1696
|
+ @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
|
|
1697
|
+
|
|
|
1698
|
+**/
|
|
|
1699
|
+RETURN_STATUS
|
|
|
1700
|
+EFIAPI
|
|
|
1701
|
+AsciiStrToUnicodeStrS (
|
|
|
1702
|
+ IN CONST CHAR8 *Source,
|
|
|
1703
|
+ OUT CHAR16 *Destination,
|
|
|
1704
|
+ IN UINTN DestMax
|
|
|
1705
|
+ );
|
|
1567
|
1706
|
|
|
1568
|
1707
|
/**
|
|
1569
|
1708
|
Converts an 8-bit value to an 8-bit BCD value.
|
|
|
@@ -1635,7 +1774,7 @@ PathRemoveLastItem(
|
|
1635
|
1774
|
|
|
1636
|
1775
|
@param[in] Path The pointer to the string containing the path.
|
|
1637
|
1776
|
|
|
1638
|
|
- @return Returns Path, otherwise returns NULL to indicate that an error has occured.
|
|
|
1777
|
+ @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
|
|
1639
|
1778
|
**/
|
|
1640
|
1779
|
CHAR16*
|
|
1641
|
1780
|
EFIAPI
|