aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe/efi/Library/BaseLib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/ipxe/efi/Library/BaseLib.h')
-rw-r--r--src/include/ipxe/efi/Library/BaseLib.h143
1 files changed, 141 insertions, 2 deletions
diff --git a/src/include/ipxe/efi/Library/BaseLib.h b/src/include/ipxe/efi/Library/BaseLib.h
index a45a20d..a254ed2 100644
--- a/src/include/ipxe/efi/Library/BaseLib.h
+++ b/src/include/ipxe/efi/Library/BaseLib.h
@@ -2,7 +2,7 @@
Provides string functions, linked list functions, math functions, synchronization
functions, file path functions, and CPU architecture-specific functions.
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -189,6 +189,8 @@ typedef struct {
/**
Returns the length of a Null-terminated Unicode string.
+ This function is similar as strlen_s defined in C11.
+
If String is not aligned on a 16-bit boundary, then ASSERT().
@param String A pointer to a Null-terminated Unicode string.
@@ -211,10 +213,14 @@ StrnLenS (
Copies the string pointed to by Source (including the terminating null char)
to the array pointed to by Destination.
+ This function is similar as strcpy_s defined in C11.
+
If Destination is not aligned on a 16-bit boundary, then ASSERT().
If Source is not aligned on a 16-bit boundary, then ASSERT().
If an error would be returned, then the function will also ASSERT().
+ If an error is returned, then the Destination is unmodified.
+
@param Destination A pointer to a Null-terminated Unicode string.
@param DestMax The maximum number of Destination Unicode
char, including terminating null char.
@@ -243,10 +249,14 @@ StrCpyS (
Source to the array pointed to by Destination. If no null char is copied from
Source, then Destination[Length] is always set to null.
+ This function is similar as strncpy_s defined in C11.
+
If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
If an error would be returned, then the function will also ASSERT().
+ If an error is returned, then the Destination is unmodified.
+
@param Destination A pointer to a Null-terminated Unicode string.
@param DestMax The maximum number of Destination Unicode
char, including terminating null char.
@@ -277,10 +287,14 @@ StrnCpyS (
Appends a copy of the string pointed to by Source (including the terminating
null char) to the end of the string pointed to by Destination.
+ This function is similar as strcat_s defined in C11.
+
If Destination is not aligned on a 16-bit boundary, then ASSERT().
If Source is not aligned on a 16-bit boundary, then ASSERT().
If an error would be returned, then the function will also ASSERT().
+ If an error is returned, then the Destination is unmodified.
+
@param Destination A pointer to a Null-terminated Unicode string.
@param DestMax The maximum number of Destination Unicode
char, including terminating null char.
@@ -313,10 +327,14 @@ StrCatS (
copied from Source, then Destination[StrLen(Destination) + Length] is always
set to null.
+ This function is similar as strncat_s defined in C11.
+
If Destination is not aligned on a 16-bit boundary, then ASSERT().
If Source is not aligned on a 16-bit boundary, then ASSERT().
If an error would be returned, then the function will also ASSERT().
+ If an error is returned, then the Destination is unmodified.
+
@param Destination A pointer to a Null-terminated Unicode string.
@param DestMax The maximum number of Destination Unicode
char, including terminating null char.
@@ -348,6 +366,8 @@ StrnCatS (
/**
Returns the length of a Null-terminated Ascii string.
+ This function is similar as strlen_s defined in C11.
+
@param String A pointer to a Null-terminated Ascii string.
@param MaxSize The maximum number of Destination Ascii
char, including terminating null char.
@@ -368,8 +388,12 @@ AsciiStrnLenS (
Copies the string pointed to by Source (including the terminating null char)
to the array pointed to by Destination.
+ This function is similar as strcpy_s defined in C11.
+
If an error would be returned, then the function will also ASSERT().
+ If an error is returned, then the Destination is unmodified.
+
@param Destination A pointer to a Null-terminated Ascii string.
@param DestMax The maximum number of Destination Ascii
char, including terminating null char.
@@ -398,8 +422,12 @@ AsciiStrCpyS (
Source to the array pointed to by Destination. If no null char is copied from
Source, then Destination[Length] is always set to null.
+ This function is similar as strncpy_s defined in C11.
+
If an error would be returned, then the function will also ASSERT().
+ If an error is returned, then the Destination is unmodified.
+
@param Destination A pointer to a Null-terminated Ascii string.
@param DestMax The maximum number of Destination Ascii
char, including terminating null char.
@@ -430,8 +458,12 @@ AsciiStrnCpyS (
Appends a copy of the string pointed to by Source (including the terminating
null char) to the end of the string pointed to by Destination.
+ This function is similar as strcat_s defined in C11.
+
If an error would be returned, then the function will also ASSERT().
+ If an error is returned, then the Destination is unmodified.
+
@param Destination A pointer to a Null-terminated Ascii string.
@param DestMax The maximum number of Destination Ascii
char, including terminating null char.
@@ -464,8 +496,12 @@ AsciiStrCatS (
copied from Source, then Destination[StrLen(Destination) + Length] is always
set to null.
+ This function is similar as strncat_s defined in C11.
+
If an error would be returned, then the function will also ASSERT().
+ If an error is returned, then the Destination is unmodified.
+
@param Destination A pointer to a Null-terminated Ascii string.
@param DestMax The maximum number of Destination Ascii
char, including terminating null char.
@@ -986,7 +1022,11 @@ StrHexToUint64 (
IN CONST CHAR16 *String
);
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
+
/**
+ [ATTENTION] This function is deprecated for security reason.
+
Convert a Null-terminated Unicode string to a Null-terminated
ASCII string and returns the ASCII string.
@@ -1026,6 +1066,56 @@ UnicodeStrToAsciiStr (
OUT CHAR8 *Destination
);
+#endif
+
+/**
+ Convert a Null-terminated Unicode string to a Null-terminated
+ ASCII string.
+
+ This function is similar to AsciiStrCpyS.
+
+ This function converts the content of the Unicode string Source
+ to the ASCII string Destination by copying the lower 8 bits of
+ each Unicode character. The function terminates the ASCII string
+ Destination by appending a Null-terminator character at the end.
+
+ The caller is responsible to make sure Destination points to a buffer with size
+ equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
+
+ If any Unicode characters in Source contain non-zero value in
+ the upper 8 bits, then ASSERT().
+
+ If Source is not aligned on a 16-bit boundary, then ASSERT().
+ If an error would be returned, then the function will also ASSERT().
+
+ If an error is returned, then the Destination is unmodified.
+
+ @param Source The pointer to a Null-terminated Unicode string.
+ @param Destination The pointer to a Null-terminated ASCII string.
+ @param DestMax The maximum number of Destination Ascii
+ char, including terminating null char.
+
+ @retval RETURN_SUCCESS String is converted.
+ @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
+ @retval RETURN_INVALID_PARAMETER If Destination is NULL.
+ If Source is NULL.
+ If PcdMaximumAsciiStringLength is not zero,
+ and DestMax is greater than
+ PcdMaximumAsciiStringLength.
+ If PcdMaximumUnicodeStringLength is not zero,
+ and DestMax is greater than
+ PcdMaximumUnicodeStringLength.
+ If DestMax is 0.
+ @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
+
+**/
+RETURN_STATUS
+EFIAPI
+UnicodeStrToAsciiStrS (
+ IN CONST CHAR16 *Source,
+ OUT CHAR8 *Destination,
+ IN UINTN DestMax
+ );
#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
@@ -1529,8 +1619,11 @@ AsciiStrHexToUint64 (
IN CONST CHAR8 *String
);
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
/**
+ [ATTENTION] This function is deprecated for security reason.
+
Convert one Null-terminated ASCII string to a Null-terminated
Unicode string and returns the Unicode string.
@@ -1564,6 +1657,52 @@ AsciiStrToUnicodeStr (
OUT CHAR16 *Destination
);
+#endif
+
+/**
+ Convert one Null-terminated ASCII string to a Null-terminated
+ Unicode string.
+
+ This function is similar to StrCpyS.
+
+ This function converts the contents of the ASCII string Source to the Unicode
+ string Destination. The function terminates the Unicode string Destination by
+ appending a Null-terminator character at the end.
+
+ The caller is responsible to make sure Destination points to a buffer with size
+ equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
+
+ If Destination is not aligned on a 16-bit boundary, then ASSERT().
+ If an error would be returned, then the function will also ASSERT().
+
+ If an error is returned, then the Destination is unmodified.
+
+ @param Source The pointer to a Null-terminated ASCII string.
+ @param Destination The pointer to a Null-terminated Unicode string.
+ @param DestMax The maximum number of Destination Unicode
+ char, including terminating null char.
+
+ @retval RETURN_SUCCESS String is converted.
+ @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
+ @retval RETURN_INVALID_PARAMETER If Destination is NULL.
+ If Source is NULL.
+ If PcdMaximumUnicodeStringLength is not zero,
+ and DestMax is greater than
+ PcdMaximumUnicodeStringLength.
+ If PcdMaximumAsciiStringLength is not zero,
+ and DestMax is greater than
+ PcdMaximumAsciiStringLength.
+ If DestMax is 0.
+ @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
+
+**/
+RETURN_STATUS
+EFIAPI
+AsciiStrToUnicodeStrS (
+ IN CONST CHAR8 *Source,
+ OUT CHAR16 *Destination,
+ IN UINTN DestMax
+ );
/**
Converts an 8-bit value to an 8-bit BCD value.
@@ -1635,7 +1774,7 @@ PathRemoveLastItem(
@param[in] Path The pointer to the string containing the path.
- @return Returns Path, otherwise returns NULL to indicate that an error has occured.
+ @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
**/
CHAR16*
EFIAPI