3 #include "api_action.h"
8 #include "stg/servconf.h"
19 void PrintInfo(const STG::ServerInfo::Info& info)
21 std::cout << "Server version: '" << info.version << "'\n"
22 << "Number of tariffs: " << info.tariffNum << "\n"
23 << "Tariff subsystem version: " << info.tariffType << "\n"
24 << "Number of users: " << info.usersNum << "\n"
25 << "UName: '" << info.uname << "\n"
26 << "Number of directions: " << info.dirNum << "\n"
28 for (size_t i = 0; i < info.dirName.size(); ++i)
29 std::cout << "\t - '" << info.dirName[i] << "'\n";
32 void InfoCallback(bool result, const std::string & reason, const STG::ServerInfo::Info & info, void * /*data*/)
36 std::cerr << "Failed to get server info. Reason: '" << reason << "'." << std::endl;
42 bool InfoFunction(const SGCONF::CONFIG & config,
43 const std::string& /*arg*/,
44 const std::map<std::string, std::string> & /*options*/)
46 return makeProto(config).ServerInfo(InfoCallback, NULL) == STG::st_ok;
51 void SGCONF::AppendServerInfoBlock(COMMANDS & commands, OPTION_BLOCKS & blocks)
53 blocks.Add("Server info")
54 .Add("server-info", SGCONF::MakeAPIAction(commands, InfoFunction), "\tget server info");