OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcXmlLib.c File Reference
#include <Library/OcXmlLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcStringLib.h>

Go to the source code of this file.

Data Structures

struct  XML_NODE_
 
struct  XML_NODE_LIST_
 
struct  XML_REFLIST
 
struct  XML_DOCUMENT_
 
struct  XML_PARSER_
 

Macros

#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\">"
 
#define XML_PARSER_INFO(Parser, Message)
 
#define XML_PARSER_TAG(Parser, Tag)
 
#define XML_PARSER_ERROR(Parser, Offset, Message)
 
#define XML_USAGE_ERROR(X)
 

Typedefs

typedef struct XML_NODE_LIST_ XML_NODE_LIST
 
typedef struct XML_PARSER_ XML_PARSER
 
typedef enum XML_PARSER_OFFSET_ XML_PARSER_OFFSET
 

Enumerations

enum  XML_PARSER_OFFSET_ { NO_CHARACTER = -1 , CURRENT_CHARACTER = 0 , NEXT_CHARACTER = 1 }
 

Functions

STATIC BOOLEAN XmlParseAttributeNumber (IN CONST CHAR8 *Attributes, IN CONST CHAR8 *Argument, IN UINT32 ArgumentLength, OUT UINT32 *ArgumentValue)
 
STATIC XML_NODEXmlNodeCreate (IN CONST CHAR8 *Name, IN CONST CHAR8 *Attributes OPTIONAL, IN CONST CHAR8 *Content OPTIONAL, IN XML_NODE *Real OPTIONAL, IN XML_NODE_LIST *Children OPTIONAL)
 
STATIC BOOLEAN XmlNodeChildPush (IN OUT XML_NODE *Node, IN XML_NODE *Child)
 
STATIC BOOLEAN XmlPushReference (IN OUT XML_REFLIST *References, IN XML_NODE *Node, IN UINT32 ReferenceNumber)
 
STATIC XML_NODEXmlNodeReal (IN CONST XML_REFLIST *References OPTIONAL, IN CONST CHAR8 *Attributes OPTIONAL)
 
STATIC VOID XmlNodeFree (IN OUT XML_NODE *Node)
 
STATIC VOID XmlFreeRefs (IN OUT XML_REFLIST *References)
 
VOID XmlParserError (IN CONST XML_PARSER *Parser, IN XML_PARSER_OFFSET Offset, IN CONST CHAR8 *Message)
 
STATIC CHAR8 XmlParserPeek (IN CONST XML_PARSER *Parser, IN UINT32 N)
 
STATIC VOID XmlParserConsume (IN OUT XML_PARSER *Parser, IN UINT32 N)
 
STATIC VOID XmlSkipWhitespace (IN OUT XML_PARSER *Parser)
 
STATIC CONST CHAR8 * XmlParseTagEnd (IN OUT XML_PARSER *Parser, OUT BOOLEAN *SelfClosing OPTIONAL, OUT CONST CHAR8 **Attributes OPTIONAL)
 
STATIC CONST CHAR8 * XmlParseTagOpen (IN OUT XML_PARSER *Parser, OUT BOOLEAN *SelfClosing OPTIONAL, OUT CONST CHAR8 **Attributes)
 
STATIC CONST CHAR8 * XmlParseTagClose (IN OUT XML_PARSER *Parser, IN BOOLEAN Unprefixed)
 
STATIC CONST CHAR8 * XmlParseContent (IN OUT XML_PARSER *Parser)
 
STATIC VOID XmlBufferAppend (IN OUT CHAR8 **Buffer, IN OUT UINT32 *AllocSize, IN OUT UINT32 *CurrentSize, IN CONST CHAR8 *Data, IN UINT32 DataLength)
 
STATIC VOID XmlNodeExportRecursive (IN CONST XML_NODE *Node, IN OUT CHAR8 **Buffer, IN OUT UINT32 *AllocSize, IN OUT UINT32 *CurrentSize, IN UINT32 Skip)
 
STATIC XML_NODEXmlParseNode (IN OUT XML_PARSER *Parser, IN OUT XML_REFLIST *References OPTIONAL)
 
