Data Structures | Defines | Typedefs | Functions | Variables

# xml-tree.c File Reference

`#include "wizard/studio.h"`
`#include "wizard/blob.h"`
`#include "wizard/exception.h"`
`#include "wizard/exception-private.h"`
`#include "wizard/log.h"`
`#include "wizard/memory_.h"`
`#include "wizard/semaphore.h"`
`#include "wizard/splay-tree.h"`
`#include "wizard/string_.h"`
`#include "wizard/string-private.h"`
`#include "wizard/xml-tree.h"`
`#include "wizard/utility.h"`

## Data Structures

struct | _XMLTreeInfo
struct | _XMLTreeRoot

## Defines

#define | NumberPredefinedEntities 10
#define | XMLWhitespace "\t\r\n "

## Typedefs

typedef struct _XMLTreeRoot | XMLTreeRoot

## Functions

WizardExport XMLTreeInfo * | AddChildToXMLTree (XMLTreeInfo *xml_info, const char *tag, const size_t offset)
WizardExport XMLTreeInfo * | AddPathToXMLTree (XMLTreeInfo *xml_info, const char *path, const size_t offset)
static unsigned char * | ConvertLatin1ToUTF8 (const unsigned char *content)
WizardExport char * | CanonicalXMLContent (const char *content, const WizardBooleanType pedantic)
static char ** | DestroyXMLTreeAttributes (char **attributes)
WizardExport XMLTreeInfo * | DestroyXMLTree (XMLTreeInfo *xml_info)
WizardExport XMLTreeInfo * | GetNextXMLTreeTag (XMLTreeInfo *xml_info)
WizardExport const char * | GetXMLTreeAttribute (XMLTreeInfo *xml_info, const char *tag)
WizardExport WizardBooleanType | GetXMLTreeAttributes (const XMLTreeInfo *xml_info, SplayTreeInfo *attributes)
WizardExport XMLTreeInfo * | GetXMLTreeChild (XMLTreeInfo *xml_info, const char *tag)
WizardExport const char * | GetXMLTreeContent (XMLTreeInfo *xml_info)
WizardExport XMLTreeInfo * | GetXMLTreeOrdered (XMLTreeInfo *xml_info)
WizardExport XMLTreeInfo * | GetXMLTreePath (XMLTreeInfo *xml_info, const char *path)
WizardExport const char ** | GetXMLTreeProcessingInstructions (XMLTreeInfo *xml_info, const char *target)
WizardExport XMLTreeInfo * | GetXMLTreeSibling (XMLTreeInfo *xml_info)
WizardExport const char * | GetXMLTreeTag (XMLTreeInfo *xml_info)
WizardExport XMLTreeInfo * | InsertTagIntoXMLTree (XMLTreeInfo *xml_info, XMLTreeInfo *child, const size_t offset)
static char * | ConvertUTF16ToUTF8 (const char *content, size_t *length)
static char * | ParseEntities (char *xml, char **entities, int state)
void | ParseCharacterContent (XMLTreeRoot *root, char *xml, const size_t length, const char state)
static XMLTreeInfo * | ParseCloseTag (XMLTreeRoot *root, char *tag, char *wizard_unused(xml), ExceptionInfo *exception)
static WizardBooleanType | ValidateEntities (char *tag, char *xml, char **entities)
static void | ParseProcessingInstructions (XMLTreeRoot *root, char *xml, size_t length)
static WizardBooleanType | ParseInternalDoctype (XMLTreeRoot *root, char *xml, size_t length, ExceptionInfo *exception)
static void | ParseOpenTag (XMLTreeRoot *root, char *tag, char **attributes)
WizardExport XMLTreeInfo * | NewXMLTree (const char *xml, ExceptionInfo *exception)
WizardExport XMLTreeInfo * | NewXMLTreeTag (const char *tag)
WizardExport XMLTreeInfo * | PruneTagFromXMLTree (XMLTreeInfo *xml_info)
WizardExport XMLTreeInfo * | SetXMLTreeAttribute (XMLTreeInfo *xml_info, const char *tag, const char *value)
WizardExport XMLTreeInfo * | SetXMLTreeContent (XMLTreeInfo *xml_info, const char *content)
static char * | EncodePredefinedEntities (const char *source, ssize_t offset, char **destination, size_t *length, size_t *extent, WizardBooleanType pedantic)
static char * | XMLTreeTagToXML (XMLTreeInfo *xml_info, char **source, size_t *length, size_t *extent, size_t start, char ***attributes)
WizardExport char * | XMLTreeInfoToXML (XMLTreeInfo *xml_info)

