X-Git-Url: https://code.delx.au/refind/blobdiff_plain/c88af30fa999cda624f7e9b77b3108e139457dd3..85f7e52b653f9e618ad57d511ed01db94ae3b2b3:/refind/lib.c diff --git a/refind/lib.c b/refind/lib.c index be95e0c..71f76c5 100644 --- a/refind/lib.c +++ b/refind/lib.c @@ -1200,7 +1200,8 @@ CHAR16 *FindLastDirName(IN CHAR16 *Path) { // Returns the directory portion of a pathname. For instance, // if FullPath is 'EFI\foo\bar.efi', this function returns the -// string 'EFI\foo'. +// string 'EFI\foo'. The calling function is responsible for +// freeing the returned string's memory. CHAR16 *FindPath(IN CHAR16* FullPath) { UINTN i, LastBackslash = 0; CHAR16 *PathOnly; @@ -1278,6 +1279,22 @@ CHAR16 *FindCommaDelimited(IN CHAR16 *InString, IN UINTN Index) { return (FoundString); } // CHAR16 *FindCommaDelimited() +// Returns TRUE if SmallString is an element in the comma-delimited List, +// FALSE otherwise. Performs comparison case-insensitively (except on +// buggy EFIs with case-sensitive StriCmp() functions). +BOOLEAN IsIn(IN CHAR16 *SmallString, IN CHAR16 *List) { + UINTN i = 0; + BOOLEAN Found = FALSE; + CHAR16 *OneElement; + + if (SmallString && List) { + while (!Found && (OneElement = FindCommaDelimited(List, i++))) { + if (StriCmp(OneElement, SmallString) == 0) + Found = TRUE; + } // while + } // if + return Found; +} // BOOLEAN IsIn() static EFI_GUID AppleRemovableMediaGuid = APPLE_REMOVABLE_MEDIA_PROTOCOL_GUID;