XML_DOCUMENTXmlDocumentParse (IN OUT CHAR8 *Buffer, IN UINT32 Length, IN BOOLEAN WithRefs)
 
CHAR8 * XmlDocumentExport (IN CONST XML_DOCUMENT *Document, OUT UINT32 *Length OPTIONAL, IN UINT32 Skip, IN BOOLEAN PrependPlistInfo)
 
VOID XmlDocumentFree (IN OUT XML_DOCUMENT *Document)
 
XML_NODEXmlDocumentRoot (IN CONST XML_DOCUMENT *Document)
 
CONST CHAR8 * XmlNodeName (IN CONST XML_NODE *Node)
 
CONST CHAR8 * XmlNodeContent (IN CONST XML_NODE *Node)
 
VOID XmlNodeChangeContent (IN OUT XML_NODE *Node, IN CONST CHAR8 *Content)
 
UINT32 XmlNodeChildren (IN CONST XML_NODE *Node)
 
XML_NODEXmlNodeChild (IN CONST XML_NODE *Node, IN UINT32 Child)
 
XML_NODE *EFIAPI XmlEasyChild (IN OUT XML_NODE *Node, IN CONST CHAR8 *ChildName,...)
 
XML_NODEXmlNodeAppend (IN OUT XML_NODE *Node, IN CONST CHAR8 *Name, IN CONST CHAR8 *Attributes OPTIONAL, IN CONST CHAR8 *Content OPTIONAL)
 
XML_NODEXmlNodePrepend (IN OUT XML_NODE *Node, IN CONST CHAR8 *Name, IN CONST CHAR8 *Attributes, IN CONST CHAR8 *Content)
 
VOID XmlNodeRemoveByIndex (IN OUT XML_NODE *Node, IN UINT32 Index)
 
VOID XmlNodeRemove (IN OUT XML_NODE *Node, IN XML_NODE *ChildNode)
 
CONST CHAR8 * XmlUnescapeString (IN CONST CHAR8 *String)
 
XML_NODEPlistDocumentRoot (IN CONST XML_DOCUMENT *Document)
 
XML_NODEPlistNodeCast (IN XML_NODE *Node OPTIONAL, IN PLIST_NODE_TYPE Type)
 
UINT32 PlistDictChildren (IN CONST XML_NODE *Node)
 
XML_NODEPlistDictChild (IN CONST XML_NODE *Node, IN UINT32 Child, OUT XML_NODE **Value OPTIONAL)
 
CONST CHAR8 * PlistKeyValue (IN XML_NODE *Node OPTIONAL)
 
BOOLEAN PlistStringValue (IN XML_NODE *Node OPTIONAL, OUT CHAR8 *Value, IN OUT UINT32 *Size)
 
BOOLEAN PlistDataValue (IN XML_NODE *Node OPTIONAL, OUT UINT8 *Buffer, IN OUT UINT32 *Size)
 
BOOLEAN PlistBooleanValue (IN XML_NODE *Node OPTIONAL, OUT BOOLEAN *Value)
 
BOOLEAN PlistIntegerValue (IN XML_NODE *Node OPTIONAL, OUT VOID *Value, IN UINT32 Size, IN BOOLEAN Hex)
 
BOOLEAN PlistMultiDataValue (IN XML_NODE *Node OPTIONAL, OUT VOID *Buffer, IN OUT UINT32 *Size)
 
BOOLEAN PlistStringSize (IN XML_NODE *Node OPTIONAL, OUT UINT32 *Size)
 
BOOLEAN PlistDataSize (IN XML_NODE *Node OPTIONAL, OUT UINT32 *Size)
 
BOOLEAN PlistMultiDataSize (IN XML_NODE *Node OPTIONAL, OUT UINT32 *Size)
 

Variables

CONST CHAR8 * PlistNodeTypes [PLIST_NODE_TYPE_MAX]
 

Detailed Description

OcXmlLib

Copyright (c) 2018, vit9696

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file OcXmlLib.c.

Macro Definition Documentation

