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

Function parseFile

ThirdParty/libxml2/vtklibxml2/xmllint.c:2115–2359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2113 ************************************************************************/
2114
2115static xmlDocPtr
2116parseFile(const char *filename, xmlParserCtxtPtr rectxt) {
2117 xmlParserCtxtPtr ctxt;
2118 xmlDocPtr doc = NULL;
2119
2120#ifdef LIBXML_TREE_ENABLED
2121 if ((generate) && (filename == NULL)) {
2122 xmlNodePtr n;
2123
2124 doc = xmlNewDoc(BAD_CAST "1.0");
2125 if (doc == NULL) {
2126 progresult = XMLLINT_ERR_MEM;
2127 return(NULL);
2128 }
2129 n = xmlNewDocNode(doc, NULL, BAD_CAST "info", NULL);
2130 if (n == NULL) {
2131 xmlFreeDoc(doc);
2132 progresult = XMLLINT_ERR_MEM;
2133 return(NULL);
2134 }
2135 if (xmlNodeSetContent(n, BAD_CAST "abc") < 0) {
2136 xmlFreeNode(n);
2137 xmlFreeDoc(doc);
2138 progresult = XMLLINT_ERR_MEM;
2139 return(NULL);
2140 }
2141 xmlDocSetRootElement(doc, n);
2142
2143 return(doc);
2144 }
2145#endif /* LIBXML_TREE_ENABLED */
2146
2147#ifdef LIBXML_HTML_ENABLED
2148#ifdef LIBXML_PUSH_ENABLED
2149 if ((html) && (push)) {
2150 FILE *f;
2151 int res;
2152 char chars[4096];
2153
2154 if ((filename[0] == '-') && (filename[1] == 0)) {
2155 f = stdin;
2156 } else {
2157 f = fopen(filename, "rb");
2158 if (f == NULL) {
2159 fprintf(ERR_STREAM, "Can't open %s\n", filename);
2160 progresult = XMLLINT_ERR_RDFILE;
2161 return(NULL);
2162 }
2163 }
2164
2165 res = fread(chars, 1, 4, f);
2166 ctxt = htmlCreatePushParserCtxt(NULL, NULL,
2167 chars, res, filename, XML_CHAR_ENCODING_NONE);
2168 if (ctxt == NULL) {
2169 progresult = XMLLINT_ERR_MEM;
2170 if (f != stdin)
2171 fclose(f);
2172 return(NULL);

Callers 1

parseAndPrintFileFunction · 0.85

Calls 15

xmlNewDocFunction · 0.85
xmlNewDocNodeFunction · 0.85
xmlFreeDocFunction · 0.85
xmlNodeSetContentFunction · 0.85
xmlFreeNodeFunction · 0.85
xmlDocSetRootElementFunction · 0.85
fprintfFunction · 0.85
htmlCreatePushParserCtxtFunction · 0.85
htmlCtxtUseOptionsFunction · 0.85
htmlParseChunkFunction · 0.85
htmlFreeParserCtxtFunction · 0.85
closeFunction · 0.85

Tested by

no test coverage detected