Implement BlGetConfigBooleanValue() routine
Builds / ExectOS (i686) (push) Successful in 32s Details
Builds / ExectOS (amd64) (push) Successful in 34s Details

This commit is contained in:
Rafal Kupiec 2024-03-18 20:02:43 +01:00
parent bd02da30ef
commit 12e8704ffb
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
3 changed files with 39 additions and 2 deletions

View File

@ -9,6 +9,39 @@
#include <xtldr.h>
/**
* Returns a boolean value of the specified configuration key.
*
* @param ConfigName
* Specifies the configuration key to return its boolean representation.
*
* @return This routine returns a boolean representation of the configuration value.
*
* @since XT 1.0
*/
XTCDECL
BOOLEAN
BlGetConfigBooleanValue(IN CONST PWCHAR ConfigName)
{
PWCHAR Value;
/* Get config value */
Value = BlGetConfigValue(ConfigName);
/* Check if option is enabled */
if(RtlCompareWideStringInsensitive(Value, L"ENABLED", 0) == 0 ||
RtlCompareWideStringInsensitive(Value, L"ON", 0) == 0 ||
RtlCompareWideStringInsensitive(Value, L"TRUE", 0) == 0 ||
RtlCompareWideStringInsensitive(Value, L"YES", 0) == 0)
{
/* This option is enabled */
return TRUE;
}
/* Return FALSE by default */
return FALSE;
}
/**
* Returns a value of the specified configuration key.
*

View File

@ -123,6 +123,10 @@ XTCDECL
EFI_STATUS
BlFreeMemoryPool(IN PVOID Memory);
XTCDECL
BOOLEAN
BlGetConfigBooleanValue(IN CONST PWCHAR ConfigName);
XTCDECL
PWCHAR
BlGetConfigValue(IN CONST PWCHAR ConfigName);

View File

@ -112,7 +112,7 @@ BlInitializeBootMenuList(OUT PXTBL_BOOTMENU_ITEM MenuEntries,
DefaultMenuEntry = BlGetConfigValue(L"DEFAULT");
/* Check if configuration allows to use last booted OS */
if(RtlCompareWideStringInsensitive(BlGetConfigValue(L"KEEPLASTBOOT"), L"TRUE", 0) == 0)
if(BlGetConfigBooleanValue(L"KEEPLASTBOOT"))
{
/* Attempt to get last booted Operating System from NVRAM */
Status = BlGetEfiVariable(&VendorGuid, L"XtLdrLastBootOS", (PVOID*)&LastBooted);
@ -312,7 +312,7 @@ BlInvokeBootProtocol(IN PWCHAR ShortName,
}
/* Check if chosen operating system should be saved */
if(RtlCompareWideStringInsensitive(BlGetConfigValue(L"KEEPLASTBOOT"), L"TRUE", 0) == 0)
if(BlGetConfigBooleanValue(L"KEEPLASTBOOT"))
{
/* Save chosen operating system in NVRAM */
Status = BlSetEfiVariable(&VendorGuid, L"XtLdrLastBootOS", (PVOID)ShortName, RtlWideStringLength(ShortName, 0) * sizeof(WCHAR));