◆ XML_EXPORT_MIN_ALLOCATION_SIZE

#define XML_EXPORT_MIN_ALLOCATION_SIZE   4096

Minimal extra allocation size during export.

Definition at line 53 of file OcXmlLib.c.

◆ XML_PARSER_ERROR

#define XML_PARSER_ERROR ( Parser,
Offset,
Message )
Value:
do {} while (0)

Conditionally enable error printing.

Definition at line 529 of file OcXmlLib.c.

◆ XML_PARSER_INFO

#define XML_PARSER_INFO ( Parser,
Message )
Value:
do {} while (0)

Echo the parsers call stack for debugging purposes.

Definition at line 454 of file OcXmlLib.c.

◆ XML_PARSER_TAG

#define XML_PARSER_TAG ( Parser,
Tag )
Value:
do {} while (0)

Definition at line 455 of file OcXmlLib.c.

◆ XML_PLIST_HEADER

#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\">"

Definition at line 55 of file OcXmlLib.c.

◆ XML_USAGE_ERROR

#define XML_USAGE_ERROR ( X)
Value:
do {} while (0)

Definition at line 530 of file OcXmlLib.c.

Typedef Documentation

◆ XML_NODE_LIST

typedef struct XML_NODE_LIST_ XML_NODE_LIST

Definition at line 60 of file OcXmlLib.c.

◆ XML_PARSER

typedef struct XML_PARSER_ XML_PARSER

Definition at line 61 of file OcXmlLib.c.

◆ XML_PARSER_OFFSET

Character offsets.

Enumeration Type Documentation

◆ XML_PARSER_OFFSET_

Character offsets.

Enumerator
NO_CHARACTER 
CURRENT_CHARACTER 
NEXT_CHARACTER 

Definition at line 113 of file OcXmlLib.c.

Function Documentation

◆ PlistBooleanValue()

BOOLEAN PlistBooleanValue ( IN XML_NODE *Node OPTIONAL,
OUT BOOLEAN * Value )

Get the value of a plist boolean.

Parameters
[in]NodeA pointer to the XML node. Optional.
[out]ValueValue of plist boolean.
Returns
TRUE if Node can be casted to PLIST_NODE_TYPE_TRUE or PLIST_NODE_TYPE_FALSE.

Definition at line 1922 of file OcXmlLib.c.

◆ PlistDataSize()

BOOLEAN PlistDataSize ( IN XML_NODE *Node OPTIONAL,
OUT UINT32 * Size )

Get size of a plist data.

Parameters
[in]NodeA pointer to the XML node. Optional.
[out]SizeSize of data.
Returns
TRUE if Node can be casted to PLIST_NODE_TYPE_DATA.

Definition at line 2102 of file OcXmlLib.c.

◆ PlistDataValue()

BOOLEAN PlistDataValue ( IN XML_NODE *Node OPTIONAL,
OUT UINT8 * Buffer,
IN OUT UINT32 * Size )

Decode data content for valid type or set *Size to 0.

Parameters
[in]NodeA pointer to the XML node. Optional.
[out]BufferBuffer of plist data.
[in,out]SizeSize of Buffer.
Returns
TRUE if Node can be casted to PLIST_NODE_TYPE_DATA.

Definition at line 1886 of file OcXmlLib.c.

◆ PlistDictChild()

XML_NODE * PlistDictChild ( IN CONST XML_NODE * Node,
IN UINT32 Child,
OUT XML_NODE **Value OPTIONAL )

Get the specific child node under a plist dictionary.

Parameters
[in]NodeA pointer to the XML node.
[in]ChildIndex of children of Node.
[out]ValueValue of the returned Node. Optional.
Returns
The n-th dictionary key, behaviour is undefined if out of range.

Definition at line 1823 of file OcXmlLib.c.

◆ PlistDictChildren()

UINT32 PlistDictChildren ( IN CONST XML_NODE * Node)

Get the number of plist dictionary entries.

Parameters
[in]NodeA pointer to the XML node.
Returns
Number of plist dictionary entries.

Definition at line 1813 of file OcXmlLib.c.

