X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/186fb2b18b89a0280b8cc4b5ea8f7a59d3bd0853..148f79dce19457e24754501db6844bc363c6f3fb:/projects/sgconf/xml.cpp diff --git a/projects/sgconf/xml.cpp b/projects/sgconf/xml.cpp index ec8b9178..93a06e23 100644 --- a/projects/sgconf/xml.cpp +++ b/projects/sgconf/xml.cpp @@ -1,10 +1,15 @@ #include "xml.h" +#include "api_action.h" +#include "options.h" +#include "makeproto.h" #include "config.h" #include "stg/servconf.h" #include +#include +#include #include @@ -52,19 +57,7 @@ if (el != NULL) std::cout << Indent(state->level) << "\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) +void PrintXML(const std::string& xml) { ParserState state = { 0 }; @@ -81,13 +74,27 @@ 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 & /*options*/) +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; + } +PrintXML(response); +} + +bool RawXMLFunction(const SGCONF::CONFIG & config, + const std::string & arg, + const std::map & /*options*/) +{ +return makeProto(config).RawXML(arg, RawXMLCallback, NULL) == STG::st_ok; +} + +} + +void SGCONF::AppendXMLOptionBlock(COMMANDS & commands, OPTION_BLOCKS & blocks) { - STG::SERVCONF proto(config.server.data(), - config.port.data(), - config.userName.data(), - config.userPass.data()); - return proto.RawXML(arg, RawXMLCallback, NULL) == STG::st_ok; +blocks.Add("Raw XML") + .Add("r", "raw", SGCONF::MakeAPIAction(commands, "", RawXMLFunction), "\tmake raw XML request"); }