*/
/*
- * Author : Maxim Mamontov <faust@stargazer.dp.ua>
+ * Author : Maksym Mamontov <stg@madf.info>
*/
-#include <cerrno>
-#include <cassert>
-#include <algorithm>
+#include "corps_impl.h"
#include "stg/admin.h"
#include "stg/common.h"
-#include "corps_impl.h"
+
+#include <cerrno>
+#include <cassert>
+#include <algorithm>
//-----------------------------------------------------------------------------
CORPORATIONS_IMPL::CORPORATIONS_IMPL(STORE * st)
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::Add(const CORP_CONF & corp, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->corpChg)
{
- string s = admin->GetLogStr() + " Add corporation \'" + corp.name + "\'. Access denied.";
+ std::string s = admin->GetLogStr() + " Add corporation \'" + corp.name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
return -1;
}
//-----------------------------------------------------------------------------
-int CORPORATIONS_IMPL::Del(const string & name, const ADMIN * admin)
+int CORPORATIONS_IMPL::Del(const std::string & name, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->corpChg)
{
- string s = admin->GetLogStr() + " Delete corporation \'" + name + "\'. Access denied.";
+ std::string s = admin->GetLogStr() + " Delete corporation \'" + name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
return -1;
}
-map<int, const_crp_iter>::iterator csi;
+std::map<int, const_crp_iter>::iterator csi;
csi = searchDescriptors.begin();
while (csi != searchDescriptors.end())
{
if (csi->second == si)
(csi->second)++;
- csi++;
+ ++csi;
}
data.remove(*si);
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::Change(const CORP_CONF & corp, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->corpChg)
{
- string s = admin->GetLogStr() + " Change corporation \'" + corp.name + "\'. Access denied.";
+ std::string s = admin->GetLogStr() + " Change corporation \'" + corp.name + "\'. Access denied.";
strError = "Access denied.";
WriteServLog(s.c_str());
return -1;
//-----------------------------------------------------------------------------
bool CORPORATIONS_IMPL::Read()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
-vector<string> corpsList;
+STG_LOCKER lock(&mutex);
+std::vector<std::string> corpsList;
if (store->GetCorpsList(&corpsList) < 0)
{
WriteServLog(store->GetStrError().c_str());
return false;
}
//-----------------------------------------------------------------------------
-bool CORPORATIONS_IMPL::Find(const string & name, CORP_CONF * corp)
+bool CORPORATIONS_IMPL::Find(const std::string & name, CORP_CONF * corp)
{
assert(corp != NULL && "Pointer to corporation is not null");
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
return false;
return true;
}
//-----------------------------------------------------------------------------
-bool CORPORATIONS_IMPL::Exists(const string & name) const
+bool CORPORATIONS_IMPL::Exists(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
{
printfd(__FILE__, "no admin in system!\n");
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::OpenSearch() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
handle++;
searchDescriptors[handle] = data.begin();
return handle;
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::SearchNext(int h, CORP_CONF * corp) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) == searchDescriptors.end())
{
WriteServLog("CORPORATIONS. Incorrect search handle.");
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::CloseSearch(int h) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) != searchDescriptors.end())
{
searchDescriptors.erase(searchDescriptors.find(h));