◆ PlistDocumentRoot()

XML_NODE * PlistDocumentRoot ( IN CONST XML_DOCUMENT * Document)

Get the root node of the plist document.

Parameters
[in]DocumentA pointer to the plist document.
Returns
Root node of the plist document or NULL.
Warning
Only a subset of plist is supported.
No validation of plist format is performed.

Definition at line 1736 of file OcXmlLib.c.

◆ PlistIntegerValue()

BOOLEAN PlistIntegerValue ( IN XML_NODE *Node OPTIONAL,
OUT VOID * Value,
IN UINT32 Size,
IN BOOLEAN Hex )

Get the value of a plist integer.

Parameters
[in]NodeA pointer to the XML node. Optional.
[out]ValueValue of plist integer.
[in]SizeSize of Value to be casted to (UINT8, UINT16, UINT32, or UINT64).
[in]HexTRUE to interpret the value as hexadecimal values, decimal otherwise.
Returns
TRUE if Node can be casted to PLIST_NODE_TYPE_TRUE or PLIST_NODE_TYPE_FALSE.

Definition at line 1943 of file OcXmlLib.c.

◆ PlistKeyValue()

CONST CHAR8 * PlistKeyValue ( IN XML_NODE *Node OPTIONAL)

Get the value of a plist key.

Parameters
[in]NodeA pointer to the XML node. Optional.
Returns
Key value for valid type or NULL.

Definition at line 1841 of file OcXmlLib.c.

◆ PlistMultiDataSize()

BOOLEAN PlistMultiDataSize ( IN XML_NODE *Node OPTIONAL,
OUT UINT32 * Size )

Get size of multiple types of data that are valid.

Valid type for MultiData is DATA itself, STRING, INTEGER, or BOOLEAN (as 1 byte with 1 or 0 value).

Parameters
[in]NodeA pointer to the XML node. Optional.
[out]SizeSize of MultiData.
Returns
TRUE if Node can be casted to any of the aforementioned types.

Definition at line 2126 of file OcXmlLib.c.

◆ PlistMultiDataValue()

BOOLEAN PlistMultiDataValue ( IN XML_NODE *Node OPTIONAL,
OUT VOID * Buffer,
IN OUT UINT32 * Size )

Get the values of multiple types of data that are valid.

Valid type for MultiData is DATA itself, STRING, INTEGER, or BOOLEAN (as 1 byte with 1 or 0 value).

Parameters
[in]NodeA pointer to the XML node. Optional.
[out]BufferBuffer of plist MultiData.
[in,out]SizeSize of Buffer.
Warning
Integer must fit 32-bit UNSIGNED.
Buffer must be at least 1 byte long.
Returns
TRUE if Node can be casted to any of the aforementioned types.

Definition at line 2008 of file OcXmlLib.c.

◆ PlistNodeCast()

XML_NODE * PlistNodeCast ( IN XML_NODE *Node OPTIONAL,
IN PLIST_NODE_TYPE Type )

Basic type casting (up to PLIST_NODE_TYPE_MAX).

Guarantees that node represents passed type. Guarantees that arrays and dicts have valid amount of children, while others have 0. Guarantees that keys have names and integers have values.

Parameters
[in]NodeA pointer to the XML node. Optional.
[in]TypePlist node type to be casted to.
Returns
Node if it is not NULL and represents passed Type or NULL.
Warning
It is not guaranteed that Node has valid data, for data or integer types.

Definition at line 1760 of file OcXmlLib.c.

◆ PlistStringSize()

BOOLEAN PlistStringSize ( IN XML_NODE *Node OPTIONAL,
OUT UINT32 * Size )

Get size of a plist string, including the '\0' terminator.

Parameters
[in]NodeA pointer to the XML node. Optional.
[out]SizeSize of string.
Returns
TRUE if Node can be casted to PLIST_NODE_TYPE_STRING.

Definition at line 2078 of file OcXmlLib.c.

◆ PlistStringValue()

BOOLEAN PlistStringValue ( IN XML_NODE *Node OPTIONAL,
OUT CHAR8 * Value,
IN OUT UINT32 * Size )