## Variables

static char * | sentinel [] = { (char *) NULL }

## Define Documentation

#define NumberPredefinedEntities 10

Referenced by DestroyXMLTree(), and NewXMLTreeTag().

#define XMLWhitespace "\t\r\n "

Referenced by NewXMLTree(), ParseInternalDoctype(), and ParseProcessingInstructions().

## Typedef Documentation

typedef struct _XMLTreeRoot XMLTreeRoot

## Function Documentation

WizardExport XMLTreeInfo* AddChildToXMLTree | ( | XMLTreeInfo * | xml_info,
|  | const char * | tag,
|  | const size_t | offset |
| ) |  |  |

References AcquireWizardMemory(), _XMLTreeInfo::attributes, _XMLTreeInfo::child, ConstantString(), _XMLTreeInfo::content, _XMLTreeInfo::debug, InsertTagIntoXMLTree(), IsEventLogging(), ResetWizardMemory(), sentinel, _XMLTreeInfo::signature, and _XMLTreeInfo::tag.

Referenced by AddPathToXMLTree(), and ParseOpenTag().

WizardExport XMLTreeInfo* AddPathToXMLTree | ( | XMLTreeInfo * | xml_info,
|  | const char * | path,
|  | const size_t | offset |
| ) |  |  |

References AddChildToXMLTree(), CanonicalPath, _XMLTreeInfo::child, DestroyString(), GetPathComponent(), GetPathComponents(), GetWizardModule, GetXMLTreeChild(), GetXMLTreeOrdered(), LogWizardEvent(), RelinquishWizardMemory(), ResourceDomain, _XMLTreeInfo::signature, StringToLong(), SubnodePath, _XMLTreeInfo::tag, TraceEvent, WizardAssert, and WizardSignature.

WizardExport char* CanonicalXMLContent | ( | const char * | content,
|  | const WizardBooleanType | pedantic |
| ) |  |  |

References AcquireString(), Base64Encode(), ConcatenateString(), ConvertLatin1ToUTF8(), DestroyString(), FormatWizardString(), WizardPathExtent, RelinquishWizardMemory(), ResizeQuantumMemory(), and WizardFalse.

Referenced by EncodePredefinedEntities(), and PrintKeyringProperties().

static unsigned char* ConvertLatin1ToUTF8 | ( | const unsigned char * | content | ) | `[static]`

References AcquireQuantumMemory().

Referenced by CanonicalXMLContent().

static char* ConvertUTF16ToUTF8 | ( | const char * | content,
|  | size_t * | length |
| ) |  |  | `[static]`

References AcquireQuantumMemory(), CopyWizardMemory(), WizardPathExtent, and ResizeQuantumMemory().

Referenced by NewXMLTree().

WizardExport XMLTreeInfo* DestroyXMLTree | ( | XMLTreeInfo * | xml_info | ) |

References _XMLTreeRoot::attributes, _XMLTreeInfo::attributes, DestroyString(), DestroyXMLTreeAttributes(), _XMLTreeRoot::entities, GetWizardModule, LogWizardEvent(), NumberPredefinedEntities, _XMLTreeRoot::processing_instructions, RelinquishWizardMemory(), ResourceDomain, _XMLTreeInfo::signature, TraceEvent, WizardAssert, and WizardSignature.

Referenced by LoadConfigureList(), and LoadMimeList().

static char** DestroyXMLTreeAttributes | ( | char ** | attributes | ) | `[static]`

References DestroyString(), RelinquishWizardMemory(), and sentinel.

Referenced by DestroyXMLTree(), and NewXMLTree().

static char* EncodePredefinedEntities | ( | const char * | source,
|  | ssize_t | offset,
|  | char ** | destination,
|  | size_t * | length,
|  | size_t * | extent,
|  | WizardBooleanType | pedantic |
| ) |  |  | `[static]`

