diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2005-11-09 08:56:26 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2005-11-09 08:56:26 +0000 |
commit | 9a00fd2991433a6ce04075c91b3ac6b976bdd806 (patch) | |
tree | 9e9238983fcd65f6fce849109639488a030fab36 /xmlsave.c | |
parent | 69dea3a0c01e8a952b1d2f07ab0a3aa450f0cdfe (diff) | |
download | libxml2-9a00fd2991433a6ce04075c91b3ac6b976bdd806.tar.gz |
applied patch from Geert Jansen to implement the save function to a
* xmlsave.c xmlIO.c include/libxml/xmlIO.h include/libxml/xmlsave.h:
applied patch from Geert Jansen to implement the save function to
a xmlBuffer, and a bit of cleanup.
Daniel
Diffstat (limited to 'xmlsave.c')
-rw-r--r-- | xmlsave.c | 43 |
1 files changed, 33 insertions, 10 deletions
@@ -344,9 +344,9 @@ xmlSaveCtxtInit(xmlSaveCtxtPtr ctxt) ctxt->indent[ctxt->indent_nr * ctxt->indent_size] = 0; } - if (xmlSaveNoEmptyTags) { - ctxt->options |= XML_SAVE_NO_EMPTY; - } + if (xmlSaveNoEmptyTags) { + ctxt->options |= XML_SAVE_NO_EMPTY; + } } /** @@ -400,10 +400,10 @@ xmlNewSaveCtxt(const char *encoding, int options) * Use the options */ - /* Re-check this option as it may already have been set */ - if ((ret->options & XML_SAVE_NO_EMPTY) && ! (options & XML_SAVE_NO_EMPTY)) { - options |= XML_SAVE_NO_EMPTY; - } + /* Re-check this option as it may already have been set */ + if ((ret->options & XML_SAVE_NO_EMPTY) && ! (options & XML_SAVE_NO_EMPTY)) { + options |= XML_SAVE_NO_EMPTY; + } ret->options = options; if (options & XML_SAVE_FORMAT) @@ -1477,13 +1477,36 @@ xmlSaveToFilename(const char *filename, const char *encoding, int options) * with the encoding and the options given * * Returns a new serialization context or NULL in case of error. + */ + xmlSaveCtxtPtr xmlSaveToBuffer(xmlBufferPtr buffer, const char *encoding, int options) { - TODO - return(NULL); + xmlSaveCtxtPtr ret; + xmlOutputBufferPtr out_buff; + xmlCharEncodingHandlerPtr handler; + + ret = xmlNewSaveCtxt(encoding, options); + if (ret == NULL) return(NULL); + + if (encoding != NULL) { + handler = xmlFindCharEncodingHandler(encoding); + if (handler == NULL) { + xmlFree(ret); + return(NULL); + } + } else + handler = NULL; + out_buff = xmlOutputBufferCreateBuffer(buffer, handler); + if (out_buff == NULL) { + xmlFree(ret); + if (handler) xmlCharEncCloseFunc(handler); + return(NULL); + } + + ret->buf = out_buff; + return(ret); } - */ /** * xmlSaveToIO: |