* xmlSaveFileTo: * @buf: an output I/O buffer * @cur: the document * @encoding: the encoding if any assuming the I/O layer handles the transcoding * * Dump an XML document to an I/O buffer. * Warning ! This call xmlOutputBufferClose() on buf which is not available * after this call. * * returns: the number of bytes written or -1 in case of failure. */
| 2834 | * returns: the number of bytes written or -1 in case of failure. |
| 2835 | */ |
| 2836 | int |
| 2837 | xmlSaveFileTo(xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding) { |
| 2838 | xmlSaveCtxt ctxt; |
| 2839 | int ret; |
| 2840 | |
| 2841 | if (buf == NULL) return(-1); |
| 2842 | if (cur == NULL) { |
| 2843 | xmlOutputBufferClose(buf); |
| 2844 | return(-1); |
| 2845 | } |
| 2846 | memset(&ctxt, 0, sizeof(ctxt)); |
| 2847 | ctxt.buf = buf; |
| 2848 | ctxt.level = 0; |
| 2849 | ctxt.format = 0; |
| 2850 | ctxt.encoding = (const xmlChar *) encoding; |
| 2851 | xmlSaveCtxtInit(&ctxt); |
| 2852 | ctxt.options |= XML_SAVE_AS_XML; |
| 2853 | xmlDocContentDumpOutput(&ctxt, cur); |
| 2854 | ret = xmlOutputBufferClose(buf); |
| 2855 | return(ret); |
| 2856 | } |
| 2857 | |
| 2858 | /** |
| 2859 | * xmlSaveFormatFileTo: |
nothing calls this directly
no test coverage detected