| 1613 | } |
| 1614 | |
| 1615 | static int |
| 1616 | xmlCreateUconvHandler(const char *name, xmlCharEncodingHandler **out) { |
| 1617 | xmlCharEncodingHandlerPtr enc = NULL; |
| 1618 | uconv_t *ucv_in = NULL; |
| 1619 | uconv_t *ucv_out = NULL; |
| 1620 | int ret; |
| 1621 | |
| 1622 | ret = openIcuConverter(name, 1, &ucv_in); |
| 1623 | if (ret != 0) |
| 1624 | goto error; |
| 1625 | ret = openIcuConverter(name, 0, &ucv_out); |
| 1626 | if (ret != 0) |
| 1627 | goto error; |
| 1628 | |
| 1629 | enc = (xmlCharEncodingHandlerPtr) |
| 1630 | xmlMalloc(sizeof(xmlCharEncodingHandler)); |
| 1631 | if (enc == NULL) { |
| 1632 | ret = XML_ERR_NO_MEMORY; |
| 1633 | goto error; |
| 1634 | } |
| 1635 | memset(enc, 0, sizeof(xmlCharEncodingHandler)); |
| 1636 | |
| 1637 | enc->name = xmlMemStrdup(name); |
| 1638 | if (enc->name == NULL) { |
| 1639 | ret = XML_ERR_NO_MEMORY; |
| 1640 | goto error; |
| 1641 | } |
| 1642 | enc->input = NULL; |
| 1643 | enc->output = NULL; |
| 1644 | enc->uconv_in = ucv_in; |
| 1645 | enc->uconv_out = ucv_out; |
| 1646 | |
| 1647 | *out = enc; |
| 1648 | return(0); |
| 1649 | |
| 1650 | error: |
| 1651 | if (enc != NULL) |
| 1652 | xmlFree(enc); |
| 1653 | if (ucv_in != NULL) |
| 1654 | closeIcuConverter(ucv_in); |
| 1655 | if (ucv_out != NULL) |
| 1656 | closeIcuConverter(ucv_out); |
| 1657 | return(ret); |
| 1658 | } |
| 1659 | #endif /* LIBXML_ICU_ENABLED */ |
| 1660 | |
| 1661 | /** |
no test coverage detected