References AcquireString(), CanonicalXMLContent(), _XMLTreeInfo::content, DestroyString(), FormatWizardString(), WizardPathExtent, and ResizeQuantumMemory().

Referenced by XMLTreeTagToXML().

WizardExport XMLTreeInfo* GetNextXMLTreeTag | ( | XMLTreeInfo * | xml_info | ) |

References GetWizardModule, LogWizardEvent(), ResourceDomain, _XMLTreeInfo::signature, TraceEvent, WizardAssert, and WizardSignature.

Referenced by LoadConfigureList(), and LoadMimeList().

WizardExport const char* GetXMLTreeAttribute | ( | XMLTreeInfo * | xml_info,
|  | const char * | tag |
| ) |  |  |

References _XMLTreeRoot::attributes, GetWizardModule, LogWizardEvent(), _XMLTreeInfo::parent, ResourceDomain, _XMLTreeRoot::root, _XMLTreeInfo::signature, TraceEvent, WizardAssert, and WizardSignature.

Referenced by LoadConfigureList(), LoadMimeList(), and XMLTreeTagToXML().

WizardExport WizardBooleanType GetXMLTreeAttributes | ( | const XMLTreeInfo * | xml_info,
|  | SplayTreeInfo * | attributes |
| ) |  |  |

References AddValueToSplayTree(), _XMLTreeRoot::attributes, ConstantString(), GetWizardModule, LogWizardEvent(), ResourceDomain, _XMLTreeInfo::signature, TraceEvent, WizardAssert, WizardSignature, and WizardTrue.

WizardExport XMLTreeInfo* GetXMLTreeChild | ( | XMLTreeInfo * | xml_info,
|  | const char * | tag |
| ) |  |  |

References _XMLTreeInfo::child, GetWizardModule, LogWizardEvent(), ResourceDomain, _XMLTreeInfo::sibling, _XMLTreeInfo::signature, _XMLTreeInfo::tag, TraceEvent, WizardAssert, and WizardSignature.

Referenced by AddPathToXMLTree(), GetXMLTreePath(), LoadConfigureList(), and LoadMimeList().

WizardExport const char* GetXMLTreeContent | ( | XMLTreeInfo * | xml_info | ) |

References GetWizardModule, LogWizardEvent(), ResourceDomain, _XMLTreeInfo::signature, TraceEvent, WizardAssert, and WizardSignature.

WizardExport XMLTreeInfo* GetXMLTreeOrdered | ( | XMLTreeInfo * | xml_info | ) |

References GetWizardModule, LogWizardEvent(), ResourceDomain, _XMLTreeInfo::signature, TraceEvent, WizardAssert, and WizardSignature.

Referenced by AddPathToXMLTree(), and GetXMLTreePath().

WizardExport XMLTreeInfo* GetXMLTreePath | ( | XMLTreeInfo * | xml_info,
|  | const char * | path |
| ) |  |  |

References CanonicalPath, DestroyString(), GetPathComponent(), GetPathComponents(), GetWizardModule, GetXMLTreeChild(), GetXMLTreeOrdered(), LogWizardEvent(), RelinquishWizardMemory(), ResourceDomain, _XMLTreeInfo::signature, StringToLong(), SubnodePath, _XMLTreeInfo::tag, TraceEvent, WizardAssert, and WizardSignature.

WizardExport const char** GetXMLTreeProcessingInstructions | ( | XMLTreeInfo * | xml_info,
|  | const char * | target |
| ) |  |  |

References GetWizardModule, LogWizardEvent(), _XMLTreeInfo::parent, _XMLTreeRoot::processing_instructions, ResourceDomain, _XMLTreeRoot::root, sentinel, _XMLTreeInfo::signature, TraceEvent, WizardAssert, and WizardSignature.

WizardExport XMLTreeInfo* GetXMLTreeSibling | ( | XMLTreeInfo * | xml_info | ) |

References GetWizardModule, LogWizardEvent(), ResourceDomain, _XMLTreeInfo::signature, TraceEvent, WizardAssert, and WizardSignature.

WizardExport const char* GetXMLTreeTag | ( | XMLTreeInfo * | xml_info | ) |

References GetWizardModule, LogWizardEvent(), ResourceDomain, _XMLTreeInfo::signature, TraceEvent, WizardAssert, and WizardSignature.

