]> git.stg.codes - stg.git/blobdiff - projects/sgconf/xml.cpp
Some refactoring.
[stg.git] / projects / sgconf / xml.cpp
index bf5589fe856511d0e7539e3f09343e9450b582eb..ec8b9178a06305891cdca5c3ad84fa9503500d32 100644 (file)
@@ -1,5 +1,9 @@
 #include "xml.h"
 
+#include "config.h"
+
+#include "stg/servconf.h"
+
 #include <iostream>
 
 #include <expat.h>
@@ -48,6 +52,16 @@ if (el != NULL)
     std::cout << Indent(state->level) << "</" << el << ">\n";
 }
 
+void RawXMLCallback(bool result, const std::string & reason, const std::string & response, void * /*data*/)
+{
+if (!result)
+    {
+    std::cerr << "Failed to get raw XML response. Reason: '" << reason << "'." << std::endl;
+    return;
+    }
+SGCONF::PrintXML(response);
+}
+
 }
 
 void SGCONF::PrintXML(const std::string& xml)
@@ -66,3 +80,14 @@ if (XML_Parse(parser, xml.c_str(), xml.length(), true) == XML_STATUS_ERROR)
 
 XML_ParserFree(parser);
 }
+
+bool SGCONF::RawXMLFunction(const SGCONF::CONFIG & config,
+                            const std::string & arg,
+                            const std::map<std::string, std::string> & /*options*/)
+{
+    STG::SERVCONF proto(config.server.data(),
+                        config.port.data(),
+                        config.userName.data(),
+                        config.userPass.data());
+    return proto.RawXML(arg, RawXMLCallback, NULL) == STG::st_ok;
+}