int CorporationsImpl::Add(const CorpConf & corp, const Admin * admin)
{
std::lock_guard<std::mutex> lock(mutex);
-const auto priv = admin->GetPriv();
+const auto& priv = admin->priv();
-if (!priv->corpChg)
+if (!priv.corpChg)
{
- std::string s = admin->GetLogStr() + " Add corporation \'" + corp.name + "\'. Access denied.";
+ std::string s = admin->logStr() + " Add corporation \'" + corp.name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
if (si != data.end())
{
strError = "Corporation \'" + corp.name + "\' cannot not be added. Corporation already exist.";
- WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str());
+ WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str());
return -1;
}
if (store->AddCorp(corp.name) == 0)
{
WriteServLog("%s Corporation \'%s\' added.",
- admin->GetLogStr().c_str(), corp.name.c_str());
+ admin->logStr().c_str(), corp.name.c_str());
return 0;
}
strError = "Corporation \'" + corp.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;
}
int CorporationsImpl::Del(const std::string & name, const Admin * admin)
{
std::lock_guard<std::mutex> lock(mutex);
-const auto priv = admin->GetPriv();
+const auto& priv = admin->priv();
-if (!priv->corpChg)
+if (!priv.corpChg)
{
- std::string s = admin->GetLogStr() + " Delete corporation \'" + name + "\'. Access denied.";
+ std::string s = admin->logStr() + " Delete corporation \'" + name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
if (si == data.end())
{
strError = "Corporation \'" + name + "\' cannot be deleted. Corporation 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;
}
if (store->DelCorp(name) < 0)
{
strError = "Corporation \'" + 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 Corporation \'%s\' deleted.", admin->GetLogStr().c_str(), name.c_str());
+WriteServLog("%s Corporation \'%s\' deleted.", admin->logStr().c_str(), name.c_str());
return 0;
}
//-----------------------------------------------------------------------------
int CorporationsImpl::Change(const CorpConf & corp, const Admin * admin)
{
std::lock_guard<std::mutex> lock(mutex);
-const auto priv = admin->GetPriv();
+const auto& priv = admin->priv();
-if (!priv->corpChg)
+if (!priv.corpChg)
{
- std::string s = admin->GetLogStr() + " Change corporation \'" + corp.name + "\'. Access denied.";
+ std::string s = admin->logStr() + " Change corporation \'" + corp.name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
if (si == data.end())
{
strError = "Corporation \'" + corp.name + "\' cannot be changed " + ". Corporation 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;
}
}
WriteServLog("%s Corporation \'%s\' changed.",
- admin->GetLogStr().c_str(), corp.name.c_str());
+ admin->logStr().c_str(), corp.name.c_str());
return 0;
}
std::lock_guard<std::mutex> lock(mutex);
if (data.empty())
{
- printfd(__FILE__, "no admin in system!\n");
+ printfd(__FILE__, "no corporations in system!\n");
return true;
}