Get the value of a plist string.

Parameters
[in]NodeA pointer to the XML node. Optional.
[out]ValueValue of plist string.
[in,out]SizeSize of Value, including the '\0' terminator.
Returns
TRUE if Node can be casted to PLIST_NODE_TYPE_STRING.

Definition at line 1853 of file OcXmlLib.c.

◆ XmlBufferAppend()

STATIC VOID XmlBufferAppend ( IN OUT CHAR8 ** Buffer,
IN OUT UINT32 * AllocSize,
IN OUT UINT32 * CurrentSize,
IN CONST CHAR8 * Data,
IN UINT32 DataLength )

Print to growing buffer always preserving one byte extra.

Parameters
[in,out]BufferA pointer to the buffer holding contents.
[in,out]AllocSizeSize of Buffer to be allocated.
[in,out]CurrentSizeCurrent size of Buffer before appending.
[in]DataData to be appended.
[in]DataLengthLength of Data.

Definition at line 1018 of file OcXmlLib.c.

◆ XmlDocumentExport()

CHAR8 * XmlDocumentExport ( IN CONST XML_DOCUMENT * Document,
OUT UINT32 *Length OPTIONAL,
IN UINT32 Skip,
IN BOOLEAN PrependPlistInfo )

Export parsed document into the buffer.

Parameters
[in]DocumentXML_DOCUMENT to export.
[out]LengthResulting length of the buffer without trailing '\0'. Optional.
[in]SkipNumber of root levels to be skipped before exporting, normally 0.
[in]PrependPlistInfoTRUE to prepend XML plist doc info to exported document.
Returns
The exported buffer allocated from pool or NULL.

Definition at line 1367 of file OcXmlLib.c.

◆ XmlDocumentFree()

VOID XmlDocumentFree ( IN OUT XML_DOCUMENT * Document)

Free all resources associated with the document. All XML_NODE references obtained through the document will be invalidated.

Parameters
[in,out]DocumentXML document to be freed.

Definition at line 1435 of file OcXmlLib.c.

◆ XmlDocumentParse()

XML_DOCUMENT * XmlDocumentParse ( IN OUT CHAR8 * Buffer,
IN UINT32 Length,
IN BOOLEAN WithRefs )

Parse the XML fragment in buffer. References in the document to allow deduplicated node reading: <integer ID="0" size="64">0x0</integer> <integer IDREF="0" size="64">

Parameters
[in,out]BufferChunk to be parsed.
[in]LengthSize of the buffer.
[in]WithRefTRUE to enable reference lookup support.
Warning
Buffer will be referenced by the document, it may not be freed until XML_DOCUMENT is freed.
XmlDocumentFree should be called after completion.
Buffer contents are permanently modified during parsing
Returns
The parsed xml fragment or NULL.

Definition at line 1308 of file OcXmlLib.c.

◆ XmlDocumentRoot()

XML_NODE * XmlDocumentRoot ( IN CONST XML_DOCUMENT * Document)

Get the root of the XML document.

Parameters
[in]DocumentA pointer to the XML document.
Returns
Root node of Document.

Definition at line 1447 of file OcXmlLib.c.

◆ XmlEasyChild()

XML_NODE *EFIAPI XmlEasyChild ( IN OUT XML_NODE * Node,
IN CONST CHAR8 * ChildName,
... )

Get the child node specified by the list of names.

Parameters
[in,out]NodeA pointer to the XML node.
[in]ChildNameList of child names.
Returns
The node described by the path or NULL if child cannot be found.
Warning
Each element on the way must be unique.
Last argument must be NULL.

Definition at line 1515 of file OcXmlLib.c.

◆ XmlFreeRefs()

STATIC VOID XmlFreeRefs ( IN OUT XML_REFLIST * References)

Free the XML references.

Parameters
[in,out]ReferencesA pointer to the XML references to be freed.

Definition at line 433 of file OcXmlLib.c.

◆ XmlNodeAppend()

