mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OcXmlLib: Add plist doctype export option
This commit is contained in:
parent
2b53436062
commit
cbdef704f4
@ -137,9 +137,10 @@ XmlDocumentParse (
|
||||
//
|
||||
// Exports parsed document into the buffer.
|
||||
//
|
||||
// @param Document XML_DOCUMENT to export
|
||||
// @param Length Resulting length of the buffer without trailing \0 (optional)
|
||||
// @param Skip N root levels before exporting, normally 0.
|
||||
// @param Document XML_DOCUMENT to export
|
||||
// @param Length Resulting length of the buffer without trailing \0 (optional)
|
||||
// @param Skip N root levels before exporting, normally 0.
|
||||
// @param PrependPlistInfo Prepend XML plist doc info to exported document.
|
||||
//
|
||||
// @return Exported buffer allocated from pool or NULL.
|
||||
//
|
||||
@ -147,7 +148,8 @@ CHAR8 *
|
||||
XmlDocumentExport (
|
||||
XML_DOCUMENT *Document,
|
||||
UINT32 *Length,
|
||||
UINT32 Skip
|
||||
UINT32 Skip,
|
||||
BOOLEAN PrependPlistInfo
|
||||
);
|
||||
|
||||
//
|
||||
|
||||
@ -668,7 +668,7 @@ PrelinkedInjectComplete (
|
||||
}
|
||||
}
|
||||
|
||||
ExportedInfo = XmlDocumentExport (Context->PrelinkedInfoDocument, &ExportedInfoSize, 0);
|
||||
ExportedInfo = XmlDocumentExport (Context->PrelinkedInfoDocument, &ExportedInfoSize, 0, FALSE);
|
||||
if (ExportedInfo == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -1002,7 +1002,7 @@ PrelinkedInjectKext (
|
||||
//
|
||||
// Strip outer plist & dict.
|
||||
//
|
||||
NewInfoPlist = XmlDocumentExport (InfoPlistDocument, &NewInfoPlistSize, 2);
|
||||
NewInfoPlist = XmlDocumentExport (InfoPlistDocument, &NewInfoPlistSize, 2, FALSE);
|
||||
|
||||
XmlDocumentFree (InfoPlistDocument);
|
||||
FreePool (TmpInfoPlist);
|
||||
|
||||
@ -52,6 +52,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
//
|
||||
#define XML_EXPORT_MIN_ALLOCATION_SIZE 4096
|
||||
|
||||
#define XML_PLIST_HEADER "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"
|
||||
|
||||
struct XML_NODE_LIST_;
|
||||
struct XML_PARSER_;
|
||||
|
||||
@ -1146,22 +1148,36 @@ CHAR8 *
|
||||
XmlDocumentExport (
|
||||
XML_DOCUMENT *Document,
|
||||
UINT32 *Length,
|
||||
UINT32 Skip
|
||||
UINT32 Skip,
|
||||
BOOLEAN PrependPlistInfo
|
||||
)
|
||||
{
|
||||
CHAR8 *Buffer;
|
||||
CHAR8 *BufferXmlContent;
|
||||
UINT32 AllocSize;
|
||||
UINT32 CurrentSize;
|
||||
|
||||
AllocSize = Document->Buffer.Length + 1;
|
||||
Buffer = AllocatePool (AllocSize);
|
||||
if (PrependPlistInfo && OcOverflowAddU32 (AllocSize, L_STR_SIZE_NT (XML_PLIST_HEADER), &AllocSize)) {
|
||||
return NULL;
|
||||
}
|
||||
Buffer = AllocatePool (AllocSize);
|
||||
if (Buffer == NULL) {
|
||||
XML_USAGE_ERROR ("XmlDocumentExport::failed to allocate");
|
||||
return NULL;
|
||||
}
|
||||
BufferXmlContent = PrependPlistInfo ? &Buffer[L_STR_LEN (XML_PLIST_HEADER)] : Buffer;
|
||||
|
||||
CurrentSize = 0;
|
||||
XmlNodeExportRecursive (Document->Root, &Buffer, &AllocSize, &CurrentSize, Skip);
|
||||
XmlNodeExportRecursive (Document->Root, &BufferXmlContent, &AllocSize, &CurrentSize, Skip);
|
||||
|
||||
if (PrependPlistInfo) {
|
||||
if (OcOverflowAddU32 (CurrentSize, L_STR_SIZE_NT (XML_PLIST_HEADER), &CurrentSize)) {
|
||||
FreePool (Buffer);
|
||||
return NULL;
|
||||
}
|
||||
CopyMem (Buffer, XML_PLIST_HEADER, L_STR_SIZE_NT (XML_PLIST_HEADER));
|
||||
}
|
||||
|
||||
if (Length != NULL) {
|
||||
*Length = CurrentSize;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user