WizardExport XMLTreeInfo* InsertTagIntoXMLTree | ( | XMLTreeInfo * | xml_info,
|  | XMLTreeInfo * | child,
|  | const size_t | offset |
| ) |  |  |

References _XMLTreeInfo::child, _XMLTreeInfo::next, _XMLTreeInfo::offset, _XMLTreeInfo::ordered, _XMLTreeInfo::parent, _XMLTreeInfo::sibling, and _XMLTreeInfo::tag.

Referenced by AddChildToXMLTree().

WizardExport XMLTreeInfo* NewXMLTree | ( | const char * | xml,
|  | ExceptionInfo * | exception |
| ) |  |  |

References AcquireQuantumMemory(), _XMLTreeRoot::attributes, _XMLTreeInfo::attributes, ConstantString(), ConvertUTF16ToUTF8(), DestroyString(), DestroyXMLTreeAttributes(), _XMLTreeRoot::entities, GetWizardModule, NewXMLTreeTag(), _XMLTreeRoot::node, ParseCharacterContent(), ParseCloseTag(), ParseEntities(), ParseInternalDoctype(), ParseOpenTag(), ParseProcessingInstructions(), ResizeQuantumMemory(), _XMLTreeRoot::root, sentinel, _XMLTreeInfo::tag, ThrowWizardException(), WizardFalse, and XMLWhitespace.

Referenced by LoadConfigureList(), and LoadMimeList().

WizardExport XMLTreeInfo* NewXMLTreeTag | ( | const char * | tag | ) |

References AcquireWizardMemory(), _XMLTreeRoot::attributes, _XMLTreeInfo::attributes, ConstantString(), _XMLTreeInfo::content, CopyWizardMemory(), _XMLTreeRoot::debug, _XMLTreeRoot::entities, IsEventLogging(), _XMLTreeRoot::node, NumberPredefinedEntities, _XMLTreeRoot::processing_instructions, ResetWizardMemory(), _XMLTreeRoot::root, sentinel, _XMLTreeRoot::signature, and _XMLTreeInfo::tag.

Referenced by NewXMLTree().

void ParseCharacterContent | ( | XMLTreeRoot * | root,
|  | char * | xml,
|  | const size_t | length,
|  | const char | state |
| ) |  |  |

References ConcatenateString(), _XMLTreeInfo::content, DestroyString(), _XMLTreeRoot::entities, _XMLTreeRoot::node, ParseEntities(), and _XMLTreeInfo::tag.

Referenced by NewXMLTree().

