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

Function xmlInputDefaultOpen

ThirdParty/libxml2/vtklibxml2/xmlIO.c:1168–1274  ·  view source on GitHub ↗

* xmlInputDefaultOpen: * @buf: input buffer to be filled * @filename: filename or URI * * Returns an xmlParserErrors code. */

Source from the content-addressed store, hash-verified

1166 * Returns an xmlParserErrors code.
1167 */
1168static int
1169xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename) {
1170 int ret;
1171 int fd;
1172
1173#ifdef LIBXML_FTP_ENABLED
1174 if (xmlIOFTPMatch(filename)) {
1175 buf->context = xmlIOFTPOpen(filename);
1176
1177 if (buf->context != NULL) {
1178 buf->readcallback = xmlIOFTPRead;
1179 buf->closecallback = xmlIOFTPClose;
1180 return(XML_ERR_OK);
1181 }
1182 }
1183#endif /* LIBXML_FTP_ENABLED */
1184
1185#ifdef LIBXML_HTTP_ENABLED
1186 if (xmlIOHTTPMatch(filename)) {
1187 buf->context = xmlIOHTTPOpen(filename);
1188
1189 if (buf->context != NULL) {
1190 buf->readcallback = xmlIOHTTPRead;
1191 buf->closecallback = xmlIOHTTPClose;
1192 return(XML_ERR_OK);
1193 }
1194 }
1195#endif /* LIBXML_HTTP_ENABLED */
1196
1197 if (!xmlFileMatch(filename))
1198 return(XML_IO_ENOENT);
1199
1200#ifdef LIBXML_LZMA_ENABLED
1201 {
1202 xzFile xzStream;
1203
1204 ret = xmlFdOpen(filename, 0, &fd);
1205 if (ret != XML_ERR_OK)
1206 return(ret);
1207
1208 xzStream = __libxml2_xzdopen(filename, fd, "rb");
1209
1210 if (xzStream == NULL) {
1211 close(fd);
1212 } else {
1213 /*
1214 * Non-regular files like pipes can't be reopened.
1215 * If a file isn't seekable, we pipe uncompressed
1216 * input through xzlib.
1217 */
1218 if ((lseek(fd, 0, SEEK_CUR) < 0) ||
1219 (__libxml2_xzcompressed(xzStream) > 0)) {
1220 buf->context = xzStream;
1221 buf->readcallback = xmlXzfileRead;
1222 buf->closecallback = xmlXzfileClose;
1223 buf->compressed = 1;
1224
1225 return(XML_ERR_OK);

Callers 1

Calls 13

xmlIOHTTPMatchFunction · 0.85
xmlIOHTTPOpenFunction · 0.85
xmlFileMatchFunction · 0.85
xmlFdOpenFunction · 0.85
__libxml2_xzdopenFunction · 0.85
closeFunction · 0.85
__libxml2_xzcompressedFunction · 0.85
xmlXzfileCloseFunction · 0.85
gzdopenFunction · 0.85
gzdirectFunction · 0.85
xmlGzfileCloseFunction · 0.85
xmlIOFTPMatchFunction · 0.70

Tested by

no test coverage detected