XML_NODE * XmlNodeAppend ( IN OUT XML_NODE * Node,
IN CONST CHAR8 * Name,
IN CONST CHAR8 *Attributes OPTIONAL,
IN CONST CHAR8 *Content OPTIONAL )

Append new node to current node.

Parameters
[in,out]NodeCurrent node.
[in]NameName of the new node.
[in]AttributesAttributes of the new node. Optional.
[in]ContentNew node content. Optional.
Returns
Newly created node or NULL.
Warning
Name, Attributes, and Content must stay valid till XmlDocumentFree.

Definition at line 1581 of file OcXmlLib.c.

◆ XmlNodeChangeContent()

VOID XmlNodeChangeContent ( IN OUT XML_NODE * Node,
IN CONST CHAR8 * Content )

Change the string content of an XML node.

Parameters
[in,out]NodeA pointer to the XML node.
[in]ContentNew node content.
Warning
Content must stay valid until freed by XmlDocumentFree.

Definition at line 1477 of file OcXmlLib.c.

◆ XmlNodeChild()

XML_NODE * XmlNodeChild ( IN CONST XML_NODE * Node,
IN UINT32 Child )

Get the specific child node.

Parameters
[in]NodeA pointer to the XML node.
[in]ChildIndex of children of Node.
Returns
The n-th child, behaviour is undefined if out of range.

Definition at line 1503 of file OcXmlLib.c.

◆ XmlNodeChildPush()

STATIC BOOLEAN XmlNodeChildPush ( IN OUT XML_NODE * Node,
IN XML_NODE * Child )

Add a child node to the node given.

Parameters
[in,out]NodePointer to the XML node to which the child will be added.
[in]ChildPointer to the child XML node.
Return values
TRUEon successful adding.

Definition at line 237 of file OcXmlLib.c.

◆ XmlNodeChildren()

UINT32 XmlNodeChildren ( IN CONST XML_NODE * Node)

Get the number of child nodes under an XML node.

Parameters
[in]NodeA pointer to the XML node.
Returns
Number of child nodes.

Definition at line 1493 of file OcXmlLib.c.

◆ XmlNodeContent()

CONST CHAR8 * XmlNodeContent ( IN CONST XML_NODE * Node)

Get the content of an XML node.

Parameters
[in]NodeA pointer to the XML node.
Returns
The string content of the XML node or NULL.

Definition at line 1467 of file OcXmlLib.c.

◆ XmlNodeCreate()

STATIC XML_NODE * XmlNodeCreate ( IN CONST CHAR8 * Name,
IN CONST CHAR8 *Attributes OPTIONAL,
IN CONST CHAR8 *Content OPTIONAL,
IN XML_NODE *Real OPTIONAL,
IN XML_NODE_LIST *Children OPTIONAL )

Create a new XML node.

Parameters
[in]NameName of the new node.
[in]AttributesAttributes of the new node. Optional.
[in]ContentContent of the new node. Optional.
[in]RealPointer to the acual content when a reference exists. Optional.
[in]ChildrenPointer to the children of the node. Optional.
Returns
The created XML node.

Definition at line 202 of file OcXmlLib.c.

◆ XmlNodeExportRecursive()

STATIC VOID XmlNodeExportRecursive ( IN CONST XML_NODE * Node,
IN OUT CHAR8 ** Buffer,
IN OUT UINT32 * AllocSize,
IN OUT UINT32 * CurrentSize,
IN UINT32 Skip )

Print node to growing buffer always preserving one byte extra.

Parameters
[in]NodeA pointer to the XML node.
[in,out]BufferA pointer to the buffer holding contents exported.
[in,out]AllocSizeSize of Buffer to be allocated.
[in,out]CurrentSizeCurrent size of Buffer.
[in]SkipLevels of XML contents to be skipped.

Definition at line 1070 of file OcXmlLib.c.

◆ XmlNodeFree()

STATIC VOID XmlNodeFree ( IN OUT XML_NODE * Node)

Free the resources allocated by the node.

Parameters
[in,out]NodeA pointer to the XML node to be freed.

Definition at line 407 of file OcXmlLib.c.

◆ XmlNodeName()