static XMLTreeInfo* ParseCloseTag | ( | XMLTreeRoot * | root,
|  | char * | tag,
|  | char * | wizard_unusedxml,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

References GetWizardModule, _XMLTreeRoot::node, _XMLTreeInfo::parent, _XMLTreeRoot::root, _XMLTreeInfo::tag, and ThrowWizardException().

Referenced by NewXMLTree().

static char* ParseEntities | ( | char * | xml,
|  | char ** | entities,
|  | int | state |
| ) |  |  | `[static]`

References AcquireQuantumMemory(), ConstantString(), CopyWizardMemory(), CopyWizardString(), _XMLTreeInfo::offset, ResizeQuantumMemory(), ResourceFatalError, and ThrowFatalException.

Referenced by NewXMLTree(), ParseCharacterContent(), and ParseInternalDoctype().

static WizardBooleanType ParseInternalDoctype | ( | XMLTreeRoot * | root,
|  | char * | xml,
|  | size_t | length,
|  | ExceptionInfo * | exception |
| ) |  |  | `[static]`

References AcquireQuantumMemory(), AcquireWizardMemory(), _XMLTreeRoot::attributes, ConstantString(), CopyWizardMemory(), DestroyString(), _XMLTreeRoot::entities, GetWizardModule, ParseEntities(), ParseProcessingInstructions(), RelinquishWizardMemory(), ResizeQuantumMemory(), ResourceFatalError, sentinel, _XMLTreeRoot::standalone, ThrowFatalException, ThrowWizardException(), ValidateEntities(), WizardFalse, WizardTrue, and XMLWhitespace.

Referenced by NewXMLTree().

static void ParseOpenTag | ( | XMLTreeRoot * | root,
|  | char * | tag,
|  | char ** | attributes |
| ) |  |  | `[static]`

References AddChildToXMLTree(), _XMLTreeInfo::attributes, ConstantString(), _XMLTreeInfo::content, _XMLTreeRoot::node, and _XMLTreeInfo::tag.

Referenced by NewXMLTree().

static void ParseProcessingInstructions | ( | XMLTreeRoot * | root,
|  | char * | xml,
|  | size_t | length |
| ) |  |  | `[static]`

References AcquireQuantumMemory(), AcquireWizardMemory(), ConstantString(), CopyWizardString(), _XMLTreeRoot::processing_instructions, ResizeQuantumMemory(), ResourceFatalError, _XMLTreeRoot::root, _XMLTreeRoot::standalone, _XMLTreeInfo::tag, ThrowFatalException, and XMLWhitespace.

Referenced by NewXMLTree(), and ParseInternalDoctype().

WizardExport XMLTreeInfo* PruneTagFromXMLTree | ( | XMLTreeInfo * | xml_info | ) |

References GetWizardModule, LogWizardEvent(), _XMLTreeInfo::next, _XMLTreeInfo::ordered, ResourceDomain, _XMLTreeInfo::sibling, _XMLTreeInfo::signature, _XMLTreeInfo::tag, TraceEvent, WizardAssert, and WizardSignature.

WizardExport XMLTreeInfo* SetXMLTreeAttribute | ( | XMLTreeInfo * | xml_info,
|  | const char * | tag,
|  | const char * | value |
| ) |  |  |

References AcquireQuantumMemory(), _XMLTreeRoot::attributes, ConstantString(), CopyWizardMemory(), DestroyString(), GetWizardModule, LogWizardEvent(), ResizeQuantumMemory(), ResourceDomain, ResourceFatalError, sentinel, _XMLTreeInfo::signature, ThrowFatalException, TraceEvent, WizardAssert, and WizardSignature.

WizardExport XMLTreeInfo* SetXMLTreeContent | ( | XMLTreeInfo * | xml_info,
|  | const char * | content |
| ) |  |  |

References ConstantString(), DestroyString(), GetWizardModule, LogWizardEvent(), ResourceDomain, _XMLTreeInfo::signature, TraceEvent, WizardAssert, and WizardSignature.

static WizardBooleanType ValidateEntities | ( | char * | tag,
|  | char * | xml,
|  | char ** | entities |
| ) |  |  | `[static]`

References WizardFalse, and WizardTrue.

Referenced by ParseInternalDoctype().

WizardExport char* XMLTreeInfoToXML | ( | XMLTreeInfo * | xml_info | ) |

References AcquireString(), _XMLTreeRoot::attributes, FormatWizardString(), GetWizardModule, LogWizardEvent(), _XMLTreeInfo::ordered, _XMLTreeInfo::parent, _XMLTreeRoot::processing_instructions, ResizeQuantumMemory(), ResourceDomain, _XMLTreeRoot::root, _XMLTreeInfo::signature, TraceEvent, WizardAssert, WizardSignature, and XMLTreeTagToXML().

static char* XMLTreeTagToXML | ( | XMLTreeInfo * | xml_info,
|  | char ** | source,
|  | size_t * | length,
|  | size_t * | extent,
|  | size_t | start,
|  | char *** | attributes |
| ) |  |  | `[static]`

References _XMLTreeInfo::attributes, _XMLTreeInfo::child, _XMLTreeInfo::content, EncodePredefinedEntities(), FormatWizardString(), GetXMLTreeAttribute(), WizardPathExtent, _XMLTreeInfo::offset, _XMLTreeInfo::ordered, _XMLTreeInfo::parent, ResizeQuantumMemory(), _XMLTreeInfo::tag, WizardFalse, and WizardTrue.

Referenced by XMLTreeInfoToXML().

## Variable Documentation

char* sentinel[] = { (char *) NULL }`[static]`

Referenced by AddChildToXMLTree(), DestroyXMLTreeAttributes(), GetXMLTreeProcessingInstructions(), NewXMLTree(), NewXMLTreeTag(), ParseInternalDoctype(), and SetXMLTreeAttribute().