File->Buffer = AllocatePool(File->BufferSize);
Status = refit_call3_wrapper(FileHandle->Read, FileHandle, &File->BufferSize, File->Buffer);
if (CheckError(Status, L"while loading the configuration file")) {
- FreePool(File->Buffer);
+ MyFreePool(File->Buffer);
File->Buffer = NULL;
refit_call1_wrapper(FileHandle->Close, FileHandle);
return Status;
// handle a parameter with a single string argument
static VOID HandleString(IN CHAR16 **TokenList, IN UINTN TokenCount, OUT CHAR16 **Target) {
if (TokenCount == 2) {
- if (*Target != NULL)
- FreePool(*Target);
+ MyFreePool(*Target);
*Target = StrDuplicate(TokenList[1]);
} // if
} // static VOID HandleString()
GlobalConfig.ScanFor[i] = ' ';
}
+ } else if ((StriCmp(TokenList[0], L"scan_delay") == 0) && (TokenCount == 2)) {
+ HandleInt(TokenList, TokenCount, &(GlobalConfig.ScanDelay));
+
} else if (StriCmp(TokenList[0], L"also_scan_dirs") == 0) {
HandleStrings(TokenList, TokenCount, &(GlobalConfig.AlsoScan));
GlobalConfig.ShowTools[i - 1] = TAG_REBOOT;
} else if (StriCmp(FlagName, L"shutdown") == 0) {
GlobalConfig.ShowTools[i - 1] = TAG_SHUTDOWN;
+ } else if (StriCmp(FlagName, L"apple_recovery") == 0) {
+ GlobalConfig.ShowTools[i - 1] = TAG_APPLE_RECOVERY;
} else {
Print(L" unknown showtools flag: '%s'\n", FlagName);
}
} else if (StriCmp(TokenList[0], L"use_graphics_for") == 0) {
GlobalConfig.GraphicsFor = 0;
for (i = 1; i < TokenCount; i++) {
- if (StriCmp(TokenList[i], L"osx")) {
+ if (StriCmp(TokenList[i], L"osx") == 0) {
GlobalConfig.GraphicsFor |= GRAPHICS_FOR_OSX;
- } else if (StriCmp(TokenList[i], L"linux")) {
+ } else if (StriCmp(TokenList[i], L"linux") == 0) {
GlobalConfig.GraphicsFor |= GRAPHICS_FOR_LINUX;
- } else if (StriCmp(TokenList[i], L"elilo")) {
+ } else if (StriCmp(TokenList[i], L"elilo") == 0) {
GlobalConfig.GraphicsFor |= GRAPHICS_FOR_ELILO;
- } else if (StriCmp(TokenList[i], L"grub")) {
+ } else if (StriCmp(TokenList[i], L"grub") == 0) {
GlobalConfig.GraphicsFor |= GRAPHICS_FOR_GRUB;
- } else if (StriCmp(TokenList[i], L"windows")) {
+ } else if (StriCmp(TokenList[i], L"windows") == 0) {
GlobalConfig.GraphicsFor |= GRAPHICS_FOR_WINDOWS;
}
} // for (graphics_on tokens)
} else if (StriCmp(TokenList[0], L"max_tags") == 0) {
HandleInt(TokenList, TokenCount, &(GlobalConfig.MaxTags));
+
}
FreeTokenLine(&TokenList, &TokenCount);
}
- FreePool(File.Buffer);
+ MyFreePool(File.Buffer);
} /* VOID ReadConfig() */
+// Finds a volume with the specified Identifier (a volume label or a number
+// followed by a colon, for the moment). If found, sets *Volume to point to
+// that volume. If not, leaves it unchanged.
+// Returns TRUE if a match was found, FALSE if not.
+static BOOLEAN FindVolume(REFIT_VOLUME **Volume, CHAR16 *Identifier) {
+ UINTN i = 0, CountedVolumes = 0;
+ INTN Number = -1;
+ BOOLEAN Found = FALSE;
+
+ if ((StrLen(Identifier) >= 2) && (Identifier[StrLen(Identifier) - 1] == L':') &&
+ (Identifier[0] >= L'0') && (Identifier[0] <= L'9')) {
+ Number = (INTN) Atoi(Identifier);
+ }
+ while ((i < VolumesCount) && (!Found)) {
+ if (Number >= 0) { // User specified a volume by number
+ if (Volumes[i]->IsReadable) {
+ if (CountedVolumes == Number) {
+ *Volume = Volumes[i];
+ Found = TRUE;
+ }
+ CountedVolumes++;
+ } // if
+ } else { // User specified a volume by label
+ if (StriCmp(Identifier, Volumes[i]->VolName) == 0) {
+ *Volume = Volumes[i];
+ Found = TRUE;
+ } // if
+ } // if/else
+ i++;
+ } // while()
+ return (Found);
+} // static VOID FindVolume()
+
static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volume, CHAR16 *Title) {
REFIT_MENU_SCREEN *SubScreen;
LOADER_ENTRY *SubEntry;
while (((TokenCount = ReadTokenLine(File, &TokenList)) > 0) && (StriCmp(TokenList[0], L"}") != 0)) {
if ((StriCmp(TokenList[0], L"loader") == 0) && (TokenCount > 1)) { // set the boot loader filename
- if (SubEntry->LoaderPath != NULL)
- FreePool(SubEntry->LoaderPath);
+ MyFreePool(SubEntry->LoaderPath);
SubEntry->LoaderPath = StrDuplicate(TokenList[1]);
SubEntry->DevicePath = FileDevicePath(Volume->DeviceHandle, SubEntry->LoaderPath);
+ } else if ((StriCmp(TokenList[0], L"volume") == 0) && (TokenCount > 1)) {
+ if (FindVolume(&Volume, TokenList[1])) {
+ MyFreePool(SubEntry->me.Title);
+ SubEntry->me.Title = AllocateZeroPool(256 * sizeof(CHAR16));
+ SPrint(SubEntry->me.Title, 255, L"Boot %s from %s", (Title != NULL) ? Title : L"Unknown", Volume->VolName);
+ SubEntry->me.BadgeImage = Volume->VolBadgeImage;
+ SubEntry->VolName = Volume->VolName;
+ } // if match found
+
} else if (StriCmp(TokenList[0], L"initrd") == 0) {
- if (SubEntry->InitrdPath != NULL)
- FreePool(SubEntry->InitrdPath);
+ MyFreePool(SubEntry->InitrdPath);
SubEntry->InitrdPath = NULL;
if (TokenCount > 1) {
SubEntry->InitrdPath = StrDuplicate(TokenList[1]);
}
} else if (StriCmp(TokenList[0], L"options") == 0) {
- if (SubEntry->LoadOptions != NULL)
- FreePool(SubEntry->LoadOptions);
+ MyFreePool(SubEntry->LoadOptions);
SubEntry->LoadOptions = NULL;
if (TokenCount > 1) {
SubEntry->LoadOptions = StrDuplicate(TokenList[1]);
if (SubEntry->InitrdPath != NULL) {
MergeStrings(&SubEntry->LoadOptions, L"initrd=", L' ');
MergeStrings(&SubEntry->LoadOptions, SubEntry->InitrdPath, 0);
- FreePool(SubEntry->InitrdPath);
+ MyFreePool(SubEntry->InitrdPath);
SubEntry->InitrdPath = NULL;
} // if
if (SubEntry->Enabled == TRUE) {
Entry->me.SubScreen = SubScreen;
} // VOID AddSubmenu()
-// Finds a volume with the specified Identifier (a volume label or a number
-// followed by a colon, for the moment). If found, sets *Volume to point to
-// that volume. If not, leaves it unchanged.
-// Returns TRUE if a match was found, FALSE if not.
-static BOOLEAN FindVolume(REFIT_VOLUME **Volume, CHAR16 *Identifier) {
- UINTN i = 0, CountedVolumes = 0;
- INTN Number = -1;
- BOOLEAN Found = FALSE;
-
- if ((StrLen(Identifier) >= 2) && (Identifier[StrLen(Identifier) - 1] == L':') &&
- (Identifier[0] >= L'0') && (Identifier[0] <= L'9')) {
- Number = (INTN) Atoi(Identifier);
- }
- while ((i < VolumesCount) && (!Found)) {
- if (Number >= 0) { // User specified a volume by number
- if (Volumes[i]->IsReadable) {
- if (CountedVolumes == Number) {
- *Volume = Volumes[i];
- Found = TRUE;
- }
- CountedVolumes++;
- } // if
- } else { // User specified a volume by label
- if (StriCmp(Identifier, Volumes[i]->VolName) == 0) {
- *Volume = Volumes[i];
- Found = TRUE;
- } // if
- } // if/else
- i++;
- } // while()
- return (Found);
-} // static VOID FindVolume()
-
// Adds the options from a SINGLE refind.conf stanza to a new loader entry and returns
// that entry. The calling function is then responsible for adding the entry to the
// list of entries.
Entry->LoaderPath = StrDuplicate(TokenList[1]);
Entry->DevicePath = FileDevicePath(CurrentVolume->DeviceHandle, Entry->LoaderPath);
SetLoaderDefaults(Entry, TokenList[1], CurrentVolume);
- FreePool(Entry->LoadOptions);
+ MyFreePool(Entry->LoadOptions);
Entry->LoadOptions = NULL; // Discard default options, if any
DefaultsSet = TRUE;
+
} else if ((StriCmp(TokenList[0], L"volume") == 0) && (TokenCount > 1)) {
if (FindVolume(&CurrentVolume, TokenList[1])) {
- FreePool(Entry->me.Title);
+ MyFreePool(Entry->me.Title);
Entry->me.Title = AllocateZeroPool(256 * sizeof(CHAR16));
SPrint(Entry->me.Title, 255, L"Boot %s from %s", (Title != NULL) ? Title : L"Unknown", CurrentVolume->VolName);
Entry->me.BadgeImage = CurrentVolume->VolBadgeImage;
Entry->VolName = CurrentVolume->VolName;
} // if match found
+
} else if ((StriCmp(TokenList[0], L"icon") == 0) && (TokenCount > 1)) {
- FreePool(Entry->me.Image);
+ MyFreePool(Entry->me.Image);
Entry->me.Image = LoadIcns(CurrentVolume->RootDir, TokenList[1], 128);
if (Entry->me.Image == NULL) {
Entry->me.Image = DummyImage(128);
}
+
} else if ((StriCmp(TokenList[0], L"initrd") == 0) && (TokenCount > 1)) {
- if (Entry->InitrdPath)
- FreePool(Entry->InitrdPath);
+ MyFreePool(Entry->InitrdPath);
Entry->InitrdPath = StrDuplicate(TokenList[1]);
+
} else if ((StriCmp(TokenList[0], L"options") == 0) && (TokenCount > 1)) {
- if (Entry->LoadOptions)
- FreePool(Entry->LoadOptions);
+ MyFreePool(Entry->LoadOptions);
Entry->LoadOptions = StrDuplicate(TokenList[1]);
+
} else if ((StriCmp(TokenList[0], L"ostype") == 0) && (TokenCount > 1)) {
if (TokenCount > 1) {
Entry->OSType = TokenList[1][0];
}
+
} else if ((StriCmp(TokenList[0], L"graphics") == 0) && (TokenCount > 1)) {
Entry->UseGraphicsMode = (StriCmp(TokenList[1], L"on") == 0);
+
} else if (StriCmp(TokenList[0], L"disabled") == 0) {
Entry->Enabled = FALSE;
+
} else if ((StriCmp(TokenList[0], L"submenuentry") == 0) && (TokenCount > 1)) {
AddSubmenu(Entry, File, CurrentVolume, TokenList[1]);
AddedSubmenu = TRUE;
+
} // set options to pass to the loader program
FreeTokenLine(&TokenList, &TokenCount);
} // while()
if (Entry->InitrdPath) {
MergeStrings(&Entry->LoadOptions, L"initrd=", L' ');
MergeStrings(&Entry->LoadOptions, Entry->InitrdPath, 0);
- FreePool(Entry->InitrdPath);
+ MyFreePool(Entry->InitrdPath);
Entry->InitrdPath = NULL;
} // if
GenerateSubScreen(Entry, Volume);
AddPreparedLoaderEntry(Entry);
} else {
- FreePool(Entry);
+ MyFreePool(Entry);
} // if/else
- FreePool(Title);
+ MyFreePool(Title);
} // if
FreeTokenLine(&TokenList, &TokenCount);
} // while()
} else { // a filename string is NULL
GoOn = FALSE;
} // if/else
- if (OptionsFilename != NULL)
- FreePool(OptionsFilename);
- if (FullFilename != NULL)
- FreePool(FullFilename);
+ MyFreePool(OptionsFilename);
+ MyFreePool(FullFilename);
OptionsFilename = FullFilename = NULL;
} while (GoOn);
return (File);
Options = StrDuplicate(TokenList[1]);
FreeTokenLine(&TokenList, &TokenCount);
FreePool(File);
- }
+ } // if
return Options;
} // static CHAR16 * GetOptionsFile()