}
}
-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);
}