3 #include "api_action.h"
7 #include "stg/servconf.h"
18 void PrintInfo(const STG::ServerInfo::Info& info)
20 std::cout << "Server version: '" << info.version << "'\n"
21 << "Number of tariffs: " << info.tariffNum << "\n"
22 << "Tariff subsystem version: " << info.tariffType << "\n"
23 << "Number of users: " << info.usersNum << "\n"
24 << "UName: '" << info.uname << "\n"
25 << "Number of directions: " << info.dirNum << "\n"
27 for (size_t i = 0; i < info.dirName.size(); ++i)
28 std::cout << "\t - '" << info.dirName[i] << "'\n";
31 void InfoCallback(bool result, const std::string & reason, const STG::ServerInfo::Info & info, void * /*data*/)
35 std::cerr << "Failed to get server info. Reason: '" << reason << "'." << std::endl;
41 bool InfoFunction(const SGCONF::CONFIG & config,
42 const std::string& /*arg*/,
43 const std::map<std::string, std::string> & /*options*/)
45 STG::ServConf proto(config.server.data(),
47 config.localAddress.data(),
48 config.localPort.data(),
49 config.userName.data(),
50 config.userPass.data());
51 return proto.ServerInfo(InfoCallback, NULL) == STG::st_ok;
56 void SGCONF::AppendServerInfoBlock(COMMANDS & commands, OPTION_BLOCKS & blocks)
58 blocks.Add("Server info")
59 .Add("server-info", SGCONF::MakeAPIAction(commands, InfoFunction), "\tget server info");