* xmlParserInputBufferCreateFilenameInt: * @URI: the filename or URI * @enc: encoding enum (deprecated) * @out: pointer to resulting input buffer * * Returns an xmlParserErrors code. */
| 1573 | * Returns an xmlParserErrors code. |
| 1574 | */ |
| 1575 | static int |
| 1576 | xmlParserInputBufferCreateFilenameInt(const char *URI, xmlCharEncoding enc, |
| 1577 | xmlParserInputBufferPtr *out) { |
| 1578 | xmlParserInputBufferPtr buf; |
| 1579 | int ret; |
| 1580 | int i; |
| 1581 | |
| 1582 | xmlInitParser(); |
| 1583 | |
| 1584 | *out = NULL; |
| 1585 | if (URI == NULL) |
| 1586 | return(XML_ERR_ARGUMENT); |
| 1587 | |
| 1588 | /* |
| 1589 | * Allocate the Input buffer front-end. |
| 1590 | */ |
| 1591 | buf = xmlAllocParserInputBuffer(enc); |
| 1592 | if (buf == NULL) |
| 1593 | return(XML_ERR_NO_MEMORY); |
| 1594 | |
| 1595 | /* |
| 1596 | * Try to find one of the input accept method accepting that scheme |
| 1597 | * Go in reverse to give precedence to user defined handlers. |
| 1598 | */ |
| 1599 | ret = XML_IO_ENOENT; |
| 1600 | for (i = xmlInputCallbackNr - 1; i >= 0; i--) { |
| 1601 | xmlInputCallback *cb = &xmlInputCallbackTable[i]; |
| 1602 | |
| 1603 | if (cb->matchcallback == xmlIODefaultMatch) { |
| 1604 | ret = xmlInputDefaultOpen(buf, URI); |
| 1605 | |
| 1606 | if ((ret == XML_ERR_OK) || (ret != XML_IO_ENOENT)) |
| 1607 | break; |
| 1608 | } else if ((cb->matchcallback != NULL) && |
| 1609 | (cb->matchcallback(URI) != 0)) { |
| 1610 | buf->context = cb->opencallback(URI); |
| 1611 | if (buf->context != NULL) { |
| 1612 | buf->readcallback = cb->readcallback; |
| 1613 | buf->closecallback = cb->closecallback; |
| 1614 | ret = XML_ERR_OK; |
| 1615 | break; |
| 1616 | } |
| 1617 | } |
| 1618 | } |
| 1619 | if (ret != XML_ERR_OK) { |
| 1620 | xmlFreeParserInputBuffer(buf); |
| 1621 | *out = NULL; |
| 1622 | return(ret); |
| 1623 | } |
| 1624 | |
| 1625 | *out = buf; |
| 1626 | return(ret); |
| 1627 | } |
| 1628 | |
| 1629 | xmlParserInputBufferPtr |
| 1630 | __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { |
no test coverage detected