X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/c1b9be104712ea200385bd4f7d76f185a2d76eb7..05e29980ab6ee71b0436f7ca58d109a79a512b0f:/projects/sgconf/corps.cpp diff --git a/projects/sgconf/corps.cpp b/projects/sgconf/corps.cpp index 97c3add0..18217705 100644 --- a/projects/sgconf/corps.cpp +++ b/projects/sgconf/corps.cpp @@ -3,6 +3,7 @@ #include "api_action.h" #include "options.h" #include "config.h" +#include "utils.h" #include "stg/servconf.h" #include "stg/servconf_types.h" @@ -32,7 +33,7 @@ std::cout << Indent(level, true) << "name: " << info.name << "\n" std::vector GetCorpParams() { std::vector params; -params.push_back({"cash", "", "\tcorporation's cash"}); +params.push_back(SGCONF::API_ACTION::PARAM("cash", "", "\tcorporation's cash")); return params; } @@ -111,20 +112,30 @@ return proto.DelCorp(arg, SimpleCallback, NULL) == STG::st_ok; bool AddCorpFunction(const SGCONF::CONFIG & config, const std::string & arg, - const std::map & /*options*/) + const std::map & options) { -// TODO -std::cerr << "Unimplemented.\n"; -return false; +CORP_CONF_RES conf; +conf.name = arg; +SGCONF::MaybeSet(options, "cash", conf.cash); +STG::SERVCONF proto(config.server.data(), + config.port.data(), + config.userName.data(), + config.userPass.data()); +return proto.AddCorp(arg, conf, SimpleCallback, NULL) == STG::st_ok; } bool ChgCorpFunction(const SGCONF::CONFIG & config, const std::string & arg, const std::map & options) { -// TODO -std::cerr << "Unimplemented.\n"; -return false; +CORP_CONF_RES conf; +conf.name = arg; +SGCONF::MaybeSet(options, "cash", conf.cash); +STG::SERVCONF proto(config.server.data(), + config.port.data(), + config.userName.data(), + config.userPass.data()); +return proto.ChgCorp(conf, SimpleCallback, NULL) == STG::st_ok; } } // namespace anonymous