CONST CHAR8 * XmlNodeName ( IN CONST XML_NODE * Node)

Get the name of an XML node.

Parameters
[in]NodeA pointer to the XML node.
Returns
The name of the XML node.

Definition at line 1457 of file OcXmlLib.c.

◆ XmlNodePrepend()

XML_NODE * XmlNodePrepend ( IN OUT XML_NODE * Node,
IN CONST CHAR8 * Name,
IN CONST CHAR8 * Attributes,
IN CONST CHAR8 * Content )

Prepend new node to current node.

Parameters
[in,out]NodeCurrent node.
[in]NameName of the new node.
[in]AttributesAttributes of the new node. Optional.
[in]ContentNew node content. Optional.
Returns
Newly created node or NULL.
Warning
Name, Attributes, and Content must stay valid till XmlDocumentFree.

Definition at line 1607 of file OcXmlLib.c.

◆ XmlNodeReal()

STATIC XML_NODE * XmlNodeReal ( IN CONST XML_REFLIST *References OPTIONAL,
IN CONST CHAR8 *Attributes OPTIONAL )

Get real value from a node referencing another.

Parameters
[in]ReferencesA pointer to the XML references. Optional.
[in]AttributesXML attributes. Optional.
Returns
The real XML node from the one referencing it.

Definition at line 374 of file OcXmlLib.c.

◆ XmlNodeRemove()

VOID XmlNodeRemove ( IN OUT XML_NODE * Node,
IN XML_NODE * ChildNode )

Remove the child node from the current node.

Parameters
[in,out]NodeCurrent node.
[in]ChildNodeChild node to be removed.

Definition at line 1664 of file OcXmlLib.c.

◆ XmlNodeRemoveByIndex()

VOID XmlNodeRemoveByIndex ( IN OUT XML_NODE * Node,
IN UINT32 Index )

Remove the Index-th child node inside an XML node.

Parameters
[in,out]NodeCurrent node.
[in]IndexIndex-th child node to be removed.

Definition at line 1633 of file OcXmlLib.c.

◆ XmlParseAttributeNumber()

STATIC BOOLEAN XmlParseAttributeNumber ( IN CONST CHAR8 * Attributes,
IN CONST CHAR8 * Argument,
IN UINT32 ArgumentLength,
OUT UINT32 * ArgumentValue )

Parse the attribute number.

Parameters
[in]AttributesXML attributes.
[in]ArgumentName of the XML argument.
[in]ArgumentLengthLength of the XML argument.
[out]ArgumentValueThe parsed XML argument value.
Return values
TRUEon successful parsing.

Definition at line 149 of file OcXmlLib.c.

◆ XmlParseContent()

STATIC CONST CHAR8 * XmlParseContent ( IN OUT XML_PARSER * Parser)

Parse a tag's content.

—( Example )— this is a

tag {} content

Warning
CDATA etc. is not and will never be supported
Parameters
[in,out]ParserA pointer to the XML parser.
Returns
The parsed content of the tag.

Definition at line 950 of file OcXmlLib.c.

◆ XmlParseNode()

STATIC XML_NODE * XmlParseNode ( IN OUT XML_PARSER * Parser,
IN OUT XML_REFLIST *References OPTIONAL )

Parse an XML fragment node.

—( Example without children )—

<Node>Text</Node>

—( Example with children )— <Parent> <Child>Text</Child> <Child>Text</Child> <Test>Content</Test>

</Parent>

Parameters
[in,out]ParserA pointer to the XML parser.
[in,out]ReferencesA pointer to the XML references. Optional.
Returns
The parsed XML node.

Definition at line 1147 of file OcXmlLib.c.

◆ XmlParserConsume()

STATIC VOID XmlParserConsume ( IN OUT XML_PARSER * Parser,
IN UINT32 N )

Move the parser's position n bytes. If the new position would be out of bounds, it will be converted to the bounds itself.

Parameters
[in,out]ParserA pointer to the XML parser.
[in]NThe N-th index.

Definition at line 570 of file OcXmlLib.c.

◆ XmlParserError()

