* xmlOutputBufferClose: * @out: a buffered output * * flushes and close the output I/O channel * and free up all the associated resources * * Returns the number of byte written or a negative xmlParserErrors * code in case of error. */
| 1520 | * code in case of error. |
| 1521 | */ |
| 1522 | int |
| 1523 | xmlOutputBufferClose(xmlOutputBufferPtr out) |
| 1524 | { |
| 1525 | int ret; |
| 1526 | |
| 1527 | if (out == NULL) |
| 1528 | return (-1); |
| 1529 | |
| 1530 | if (out->writecallback != NULL) |
| 1531 | xmlOutputBufferFlush(out); |
| 1532 | |
| 1533 | if (out->closecallback != NULL) { |
| 1534 | int code = out->closecallback(out->context); |
| 1535 | |
| 1536 | if ((code != XML_ERR_OK) && (out->error == XML_ERR_OK)) { |
| 1537 | if (code < 0) |
| 1538 | out->error = XML_IO_UNKNOWN; |
| 1539 | else |
| 1540 | out->error = code; |
| 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | if (out->error != XML_ERR_OK) |
| 1545 | ret = -out->error; |
| 1546 | else |
| 1547 | ret = out->written; |
| 1548 | |
| 1549 | if (out->conv) { |
| 1550 | xmlBufFree(out->conv); |
| 1551 | out->conv = NULL; |
| 1552 | } |
| 1553 | if (out->encoder != NULL) { |
| 1554 | xmlCharEncCloseFunc(out->encoder); |
| 1555 | } |
| 1556 | if (out->buffer != NULL) { |
| 1557 | xmlBufFree(out->buffer); |
| 1558 | out->buffer = NULL; |
| 1559 | } |
| 1560 | |
| 1561 | xmlFree(out); |
| 1562 | |
| 1563 | return(ret); |
| 1564 | } |
| 1565 | #endif /* LIBXML_OUTPUT_ENABLED */ |
| 1566 | |
| 1567 | /** |
no test coverage detected