- CHAR16 *NameClues, *PathOnly, *NoExtension, *OSIconName = NULL, *Temp, *SubString;
- CHAR16 ShortcutLetter = 0;
- UINTN i = 0, Length;
-
- NameClues = Basename(LoaderPath);
- PathOnly = FindPath(LoaderPath);
- NoExtension = StripEfiExtension(NameClues);
-
- if (Volume->DiskKind == DISK_KIND_NET) {
- MergeStrings(&NameClues, Entry->me.Title, L' ');
- } else {
- // locate a custom icon for the loader
- // Anything found here takes precedence over the "hints" in the OSIconName variable
- if (!Entry->me.Image) {
- Entry->me.Image = egLoadIconAnyType(Volume->RootDir, PathOnly, NoExtension, GlobalConfig.IconSizes[ICON_SIZE_BIG]);
- }
- if (!Entry->me.Image) {
- Entry->me.Image = egCopyImage(Volume->VolIconImage);
- }
-
- // Begin creating icon "hints" by using last part of directory path leading
- // to the loader
- Temp = FindLastDirName(LoaderPath);
- MergeStrings(&OSIconName, Temp, L',');
- MyFreePool(Temp);
- Temp = NULL;
- if (OSIconName != NULL) {
- ShortcutLetter = OSIconName[0];
- }
-
- // Add every "word" in the volume label, delimited by spaces, dashes (-), or
- // underscores (_), to the list of hints to be used in searching for OS
- // icons.
- if ((Volume->VolName) && (StrLen(Volume->VolName) > 0)) {
- Temp = SubString = StrDuplicate(Volume->VolName);
- if (Temp != NULL) {
- Length = StrLen(Temp);
- for (i = 0; i < Length; i++) {
- if ((Temp[i] == L' ') || (Temp[i] == L'_') || (Temp[i] == L'-')) {
- Temp[i] = 0;
- if (StrLen(SubString) > 0)
- MergeStrings(&OSIconName, SubString, L',');
- SubString = Temp + i + 1;
- } // if
- } // for
- MergeStrings(&OSIconName, SubString, L',');
- MyFreePool(Temp);
- } // if
- } // if
- } // if/else network boot
-
- // detect specific loaders
- if (StriSubCmp(L"bzImage", NameClues) || StriSubCmp(L"vmlinuz", NameClues)) {
- if (Volume->DiskKind != DISK_KIND_NET) {
- GuessLinuxDistribution(&OSIconName, Volume, LoaderPath);
- Entry->LoadOptions = GetMainLinuxOptions(LoaderPath, Volume);
- }
- MergeStrings(&OSIconName, L"linux", L',');
- Entry->OSType = 'L';
- if (ShortcutLetter == 0)
- ShortcutLetter = 'L';
- Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_LINUX;
- } else if (StriSubCmp(L"refit", LoaderPath)) {
- MergeStrings(&OSIconName, L"refit", L',');
- Entry->OSType = 'R';
- ShortcutLetter = 'R';
- } else if (StriSubCmp(L"refind", LoaderPath)) {
- MergeStrings(&OSIconName, L"refind", L',');
- Entry->OSType = 'R';
- ShortcutLetter = 'R';
- } else if (StriCmp(LoaderPath, MACOSX_LOADER_PATH) == 0) {
- MergeStrings(&OSIconName, L"mac", L',');
- Entry->OSType = 'M';
- ShortcutLetter = 'M';
- Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_OSX;
- } else if (StriCmp(NameClues, L"diags.efi") == 0) {
- MergeStrings(&OSIconName, L"hwtest", L',');
- } else if (StriCmp(NameClues, L"e.efi") == 0 || StriCmp(NameClues, L"elilo.efi") == 0 || StriSubCmp(L"elilo", NameClues)) {
- MergeStrings(&OSIconName, L"elilo,linux", L',');
- Entry->OSType = 'E';
- if (ShortcutLetter == 0)
- ShortcutLetter = 'L';
- Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO;
- } else if (StriSubCmp(L"grub", NameClues)) {
- MergeStrings(&OSIconName, L"grub,linux", L',');
- Entry->OSType = 'G';
- ShortcutLetter = 'G';
- Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_GRUB;
- } else if (StriCmp(NameClues, L"cdboot.efi") == 0 ||
- StriCmp(NameClues, L"bootmgr.efi") == 0 ||
- StriCmp(NameClues, L"bootmgfw.efi") == 0 ||
- StriCmp(NameClues, L"bkpbootmgfw.efi") == 0) {
- MergeStrings(&OSIconName, L"win8", L',');
- Entry->OSType = 'W';
- ShortcutLetter = 'W';
- Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS;
- } else if (StriCmp(NameClues, L"xom.efi") == 0) {
- MergeStrings(&OSIconName, L"xom,win,win8", L',');
- Entry->OSType = 'X';
- ShortcutLetter = 'W';
- Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS;
- }
- else if (StriSubCmp(L"ipxe", NameClues)) {
- Entry->OSType = 'N';
- ShortcutLetter = 'N';
- MergeStrings(&OSIconName, L"network", L',');
- }
-
- if ((ShortcutLetter >= 'a') && (ShortcutLetter <= 'z'))
- ShortcutLetter = ShortcutLetter - 'a' + 'A'; // convert lowercase to uppercase
- Entry->me.ShortcutLetter = ShortcutLetter;
- if (Entry->me.Image == NULL)
- Entry->me.Image = LoadOSIcon(OSIconName, L"unknown", FALSE);
- MyFreePool(PathOnly);
+ CHAR16 *NameClues, *PathOnly, *NoExtension, *OSIconName = NULL, *Temp;
+ CHAR16 ShortcutLetter = 0;
+
+ NameClues = Basename(LoaderPath);
+ PathOnly = FindPath(LoaderPath);
+ NoExtension = StripEfiExtension(NameClues);
+
+ if (Volume->DiskKind == DISK_KIND_NET) {
+ MergeStrings(&NameClues, Entry->me.Title, L' ');
+ } else {
+ // locate a custom icon for the loader
+ // Anything found here takes precedence over the "hints" in the OSIconName variable
+ if (!Entry->me.Image) {
+ Entry->me.Image = egLoadIconAnyType(Volume->RootDir, PathOnly, NoExtension, GlobalConfig.IconSizes[ICON_SIZE_BIG]);
+ }
+ if (!Entry->me.Image) {
+ Entry->me.Image = egCopyImage(Volume->VolIconImage);
+ }
+
+ // Begin creating icon "hints" by using last part of directory path leading
+ // to the loader
+ Temp = FindLastDirName(LoaderPath);
+ MergeStrings(&OSIconName, Temp, L',');
+ MyFreePool(Temp);
+ Temp = NULL;
+ if (OSIconName != NULL) {
+ ShortcutLetter = OSIconName[0];
+ }
+
+ // Add every "word" in the volume label, delimited by spaces, dashes (-), or
+ // underscores (_), to the list of hints to be used in searching for OS
+ // icons.
+ MergeWords(&OSIconName, Volume->VolName, L',');
+ } // if/else network boot
+
+ // detect specific loaders
+ if (StriSubCmp(L"bzImage", NameClues) || StriSubCmp(L"vmlinuz", NameClues)) {
+ if (Volume->DiskKind != DISK_KIND_NET) {
+ GuessLinuxDistribution(&OSIconName, Volume, LoaderPath);
+ Entry->LoadOptions = GetMainLinuxOptions(LoaderPath, Volume);
+ }
+ MergeStrings(&OSIconName, L"linux", L',');
+ Entry->OSType = 'L';
+ if (ShortcutLetter == 0)
+ ShortcutLetter = 'L';
+ Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_LINUX;
+ } else if (StriSubCmp(L"refit", LoaderPath)) {
+ MergeStrings(&OSIconName, L"refit", L',');
+ Entry->OSType = 'R';
+ ShortcutLetter = 'R';
+ } else if (StriSubCmp(L"refind", LoaderPath)) {
+ MergeStrings(&OSIconName, L"refind", L',');
+ Entry->OSType = 'R';
+ ShortcutLetter = 'R';
+ } else if (MyStriCmp(LoaderPath, MACOSX_LOADER_PATH)) {
+ MergeStrings(&OSIconName, L"mac", L',');
+ Entry->OSType = 'M';
+ ShortcutLetter = 'M';
+ Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_OSX;
+ } else if (MyStriCmp(NameClues, L"diags.efi")) {
+ MergeStrings(&OSIconName, L"hwtest", L',');
+ } else if (MyStriCmp(NameClues, L"e.efi") || MyStriCmp(NameClues, L"elilo.efi") || StriSubCmp(L"elilo", NameClues)) {
+ MergeStrings(&OSIconName, L"elilo,linux", L',');
+ Entry->OSType = 'E';
+ if (ShortcutLetter == 0)
+ ShortcutLetter = 'L';
+ Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_ELILO;
+ } else if (StriSubCmp(L"grub", NameClues)) {
+ MergeStrings(&OSIconName, L"grub,linux", L',');
+ Entry->OSType = 'G';
+ ShortcutLetter = 'G';
+ Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_GRUB;
+ } else if (MyStriCmp(NameClues, L"cdboot.efi") ||
+ MyStriCmp(NameClues, L"bootmgr.efi") ||
+ MyStriCmp(NameClues, L"bootmgfw.efi") ||
+ MyStriCmp(NameClues, L"bkpbootmgfw.efi")) {
+ MergeStrings(&OSIconName, L"win8", L',');
+ Entry->OSType = 'W';
+ ShortcutLetter = 'W';
+ Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS;
+ } else if (MyStriCmp(NameClues, L"xom.efi")) {
+ MergeStrings(&OSIconName, L"xom,win,win8", L',');
+ Entry->OSType = 'X';
+ ShortcutLetter = 'W';
+ Entry->UseGraphicsMode = GlobalConfig.GraphicsFor & GRAPHICS_FOR_WINDOWS;
+ }
+ else if (StriSubCmp(L"ipxe", NameClues)) {
+ Entry->OSType = 'N';
+ ShortcutLetter = 'N';
+ MergeStrings(&OSIconName, L"network", L',');
+ }
+
+ if ((ShortcutLetter >= 'a') && (ShortcutLetter <= 'z'))
+ ShortcutLetter = ShortcutLetter - 'a' + 'A'; // convert lowercase to uppercase
+ Entry->me.ShortcutLetter = ShortcutLetter;
+ if (Entry->me.Image == NULL)
+ Entry->me.Image = LoadOSIcon(OSIconName, L"unknown", FALSE);
+ MyFreePool(PathOnly);