VOID XmlParserError ( IN CONST XML_PARSER * Parser,
IN XML_PARSER_OFFSET Offset,
IN CONST CHAR8 * Message )

Echo an error regarding the parser's source to the console.

Parameters
[in]ParserA pointer to the XML parser.
[in]OffsetOffset of the XML parser.
[in]MessageMessage to be displayed

Definition at line 466 of file OcXmlLib.c.

◆ XmlParserPeek()

STATIC CHAR8 XmlParserPeek ( IN CONST XML_PARSER * Parser,
IN UINT32 N )

Return the N-th not-whitespace byte in parser or 0 if such a byte does not exist.

Parameters
[in]ParserA pointer to the XML parser.
[in]NThe N-th index.
Returns
The N-th not-whitespace byte or 0.

Definition at line 543 of file OcXmlLib.c.

◆ XmlParseTagClose()

STATIC CONST CHAR8 * XmlParseTagClose ( IN OUT XML_PARSER * Parser,
IN BOOLEAN Unprefixed )

Parse an closing XML tag without attributes.

—( Example )—

</tag_name>

Parameters
[in,out]ParserA pointer to the XML parser.
[in]UnprefixedTRUE to parse without the starting ‘<’.
Returns
The parsed closing XML tag.

Definition at line 890 of file OcXmlLib.c.

◆ XmlParseTagEnd()

STATIC CONST CHAR8 * XmlParseTagEnd ( IN OUT XML_PARSER * Parser,
OUT BOOLEAN *SelfClosing OPTIONAL,
OUT CONST CHAR8 **Attributes OPTIONAL )

Parse the name out of the an XML tag's ending.

—( Example )—

tag_name>

Parameters
[in,out]ParserA pointer to the XML parser.
[out]SelfClosingTRUE to indicate self-closing. Optional.
[out]AttributesExported XML attributes. Optional.
Returns
The XML tag in the end.

Definition at line 658 of file OcXmlLib.c.

◆ XmlParseTagOpen()

STATIC CONST CHAR8 * XmlParseTagOpen ( IN OUT XML_PARSER * Parser,
OUT BOOLEAN *SelfClosing OPTIONAL,
OUT CONST CHAR8 ** Attributes )

Parse an opening XML tag without attributes.

—( Example )—

<tag_name>

Parameters
[in,out]ParserA pointer to the XML parser.
[out]SelfClosingTRUE to indicate self-closing. Optional.
[out]AttributesExported XML attributes. Optional.
Returns
The parsed opening XML tag.

Definition at line 765 of file OcXmlLib.c.

◆ XmlPushReference()

STATIC BOOLEAN XmlPushReference ( IN OUT XML_REFLIST * References,
IN XML_NODE * Node,
IN UINT32 ReferenceNumber )

Store XML reference.

Parameters
[in,out]ReferencesA pointer to the list of XML references.
[in]NodeA pointer to the XML node.
[in]ReferenceNumberNumber of reference.
Return values
TRUEif the XML reference was successfully pushed.

Definition at line 317 of file OcXmlLib.c.

◆ XmlSkipWhitespace()

STATIC VOID XmlSkipWhitespace ( IN OUT XML_PARSER * Parser)

Skip to the next non-whitespace character.

Parameters
[in,out]ParserA pointer to the XML parser.

Definition at line 628 of file OcXmlLib.c.

◆ XmlUnescapeString()

CONST CHAR8 * XmlUnescapeString ( IN CONST CHAR8 * String)

Unescape XML string.

Parameters
[in]StringEscaped string to be converted to unescaped.
Returns
Unescaped XML string that must be freed manually, or NULL on memory allocation failure.

Definition at line 1687 of file OcXmlLib.c.

Variable Documentation

◆ PlistNodeTypes

CONST CHAR8* PlistNodeTypes[PLIST_NODE_TYPE_MAX]
Initial value:
= {
NULL,
"array",
"dict",
"key",
"string",
"data",
"date",
"true",
"false",
"real",
"integer"
}

Plist node types.

Definition at line 123 of file OcXmlLib.c.