X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/0fc9896e27b94093ccde0b8566e2b8109ae8f657..9f1473ca33ad6847f22809ca50aaa00fe4944e6c:/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp index 5bc68d2a..fef2efba 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp @@ -1,8 +1,10 @@ -#include -#include - #include "parser.h" +#include "stg/admins.h" +#include "stg/common.h" + +#include // strcasecmp + //----------------------------------------------------------------------------- // GET ADMINS //----------------------------------------------------------------------------- @@ -30,37 +32,29 @@ void PARSER_GET_ADMINS::CreateAnswer() const PRIV * priv = currAdmin->GetPriv(); if (!priv->adminChg) { - //answerList->clear(); - answerList->erase(answerList->begin(), answerList->end()); - - answerList->push_back(""); + answer = ""; return; } -string s; -//answerList->clear(); -answerList->erase(answerList->begin(), answerList->end()); +answer.clear(); -answerList->push_back(""); +answer += ""; ADMIN_CONF ac; int h = admins->OpenSearch(); -unsigned int p; while (admins->SearchNext(h, &ac) == 0) { - //memcpy(&p, &ac.priv, sizeof(unsigned int)); - p = (ac.priv.userStat << 0) + - (ac.priv.userConf << 2) + - (ac.priv.userCash << 4) + - (ac.priv.userPasswd << 6) + - (ac.priv.userAddDel << 8) + - (ac.priv.adminChg << 10) + - (ac.priv.tariffChg << 12); - strprintf(&s, "", ac.login.c_str(), p); - answerList->push_back(s); + unsigned int p = (ac.priv.userStat << 0) + + (ac.priv.userConf << 2) + + (ac.priv.userCash << 4) + + (ac.priv.userPasswd << 6) + + (ac.priv.userAddDel << 8) + + (ac.priv.adminChg << 10) + + (ac.priv.tariffChg << 12); + answer += ""; } admins->CloseSearch(h); -answerList->push_back(""); +answer += ""; } //----------------------------------------------------------------------------- @@ -90,33 +84,10 @@ return -1; //----------------------------------------------------------------------------- void PARSER_DEL_ADMIN::CreateAnswer() { -//answerList->clear(); -answerList->erase(answerList->begin(), answerList->end()); - if (admins->Del(adminToDel, currAdmin) == 0) - { - answerList->push_back(""); - } + answer = ""; else - { - string s; - strprintf(&s, "", admins->GetStrError().c_str()); - answerList->push_back(s); - } -} -//----------------------------------------------------------------------------- -int PARSER_DEL_ADMIN::CheckAttr(const char **attr) -{ -/* - * attr[0] = "login" (word login) - * attr[1] = login, value of login - * attr[2] = NULL */ - -if (strcasecmp(attr[0], "login") == 0 && attr[1] && !attr[2]) - { - return 0; - } -return -1; + answer = "GetStrError() + "\"/>"; } //----------------------------------------------------------------------------- // ADD ADMIN @@ -133,9 +104,6 @@ return -1; //----------------------------------------------------------------------------- int PARSER_ADD_ADMIN::ParseEnd(void *, const char *el) { -//answerList->clear(); -answerList->erase(answerList->begin(), answerList->end()); - if (strcasecmp(el, "AddAdmin") == 0) { CreateAnswer(); @@ -146,19 +114,10 @@ return -1; //----------------------------------------------------------------------------- void PARSER_ADD_ADMIN::CreateAnswer() { -//answerList->clear(); -answerList->erase(answerList->begin(), answerList->end()); - if (admins->Add(adminToAdd, currAdmin) == 0) - { - answerList->push_back(""); - } + answer = ""; else - { - string s; - strprintf(&s, "", admins->GetStrError().c_str()); - answerList->push_back(s); - } + answer = "GetStrError() + "\"/>"; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -210,30 +169,27 @@ return -1; //----------------------------------------------------------------------------- void PARSER_CHG_ADMIN::CreateAnswer() { -answerList->erase(answerList->begin(), answerList->end()); - - -if (!login.res_empty()) +if (!login.empty()) { ADMIN * origAdmin = NULL; - if (admins->Find(login, &origAdmin)) + if (admins->Find(login.data(), &origAdmin)) { - answerList->push_back(std::string(""); + answer = ""; return; } ADMIN_CONF conf(origAdmin->GetConf()); - if (!password.res_empty()) + if (!password.empty()) conf.password = password.data(); - if (!privAsString.res_empty()) + if (!privAsString.empty()) { int p = 0; if (str2x(privAsString.data().c_str(), p) < 0) { - answerList->push_back(""); + answer = ""; return; } @@ -241,20 +197,10 @@ if (!login.res_empty()) } if (admins->Change(conf, currAdmin) != 0) - { - string s; - strprintf(&s, "", admins->GetStrError().c_str()); - answerList->push_back(s); - } + answer = "GetStrError() + "\"/>"; else - { - answerList->push_back(""); - } + answer = ""; } else - { - answerList->push_back(""); - } + answer = ""; } -//-----------------------------------------------------------------------------*/ -