X-Git-Url: https://git.sesse.net/?p=xml-template;a=blobdiff_plain;f=c%2B%2B0x%2Fxml-template.cpp;h=e8fc0edb086678d12ebea5eddc04fe355478d7e9;hp=30e5a7e1e3f96a6d740ebefdb68ea1c2d1c6bfb4;hb=ad45bc892752571fec46b21564e4683c074f1d46;hpb=d9fe760eebc1e40789f2fd769dcba74e3b0dbcbb diff --git a/c++0x/xml-template.cpp b/c++0x/xml-template.cpp index 30e5a7e..e8fc0ed 100644 --- a/c++0x/xml-template.cpp +++ b/c++0x/xml-template.cpp @@ -196,17 +196,21 @@ void Substitute::process(xmlNode *node, bool clean) } } -void process_file(const string &input_filename, - const string &output_filename, - Directive *root_directive) +xmlDocPtr process_file(const string &input_filename, + Directive *root_directive) { LIBXML_TEST_VERSION xmlDocPtr doc = xmlParseFile(input_filename.c_str()); root_directive->process(xmlDocGetRootElement(doc), true); - xmlSaveFile(output_filename.c_str(), doc); - xmlFreeDoc(doc); - xmlCleanupParser(); xmlMemoryDump(); + return doc; +} + +void output_to_fd_and_free(xmlDocPtr doc, int fd) +{ + xmlOutputBufferPtr buf = xmlOutputBufferCreateFd(fd, NULL); + xmlSaveFileTo(buf, doc, NULL); + xmlFreeDoc(doc); }