MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlNewTextReader

Function xmlNewTextReader

ThirdParty/libxml2/vtklibxml2/xmlreader.c:2058–2152  ·  view source on GitHub ↗

* * * Constructor and destructors * * * ************************************************************************/ * xmlNewTextReader: * @input: the xmlParserInputBufferPtr used to read data * @URI: the URI information for the source if available * * Create an xmlTextReader structure fed with @input * * Returns the new xmlTextReaderPtr or NULL in case of error */

Source from the content-addressed store, hash-verified

2056 * Returns the new xmlTextReaderPtr or NULL in case of error
2057 */
2058xmlTextReaderPtr
2059xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
2060 xmlTextReaderPtr ret;
2061
2062 if (input == NULL)
2063 return(NULL);
2064 ret = xmlMalloc(sizeof(xmlTextReader));
2065 if (ret == NULL)
2066 return(NULL);
2067 memset(ret, 0, sizeof(xmlTextReader));
2068 ret->doc = NULL;
2069 ret->entTab = NULL;
2070 ret->entMax = 0;
2071 ret->entNr = 0;
2072 ret->input = input;
2073 ret->buffer = xmlBufCreateSize(100);
2074 if (ret->buffer == NULL) {
2075 xmlFree(ret);
2076 return(NULL);
2077 }
2078 /* no operation on a reader should require a huge buffer */
2079 xmlBufSetAllocationScheme(ret->buffer,
2080 XML_BUFFER_ALLOC_DOUBLEIT);
2081 ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
2082 if (ret->sax == NULL) {
2083 xmlBufFree(ret->buffer);
2084 xmlFree(ret);
2085 return(NULL);
2086 }
2087 xmlSAXVersion(ret->sax, 2);
2088 ret->startElement = ret->sax->startElement;
2089 ret->sax->startElement = xmlTextReaderStartElement;
2090 ret->endElement = ret->sax->endElement;
2091 ret->sax->endElement = xmlTextReaderEndElement;
2092#ifdef LIBXML_SAX1_ENABLED
2093 if (ret->sax->initialized == XML_SAX2_MAGIC) {
2094#endif /* LIBXML_SAX1_ENABLED */
2095 ret->startElementNs = ret->sax->startElementNs;
2096 ret->sax->startElementNs = xmlTextReaderStartElementNs;
2097 ret->endElementNs = ret->sax->endElementNs;
2098 ret->sax->endElementNs = xmlTextReaderEndElementNs;
2099#ifdef LIBXML_SAX1_ENABLED
2100 } else {
2101 ret->startElementNs = NULL;
2102 ret->endElementNs = NULL;
2103 }
2104#endif /* LIBXML_SAX1_ENABLED */
2105 ret->characters = ret->sax->characters;
2106 ret->sax->characters = xmlTextReaderCharacters;
2107 ret->sax->ignorableWhitespace = xmlTextReaderCharacters;
2108 ret->cdataBlock = ret->sax->cdataBlock;
2109 ret->sax->cdataBlock = xmlTextReaderCDataBlock;
2110
2111 ret->mode = XML_TEXTREADER_MODE_INITIAL;
2112 ret->node = NULL;
2113 ret->curnode = NULL;
2114 if (xmlBufUse(ret->input->buffer) < 4) {
2115 xmlParserInputBufferRead(input, 4);

Callers 4

xmlNewTextReaderFilenameFunction · 0.85
xmlReaderForMemoryFunction · 0.85
xmlReaderForFdFunction · 0.85
xmlReaderForIOFunction · 0.85

Calls 8

xmlBufCreateSizeFunction · 0.85
xmlBufFreeFunction · 0.85
xmlSAXVersionFunction · 0.85
xmlBufUseFunction · 0.85
xmlParserInputBufferReadFunction · 0.85
xmlCreatePushParserCtxtFunction · 0.85
xmlBufContentFunction · 0.85

Tested by

no test coverage detected