X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/e9ae1f101b5418c0ba2e6c9d86b23c12f0140982..20d4dd0571e75d254444acf755a01b48a691c7c2:/stargazer/services_impl.cpp?ds=sidebyside diff --git a/stargazer/services_impl.cpp b/stargazer/services_impl.cpp index 620a6ecb..36640c88 100644 --- a/stargazer/services_impl.cpp +++ b/stargazer/services_impl.cpp @@ -43,11 +43,11 @@ Read(); int ServicesImpl::Add(const ServiceConf & service, const Admin * admin) { std::lock_guard lock(mutex); -const auto priv = admin->GetPriv(); +const auto& priv = admin->priv(); -if (!priv->serviceChg) +if (!priv.serviceChg) { - std::string s = admin->GetLogStr() + " Add service \'" + service.name + "\'. Access denied."; + std::string s = admin->logStr() + " Add service \'" + service.name + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; @@ -58,7 +58,7 @@ iterator si(std::find(data.begin(), data.end(), service)); if (si != data.end()) { strError = "Service \'" + service.name + "\' cannot not be added. Service already exist."; - WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); + WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str()); return -1; } @@ -68,12 +68,12 @@ data.push_back(service); if (store->AddService(service.name) == 0) { WriteServLog("%s Service \'%s\' added.", - admin->GetLogStr().c_str(), service.name.c_str()); + admin->logStr().c_str(), service.name.c_str()); return 0; } strError = "Service \'" + service.name + "\' was not added. Error: " + store->GetStrError(); -WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); +WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str()); return -1; } @@ -81,11 +81,11 @@ return -1; int ServicesImpl::Del(const std::string & name, const Admin * admin) { std::lock_guard lock(mutex); -const auto priv = admin->GetPriv(); +const auto& priv = admin->priv(); -if (!priv->serviceChg) +if (!priv.serviceChg) { - std::string s = admin->GetLogStr() + " Delete service \'" + name + "\'. Access denied."; + std::string s = admin->logStr() + " Delete service \'" + name + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; @@ -96,7 +96,7 @@ iterator si(std::find(data.begin(), data.end(), ServiceConf(name))); if (si == data.end()) { strError = "Service \'" + name + "\' cannot be deleted. Service does not exist."; - WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); + WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str()); return -1; } @@ -113,23 +113,23 @@ data.erase(si); if (store->DelService(name) < 0) { strError = "Service \'" + name + "\' was not deleted. Error: " + store->GetStrError(); - WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); + WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str()); return -1; } -WriteServLog("%s Service \'%s\' deleted.", admin->GetLogStr().c_str(), name.c_str()); +WriteServLog("%s Service \'%s\' deleted.", admin->logStr().c_str(), name.c_str()); return 0; } //----------------------------------------------------------------------------- int ServicesImpl::Change(const ServiceConf & service, const Admin * admin) { std::lock_guard lock(mutex); -const auto priv = admin->GetPriv(); +const auto& priv = admin->priv(); -if (!priv->serviceChg) +if (!priv.serviceChg) { - std::string s = admin->GetLogStr() + " Change service \'" + service.name + "\'. Access denied."; + std::string s = admin->logStr() + " Change service \'" + service.name + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; @@ -140,13 +140,13 @@ iterator si(std::find(data.begin(), data.end(), service)); if (si == data.end()) { strError = "Service \'" + service.name + "\' cannot be changed " + ". Service does not exist."; - WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); + WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str()); return -1; } -printfd(__FILE__, "Old cost = %f, old pay day = %d\n", si->cost, (unsigned)si->payDay); +printfd(__FILE__, "Old cost = %f, old pay day = %u\n", si->cost, static_cast(si->payDay)); *si = service; -printfd(__FILE__, "New cost = %f, New pay day = %d\n", si->cost, (unsigned)si->payDay); +printfd(__FILE__, "New cost = %f, New pay day = %u\n", si->cost, static_cast(si->payDay)); if (store->SaveService(service)) { WriteServLog("Cannot write service %s.", service.name.c_str()); @@ -155,7 +155,7 @@ if (store->SaveService(service)) } WriteServLog("%s Service \'%s\' changed.", - admin->GetLogStr().c_str(), service.name.c_str()); + admin->logStr().c_str(), service.name.c_str()); return 0; }