|
Xoxa-c
0.3.1
Normalizer/Parser for XML
|
This module provides direct analogues of the Expat XML_* functions.
More...
#include <expat.h>#include "xml_expat.h"
Go to the source code of this file.
Typedefs | |
| typedef ParserState * | Xoxa_Parser |
| The Xoxa analogue of the Expat XML_Parser type. | |
Functions | |
| void | Xoxa_DefaultCurrent (Xoxa_Parser xp) |
| The Xoxa version of XML_DefaultCurrent. | |
| const XML_LChar * | Xoxa_ErrorString (enum XML_Error code) |
| Returns the last error string. | |
| const XML_LChar * | Xoxa_ExpatVersion (void) |
| Reports the Expat version (not the Xoxa version) | |
| XML_Expat_Version | Xoxa_ExpatVersionInfo (void) |
| Reports the Expat version (not the Xoxa version) | |
| Xoxa_Parser | Xoxa_ExternalEntityParserCreate (Xoxa_Parser xoxa_parser, const XML_Char *context, const XML_Char *encoding) |
Creates a new parser; see XML_ExternalEntityParserCreate | |
| void | Xoxa_FreeContentModel (Xoxa_Parser xp, XML_Content *arg1) |
| The Xoxa version of XML_FreeContentModel. | |
| const XML_Char * | Xoxa_GetBase (Xoxa_Parser xp) |
| The Xoxa version of XML_GetBase. | |
| void * | Xoxa_GetBuffer (Xoxa_Parser xp, int arg1) |
| The Xoxa version of XML_GetBuffer. | |
| int | Xoxa_GetCurrentByteCount (Xoxa_Parser xp) |
| The Xoxa version of XML_GetCurrentByteCount. | |
| XML_Index | Xoxa_GetCurrentByteIndex (Xoxa_Parser xp) |
| The Xoxa version of XML_GetCurrentByteIndex. | |
| XML_Size | Xoxa_GetCurrentColumnNumber (Xoxa_Parser xp) |
| The Xoxa version of XML_GetCurrentColumnNumber. | |
| XML_Size | Xoxa_GetCurrentLineNumber (Xoxa_Parser xp) |
| The Xoxa version of XML_GetCurrentLineNumber. | |
| enum XML_Error | Xoxa_GetErrorCode (Xoxa_Parser xp) |
| The Xoxa version of XML_GetErrorCode. | |
| const XML_Feature * | Xoxa_GetFeatureList (void) |
| Reports the Expat feature list (not any Xoxa features) | |
| int | Xoxa_GetIdAttributeIndex (Xoxa_Parser xp) |
| The Xoxa version of XML_GetIdAttributeIndex. | |
| const char * | Xoxa_GetInputContext (Xoxa_Parser xp, int *arg2, int *arg1) |
| The Xoxa version of XML_GetInputContext. | |
| void | Xoxa_GetParsingStatus (Xoxa_Parser xp, XML_ParsingStatus *arg1) |
| The Xoxa version of XML_GetParsingStatus. | |
| int | Xoxa_GetSpecifiedAttributeCount (Xoxa_Parser xp) |
| The Xoxa version of XML_GetSpecifiedAttributeCount. | |
| void | Xoxa_MemFree (Xoxa_Parser xp, void *arg1) |
| The Xoxa version of XML_MemFree. | |
| void * | Xoxa_MemMalloc (Xoxa_Parser xp, size_t arg1) |
| The Xoxa version of XML_MemMalloc. | |
| void * | Xoxa_MemRealloc (Xoxa_Parser xp, void *arg2, size_t arg1) |
| The Xoxa version of XML_MemRealloc. | |
| enum XML_Status | Xoxa_Parse (Xoxa_Parser xp, const char *arg3, int arg2, int arg1) |
| The Xoxa version of XML_Parse. | |
| enum XML_Status | Xoxa_ParseBuffer (Xoxa_Parser xp, int arg2, int arg1) |
| The Xoxa version of XML_ParseBuffer. | |
| Xoxa_Parser | Xoxa_ParserCreate (const XML_Char *encoding) |
| Creates a new parser. | |
| Xoxa_Parser | Xoxa_ParserCreate_MM (const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, const XML_Char *namespaceSeparator) |
| Creates a new parser. | |
| Xoxa_Parser | Xoxa_ParserCreateNS (const XML_Char *encoding, XML_Char namespaceSeparator) |
| Creates a new parser. | |
| void | Xoxa_ParserFree (Xoxa_Parser P) |
| Frees both the Xoxa_Parser and the underlying Expat parser. | |
| XML_Bool | Xoxa_ParserReset (Xoxa_Parser xp, const XML_Char *arg1) |
| The Xoxa version of XML_ParserReset. | |
| enum XML_Status | Xoxa_ResumeParser (Xoxa_Parser xp) |
| The Xoxa version of XML_ResumeParser. | |
| void | Xoxa_SetAttlistDeclHandler (Xoxa_Parser xp, XML_AttlistDeclHandler arg1) |
| The Xoxa version of XML_SetAttlistDeclHandler. | |
| enum XML_Status | Xoxa_SetBase (Xoxa_Parser xp, const XML_Char *arg1) |
| The Xoxa version of XML_SetBase. | |
| void | Xoxa_SetCharacterDataHandler (Xoxa_Parser xp, XML_CharacterDataHandler arg) |
| The analogue of XML_CharacterDataHandler. | |
| void | Xoxa_SetCommentHandler (Xoxa_Parser xp, XML_CommentHandler arg1) |
| The Xoxa version of XML_SetCommentHandler. | |
| void | Xoxa_SetDefaultHandler (Xoxa_Parser xp, XML_DefaultHandler arg1) |
| The Xoxa version of XML_SetDefaultHandler. | |
| void | Xoxa_SetDefaultHandlerExpand (Xoxa_Parser xp, XML_DefaultHandler arg1) |
| The Xoxa version of XML_SetDefaultHandlerExpand. | |
| void | Xoxa_SetDoctypeDeclHandler (Xoxa_Parser xp, XML_StartDoctypeDeclHandler arg2, XML_EndDoctypeDeclHandler arg1) |
| The Xoxa version of XML_SetDoctypeDeclHandler. | |
| void | Xoxa_SetElementDeclHandler (Xoxa_Parser xp, XML_ElementDeclHandler arg1) |
| The Xoxa version of XML_SetElementDeclHandler. | |
| void | Xoxa_SetElementHandler (Xoxa_Parser xp, XML_StartElementHandler arg2, XML_EndElementHandler arg1) |
| Sets both start and end element handlers. | |
| enum XML_Status | Xoxa_SetEncoding (Xoxa_Parser xp, const XML_Char *arg1) |
| The Xoxa version of XML_SetEncoding. | |
| void | Xoxa_SetEndCdataSectionHandler (Xoxa_Parser xp, XML_EndCdataSectionHandler arg) |
| The analogue of XML_EndCdataSectionHandler. | |
| void | Xoxa_SetEndDoctypeDeclHandler (Xoxa_Parser xp, XML_EndDoctypeDeclHandler arg1) |
| The Xoxa version of XML_SetEndDoctypeDeclHandler. | |
| void | Xoxa_SetEndElementHandler (Xoxa_Parser xp, XML_EndElementHandler arg) |
| The analogue of XML_EndElementHandler. | |
| void | Xoxa_SetEndNamespaceDeclHandler (Xoxa_Parser xp, XML_EndNamespaceDeclHandler arg) |
| The analogue of XML_EndNamespaceDeclHandler. | |
| void | Xoxa_SetEntityDeclHandler (Xoxa_Parser xp, XML_EntityDeclHandler arg1) |
| The Xoxa version of XML_SetEntityDeclHandler. | |
| void | Xoxa_SetExternalEntityRefHandler (Xoxa_Parser xoxa_parser, Xoxa_ExternalEntityRefHandler handler) |
| Sets an external entity reference handler. | |
| void | Xoxa_SetExternalEntityRefHandlerArg (Xoxa_Parser xoxa_parser, void *arg1) |
Corresponds to XML_SetExternalEntityRefHandlerArg. | |
| void | Xoxa_SetNamespaceDeclHandler (Xoxa_Parser xp, XML_StartNamespaceDeclHandler arg2, XML_EndNamespaceDeclHandler arg1) |
| Sets both start and end namespace handlers. | |
| void | Xoxa_SetNotationDeclHandler (Xoxa_Parser xp, XML_NotationDeclHandler arg1) |
| The Xoxa version of XML_SetNotationDeclHandler. | |
| void | Xoxa_SetNotStandaloneHandler (Xoxa_Parser xp, XML_NotStandaloneHandler arg1) |
| The Xoxa version of XML_SetNotStandaloneHandler. | |
| int | Xoxa_SetParamEntityParsing (Xoxa_Parser xp, enum XML_ParamEntityParsing arg1) |
| The Xoxa version of XML_SetParamEntityParsing. | |
| void | Xoxa_SetProcessingInstructionHandler (Xoxa_Parser xp, XML_ProcessingInstructionHandler arg) |
| The analogue of XML_ProcessingInstructionHandler. | |
| void | Xoxa_SetReturnNSTriplet (Xoxa_Parser xp, int arg1) |
| The Xoxa version of XML_SetReturnNSTriplet. | |
| void | Xoxa_SetSkippedEntityHandler (Xoxa_Parser xp, XML_SkippedEntityHandler arg) |
| The analogue of XML_SkippedEntityHandler. | |
| void | Xoxa_SetStartCdataSectionHandler (Xoxa_Parser xp, XML_StartCdataSectionHandler arg) |
| The analogue of XML_StartCdataSectionHandler. | |
| void | Xoxa_SetStartDoctypeDeclHandler (Xoxa_Parser xp, XML_StartDoctypeDeclHandler arg1) |
| The Xoxa version of XML_SetStartDoctypeDeclHandler. | |
| void | Xoxa_SetStartElementHandler (Xoxa_Parser xp, XML_StartElementHandler arg) |
| The analogue of XML_StartElementHandler. | |
| void | Xoxa_SetStartNamespaceDeclHandler (Xoxa_Parser xp, XML_StartNamespaceDeclHandler arg) |
| The analogue of XML_StartNamespaceDeclHandler. | |
| void | Xoxa_SetUnknownEncodingHandler (Xoxa_Parser xp, XML_UnknownEncodingHandler arg2, void *arg1) |
| The Xoxa version of XML_SetUnknownEncodingHandler. | |
| void | Xoxa_SetUnparsedEntityDeclHandler (Xoxa_Parser xp, XML_UnparsedEntityDeclHandler arg1) |
| The Xoxa version of XML_SetUnparsedEntityDeclHandler. | |
| void | Xoxa_SetUserData (Xoxa_Parser xp, void *arg1) |
| Sets the user data passed to handlers. | |
| void | Xoxa_SetXmlDeclHandler (Xoxa_Parser xp, XML_XmlDeclHandler arg) |
| The analogue of XML_XmlDeclHandler. | |
| enum XML_Status | Xoxa_StopParser (Xoxa_Parser xp, XML_Bool arg1) |
| The Xoxa version of XML_StopParser. | |
| enum XML_Error | Xoxa_UseForeignDTD (Xoxa_Parser xp, XML_Bool arg1) |
| The Xoxa version of XML_UseForeignDTD. | |
| void | Xoxa_UseParserAsHandlerArg (Xoxa_Parser xp) |
| The Xoxa version of XML_UseParserAsHandlerArg. | |
This module provides direct analogues of the Expat XML_* functions.
Each of the Xoxa_* functions below should be used in the same way as the corresponding XML_* function, except that the first argument is of type Xoxa_Parser rather than Expat's XML_Parser.
The library also provides a set of functions Xoxa_... which precisely mirror the XML_... functions of the Expat library, and which can be used in an analogous way. The intention is that the XML_* functions can be directly replaced by the Xoxa_* functions (for example with #define XML_ParserCreate Xoxa_ParserCreate) with no other code changes.
#include "xoxa_expat.h" [...] Xoxa_Parser xoxa_p = Xoxa_ParserCreateNS(NULL); void* digest_ctx; // Install element and content handlers, just as with Expat Xoxa_SetElementHandler(xoxa_p, start_element_handler, end_element_handler); Xoxa_SetCharacterDataHandler(xoxa_p, characterdata_handler); Xoxa_SetUserData(xoxa_p, (void*)&S); // Initialise the Xoxa digest digest_ctx = xoxa_digest_initialize(xoxa_p, "SHA1"); [...] // Process the file (the installed handlers are called as usual) buf = Xoxa_GetBuffer(xoxa_p, BUFSIZ); Xoxa_ParseBuffer(xoxa_p, bytes_read, is_eof); [...] byte* md; size_t digest_length; // use a Xoxa function to extract the message digest. // (the contents of this buffer are owned by xoxa_p) md = xoxa_get_digest(xoxa_p, &digest_length); [...print out md...] Xoxa_ParserFree(xoxa_p);
The Xoxa_... functions require namespace-aware parsing. Therefore the Xoxa_ParserCreate and Xoxa_ParserCreate_MM functions, if called, emit a warning and call the equivalent of Xoxa_ParserCreateNS instead. The handler functions which are passed to the library should be written with this in mind.
The Xoxa-C library supports both message-digest functions. You can call either or both of xoxa_get_digest and xoxa_get_signature on the result.
| typedef ParserState* Xoxa_Parser |
The Xoxa analogue of the Expat XML_Parser type.
| const XML_LChar* Xoxa_ErrorString | ( | enum XML_Error | code | ) |
Returns the last error string.
| Xoxa_Parser Xoxa_ParserCreate | ( | const XML_Char * | encoding | ) |
Creates a new parser.
Because The Xoxa_... functions require namespace-aware parsing, this function acts exactly as Xoxa_ParserCreateNS.
| Xoxa_Parser Xoxa_ParserCreate_MM | ( | const XML_Char * | encoding, |
| const XML_Memory_Handling_Suite * | memsuite, | ||
| const XML_Char * | namespaceSeparator | ||
| ) |
Creates a new parser.
Because The Xoxa_... functions require namespace-aware parsing, this function acts exactly as Xoxa_ParserCreateNS.
| Xoxa_Parser Xoxa_ParserCreateNS | ( | const XML_Char * | encoding, |
| XML_Char | namespaceSeparator | ||
| ) |
Creates a new parser.
| void Xoxa_ParserFree | ( | Xoxa_Parser | P | ) |
Frees both the Xoxa_Parser and the underlying Expat parser.
| void Xoxa_SetExternalEntityRefHandler | ( | Xoxa_Parser | xoxa_parser, |
| Xoxa_ExternalEntityRefHandler | handler | ||
| ) |
Sets an external entity reference handler.
The second argument is of type Xoxa_ExternalEntityRefHandler. If Xoxa_SetExternalEntityRefHandlerArg is not called, then the handler is passed the Xoxa_Parser instance. See the documentation for XML_SetExternalEntityRefHandler.
| xoxa_parser | a Xoxa_Parser instance |
| handler | an Expat external entity handler |
| void Xoxa_SetExternalEntityRefHandlerArg | ( | Xoxa_Parser | xoxa_parser, |
| void * | arg1 | ||
| ) |
Corresponds to XML_SetExternalEntityRefHandlerArg.
| void Xoxa_SetUserData | ( | Xoxa_Parser | xp, |
| void * | arg1 | ||
| ) |
Sets the user data passed to handlers.
1.8.2