mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
Refactor tagNext in tagSruct as a XObjArray<TagStruct>
This commit is contained in:
parent
3eece0918c
commit
95d477c9a3
@ -380,7 +380,10 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,
|
||||
EFI_STATUS Status = EFI_NOT_FOUND;
|
||||
UINT8 *PrefBuffer = NULL;
|
||||
UINTN PrefBufferLen = 0;
|
||||
TagPtr PrefDict, dict, dict2, prop;
|
||||
TagStruct* PrefDict;
|
||||
const TagStruct* dict;
|
||||
const TagStruct* dict2;
|
||||
const TagStruct* prop;
|
||||
CONST CHAR16 *PrefName = L"\\Library\\Preferences\\SystemConfiguration\\com.apple.PowerManagement.plist";
|
||||
CONST CHAR16 *PrefName2 = L"\\Library\\Preferences\\com.apple.PowerManagement.plist";
|
||||
REFIT_VOLUME *ImageVolume = Volume;
|
||||
|
@ -26,7 +26,7 @@
|
||||
extern XObjArray<REFIT_VOLUME> Volumes;
|
||||
|
||||
// for saving nvram.plist and it's data
|
||||
TagPtr gNvramDict;
|
||||
TagStruct* gNvramDict;
|
||||
|
||||
//
|
||||
// vars filled after call to GetEfiBootDeviceFromNvram ()
|
||||
@ -1030,10 +1030,9 @@ VOID
|
||||
PutNvramPlistToRtVars ()
|
||||
{
|
||||
// EFI_STATUS Status;
|
||||
TagPtr Tag;
|
||||
TagPtr ValTag;
|
||||
const TagStruct* ValTag;
|
||||
INTN Size, i;
|
||||
VOID *Value;
|
||||
const VOID *Value;
|
||||
|
||||
if (gNvramDict == NULL) {
|
||||
/*Status = */LoadLatestNvramPlist();
|
||||
@ -1046,101 +1045,105 @@ PutNvramPlistToRtVars ()
|
||||
DbgHeader("PutNvramPlistToRtVars");
|
||||
// DBG("PutNvramPlistToRtVars ...\n");
|
||||
// iterate over dict elements
|
||||
for (Tag = gNvramDict->dictTagValue(); Tag != NULL; Tag = Tag->nextTagValue())
|
||||
for (size_t tagIdx = 0 ; tagIdx < gNvramDict->dictOrArrayContent().size() ; tagIdx++ )
|
||||
{
|
||||
const TagStruct& Tag = gNvramDict->dictOrArrayContent()[tagIdx];
|
||||
EFI_GUID *VendorGuid = &gEfiAppleBootGuid;
|
||||
Value = NULL;
|
||||
if ( Tag->isKey() ) ValTag = Tag->keyTagValue();
|
||||
if ( Tag.isKey() )
|
||||
{
|
||||
ValTag = Tag.keyTagValue();
|
||||
|
||||
// process only valid <key> tags
|
||||
if (!Tag->isKey() || ValTag == NULL) {
|
||||
DBG(" ERROR: Tag is not <key> : type %s\n", ValTag->getTypeAsXString8().c_str());
|
||||
continue;
|
||||
}
|
||||
// DBG("tag: %s\n", Tag->stringValue());
|
||||
// skip OsxAptioFixDrv-RelocBase - appears and causes trouble
|
||||
// in kernel and kext patcher when mixing UEFI and CloverEFI boot
|
||||
if ( Tag->keyValue() == "OsxAptioFixDrv-RelocBase"_XS8 ) {
|
||||
DBG(" Skipping OsxAptioFixDrv-RelocBase\n");
|
||||
continue;
|
||||
} else if ( Tag->keyValue() == "OsxAptioFixDrv-ErrorExitingBootServices"_XS8 ) {
|
||||
DBG(" Skipping OsxAptioFixDrv-ErrorExitingBootServices\n");
|
||||
continue;
|
||||
} else if ( Tag->keyValue() == "EmuVariableUefiPresent"_XS8 ) {
|
||||
DBG(" Skipping EmuVariableUefiPresent\n");
|
||||
continue;
|
||||
} else if ( Tag->keyValue() == "aapl,panic-info"_XS8 ) {
|
||||
DBG(" Skipping aapl,panic-info\n");
|
||||
// process only valid <key> tags
|
||||
if (!Tag.isKey() || ValTag == NULL) {
|
||||
DBG(" ERROR: Tag is not <key> : type %s\n", ValTag->getTypeAsXString8().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
// // key to unicode; check if key buffer is large enough
|
||||
// if ( Tag->keyValue().length() > sizeof(KeyBuf) - 1 ) {
|
||||
// DBG(" ERROR: Skipping too large key %s\n", Tag->keyValue().c_str());
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if ( Tag->keyValue() == "Boot0082"_XS8 || Tag->keyValue() == "BootNext"_XS8 ) {
|
||||
VendorGuid = &gEfiGlobalVariableGuid;
|
||||
// it may happen only in this case
|
||||
GlobalConfig.HibernationFixup = TRUE;
|
||||
}
|
||||
|
||||
// AsciiStrToUnicodeStrS(Tag->stringValue(), KeyBuf, 128);
|
||||
XStringW KeyBuf = Tag->keyValue();
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG(" Adding Key: %ls: ", KeyBuf.wc_str());
|
||||
}
|
||||
// process value tag
|
||||
|
||||
if (ValTag->isString()) {
|
||||
|
||||
// <string> element
|
||||
Value = (void*)ValTag->stringValue().c_str();
|
||||
Size = ValTag->stringValue().length();
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("String: Size = %lld, Val = '%s'\n", Size, ValTag->stringValue().c_str());
|
||||
}
|
||||
|
||||
} else if (ValTag->isData()) {
|
||||
|
||||
// <data> element
|
||||
Size = ValTag->dataLenValue();
|
||||
Value = ValTag->dataValue();
|
||||
// DBG("tag: %s\n", Tag.stringValue());
|
||||
// skip OsxAptioFixDrv-RelocBase - appears and causes trouble
|
||||
// in kernel and kext patcher when mixing UEFI and CloverEFI boot
|
||||
if ( Tag.keyValue() == "OsxAptioFixDrv-RelocBase"_XS8 ) {
|
||||
DBG(" Skipping OsxAptioFixDrv-RelocBase\n");
|
||||
continue;
|
||||
} else if ( Tag.keyValue() == "OsxAptioFixDrv-ErrorExitingBootServices"_XS8 ) {
|
||||
DBG(" Skipping OsxAptioFixDrv-ErrorExitingBootServices\n");
|
||||
continue;
|
||||
} else if ( Tag.keyValue() == "EmuVariableUefiPresent"_XS8 ) {
|
||||
DBG(" Skipping EmuVariableUefiPresent\n");
|
||||
continue;
|
||||
} else if ( Tag.keyValue() == "aapl,panic-info"_XS8 ) {
|
||||
DBG(" Skipping aapl,panic-info\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
// // key to unicode; check if key buffer is large enough
|
||||
// if ( Tag.keyValue().length() > sizeof(KeyBuf) - 1 ) {
|
||||
// DBG(" ERROR: Skipping too large key %s\n", Tag.keyValue().c_str());
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if ( Tag.keyValue() == "Boot0082"_XS8 || Tag.keyValue() == "BootNext"_XS8 ) {
|
||||
VendorGuid = &gEfiGlobalVariableGuid;
|
||||
// it may happen only in this case
|
||||
GlobalConfig.HibernationFixup = TRUE;
|
||||
}
|
||||
|
||||
// AsciiStrToUnicodeStrS(Tag.stringValue(), KeyBuf, 128);
|
||||
XStringW KeyBuf = Tag.keyValue();
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("Size = %lld, Data: ", Size);
|
||||
for (i = 0; i < Size; i++) {
|
||||
DBG("%02hhX ", *(((UINT8*)Value) + i));
|
||||
DBG(" Adding Key: %ls: ", KeyBuf.wc_str());
|
||||
}
|
||||
// process value tag
|
||||
|
||||
if (ValTag->isString()) {
|
||||
|
||||
// <string> element
|
||||
Value = (void*)ValTag->stringValue().c_str();
|
||||
Size = ValTag->stringValue().length();
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("String: Size = %lld, Val = '%s'\n", Size, ValTag->stringValue().c_str());
|
||||
}
|
||||
|
||||
} else if (ValTag->isData()) {
|
||||
|
||||
// <data> element
|
||||
Size = ValTag->dataLenValue();
|
||||
Value = ValTag->dataValue();
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("Size = %lld, Data: ", Size);
|
||||
for (i = 0; i < Size; i++) {
|
||||
DBG("%02hhX ", *(((UINT8*)Value) + i));
|
||||
}
|
||||
}
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("\n");
|
||||
}
|
||||
} else {
|
||||
DBG("ERROR: Unsupported tag type: %s\n", ValTag->getTypeAsXString8().c_str());
|
||||
continue;
|
||||
}
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("\n");
|
||||
|
||||
if (Size == 0 || !Value) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
DBG("ERROR: Unsupported tag type: %s\n", ValTag->getTypeAsXString8().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Size == 0 || !Value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// set RT var: all vars visible in nvram.plist are gEfiAppleBootGuid
|
||||
/* Status = gRT->SetVariable (
|
||||
KeyBuf,
|
||||
VendorGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
Size,
|
||||
Value
|
||||
); */
|
||||
|
||||
SetNvramVariable (
|
||||
KeyBuf.wc_str(),
|
||||
|
||||
// set RT var: all vars visible in nvram.plist are gEfiAppleBootGuid
|
||||
/* Status = gRT->SetVariable (
|
||||
KeyBuf,
|
||||
VendorGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
Size,
|
||||
Value
|
||||
);
|
||||
); */
|
||||
|
||||
SetNvramVariable (
|
||||
KeyBuf.wc_str(),
|
||||
VendorGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
Size,
|
||||
Value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ SIDELOAD_KEXT *InjectKextList = NULL;
|
||||
//SYSVARIABLES *SysVariables;
|
||||
CHAR16 *IconFormat = NULL;
|
||||
|
||||
TagPtr gConfigDict[NUM_OF_CONFIGS] = {NULL, NULL, NULL};
|
||||
TagStruct* gConfigDict[NUM_OF_CONFIGS] = {NULL, NULL, NULL};
|
||||
|
||||
SETTINGS_DATA gSettings;
|
||||
LANGUAGES gLanguage;
|
||||
@ -238,7 +238,7 @@ ParseACPIName(const XString8& String)
|
||||
VOID
|
||||
ParseLoadOptions (
|
||||
OUT XStringW* ConfNamePtr,
|
||||
OUT TagPtr* Dict
|
||||
OUT TagStruct** Dict
|
||||
)
|
||||
{
|
||||
CHAR8 *End;
|
||||
@ -455,12 +455,12 @@ SetBootCurrent(REFIT_MENU_ITEM_BOOTNUM *Entry)
|
||||
//
|
||||
UINT8
|
||||
*GetDataSetting (
|
||||
IN TagPtr Dict,
|
||||
IN const TagStruct* Dict,
|
||||
IN CONST CHAR8 *PropName,
|
||||
OUT UINTN *DataLen
|
||||
)
|
||||
{
|
||||
TagPtr Prop;
|
||||
const TagStruct* Prop;
|
||||
UINT8 *Data = NULL;
|
||||
|
||||
Prop = GetProperty(Dict, PropName);
|
||||
@ -506,7 +506,7 @@ EFI_STATUS
|
||||
LoadUserSettings (
|
||||
IN EFI_FILE *RootDir,
|
||||
IN const XStringW& ConfName,
|
||||
TagPtr *Dict)
|
||||
TagStruct** Dict)
|
||||
{
|
||||
EFI_STATUS Status = EFI_NOT_FOUND;
|
||||
UINTN Size = 0;
|
||||
@ -836,9 +836,9 @@ CUSTOM_LOADER_ENTRY
|
||||
STATIC
|
||||
BOOLEAN
|
||||
FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches,
|
||||
TagPtr DictPointer)
|
||||
const TagStruct* DictPointer)
|
||||
{
|
||||
TagPtr Prop;
|
||||
const TagStruct* Prop;
|
||||
// UINTN i;
|
||||
|
||||
if (Patches == NULL || DictPointer == NULL) {
|
||||
@ -944,7 +944,7 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches,
|
||||
if ( Prop != NULL ) {
|
||||
INTN i, Count = GetTagCount (Prop);
|
||||
if (Count > 0) {
|
||||
TagPtr Prop2 = NULL;
|
||||
const TagStruct* Prop2 = NULL;
|
||||
|
||||
DBG("ForceKextsToLoad: %lld requested\n", Count);
|
||||
|
||||
@ -984,7 +984,8 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches,
|
||||
Patches->KextPatches.setEmpty();
|
||||
|
||||
if (Count > 0) {
|
||||
TagPtr Prop2 = NULL, Dict = NULL;
|
||||
const TagStruct* Prop2 = NULL;
|
||||
const TagStruct* Dict = NULL;
|
||||
|
||||
DBG("KextsToPatch: %lld requested\n", Count);
|
||||
for (i = 0; i < Count; i++) {
|
||||
@ -1147,7 +1148,8 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches,
|
||||
//delete old and create new
|
||||
Patches->KernelPatches.setEmpty();
|
||||
if (Count > 0) {
|
||||
TagPtr Prop2 = NULL, Dict = NULL;
|
||||
const TagStruct* Prop2 = NULL;
|
||||
const TagStruct* Dict = NULL;
|
||||
DBG("KernelToPatch: %lld requested\n", Count);
|
||||
for (i = 0; i < Count; i++) {
|
||||
UINTN FindLen = 0, ReplaceLen = 0, MaskLen = 0;
|
||||
@ -1274,7 +1276,8 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches,
|
||||
//delete old and create new
|
||||
Patches->BootPatches.setEmpty();
|
||||
if (Count > 0) {
|
||||
TagPtr Prop2 = NULL, Dict = NULL;
|
||||
const TagStruct* Prop2 = NULL;
|
||||
const TagStruct* Dict = NULL;
|
||||
|
||||
DBG("BootPatches: %lld requested\n", Count);
|
||||
for (i = 0; i < Count; i++) {
|
||||
@ -1468,7 +1471,7 @@ BOOLEAN IsOSValid(const XString8& MatchOS, const XString8& CurrOS)
|
||||
return ret;
|
||||
}
|
||||
|
||||
UINT8 CheckVolumeType(UINT8 VolumeType, TagPtr Prop)
|
||||
UINT8 CheckVolumeType(UINT8 VolumeType, const TagStruct* Prop)
|
||||
{
|
||||
if ( !Prop->isString() ) {
|
||||
MsgLog("ATTENTION : Prop property not string in CheckVolumeType\n");
|
||||
@ -1487,9 +1490,10 @@ UINT8 CheckVolumeType(UINT8 VolumeType, TagPtr Prop)
|
||||
return VolumeTypeTmp;
|
||||
}
|
||||
|
||||
UINT8 GetVolumeType(TagPtr DictPointer)
|
||||
UINT8 GetVolumeType(const TagStruct* DictPointer)
|
||||
{
|
||||
TagPtr Prop, Prop2;
|
||||
const TagStruct* Prop;
|
||||
const TagStruct* Prop2;
|
||||
UINT8 VolumeType = 0;
|
||||
|
||||
Prop = GetProperty(DictPointer, "VolumeType");
|
||||
@ -1525,11 +1529,11 @@ STATIC
|
||||
BOOLEAN
|
||||
FillinCustomEntry (
|
||||
IN OUT CUSTOM_LOADER_ENTRY *Entry,
|
||||
TagPtr DictPointer,
|
||||
const TagStruct* DictPointer,
|
||||
IN BOOLEAN SubEntry
|
||||
)
|
||||
{
|
||||
TagPtr Prop;
|
||||
const TagStruct* Prop;
|
||||
|
||||
if ((Entry == NULL) || (DictPointer == NULL)) {
|
||||
return FALSE;
|
||||
@ -1829,7 +1833,7 @@ FillinCustomEntry (
|
||||
} else if ( Prop->isDict() || Prop->isArray() ) {
|
||||
CUSTOM_LOADER_ENTRY *CustomSubEntry;
|
||||
INTN i, Count = GetTagCount (Prop);
|
||||
TagPtr Dict = NULL;
|
||||
const TagStruct* Dict = NULL;
|
||||
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTMENU);
|
||||
if (Count > 0) {
|
||||
for (i = 0; i < Count; i++) {
|
||||
@ -1858,10 +1862,10 @@ FillinCustomEntry (
|
||||
BOOLEAN
|
||||
FillingCustomLegacy (
|
||||
IN OUT CUSTOM_LEGACY_ENTRY *Entry,
|
||||
TagPtr DictPointer
|
||||
const TagStruct* DictPointer
|
||||
)
|
||||
{
|
||||
TagPtr Prop;
|
||||
const TagStruct* Prop;
|
||||
if ((Entry == NULL) || (DictPointer == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -1954,9 +1958,9 @@ FillingCustomLegacy (
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
FillingCustomTool (IN OUT CUSTOM_TOOL_ENTRY *Entry, TagPtr DictPointer)
|
||||
FillingCustomTool (IN OUT CUSTOM_TOOL_ENTRY *Entry, const TagStruct* DictPointer)
|
||||
{
|
||||
TagPtr Prop;
|
||||
const TagStruct* Prop;
|
||||
if ((Entry == NULL) || (DictPointer == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -2041,9 +2045,10 @@ FillingCustomTool (IN OUT CUSTOM_TOOL_ENTRY *Entry, TagPtr DictPointer)
|
||||
|
||||
// EDID reworked by Sherlocks
|
||||
VOID
|
||||
GetEDIDSettings(TagPtr DictPointer)
|
||||
GetEDIDSettings(const TagStruct* DictPointer)
|
||||
{
|
||||
TagPtr Prop, Dict;
|
||||
const TagStruct* Prop;
|
||||
const TagStruct* Dict;
|
||||
UINTN j = 128;
|
||||
|
||||
Dict = GetProperty(DictPointer, "EDID");
|
||||
@ -2097,14 +2102,14 @@ GetEDIDSettings(TagPtr DictPointer)
|
||||
EFI_STATUS
|
||||
GetEarlyUserSettings (
|
||||
IN EFI_FILE *RootDir,
|
||||
TagPtr CfgDict
|
||||
const TagStruct* CfgDict
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
TagPtr Dict;
|
||||
TagPtr Dict2;
|
||||
TagPtr DictPointer;
|
||||
TagPtr Prop;
|
||||
const TagStruct* Dict;
|
||||
const TagStruct* Dict2;
|
||||
const TagStruct* DictPointer;
|
||||
const TagStruct* Prop;
|
||||
VOID *Value = NULL;
|
||||
BOOLEAN SpecialBootMode = FALSE;
|
||||
|
||||
@ -2663,7 +2668,7 @@ GetEarlyUserSettings (
|
||||
if (Prop != NULL) {
|
||||
// CUSTOM_LOADER_ENTRY *Entry;
|
||||
INTN i, Count = GetTagCount(Prop);
|
||||
TagPtr Dict3;
|
||||
const TagStruct* Dict3;
|
||||
|
||||
if (Count > 0) {
|
||||
for (i = 0; i < Count; i++) {
|
||||
@ -2689,7 +2694,7 @@ GetEarlyUserSettings (
|
||||
if (Prop != NULL) {
|
||||
CUSTOM_LEGACY_ENTRY *Entry;
|
||||
INTN i, Count = GetTagCount(Prop);
|
||||
TagPtr Dict3;
|
||||
const TagStruct* Dict3;
|
||||
|
||||
if (Count > 0) {
|
||||
for (i = 0; i < Count; i++) {
|
||||
@ -2716,7 +2721,7 @@ GetEarlyUserSettings (
|
||||
if (Prop != NULL) {
|
||||
CUSTOM_TOOL_ENTRY *Entry;
|
||||
INTN i, Count = GetTagCount(Prop);
|
||||
TagPtr Dict3;
|
||||
const TagStruct* Dict3;
|
||||
if (Count > 0) {
|
||||
for (i = 0; i < Count; i++) {
|
||||
if (EFI_ERROR(GetElement(Prop, i, &Dict3))) {
|
||||
@ -2919,7 +2924,7 @@ GetEarlyUserSettings (
|
||||
Dict2 = GetProperty(DictPointer, "MmioWhitelist");
|
||||
if (Dict2 != NULL) {
|
||||
INTN Count = GetTagCount(Dict2);
|
||||
TagPtr Dict3;
|
||||
const TagStruct* Dict3;
|
||||
//OC_SCHEMA_INTEGER_IN ("Address", OC_MMIO_WL_STRUCT, Address),
|
||||
//OC_SCHEMA_STRING_IN ("Comment", OC_MMIO_WL_STRUCT, Comment),
|
||||
//OC_SCHEMA_BOOLEAN_IN ("Enabled", OC_MMIO_WL_STRUCT, Enabled),
|
||||
@ -3095,8 +3100,8 @@ XStringW GetBundleVersion(const XStringW& FullName)
|
||||
XStringW CFBundleVersion;
|
||||
XStringW InfoPlistPath;
|
||||
CHAR8* InfoPlistPtr = NULL;
|
||||
TagPtr InfoPlistDict = NULL;
|
||||
TagPtr Prop = NULL;
|
||||
TagStruct* InfoPlistDict = NULL;
|
||||
const TagStruct* Prop = NULL;
|
||||
UINTN Size;
|
||||
|
||||
InfoPlistPath = SWPrintf("%ls\\%ls", FullName.wc_str(), L"Contents\\Info.plist");
|
||||
@ -3260,10 +3265,11 @@ GetListOfThemes ()
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
XTheme::GetThemeTagSettings(void* DictP)
|
||||
XTheme::GetThemeTagSettings(const TagStruct* DictPointer)
|
||||
{
|
||||
TagPtr Dict, Dict2, Dict3;
|
||||
TagPtr DictPointer = (TagPtr)DictP;
|
||||
const TagStruct* Dict;
|
||||
const TagStruct* Dict2;
|
||||
const TagStruct* Dict3;
|
||||
|
||||
//fill default to have an ability change theme
|
||||
//assume Xtheme is already inited by embedded values
|
||||
@ -3275,7 +3281,7 @@ XTheme::GetThemeTagSettings(void* DictP)
|
||||
Font = FONT_LOAD; //not default
|
||||
|
||||
// if NULL parameter, quit after setting default values, this is embedded theme
|
||||
if (DictP == NULL) {
|
||||
if (DictPointer == NULL) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -3626,11 +3632,11 @@ XTheme::GetThemeTagSettings(void* DictP)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
void* XTheme::LoadTheme(const XStringW& TestTheme)
|
||||
TagStruct* XTheme::LoadTheme(const XStringW& TestTheme)
|
||||
|
||||
{
|
||||
EFI_STATUS Status = EFI_UNSUPPORTED;
|
||||
TagPtr ThemeDict = NULL;
|
||||
TagStruct* ThemeDict = NULL;
|
||||
CHAR8 *ThemePtr = NULL;
|
||||
UINTN Size = 0;
|
||||
|
||||
@ -3655,11 +3661,12 @@ void* XTheme::LoadTheme(const XStringW& TestTheme)
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = egLoadFile(ThemeDir, CONFIG_THEME_SVG, (UINT8**)&ThemePtr, &Size);
|
||||
if (!EFI_ERROR(Status) && (ThemePtr != NULL) && (Size != 0)) {
|
||||
Status = ParseSVGXTheme((const CHAR8*)ThemePtr);
|
||||
Status = ParseSVGXTheme(ThemePtr);
|
||||
if (EFI_ERROR(Status)) {
|
||||
ThemeDict = NULL;
|
||||
} else {
|
||||
ThemeDict = new TagStruct;
|
||||
ThemeDict = NewTag();
|
||||
ThemeDict->setDictTagValue(NULL); // to make it a dict // TODO improve by creating a newDictTag static method.
|
||||
}
|
||||
if (ThemeDict == NULL) {
|
||||
DBG("svg file %ls not parsed\n", CONFIG_THEME_SVG);
|
||||
@ -3669,7 +3676,7 @@ void* XTheme::LoadTheme(const XStringW& TestTheme)
|
||||
} else {
|
||||
Status = egLoadFile(ThemeDir, CONFIG_THEME_FILENAME, (UINT8**)&ThemePtr, &Size);
|
||||
if (!EFI_ERROR(Status) && (ThemePtr != NULL) && (Size != 0)) {
|
||||
Status = ParseXML((const CHAR8*)ThemePtr, &ThemeDict, 0);
|
||||
Status = ParseXML(ThemePtr, &ThemeDict, 0);
|
||||
if (EFI_ERROR(Status)) {
|
||||
ThemeDict = NULL;
|
||||
}
|
||||
@ -3684,7 +3691,7 @@ void* XTheme::LoadTheme(const XStringW& TestTheme)
|
||||
if (ThemePtr != NULL) {
|
||||
FreePool(ThemePtr);
|
||||
}
|
||||
return (void*)ThemeDict;
|
||||
return ThemeDict;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
@ -3693,7 +3700,7 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam)
|
||||
EFI_STATUS Status = EFI_NOT_FOUND;
|
||||
UINTN Size = 0;
|
||||
UINTN i;
|
||||
TagPtr ThemeDict = NULL;
|
||||
TagStruct* ThemeDict = NULL;
|
||||
CHAR8 *ChosenTheme = NULL;
|
||||
UINTN Rnd;
|
||||
EFI_TIME Now;
|
||||
@ -3763,7 +3770,7 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam)
|
||||
}
|
||||
|
||||
if (TestTheme.notEmpty()) {
|
||||
ThemeDict = (TagPtr)ThemeX.LoadTheme(TestTheme);
|
||||
ThemeDict = ThemeX.LoadTheme(TestTheme);
|
||||
if (ThemeDict != NULL) {
|
||||
DBG("special theme %ls found and %ls parsed\n", TestTheme.wc_str(), CONFIG_THEME_FILENAME);
|
||||
// ThemeX.Theme.takeValueFrom(TestTheme);
|
||||
@ -3783,13 +3790,13 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam)
|
||||
goto finish;
|
||||
}
|
||||
if (AsciiStrCmp(ChosenTheme, "random") == 0) {
|
||||
ThemeDict = (TagPtr)ThemeX.LoadTheme(XStringW(ThemesList[Rnd]));
|
||||
ThemeDict = ThemeX.LoadTheme(XStringW(ThemesList[Rnd]));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
TestTheme.takeValueFrom(ChosenTheme);
|
||||
if (TestTheme.notEmpty()) {
|
||||
ThemeDict = (TagPtr)ThemeX.LoadTheme (TestTheme);
|
||||
ThemeDict = ThemeX.LoadTheme (TestTheme);
|
||||
if (ThemeDict != NULL) {
|
||||
DBG("theme %s defined in NVRAM found and %ls parsed\n", ChosenTheme, CONFIG_THEME_FILENAME);
|
||||
// ThemeX.Theme.takeValueFrom(TestTheme);
|
||||
@ -3811,12 +3818,12 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam)
|
||||
if (ThemeDict == NULL) {
|
||||
if (GlobalConfig.Theme.isEmpty()) {
|
||||
DBG("no default theme, get random theme %ls\n", ThemesList[Rnd]);
|
||||
ThemeDict = (TagPtr)ThemeX.LoadTheme(XStringW(ThemesList[Rnd]));
|
||||
ThemeDict = ThemeX.LoadTheme(XStringW(ThemesList[Rnd]));
|
||||
} else {
|
||||
if (StriCmp(GlobalConfig.Theme.wc_str(), L"random") == 0) {
|
||||
ThemeDict = (TagPtr)ThemeX.LoadTheme(XStringW(ThemesList[Rnd]));
|
||||
ThemeDict = ThemeX.LoadTheme(XStringW(ThemesList[Rnd]));
|
||||
} else {
|
||||
ThemeDict = (TagPtr)ThemeX.LoadTheme(GlobalConfig.Theme);
|
||||
ThemeDict = ThemeX.LoadTheme(GlobalConfig.Theme);
|
||||
if (ThemeDict == NULL) {
|
||||
DBG("GlobalConfig: %ls not found, get embedded theme\n", GlobalConfig.Theme.wc_str());
|
||||
} else {
|
||||
@ -3854,9 +3861,9 @@ finish:
|
||||
ThemeX.Theme.takeValueFrom(GlobalConfig.Theme); //XStringW from CHAR16*)
|
||||
// read theme settings
|
||||
if (!ThemeX.TypeSVG) {
|
||||
TagPtr DictPointer = GetProperty(ThemeDict, "Theme");
|
||||
const TagStruct* DictPointer = GetProperty(ThemeDict, "Theme");
|
||||
if (DictPointer != NULL) {
|
||||
Status = ThemeX.GetThemeTagSettings((void*)DictPointer);
|
||||
Status = ThemeX.GetThemeTagSettings(DictPointer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DBG("Config theme error: %s\n", strerror(Status));
|
||||
} else {
|
||||
@ -3895,10 +3902,11 @@ finish:
|
||||
|
||||
VOID
|
||||
ParseSMBIOSSettings(
|
||||
TagPtr DictPointer
|
||||
const TagStruct* DictPointer
|
||||
)
|
||||
{
|
||||
TagPtr Prop, Prop1;
|
||||
const TagStruct* Prop;
|
||||
const TagStruct* Prop1;
|
||||
BOOLEAN Default = FALSE;
|
||||
|
||||
|
||||
@ -4352,16 +4360,16 @@ ParseSMBIOSSettings(
|
||||
EFI_STATUS
|
||||
GetUserSettings(
|
||||
IN EFI_FILE *RootDir,
|
||||
TagPtr CfgDict
|
||||
const TagStruct* CfgDict
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status = EFI_NOT_FOUND;
|
||||
TagPtr Dict;
|
||||
TagPtr Dict2;
|
||||
TagPtr Prop;
|
||||
TagPtr Prop2;
|
||||
TagPtr Prop3;
|
||||
TagPtr DictPointer;
|
||||
const TagStruct* Dict;
|
||||
const TagStruct* Dict2;
|
||||
const TagStruct* Prop;
|
||||
const TagStruct* Prop2;
|
||||
const TagStruct* Prop3;
|
||||
const TagStruct* DictPointer;
|
||||
BOOLEAN IsValidCustomUUID = FALSE;
|
||||
//UINTN i;
|
||||
|
||||
@ -4715,7 +4723,7 @@ GetUserSettings(
|
||||
DBG("\n");
|
||||
Dict2 = GetProperty(Prop2, "CustomProperties");
|
||||
if (Dict2 != NULL) {
|
||||
TagPtr Dict3;
|
||||
const TagStruct* Dict3;
|
||||
INTN PropIndex, PropCount = GetTagCount (Dict2);
|
||||
|
||||
for (PropIndex = 0; PropIndex < PropCount; PropIndex++) {
|
||||
@ -6030,7 +6038,7 @@ GetUserSettings(
|
||||
|
||||
DictPointer = GetProperty(Dict, "SMCKeys");
|
||||
if (DictPointer != NULL) { //sss
|
||||
TagPtr Key, ValArray;
|
||||
TagStruct* Key, ValArray;
|
||||
for (Key = DictPointer->tag; Key != NULL; Key = Key->tagNext) {
|
||||
ValArray = Prop->tag;
|
||||
if (Key->type != kTagTypeKey || ValArray == NULL) {
|
||||
@ -6104,9 +6112,9 @@ XString8 GetOSVersion(IN LOADER_ENTRY *Entry)
|
||||
EFI_STATUS Status = EFI_NOT_FOUND;
|
||||
CHAR8* PlistBuffer = NULL;
|
||||
UINTN PlistLen;
|
||||
TagPtr DictPointer = NULL;
|
||||
TagPtr Dict = NULL;
|
||||
TagPtr Prop = NULL;
|
||||
TagStruct* Dict = NULL;
|
||||
const TagStruct* DictPointer = NULL;
|
||||
const TagStruct* Prop = NULL;
|
||||
|
||||
if (!Entry || !Entry->Volume) {
|
||||
return NullXString8;
|
||||
@ -6508,8 +6516,8 @@ GetRootUUID (IN REFIT_VOLUME *Volume)
|
||||
EFI_STATUS Status;
|
||||
CHAR8 *PlistBuffer;
|
||||
UINTN PlistLen;
|
||||
TagPtr Dict;
|
||||
TagPtr Prop;
|
||||
TagStruct* Dict;
|
||||
const TagStruct* Prop;
|
||||
|
||||
CONST CHAR16* SystemPlistR;
|
||||
CONST CHAR16* SystemPlistP;
|
||||
|
@ -738,7 +738,7 @@ extern UINT16 gBacklightLevel;
|
||||
//extern BOOLEAN defDSM;
|
||||
//extern UINT16 dropDSM;
|
||||
|
||||
extern TagPtr gConfigDict[];
|
||||
extern TagStruct* gConfigDict[];
|
||||
|
||||
// ACPI/PATCHED/AML
|
||||
extern ACPI_PATCHED_AML *ACPIPatchedAML;
|
||||
@ -890,13 +890,13 @@ GetRootUUID (
|
||||
EFI_STATUS
|
||||
GetEarlyUserSettings (
|
||||
IN EFI_FILE *RootDir,
|
||||
TagPtr CfgDict
|
||||
const TagStruct* CfgDict
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
GetUserSettings (
|
||||
IN EFI_FILE *RootDir,
|
||||
TagPtr CfgDict
|
||||
const TagStruct* CfgDict
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
@ -922,7 +922,7 @@ InjectKextsFromDir (
|
||||
VOID
|
||||
ParseLoadOptions (
|
||||
OUT XStringW* ConfName,
|
||||
OUT TagPtr *Dict
|
||||
OUT TagStruct** Dict
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
@ -948,12 +948,12 @@ EFI_STATUS
|
||||
LoadUserSettings (
|
||||
IN EFI_FILE *RootDir,
|
||||
const XStringW& ConfName,
|
||||
TagPtr *dict
|
||||
TagStruct** dict
|
||||
);
|
||||
|
||||
VOID
|
||||
ParseSMBIOSSettings (
|
||||
TagPtr dictPointer
|
||||
const TagStruct* dictPointer
|
||||
);
|
||||
|
||||
//BOOLEAN
|
||||
|
@ -101,12 +101,12 @@ CARDLIST* FindCardWithIds(UINT32 Id, UINT32 SubId)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VOID FillCardList(TagPtr CfgDict)
|
||||
VOID FillCardList(const TagStruct* CfgDict)
|
||||
{
|
||||
if (IsListEmpty(&gCardList) && (CfgDict != NULL)) {
|
||||
CONST CHAR8 *VEN[] = { "NVIDIA", "ATI" };
|
||||
INTN Index, Count = sizeof(VEN) / sizeof(VEN[0]);
|
||||
TagPtr prop;
|
||||
const TagStruct* prop;
|
||||
|
||||
for (Index = 0; Index < Count; Index++) {
|
||||
CONST CHAR8 *key = VEN[Index];
|
||||
@ -116,8 +116,8 @@ VOID FillCardList(TagPtr CfgDict)
|
||||
INTN i;
|
||||
INTN count;
|
||||
|
||||
TagPtr element = 0;
|
||||
TagPtr prop2 = 0;
|
||||
const TagStruct* prop2 = 0;
|
||||
const TagStruct* element = 0;
|
||||
count = GetTagCount(prop);
|
||||
for (i = 0; i < count; i++) {
|
||||
CONST CHAR8 *model_name = NULL;
|
||||
|
@ -28,7 +28,7 @@ typedef struct {
|
||||
|
||||
VOID
|
||||
FillCardList (
|
||||
TagPtr CfgDict
|
||||
const TagStruct* CfgDict
|
||||
);
|
||||
|
||||
CARDLIST
|
||||
|
@ -95,10 +95,10 @@ void toLowerStr(CHAR8 *tstr, IN CONST CHAR8 *str) {
|
||||
*tstr = '\0';
|
||||
}
|
||||
|
||||
BOOLEAN checkOSBundleRequired(UINT8 loaderType, TagPtr dict)
|
||||
BOOLEAN checkOSBundleRequired(UINT8 loaderType, const TagStruct* dict)
|
||||
{
|
||||
BOOLEAN inject = TRUE;
|
||||
TagPtr osBundleRequiredTag;
|
||||
const TagStruct* osBundleRequiredTag;
|
||||
XString8 osbundlerequired;
|
||||
|
||||
osBundleRequiredTag = GetProperty(dict,"OSBundleRequired");
|
||||
@ -135,8 +135,8 @@ EFI_STATUS LOADER_ENTRY::LoadKext(IN EFI_FILE *RootDir, IN CONST CHAR16 *FileNam
|
||||
UINTN bundlePathBufferLength = 0;
|
||||
XStringW TempName;
|
||||
XStringW Executable;
|
||||
TagPtr dict = NULL;
|
||||
TagPtr prop = NULL;
|
||||
TagStruct* dict = NULL;
|
||||
const TagStruct* prop = NULL;
|
||||
BOOLEAN NoContents = FALSE;
|
||||
BOOLEAN inject = FALSE;
|
||||
_BooterKextFileInfo *infoAddr = NULL;
|
||||
|
@ -70,11 +70,22 @@ void TagStruct::FreeTag()
|
||||
_tag->FreeTag();
|
||||
_tag = NULL;
|
||||
}
|
||||
if ( _nextTag ) {
|
||||
_nextTag->FreeTag();
|
||||
_nextTag = NULL;
|
||||
// while ( tagIdx < _dictOrArrayContent.notEmpty() ) {
|
||||
// _dictOrArrayContent[0].FreeTag();
|
||||
// _dictOrArrayContent.RemoveWithoutFreeingAtIndex(0);
|
||||
// }
|
||||
// this loop is better because removing objects from the end don't do any memory copying.
|
||||
for (size_t tagIdx = _dictOrArrayContent.size() ; tagIdx > 0 ; ) {
|
||||
tagIdx--;
|
||||
_dictOrArrayContent[tagIdx].FreeTag();
|
||||
_dictOrArrayContent.RemoveWithoutFreeingAtIndex(tagIdx);
|
||||
}
|
||||
|
||||
// if ( _nextTag ) {
|
||||
// _nextTag->FreeTag();
|
||||
// _nextTag = NULL;
|
||||
// }
|
||||
|
||||
gTagsFree.AddReference(this, false);
|
||||
}
|
||||
|
||||
@ -89,20 +100,19 @@ void TagStruct::FreeTag()
|
||||
CHAR8* buffer_start = NULL;
|
||||
|
||||
// Forward declarations
|
||||
EFI_STATUS ParseTagDict( CHAR8* buffer, TagPtr * tag, UINT32 empty, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagArray( CHAR8* buffer, TagPtr * tag, UINT32 empty, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagKey( char * buffer, TagPtr * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagString(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagInteger(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagFloat(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagData(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagDate(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagPtr * tag, bool value, UINT32* lenPtr);
|
||||
//defined in Platform.h
|
||||
//EFI_STATUS GetElement( TagPtr dict, INTN id, TagPtr *dict1);
|
||||
//INTN GetTagCount( TagPtr dict );
|
||||
EFI_STATUS ParseTagDict( CHAR8* buffer, TagStruct* * tag, UINT32 empty, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagArray( CHAR8* buffer, TagStruct* * tag, UINT32 empty, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagKey( char * buffer, TagStruct* * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagString(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagFloat(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagData(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagDate(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr);
|
||||
EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagStruct* * tag, bool value, UINT32* lenPtr);
|
||||
|
||||
TagPtr NewTag( void );
|
||||
EFI_STATUS XMLParseNextTag (CHAR8 *buffer, TagStruct**tag, UINT32 *lenPtr);
|
||||
|
||||
TagStruct* NewTag( void );
|
||||
EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag,UINT32* lenPtr);
|
||||
|
||||
/* Function for basic XML character entities parsing */
|
||||
@ -171,56 +181,53 @@ XMLDecode(CHAR8* src)
|
||||
return out;
|
||||
}
|
||||
|
||||
INTN GetTagCount( TagPtr dict )
|
||||
INTN GetTagCount(const TagStruct* dict )
|
||||
{
|
||||
INTN count = 0;
|
||||
TagPtr tagList, tag;
|
||||
|
||||
if ( !dict || (!dict->isDict() && !dict->isArray()) ) {
|
||||
if ( !dict ) return 0;
|
||||
|
||||
if ( dict->isArray() ) {
|
||||
return dict->dictOrArrayContent().size(); // If we are an array, any element is valid
|
||||
}else
|
||||
if ( dict->isDict() ) {
|
||||
const XObjArray<TagStruct>& tagList = dict->dictOrArrayContent();
|
||||
for (size_t tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ ) {
|
||||
if ( tagList[tagIdx].isKey() ) count++;
|
||||
}
|
||||
return count;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
tag = 0;
|
||||
tagList = dict->dictOrArrayTagValue();
|
||||
while (tagList)
|
||||
{
|
||||
tag = tagList;
|
||||
tagList = tag->nextTagValue();
|
||||
|
||||
if ( (dict->isDict() && tag->isKey()) ||
|
||||
dict->isArray() // If we are an array, any element is valid
|
||||
)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
//if(tag->type == kTagTypeKey) printf("Located key %s\n", tag->stringValue());
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
EFI_STATUS GetElement( TagPtr dict, INTN id, TagPtr * dict1)
|
||||
EFI_STATUS GetElement(const TagStruct* dict, INTN id, const TagStruct** dict1)
|
||||
{
|
||||
INTN element = 0;
|
||||
TagPtr child;
|
||||
|
||||
if( !dict || (!dict->isArray() && !dict->isDict()) ) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
if ( !dict ) return EFI_UNSUPPORTED;
|
||||
if ( id < 0 ) return EFI_UNSUPPORTED;
|
||||
|
||||
child = dict->dictOrArrayTagValue();
|
||||
while (child != NULL)
|
||||
{
|
||||
if ( (dict->isDict() && child->isKey()) || //in Dict count Keys
|
||||
dict->isArray() // If we are an array, any element is valid
|
||||
)
|
||||
{
|
||||
if (element++ >= id) break;
|
||||
}
|
||||
child = child->nextTagValue();
|
||||
if ( dict->isArray() ) {
|
||||
if ( (size_t)id < dict->dictOrArrayContent().size() ) {
|
||||
*dict1 = &dict->dictOrArrayContent()[id];
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}else
|
||||
if ( dict->isDict() ) {
|
||||
const XObjArray<TagStruct>& tagList = dict->dictOrArrayContent();
|
||||
size_t tagIdx;
|
||||
for (tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ ) {
|
||||
if ( tagList[tagIdx].isKey() ) {
|
||||
if ( element == id ) {
|
||||
*dict1 = &tagList[tagIdx];
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
element++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*dict1 = child;
|
||||
return EFI_SUCCESS;
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
// Expects to see one dictionary in the XML file, the final pos will be returned
|
||||
@ -229,12 +236,12 @@ EFI_STATUS GetElement( TagPtr dict, INTN id, TagPtr * dict1)
|
||||
// tag pointer and returns the end of the dic, or returns -1 if not found.
|
||||
//
|
||||
|
||||
EFI_STATUS ParseXML(const CHAR8* buffer, TagPtr * dict, UINT32 bufSize)
|
||||
EFI_STATUS ParseXML(const CHAR8* buffer, TagStruct** dict, UINT32 bufSize)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 length = 0;
|
||||
UINT32 pos = 0;
|
||||
TagPtr tag = NULL;
|
||||
TagStruct* tag = NULL;
|
||||
CHAR8* configBuffer = NULL;
|
||||
UINT32 bufferSize = 0;
|
||||
UINTN i;
|
||||
@ -301,26 +308,22 @@ EFI_STATUS ParseXML(const CHAR8* buffer, TagPtr * dict, UINT32 bufSize)
|
||||
//==========================================================================
|
||||
// GetProperty
|
||||
|
||||
TagPtr GetProperty( TagPtr dict, const CHAR8* key )
|
||||
const TagStruct* GetProperty(const TagStruct* dict, const CHAR8* key )
|
||||
{
|
||||
if ( !dict->isDict() ) return NULL;
|
||||
|
||||
TagPtr tag = NULL;
|
||||
TagPtr tagList = dict->dictOrArrayTagValue();
|
||||
while (tagList)
|
||||
const XObjArray<TagStruct>& tagList = dict->dictOrArrayContent();
|
||||
for (size_t tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ )
|
||||
{
|
||||
tag = tagList;
|
||||
tagList = tag->nextTagValue();
|
||||
|
||||
if ( tag->isKey() && tag->keyValue().equalIC(key) ) return tag->keyTagValue();
|
||||
if ( tagList[tagIdx].isKey() && tagList[tagIdx].keyValue().equalIC(key) ) return tagList[tagIdx].keyTagValue();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//TagPtr GetNextProperty(TagPtr dict)
|
||||
//TagStruct* GetNextProperty(TagStruct* dict)
|
||||
//{
|
||||
// TagPtr tagList, tag;
|
||||
// TagStruct* tagList, tag;
|
||||
//
|
||||
// if (dict->isDict()) {
|
||||
// return NULL;
|
||||
@ -348,7 +351,7 @@ TagPtr GetProperty( TagPtr dict, const CHAR8* key )
|
||||
//==========================================================================
|
||||
// ParseNextTag
|
||||
|
||||
EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagPtr* tag, UINT32* lenPtr)
|
||||
EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagStruct** tag, UINT32* lenPtr)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 length = 0;
|
||||
@ -484,13 +487,11 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagPtr* tag, UINT32* lenPtr)
|
||||
//==========================================================================
|
||||
// ParseTagList
|
||||
|
||||
EFI_STATUS __ParseTagList(bool isArray, CHAR8* buffer, TagPtr* tag, UINT32 empty, UINT32* lenPtr)
|
||||
EFI_STATUS __ParseTagList(bool isArray, CHAR8* buffer, TagStruct** tag, UINT32 empty, UINT32* lenPtr)
|
||||
{
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
UINT32 pos;
|
||||
TagPtr tagList;
|
||||
TagPtr tagTail;
|
||||
TagPtr tmpTag = NULL;
|
||||
TagStruct* tagTail;
|
||||
UINT32 length = 0;
|
||||
|
||||
if (isArray) {
|
||||
@ -498,13 +499,21 @@ EFI_STATUS __ParseTagList(bool isArray, CHAR8* buffer, TagPtr* tag, UINT32 empty
|
||||
} else {
|
||||
DBG("parsing dict len=%d\n", *lenPtr);
|
||||
}
|
||||
tagList = NULL;
|
||||
tagTail = NULL;
|
||||
pos = 0;
|
||||
|
||||
TagStruct* dictOrArrayTag = NewTag();
|
||||
if (isArray) {
|
||||
dictOrArrayTag->setArrayTagValue(NULL);
|
||||
} else {
|
||||
dictOrArrayTag->setDictTagValue(NULL);
|
||||
}
|
||||
XObjArray<TagStruct>& tagList = dictOrArrayTag->dictOrArrayContent();
|
||||
|
||||
if (!empty) {
|
||||
while (TRUE) {
|
||||
Status = XMLParseNextTag(buffer + pos, &tmpTag, &length);
|
||||
TagStruct* newDictOrArrayTag = NULL;
|
||||
Status = XMLParseNextTag(buffer + pos, &newDictOrArrayTag, &length);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DBG("error XMLParseNextTag in array: %s\n", strerror(Status));
|
||||
break;
|
||||
@ -512,53 +521,31 @@ EFI_STATUS __ParseTagList(bool isArray, CHAR8* buffer, TagPtr* tag, UINT32 empty
|
||||
|
||||
pos += length;
|
||||
|
||||
if (tmpTag == NULL) {
|
||||
if (newDictOrArrayTag == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (tagTail) {
|
||||
tagTail->setNextTagValue(tmpTag);
|
||||
} else {
|
||||
tagList = tmpTag;
|
||||
}
|
||||
tagTail = tmpTag;
|
||||
tagList.AddReference(newDictOrArrayTag, true);
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (tagList) {
|
||||
FreeTag(tagList);
|
||||
}
|
||||
FreeTag(dictOrArrayTag);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
tmpTag = NewTag();
|
||||
if (tmpTag == NULL) {
|
||||
if (tagList) {
|
||||
FreeTag(tagList);
|
||||
}
|
||||
DBG("next tag is NULL\n");
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
if (isArray) {
|
||||
tmpTag->setArrayTagValue(tagList);
|
||||
} else {
|
||||
tmpTag->setDictTagValue(tagList);
|
||||
}
|
||||
|
||||
*tag = tmpTag;
|
||||
*tag = dictOrArrayTag;
|
||||
*lenPtr=pos;
|
||||
DBG(" return from ParseTagList with len=%d\n", *lenPtr);
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS ParseTagDict( CHAR8* buffer, TagPtr* tag, UINT32 empty, UINT32* lenPtr)
|
||||
EFI_STATUS ParseTagDict( CHAR8* buffer, TagStruct** tag, UINT32 empty, UINT32* lenPtr)
|
||||
{
|
||||
return __ParseTagList(false, buffer, tag, empty, lenPtr);
|
||||
}
|
||||
|
||||
EFI_STATUS ParseTagArray( CHAR8* buffer, TagPtr* tag, UINT32 empty, UINT32* lenPtr)
|
||||
EFI_STATUS ParseTagArray( CHAR8* buffer, TagStruct** tag, UINT32 empty, UINT32* lenPtr)
|
||||
{
|
||||
return __ParseTagList(true, buffer, tag, empty, lenPtr);
|
||||
}
|
||||
@ -566,13 +553,13 @@ EFI_STATUS ParseTagArray( CHAR8* buffer, TagPtr* tag, UINT32 empty, UINT32* lenP
|
||||
//==========================================================================
|
||||
// ParseTagKey
|
||||
|
||||
EFI_STATUS ParseTagKey( char * buffer, TagPtr* tag, UINT32* lenPtr)
|
||||
EFI_STATUS ParseTagKey( char * buffer, TagStruct** tag, UINT32* lenPtr)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 length = 0;
|
||||
UINT32 length2 = 0;
|
||||
TagPtr tmpTag;
|
||||
TagPtr subTag = NULL;
|
||||
TagStruct* tmpTag;
|
||||
TagStruct* subTag = NULL;
|
||||
|
||||
Status = FixDataMatchingTag(buffer, kXMLTagKey, &length);
|
||||
DBG("fixing key len=%d status=%s\n", length, strerror(Status));
|
||||
@ -596,11 +583,11 @@ EFI_STATUS ParseTagKey( char * buffer, TagPtr* tag, UINT32* lenPtr)
|
||||
//==========================================================================
|
||||
// ParseTagString
|
||||
|
||||
EFI_STATUS ParseTagString(CHAR8* buffer, TagPtr * tag,UINT32* lenPtr)
|
||||
EFI_STATUS ParseTagString(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 length = 0;
|
||||
TagPtr tmpTag;
|
||||
TagStruct* tmpTag;
|
||||
|
||||
Status = FixDataMatchingTag(buffer, kXMLTagString, &length);
|
||||
if (EFI_ERROR(Status)) {
|
||||
@ -622,7 +609,7 @@ EFI_STATUS ParseTagString(CHAR8* buffer, TagPtr * tag,UINT32* lenPtr)
|
||||
//==========================================================================
|
||||
// ParseTagInteger
|
||||
|
||||
EFI_STATUS ParseTagInteger(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr)
|
||||
EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 length = 0;
|
||||
@ -630,7 +617,7 @@ EFI_STATUS ParseTagInteger(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr)
|
||||
UINT32 size;
|
||||
BOOLEAN negative = FALSE;
|
||||
CHAR8* val = buffer;
|
||||
TagPtr tmpTag;
|
||||
TagStruct* tmpTag;
|
||||
|
||||
Status = FixDataMatchingTag(buffer, kXMLTagInteger, &length);
|
||||
if (EFI_ERROR(Status)) {
|
||||
@ -704,11 +691,11 @@ EFI_STATUS ParseTagInteger(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr)
|
||||
//==========================================================================
|
||||
// ParseTagFloat
|
||||
|
||||
EFI_STATUS ParseTagFloat(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr)
|
||||
EFI_STATUS ParseTagFloat(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 length;
|
||||
TagPtr tmpTag;
|
||||
TagStruct* tmpTag;
|
||||
|
||||
Status = FixDataMatchingTag(buffer, kXMLTagFloat, &length);
|
||||
if (EFI_ERROR(Status)) {
|
||||
@ -733,11 +720,11 @@ EFI_STATUS ParseTagFloat(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr)
|
||||
//==========================================================================
|
||||
// ParseTagData
|
||||
|
||||
EFI_STATUS ParseTagData(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr)
|
||||
EFI_STATUS ParseTagData(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 length = 0;
|
||||
TagPtr tmpTag;
|
||||
TagStruct* tmpTag;
|
||||
|
||||
Status = FixDataMatchingTag(buffer, kXMLTagData,&length);
|
||||
if (EFI_ERROR(Status)) {
|
||||
@ -764,11 +751,11 @@ EFI_STATUS ParseTagData(CHAR8* buffer, TagPtr * tag, UINT32* lenPtr)
|
||||
//==========================================================================
|
||||
// ParseTagDate
|
||||
|
||||
EFI_STATUS ParseTagDate(CHAR8* buffer, TagPtr * tag,UINT32* lenPtr)
|
||||
EFI_STATUS ParseTagDate(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 length = 0;
|
||||
TagPtr tmpTag;
|
||||
TagStruct* tmpTag;
|
||||
|
||||
Status = FixDataMatchingTag(buffer, kXMLTagDate,&length);
|
||||
if (EFI_ERROR(Status)) {
|
||||
@ -792,9 +779,9 @@ EFI_STATUS ParseTagDate(CHAR8* buffer, TagPtr * tag,UINT32* lenPtr)
|
||||
//==========================================================================
|
||||
// ParseTagBoolean
|
||||
|
||||
EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagPtr * tag, bool value, UINT32* lenPtr)
|
||||
EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagStruct* * tag, bool value, UINT32* lenPtr)
|
||||
{
|
||||
TagPtr tmpTag;
|
||||
TagStruct* tmpTag;
|
||||
|
||||
tmpTag = NewTag();
|
||||
if (tmpTag == NULL) {
|
||||
@ -898,9 +885,9 @@ EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag, UINT32* lenPtr)
|
||||
//==========================================================================
|
||||
// NewTag
|
||||
|
||||
TagPtr NewTag( void )
|
||||
TagStruct* NewTag( void )
|
||||
{
|
||||
TagPtr tag;
|
||||
TagStruct* tag;
|
||||
|
||||
if ( gTagsFree.size() > 0 ) {
|
||||
tag = &gTagsFree[0];
|
||||
@ -914,7 +901,7 @@ TagPtr NewTag( void )
|
||||
//==========================================================================
|
||||
// XMLFreeTag
|
||||
|
||||
void FreeTag( TagPtr tag )
|
||||
void FreeTag( TagStruct* tag )
|
||||
{
|
||||
if (tag == NULL) {
|
||||
return;
|
||||
@ -931,7 +918,7 @@ void FreeTag( TagPtr tag )
|
||||
else return FALSE
|
||||
*/
|
||||
BOOLEAN
|
||||
IsPropertyTrue(TagPtr Prop)
|
||||
IsPropertyTrue(const TagStruct* Prop)
|
||||
{
|
||||
return Prop != NULL && Prop->isTrueOrYy();
|
||||
}
|
||||
@ -941,7 +928,7 @@ IsPropertyTrue(TagPtr Prop)
|
||||
else return FALSE
|
||||
*/
|
||||
BOOLEAN
|
||||
IsPropertyFalse(TagPtr Prop)
|
||||
IsPropertyFalse(const TagStruct* Prop)
|
||||
{
|
||||
return Prop != NULL && Prop->isFalseOrNn();
|
||||
}
|
||||
@ -955,7 +942,7 @@ IsPropertyFalse(TagPtr Prop)
|
||||
*/
|
||||
INTN
|
||||
GetPropertyInteger(
|
||||
TagPtr Prop,
|
||||
const TagStruct* Prop,
|
||||
INTN Default
|
||||
)
|
||||
{
|
||||
@ -980,7 +967,7 @@ GetPropertyInteger(
|
||||
return Default;
|
||||
}
|
||||
|
||||
float GetPropertyFloat (TagPtr Prop, float Default)
|
||||
float GetPropertyFloat (const TagStruct* Prop, float Default)
|
||||
{
|
||||
if (Prop == NULL) {
|
||||
return Default;
|
||||
|
@ -45,47 +45,55 @@ extern XObjArray<TagStruct> gTagsFree;
|
||||
|
||||
class TagStruct
|
||||
{
|
||||
UINTN type; // type is private. Use is... functions.
|
||||
UINTN type; // type is private. Use is...() functions.
|
||||
XString8 _string;
|
||||
INTN _intValue;
|
||||
float _floatValue;
|
||||
UINT8 *_data;
|
||||
UINTN _dataLen;
|
||||
TagStruct *_tag;
|
||||
TagStruct *_nextTag;
|
||||
XObjArray<TagStruct> _dictOrArrayContent;
|
||||
|
||||
public:
|
||||
|
||||
TagStruct() : type(kTagTypeNone), _string(), _intValue(0), _floatValue(0), _data(0), _dataLen(0), /*offset(0), */_tag(NULL), _nextTag(NULL) {}
|
||||
TagStruct() : type(kTagTypeNone), _string(), _intValue(0), _floatValue(0), _data(0), _dataLen(0), /*offset(0), */_tag(NULL), _dictOrArrayContent() {}
|
||||
TagStruct(const TagStruct& other) = delete; // Can be defined if needed
|
||||
const TagStruct& operator = ( const TagStruct & ) = delete; // Can be defined if needed
|
||||
~TagStruct() {}
|
||||
~TagStruct() { delete _data; delete _tag; }
|
||||
|
||||
void FreeTag();
|
||||
|
||||
// Property<XString8> string();
|
||||
bool isDict() { return type == kTagTypeDict; }
|
||||
bool isKey() { return type == kTagTypeKey; }
|
||||
bool isString() { return type == kTagTypeString; }
|
||||
bool isInt() { return type == kTagTypeInteger; }
|
||||
bool isFloat() { return type == kTagTypeFloat; }
|
||||
bool isBool() { return type == kTagTypeTrue || type == kTagTypeFalse; }
|
||||
bool isData() { return type == kTagTypeData; }
|
||||
bool isDate() { return type == kTagTypeDate; }
|
||||
bool isArray() { return type == kTagTypeArray; }
|
||||
bool isDict() const { return type == kTagTypeDict; }
|
||||
bool isKey() const { return type == kTagTypeKey; }
|
||||
bool isString() const { return type == kTagTypeString; }
|
||||
bool isInt() const { return type == kTagTypeInteger; }
|
||||
bool isFloat() const { return type == kTagTypeFloat; }
|
||||
bool isBool() const { return type == kTagTypeTrue || type == kTagTypeFalse; }
|
||||
bool isData() const { return type == kTagTypeData; }
|
||||
bool isDate() const { return type == kTagTypeDate; }
|
||||
bool isArray() const { return type == kTagTypeArray; }
|
||||
|
||||
TagStruct* nextTagValue()
|
||||
const XObjArray<TagStruct>& dictOrArrayContent() const
|
||||
{
|
||||
return _nextTag;
|
||||
if ( isDict() ) return _dictOrArrayContent;
|
||||
if ( isArray() ) return _dictOrArrayContent;
|
||||
panic("TagStruct::dictOrArrayTagValue() : !isDict() && isArray() ");
|
||||
}
|
||||
void setNextTagValue(TagStruct* nextTag)
|
||||
XObjArray<TagStruct>& dictOrArrayContent()
|
||||
{
|
||||
if ( nextTag == NULL ) panic("TagStruct::setDictNextTagValue() : nextTag == NULL ");
|
||||
if ( _nextTag != NULL ) panic("TagStruct::setDictNextTagValue() : _nextTag != NULL ");
|
||||
_nextTag = nextTag;
|
||||
if ( isDict() ) return _dictOrArrayContent;
|
||||
if ( isArray() ) return _dictOrArrayContent;
|
||||
panic("TagStruct::dictOrArrayTagValue() : !isDict() && isArray() ");
|
||||
}
|
||||
// void setNextTagValue(TagStruct* nextTag)
|
||||
// {
|
||||
// if ( nextTag == NULL ) panic("TagStruct::setDictNextTagValue() : nextTag == NULL ");
|
||||
// if ( _nextTag != NULL ) panic("TagStruct::setDictNextTagValue() : _nextTag != NULL ");
|
||||
// _nextTag = nextTag;
|
||||
// }
|
||||
|
||||
const XString8 getTypeAsXString8() {
|
||||
const XString8 getTypeAsXString8() const {
|
||||
if ( isDict() ) return "Dict"_XS8;
|
||||
if ( isKey() ) return "Dict"_XS8;
|
||||
if ( isString() ) return "Dict"_XS8;
|
||||
@ -99,6 +107,11 @@ public:
|
||||
}
|
||||
|
||||
// getter and setter
|
||||
const UINT8* dataValue() const
|
||||
{
|
||||
if ( !isData() ) panic("TagStruct::dataValue() : !isData() ");
|
||||
return _data;
|
||||
}
|
||||
UINT8* dataValue()
|
||||
{
|
||||
if ( !isData() ) panic("TagStruct::dataValue() : !isData() ");
|
||||
@ -109,7 +122,7 @@ public:
|
||||
if ( !isData() ) panic("TagStruct::dataStringValue() : !isData() ");
|
||||
return _string;
|
||||
}
|
||||
UINTN dataLenValue()
|
||||
UINTN dataLenValue() const
|
||||
{
|
||||
if ( !isData() ) panic("TagStruct::dataLenValue() : !isData() ");
|
||||
return _dataLen;
|
||||
@ -144,9 +157,8 @@ public:
|
||||
// empty dict is allowed
|
||||
//if ( tagList == NULL ) panic("TagStruct::setDictTagValue() : tagList == NULL ");
|
||||
if ( _tag != NULL ) panic("TagStruct::setDictTagValue() : _tag != NULL ");
|
||||
if ( _nextTag != NULL ) panic("TagStruct::setDictTagValue() : _nextTag != NULL ");
|
||||
if ( _dictOrArrayContent.notEmpty() ) panic("TagStruct::setDictTagValue() : __dictOrArrayContent.notEmpty() ");
|
||||
_tag = tagList;
|
||||
_nextTag = NULL;
|
||||
type = kTagTypeDict;
|
||||
}
|
||||
|
||||
@ -160,17 +172,23 @@ public:
|
||||
// Array value with tagList = NULL is allowed
|
||||
//if ( tag == NULL ) panic("TagStruct::setArrayValue() : tag == NULL ");
|
||||
if ( _tag != NULL ) panic("TagStruct::setArrayValue() : _tag != NULL ");
|
||||
if ( _nextTag != NULL ) panic("TagStruct::setArrayTagValue() : _nextTag != NULL ");
|
||||
if ( _dictOrArrayContent.notEmpty() ) panic("TagStruct::setArrayTagValue() : __dictOrArrayContent.notEmpty() ");
|
||||
_tag = tag;
|
||||
type = kTagTypeArray;
|
||||
}
|
||||
|
||||
|
||||
const XString8& keyValue() const
|
||||
{
|
||||
if ( !isKey() ) panic("TagStruct::keyValue() : !isKey() ");
|
||||
return _string;
|
||||
}
|
||||
XString8& keyValue()
|
||||
{
|
||||
if ( !isKey() ) panic("TagStruct::keyValue() : !isKey() ");
|
||||
return _string;
|
||||
}
|
||||
TagStruct* keyTagValue()
|
||||
const TagStruct* keyTagValue() const
|
||||
{
|
||||
if ( !isKey() ) panic("TagStruct::keyTagValue() : !isKey() ");
|
||||
return _tag;
|
||||
@ -183,7 +201,12 @@ public:
|
||||
_tag = subTag;
|
||||
}
|
||||
|
||||
const XString8& stringValue()
|
||||
const XString8& stringValue() const
|
||||
{
|
||||
if ( !isString() ) panic("TagStruct::stringValue() : !isString() ");
|
||||
return _string;
|
||||
}
|
||||
XString8& stringValue()
|
||||
{
|
||||
if ( !isString() ) panic("TagStruct::stringValue() : !isString() ");
|
||||
return _string;
|
||||
@ -196,7 +219,7 @@ public:
|
||||
_string = xstring;
|
||||
}
|
||||
|
||||
INTN intValue()
|
||||
INTN intValue() const
|
||||
{
|
||||
if ( !isInt() ) panic("TagStruct::intValue() : !isInt() ");
|
||||
return _intValue;
|
||||
@ -207,7 +230,7 @@ public:
|
||||
_intValue = i;
|
||||
}
|
||||
|
||||
float floatValue()
|
||||
float floatValue() const
|
||||
{
|
||||
if ( !isFloat() ) panic("TagStruct::floatValue() : !isFloat() ");
|
||||
return _floatValue;
|
||||
@ -218,7 +241,7 @@ public:
|
||||
_floatValue = f;
|
||||
}
|
||||
|
||||
INTN boolValue()
|
||||
INTN boolValue() const
|
||||
{
|
||||
if ( !isBool() ) panic("TagStruct::boolValue() : !isBool() ");
|
||||
return type == kTagTypeTrue;
|
||||
@ -230,29 +253,29 @@ public:
|
||||
}
|
||||
|
||||
// Convenience method
|
||||
bool isTrue()
|
||||
bool isTrue() const
|
||||
{
|
||||
if ( isBool() ) return boolValue();
|
||||
return false;
|
||||
}
|
||||
bool isFalse()
|
||||
bool isFalse() const
|
||||
{
|
||||
if ( isBool() ) return !boolValue();
|
||||
return false;
|
||||
}
|
||||
bool isTrueOrYy()
|
||||
bool isTrueOrYy() const
|
||||
{
|
||||
if ( isBool() ) return boolValue();
|
||||
if ( isString() && stringValue().notEmpty() && (stringValue()[0] == 'y' || stringValue()[0] == 'Y') ) return true;
|
||||
return false;
|
||||
}
|
||||
bool isTrueOrYes()
|
||||
bool isTrueOrYes() const
|
||||
{
|
||||
if ( isBool() ) return boolValue();
|
||||
if ( isString() && stringValue().equal("Yes"_XS8) ) return true;
|
||||
return false;
|
||||
}
|
||||
bool isFalseOrNn()
|
||||
bool isFalseOrNn() const
|
||||
{
|
||||
if ( isBool() ) return !boolValue();
|
||||
if ( isString() && stringValue().notEmpty() && (stringValue()[0] == 'n' || stringValue()[0] == 'N') ) return true;
|
||||
@ -266,15 +289,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
typedef TagStruct* TagPtr;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
float fNum; //4 bytes
|
||||
UINT32 pad; // else 4
|
||||
} B;
|
||||
CHAR8 *string;
|
||||
} FlMix;
|
||||
//typedef union {
|
||||
// struct {
|
||||
// float fNum; //4 bytes
|
||||
// UINT32 pad; // else 4
|
||||
// } B;
|
||||
// CHAR8 *string;
|
||||
//} FlMix;
|
||||
|
||||
|
||||
CHAR8*
|
||||
@ -285,29 +306,24 @@ XMLDecode (
|
||||
EFI_STATUS
|
||||
ParseXML(
|
||||
CONST CHAR8 *buffer,
|
||||
TagPtr *dict,
|
||||
TagStruct* *dict,
|
||||
UINT32 bufSize
|
||||
);
|
||||
|
||||
|
||||
//VOID RenderSVGfont(NSVGfont *fontSVG);
|
||||
|
||||
TagPtr
|
||||
const TagStruct*
|
||||
GetProperty(
|
||||
TagPtr dict,
|
||||
const TagStruct* dict,
|
||||
CONST CHAR8* key
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
XMLParseNextTag (
|
||||
CHAR8 *buffer,
|
||||
TagPtr *tag,
|
||||
UINT32 *lenPtr
|
||||
);
|
||||
TagStruct* NewTag( void );
|
||||
|
||||
VOID
|
||||
FreeTag (
|
||||
TagPtr tag
|
||||
TagStruct* tag
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
@ -320,33 +336,33 @@ GetNextTag (
|
||||
|
||||
INTN
|
||||
GetTagCount (
|
||||
TagPtr dict
|
||||
const TagStruct* dict
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
GetElement(
|
||||
TagPtr dict,
|
||||
const TagStruct* dict,
|
||||
INTN id,
|
||||
TagPtr *dict1
|
||||
const TagStruct** dict1
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
IsPropertyTrue(
|
||||
TagPtr Prop
|
||||
const TagStruct* Prop
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
IsPropertyFalse(
|
||||
TagPtr Prop
|
||||
const TagStruct* Prop
|
||||
);
|
||||
|
||||
INTN
|
||||
GetPropertyInteger(
|
||||
TagPtr Prop,
|
||||
const TagStruct* Prop,
|
||||
INTN Default
|
||||
);
|
||||
|
||||
float GetPropertyFloat (TagPtr Prop, float Default);
|
||||
float GetPropertyFloat (const TagStruct* Prop, float Default);
|
||||
|
||||
|
||||
#endif /* PLATFORM_PLIST_H_ */
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "XIcon.h"
|
||||
#include "XCinema.h"
|
||||
|
||||
class TagStruct;
|
||||
|
||||
#define INDICATOR_SIZE (52)
|
||||
|
||||
class XTheme
|
||||
@ -141,11 +143,11 @@ public:
|
||||
// void AddIcon(XIcon& NewIcon); //return EFI_STATUS?
|
||||
void FillByEmbedded();
|
||||
void FillByDir();
|
||||
EFI_STATUS GetThemeTagSettings(void* DictPointer);
|
||||
EFI_STATUS GetThemeTagSettings(const TagStruct* DictPointer);
|
||||
void parseTheme(void* p, const char** dict); //in nano project
|
||||
EFI_STATUS ParseSVGXTheme(const CHAR8* buffer); // in VectorTheme
|
||||
EFI_STATUS ParseSVGXIcon(INTN Id, const XString8& IconNameX, XImage* Image, void **SVGIcon);
|
||||
void* LoadTheme(const XStringW& TestTheme); //return TagPtr why?
|
||||
TagStruct* LoadTheme(const XStringW& TestTheme); //return TagStruct* why?
|
||||
EFI_STATUS LoadSvgFrame(INTN i, OUT XImage* XFrame); // for animation
|
||||
|
||||
//screen operations
|
||||
|
@ -571,7 +571,7 @@ VOID LOADER_ENTRY::StartLoader()
|
||||
EFI_HANDLE ImageHandle = NULL;
|
||||
EFI_LOADED_IMAGE *LoadedImage = NULL;
|
||||
CONST CHAR8 *InstallerVersion;
|
||||
TagPtr dict = NULL;
|
||||
TagStruct* dict = NULL;
|
||||
UINTN i;
|
||||
NSVGfont *font; // , *nextFont;
|
||||
|
||||
@ -1801,8 +1801,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
//UINT64 TscRemainder = 0;
|
||||
// LOADER_ENTRY *LoaderEntry;
|
||||
XStringW ConfName;
|
||||
TagPtr smbiosTags = NULL;
|
||||
TagPtr UniteTag = NULL;
|
||||
TagStruct* smbiosTags = NULL;
|
||||
BOOLEAN UniteConfigs = FALSE;
|
||||
EFI_TIME Now;
|
||||
BOOLEAN HaveDefaultVolume;
|
||||
@ -1953,7 +1952,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
}
|
||||
}
|
||||
if (gConfigDict[1]) {
|
||||
UniteTag = GetProperty(gConfigDict[1], "Unite");
|
||||
const TagStruct* UniteTag = GetProperty(gConfigDict[1], "Unite");
|
||||
if(UniteTag) {
|
||||
UniteConfigs = UniteTag->isTrueOrYy();
|
||||
DBG("UniteConfigs = %ls", UniteConfigs ? L"TRUE\n": L"FALSE\n" );
|
||||
@ -2219,7 +2218,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
// }
|
||||
// Load any extra SMBIOS information
|
||||
if (!EFI_ERROR(LoadUserSettings(SelfRootDir, L"smbios"_XSW, &smbiosTags)) && (smbiosTags != NULL)) {
|
||||
TagPtr dictPointer = GetProperty(smbiosTags,"SMBIOS");
|
||||
const TagStruct* dictPointer = GetProperty(smbiosTags,"SMBIOS");
|
||||
if (dictPointer) {
|
||||
ParseSMBIOSSettings(dictPointer);
|
||||
} else {
|
||||
|
@ -474,7 +474,7 @@ VOID ApplyInputs(VOID)
|
||||
// UINT32 k;
|
||||
CHAR16 *ch;
|
||||
CHAR8 AString[256];
|
||||
TagPtr dict;
|
||||
|
||||
// DBG("ApplyInputs\n");
|
||||
if (InputItems[i].Valid) {
|
||||
ZeroMem(&gSettings.BootArgs, 256);
|
||||
@ -863,6 +863,7 @@ VOID ApplyInputs(VOID)
|
||||
|
||||
i++; //90
|
||||
if (InputItems[i].Valid) {
|
||||
TagStruct* dict;
|
||||
Status = LoadUserSettings(SelfRootDir, XStringW(ConfigsList[OldChosenConfig]), &dict);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
gBootChanged = TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user