mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OcStringLib: Add OcAsciiStriStr API
This commit is contained in:
parent
2b637b91d3
commit
5c8f473541
@ -234,6 +234,38 @@ OcStrniCmp (
|
||||
IN UINTN Length
|
||||
);
|
||||
|
||||
/**
|
||||
Returns the first occurrence of a Null-terminated ASCII sub-string
|
||||
in a Null-terminated ASCII string through a case insensitive comparison.
|
||||
|
||||
This function scans the contents of the Null-terminated ASCII string
|
||||
specified by String and returns the first occurrence of SearchString.
|
||||
If SearchString is not found in String, then NULL is returned. If
|
||||
the length of SearchString is zero, then String is returned.
|
||||
|
||||
If String is NULL, then ASSERT().
|
||||
If String is not aligned on a 8-bit boundary, then ASSERT().
|
||||
If SearchString is NULL, then ASSERT().
|
||||
If SearchString is not aligned on a 8-bit boundary, then ASSERT().
|
||||
|
||||
If PcdMaximumAsciiStringLength is not zero, and SearchString
|
||||
or String contains more than PcdMaximumAsciiStringLength ASCII
|
||||
characters, not including the Null-terminator, then ASSERT().
|
||||
|
||||
@param String The pointer to a Null-terminated ASCII string.
|
||||
@param SearchString The pointer to a Null-terminated ASCII string to search for.
|
||||
|
||||
@retval NULL If the SearchString does not appear in String.
|
||||
@return others If there is a match.
|
||||
|
||||
**/
|
||||
CHAR8 *
|
||||
EFIAPI
|
||||
OcAsciiStriStr (
|
||||
IN CONST CHAR8 *String,
|
||||
IN CONST CHAR8 *SearchString
|
||||
);
|
||||
|
||||
/**
|
||||
Returns the first occurrence of a Null-terminated Unicode sub-string
|
||||
in a Null-terminated Unicode string through a case insensitive comparison.
|
||||
|
||||
@ -206,3 +206,44 @@ OcAsciiEndsWith (
|
||||
return StringLength >= SearchStringLength
|
||||
&& AsciiStrnCmp (&String[StringLength - SearchStringLength], SearchString, SearchStringLength) == 0;
|
||||
}
|
||||
|
||||
CHAR8 *
|
||||
EFIAPI
|
||||
OcAsciiStriStr (
|
||||
IN CONST CHAR8 *String,
|
||||
IN CONST CHAR8 *SearchString
|
||||
)
|
||||
{
|
||||
CONST CHAR8 *FirstMatch;
|
||||
CONST CHAR8 *SearchStringTmp;
|
||||
|
||||
ASSERT (AsciiStrSize (String) != 0);
|
||||
ASSERT (AsciiStrSize (SearchString) != 0);
|
||||
|
||||
if (*SearchString == '\0') {
|
||||
return (CHAR8 *) String;
|
||||
}
|
||||
|
||||
while (*String != '\0') {
|
||||
SearchStringTmp = SearchString;
|
||||
FirstMatch = String;
|
||||
|
||||
while ((AsciiCharToUpper (*String) == AsciiCharToUpper (*SearchStringTmp))
|
||||
&& (*String != '\0')) {
|
||||
String++;
|
||||
SearchStringTmp++;
|
||||
}
|
||||
|
||||
if (*SearchStringTmp == '\0') {
|
||||
return (CHAR8 *) FirstMatch;
|
||||
}
|
||||
|
||||
if (*String == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
String = FirstMatch + 1;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user