X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/dda964a76b486001f0debf38deb594ad7c13f416..0f4172ffbddd7b51c80f388adc69c4601d230bf6:/projects/stargazer/admins_impl.cpp diff --git a/projects/stargazer/admins_impl.cpp b/projects/stargazer/admins_impl.cpp index 08656a49..8f2760ce 100644 --- a/projects/stargazer/admins_impl.cpp +++ b/projects/stargazer/admins_impl.cpp @@ -28,21 +28,19 @@ $Author: faust $ */ -#include -#include -#include - #include "stg/common.h" #include "admins_impl.h" #include "admin_impl.h" -using namespace std; +#include +#include +#include //----------------------------------------------------------------------------- ADMINS_IMPL::ADMINS_IMPL(STORE * st) : ADMINS(), - stg(0xFFFF, "@stargazer", ""), - noAdmin(0xFFFF, "NO-ADMIN", ""), + stg(PRIV(0xFFFF), "@stargazer", ""), + noAdmin(PRIV(0xFFFF), "NO-ADMIN", ""), data(), store(st), WriteServLog(GetStgLogger()), @@ -55,20 +53,20 @@ pthread_mutex_init(&mutex, NULL); Read(); } //----------------------------------------------------------------------------- -int ADMINS_IMPL::Add(const string & login, const ADMIN * admin) +int ADMINS_IMPL::Add(const std::string & login, const ADMIN * admin) { STG_LOCKER lock(&mutex); const PRIV * priv = admin->GetPriv(); if (!priv->adminChg) { - string s = admin->GetLogStr() + " Add administrator \'" + login + "\'. Access denied."; + std::string s = admin->GetLogStr() + " Add administrator \'" + login + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; } -ADMIN_IMPL adm(0, login, ""); +ADMIN_IMPL adm(PRIV(0), login, ""); admin_iter ai(find(data.begin(), data.end(), adm)); if (ai != data.end()) @@ -94,21 +92,20 @@ WriteServLog("%s %s", admin->GetLogStr().c_str(), strError.c_str()); return -1; } //----------------------------------------------------------------------------- -int ADMINS_IMPL::Del(const string & login, const ADMIN * admin) +int ADMINS_IMPL::Del(const std::string & login, const ADMIN * admin) { STG_LOCKER lock(&mutex); -ADMIN_IMPL adm(0, login, ""); const PRIV * priv = admin->GetPriv(); if (!priv->adminChg) { - string s = admin->GetLogStr() + " Delete administrator \'" + login + "\'. Access denied."; + std::string s = admin->GetLogStr() + " Delete administrator \'" + login + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; } -admin_iter ai(find(data.begin(), data.end(), adm)); +admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), login, ""))); if (ai == data.end()) { @@ -117,13 +114,13 @@ if (ai == data.end()) return -1; } -map::iterator si; +std::map::iterator si; si = searchDescriptors.begin(); while (si != searchDescriptors.end()) { if (si->second == ai) (si->second)++; - si++; + ++si; } data.remove(*ai); @@ -146,14 +143,13 @@ const PRIV * priv = admin->GetPriv(); if (!priv->adminChg) { - string s = admin->GetLogStr() + " Change administrator \'" + ac.login + "\'. Access denied."; + std::string s = admin->GetLogStr() + " Change administrator \'" + ac.login + "\'. Access denied."; strError = "Access denied."; WriteServLog(s.c_str()); return -1; } -ADMIN_IMPL adm(0, ac.login, ""); -admin_iter ai(find(data.begin(), data.end(), adm)); +admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), ac.login, ""))); if (ai == data.end()) { @@ -179,7 +175,7 @@ return 0; int ADMINS_IMPL::Read() { STG_LOCKER lock(&mutex); -vector adminsList; +std::vector adminsList; if (store->GetAdminsList(&adminsList) < 0) { WriteServLog(store->GetStrError().c_str()); @@ -188,7 +184,7 @@ if (store->GetAdminsList(&adminsList) < 0) for (unsigned int i = 0; i < adminsList.size(); i++) { - ADMIN_CONF ac(0, adminsList[i], ""); + ADMIN_CONF ac(PRIV(0), adminsList[i], ""); if (store->RestoreAdmin(&ac, adminsList[i])) { @@ -201,7 +197,7 @@ for (unsigned int i = 0; i < adminsList.size(); i++) return 0; } //----------------------------------------------------------------------------- -bool ADMINS_IMPL::Find(const string & l, ADMIN ** admin) +bool ADMINS_IMPL::Find(const std::string & l, ADMIN ** admin) { assert(admin != NULL && "Pointer to admin is not null"); @@ -213,8 +209,7 @@ if (data.empty()) return false; } -ADMIN_IMPL adm(0, l, ""); -admin_iter ai(find(data.begin(), data.end(), adm)); +admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), l, ""))); if (ai != data.end()) { @@ -225,7 +220,7 @@ if (ai != data.end()) return true; } //----------------------------------------------------------------------------- -bool ADMINS_IMPL::Exists(const string & login) const +bool ADMINS_IMPL::Exists(const std::string & login) const { STG_LOCKER lock(&mutex); if (data.empty()) @@ -234,8 +229,7 @@ if (data.empty()) return true; } -ADMIN_IMPL adm(0, login, ""); -const_admin_iter ai(find(data.begin(), data.end(), adm)); +const_admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), login, ""))); if (ai != data.end()) return true; @@ -243,7 +237,7 @@ if (ai != data.end()) return false; } //----------------------------------------------------------------------------- -bool ADMINS_IMPL::Correct(const string & login, const std::string & password, ADMIN ** admin) +bool ADMINS_IMPL::Correct(const std::string & login, const std::string & password, ADMIN ** admin) { STG_LOCKER lock(&mutex); if (data.empty()) @@ -252,8 +246,7 @@ if (data.empty()) return true; } -ADMIN_IMPL adm(0, login, ""); -admin_iter ai(find(data.begin(), data.end(), adm)); +admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), login, ""))); if (ai == data.end()) {